Project

General

Profile

WIPVideo » History » Version 27

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