Project

General

Profile

WIPVideo » History » Version 26

Adrian Georgescu, 04/07/2014 02:25 PM

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 26 Adrian Georgescu
h4. There is a bug in SDL, when a Cocoa window is closed, it brings up the next window in the z stack. Comment this out in close() function of SDL_cocoawindow.m
82
83 3 Saúl Ibarra Corretgé
<pre>
84
./configure --disable-audio --prefix=$MY_VIDEO_LIBS
85
make
86
make install
87 10 Saúl Ibarra Corretgé
88
# If a 32bit build is wanted:
89
CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --disable-audio --prefix=$MY_VIDEO_LIBS
90 3 Saúl Ibarra Corretgé
</pre>
91 4 Saúl Ibarra Corretgé
92
h2. Compiling PJSIP (pjsua, for testing)
93
94
<pre>
95
svn co http://svn.pjsip.org/repos/pjproject/trunk pjsip
96
cd pjsip
97
echo "#define PJMEDIA_HAS_VIDEO 1" > pjlib/include/pj/config_site.h
98
./configure --with-sdl=$MY_VIDEO_LIBS --with-ffmpeg=$MY_VIDEO_LIBS
99 22 Saúl Ibarra Corretgé
# if a 32bit build is wanted:
100
# CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --with-sdl=$MY_VIDEO_LIBS --with-ffmpeg=$MY_VIDEO_LIBS
101 4 Saúl Ibarra Corretgé
make dep
102
make
103
# pjsua will be located in pjsip-apps/bin/
104
</pre>
105 12 Saúl Ibarra Corretgé
106
h2. Proposed API
107
108 13 Saúl Ibarra Corretgé
API for video components is based on 2 different types of video capable entities:
109
110
* VideoProducer: a source for video data, for example a video camera or a remote video stream
111
* VideoConsumer: a sink or destination for video data, for example a video rendering window
112
113
h3. Data flow
114
115
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.
116
117
h3. VideoProducer
118
119
Produces video data. 
120
121
Internal API:
122
123
* _add_consumer: attach a consumer, called by the consumer
124
* _remove_consumer: detach a consumer from a producer, called by the consumer
125
126 18 Saúl Ibarra Corretgé
127 1 Saúl Ibarra Corretgé
Public API:
128
129 18 Saúl Ibarra Corretgé
* start: start producing video as soon as a consumer is attached
130
* stop: immediately stop producing data
131 13 Saúl Ibarra Corretgé
* close: remove all consumers and stop producing video data
132 14 Saúl Ibarra Corretgé
* producer_port: pointer to the pjmedia_port object
133
134
h3. VideoConsumer
135
136
Consumes video data.
137
138
Public API:
139
140 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
141 14 Saúl Ibarra Corretgé
* consumer_port: pointer to the pjmedia_port object
142 25 Saúl Ibarra Corretgé
* close: detach from producer and free all resources
143 15 Saúl Ibarra Corretgé
144
h3. Producer and consumer objects
145
146
* VideoDevice: Producer, acquires video from a user camera.
147
* VideoWindow: Consumer, renders video in an SDL window. Extra methods: show/hide. Properties: native_handle, size.
148
149
* LocalVideoStream: Consumer, takes video from a VideoDevice and sends it to the remote party.
150
* RemoteVideoStream: Producer, produces video sent by the remote party.
151
152
These are just theoretical objects, won't be implemented in the first go.
153
154 17 Saúl Ibarra Corretgé
* VideoFileWriter: Consumer, saves incoming video data to a video file.
155 15 Saúl Ibarra Corretgé
* VideoFilePlayer: Producer, produces video data out of a video file.
156
157
* VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data.
158 16 Saúl Ibarra Corretgé
159
NOTE: pjsip does have a AVI file player, which also seems to support audio.
160 23 Saúl Ibarra Corretgé
161
h2. H264
162
163
Information about H264 profiles:
164
165
* http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
166
* https://supportforums.cisco.com/blog/149561/video-telepresence-sip-h264-profile-level-id