Project

General

Profile

WIPVideo » History » Version 25

Saúl Ibarra Corretgé, 04/01/2014 11:42 AM

1 1 Saúl Ibarra Corretgé
h1. WIPVideo
2
3 5 Saúl Ibarra Corretgé
Notes while video is a work in progress. Repository: http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=saul/python-sipsimple-video;a=summary
4 1 Saúl Ibarra Corretgé
5
h2. Dependencies
6
7
The following dependencies are required to build PJSIP with video support (including H264)
8
9
* SDL 2
10
* ffmpeg (libavformat, libswscale, libavcodec, libavutil)
11
* libx264
12
13
Versions I have tried:
14
15
* SDL (2.0.0-7655)
16
* ffmpeg (2.0 release)
17
* libx264 (snapshot-20130806-2245-stable)
18
19
h2. Patches
20
21 11 Saúl Ibarra Corretgé
-If the above versions are used, PJSIP needs to be patched with the attached patch (avcodec.diff) or it won't compile. This does not occur when compiling it against the latest library versions on Debian unstable.- No longer needed.
22 3 Saúl Ibarra Corretgé
23 20 Saúl Ibarra Corretgé
h2. Installing dependencies (Debian / Ubuntu systems)
24
25
The situation here is a bit sad. Both Debian and Ubuntu ship with libav instead of FFmpeg, but libraries are called the same. PJSIP had to be patched in order to properly work with libav, and the patch as not yet been included upstream.
26
27
On Debian, when the Debian-Multimedia repositories are used (quite common) you get FFmpeg and not libav. Oh the joy!
28
29
Installing dependencies on Debian:
30
31
<pre>
32
apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libsdl2-dev libx264-dev libavcodec-extra
33
</pre>
34
35
If using the Debian-Multimedia repositories, do not install libavcodec-extra.
36
37
Installing dependencies on Ubuntu:
38
39
<pre>
40
apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libsdl2-dev libx264-dev libavcodec-extra53
41
</pre>
42
43 21 Saúl Ibarra Corretgé
*Note on H.264 support*: In order to have H.264 support, FFmpeg (or libav) need to be compiled with support for it. The standard packages don't, hence the need for installing the libavcodec-extra packages.
44 20 Saúl Ibarra Corretgé
45 3 Saúl Ibarra Corretgé
h2. Compiling dependencies
46
47
All dependencies will be compiled to a directory in the user's HOME directory:
48
49
<pre>
50
export MY_VIDEO_LIBS=$HOME/work/ag-projects/video/local
51
</pre>
52
53
h3. libx264
54
55
<pre>
56
./configure --enable-shared --disable-avs --disable-swscale --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_VIDEO_LIBS
57
make
58
make install
59 8 Saúl Ibarra Corretgé
60
# If a 32bit build is wanted, then run this configure instead:
61
./configure --host=i386-apple-darwin --enable-shared --disable-avs --disable-swscale --disable-lavf --disable-ffms --disable-gpac --prefix=$MY_VIDEO_LIBS
62 3 Saúl Ibarra Corretgé
</pre>
63
64
h3. ffmpeg
65
66
<pre>
67
# Some exports
68
export PKG_CONFIG_PATH=$MY_VIDEO_LIBS/lib/pkgconfig
69 1 Saúl Ibarra Corretgé
70 7 Saúl Ibarra Corretgé
./configure --enable-shared --disable-static --enable-memalign-hack --enable-gpl --enable-libx264 --prefix=$MY_VIDEO_LIBS --extra-cflags="`pkg-config --cflags x264`" --extra-ldflags="`pkg-config --libs x264`"
71 3 Saúl Ibarra Corretgé
make
72
make install
73 9 Saúl Ibarra Corretgé
74
# If a 32bit build is wanted do:
75
./configure --enable-shared --disable-static --enable-memalign-hack --enable-gpl --enable-libx264 --prefix=$MY_VIDEO_LIBS --extra-cflags="`pkg-config --cflags x264`" --extra-ldflags="`pkg-config --libs x264`" --cc="gcc -m32" --disable-asm
76
# TODO: I WANT MY ASM
77 3 Saúl Ibarra Corretgé
</pre>
78
79
h3. SDL
80
81
<pre>
82
./configure --disable-audio --prefix=$MY_VIDEO_LIBS
83
make
84
make install
85 10 Saúl Ibarra Corretgé
86
# If a 32bit build is wanted:
87
CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --disable-audio --prefix=$MY_VIDEO_LIBS
88 3 Saúl Ibarra Corretgé
</pre>
89 4 Saúl Ibarra Corretgé
90
h2. Compiling PJSIP (pjsua, for testing)
91
92
<pre>
93
svn co http://svn.pjsip.org/repos/pjproject/trunk pjsip
94
cd pjsip
95
echo "#define PJMEDIA_HAS_VIDEO 1" > pjlib/include/pj/config_site.h
96
./configure --with-sdl=$MY_VIDEO_LIBS --with-ffmpeg=$MY_VIDEO_LIBS
97 22 Saúl Ibarra Corretgé
# if a 32bit build is wanted:
98
# CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --with-sdl=$MY_VIDEO_LIBS --with-ffmpeg=$MY_VIDEO_LIBS
99 4 Saúl Ibarra Corretgé
make dep
100
make
101
# pjsua will be located in pjsip-apps/bin/
102
</pre>
103 12 Saúl Ibarra Corretgé
104
h2. Proposed API
105
106 13 Saúl Ibarra Corretgé
API for video components is based on 2 different types of video capable entities:
107
108
* VideoProducer: a source for video data, for example a video camera or a remote video stream
109
* VideoConsumer: a sink or destination for video data, for example a video rendering window
110
111
h3. Data flow
112
113
Data flow works in _pull_ fashion, that is, a producer doesn't start to produce data until there is a consumer which will consume it.
114
115
h3. VideoProducer
116
117
Produces video data. 
118
119
Internal API:
120
121
* _add_consumer: attach a consumer, called by the consumer
122
* _remove_consumer: detach a consumer from a producer, called by the consumer
123
124 18 Saúl Ibarra Corretgé
125 1 Saúl Ibarra Corretgé
Public API:
126
127 18 Saúl Ibarra Corretgé
* start: start producing video as soon as a consumer is attached
128
* stop: immediately stop producing data
129 13 Saúl Ibarra Corretgé
* close: remove all consumers and stop producing video data
130 14 Saúl Ibarra Corretgé
* producer_port: pointer to the pjmedia_port object
131
132
h3. VideoConsumer
133
134
Consumes video data.
135
136
Public API:
137
138 24 Saúl Ibarra Corretgé
* producer: (r/w property) attach this consumer to a producer, in order to render the video data generated by the producer. If set to None, it's detached
139 14 Saúl Ibarra Corretgé
* consumer_port: pointer to the pjmedia_port object
140 25 Saúl Ibarra Corretgé
* close: detach from producer and free all resources
141 15 Saúl Ibarra Corretgé
142
h3. Producer and consumer objects
143
144
* VideoDevice: Producer, acquires video from a user camera.
145
* VideoWindow: Consumer, renders video in an SDL window. Extra methods: show/hide. Properties: native_handle, size.
146
147
* LocalVideoStream: Consumer, takes video from a VideoDevice and sends it to the remote party.
148
* RemoteVideoStream: Producer, produces video sent by the remote party.
149
150
These are just theoretical objects, won't be implemented in the first go.
151
152 17 Saúl Ibarra Corretgé
* VideoFileWriter: Consumer, saves incoming video data to a video file.
153 15 Saúl Ibarra Corretgé
* VideoFilePlayer: Producer, produces video data out of a video file.
154
155
* VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data.
156 16 Saúl Ibarra Corretgé
157
NOTE: pjsip does have a AVI file player, which also seems to support audio.
158 23 Saúl Ibarra Corretgé
159
h2. H264
160
161
Information about H264 profiles:
162
163
* http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
164
* https://supportforums.cisco.com/blog/149561/video-telepresence-sip-h264-profile-level-id