Project

General

Profile

WIPVideo » History » Version 20

Saúl Ibarra Corretgé, 03/28/2014 10:50 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
*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
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
make dep
98
make
99
# pjsua will be located in pjsip-apps/bin/
100
</pre>
101 12 Saúl Ibarra Corretgé
102
h2. Proposed API
103
104 13 Saúl Ibarra Corretgé
API for video components is based on 2 different types of video capable entities:
105
106
* VideoProducer: a source for video data, for example a video camera or a remote video stream
107
* VideoConsumer: a sink or destination for video data, for example a video rendering window
108
109
h3. Data flow
110
111
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.
112
113
h3. VideoProducer
114
115
Produces video data. 
116
117
Internal API:
118
119
* _add_consumer: attach a consumer, called by the consumer
120
* _remove_consumer: detach a consumer from a producer, called by the consumer
121
122 18 Saúl Ibarra Corretgé
123 1 Saúl Ibarra Corretgé
Public API:
124
125 18 Saúl Ibarra Corretgé
* start: start producing video as soon as a consumer is attached
126
* stop: immediately stop producing data
127 13 Saúl Ibarra Corretgé
* close: remove all consumers and stop producing video data
128 14 Saúl Ibarra Corretgé
* producer_port: pointer to the pjmedia_port object
129
130
h3. VideoConsumer
131
132
Consumes video data.
133
134
Public API:
135
136
* attach: tie this consumer to a producer, in order to render the video data generated by the producer
137
* detach: untie this consumer from a producer
138
* consumer_port: pointer to the pjmedia_port object
139 15 Saúl Ibarra Corretgé
140
h3. Producer and consumer objects
141
142
* VideoDevice: Producer, acquires video from a user camera.
143
* VideoWindow: Consumer, renders video in an SDL window. Extra methods: show/hide. Properties: native_handle, size.
144
145
* LocalVideoStream: Consumer, takes video from a VideoDevice and sends it to the remote party.
146
* RemoteVideoStream: Producer, produces video sent by the remote party.
147
148
These are just theoretical objects, won't be implemented in the first go.
149
150 17 Saúl Ibarra Corretgé
* VideoFileWriter: Consumer, saves incoming video data to a video file.
151 15 Saúl Ibarra Corretgé
* VideoFilePlayer: Producer, produces video data out of a video file.
152
153
* VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data.
154 16 Saúl Ibarra Corretgé
155
NOTE: pjsip does have a AVI file player, which also seems to support audio.