WIPVideo » History » Version 43
Saúl Ibarra Corretgé, 02/26/2015 10:08 AM
1 | 40 | Saúl Ibarra Corretgé | h1. Video Support |
---|---|---|---|
2 | 1 | Saúl Ibarra Corretgé | |
3 | |||
4 | h2. Dependencies |
||
5 | |||
6 | The following dependencies are required to build PJSIP with video support (including H264) |
||
7 | |||
8 | * ffmpeg (libavformat, libswscale, libavcodec, libavutil) |
||
9 | * libx264 |
||
10 | |||
11 | Versions I have tried: |
||
12 | |||
13 | 41 | Saúl Ibarra Corretgé | * ffmpeg 2.5.3 |
14 | * libx264 (snapshot-20141218-2245) |
||
15 | 1 | Saúl Ibarra Corretgé | |
16 | 20 | Saúl Ibarra Corretgé | h2. Installing dependencies (Debian / Ubuntu systems) |
17 | |||
18 | 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. |
||
19 | 1 | Saúl Ibarra Corretgé | |
20 | 20 | Saúl Ibarra Corretgé | On Debian, when the Debian-Multimedia repositories are used (quite common) you get FFmpeg and not libav. Oh the joy! |
21 | |||
22 | Installing dependencies on Debian: |
||
23 | |||
24 | <pre> |
||
25 | 34 | Saúl Ibarra Corretgé | apt-get install libv4l-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libx264-dev libavcodec-extra |
26 | 1 | Saúl Ibarra Corretgé | </pre> |
27 | 20 | Saúl Ibarra Corretgé | |
28 | If using the Debian-Multimedia repositories, do not install libavcodec-extra. |
||
29 | |||
30 | Installing dependencies on Ubuntu: |
||
31 | |||
32 | <pre> |
||
33 | 39 | Saúl Ibarra Corretgé | apt-get install libv4l-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libx264-dev libavcodec-extra |
34 | 20 | Saúl Ibarra Corretgé | </pre> |
35 | 1 | Saúl Ibarra Corretgé | |
36 | 20 | 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. |
37 | 21 | Saúl Ibarra Corretgé | |
38 | 41 | Saúl Ibarra Corretgé | h2. Manually compiling dependencies (for OSX) |
39 | 1 | Saúl Ibarra Corretgé | |
40 | 3 | Saúl Ibarra Corretgé | All dependencies will be compiled to a directory in the user's HOME directory: |
41 | 1 | Saúl Ibarra Corretgé | |
42 | 3 | Saúl Ibarra Corretgé | <pre> |
43 | 41 | Saúl Ibarra Corretgé | export SIPSIMPLE_FFMPEG_PATH=$HOME/work/ag-projects/video/local |
44 | 3 | Saúl Ibarra Corretgé | </pre> |
45 | |||
46 | 41 | Saúl Ibarra Corretgé | NOTE: yasm is required in order to enable asm optimizations. It does not come preinstalled on OSX, so it has to be manually installed. (brew install yasn will do) |
47 | 36 | Saúl Ibarra Corretgé | |
48 | 3 | Saúl Ibarra Corretgé | h3. libx264 |
49 | 37 | Saúl Ibarra Corretgé | |
50 | 3 | Saúl Ibarra Corretgé | |
51 | 1 | Saúl Ibarra Corretgé | <pre> |
52 | 41 | Saúl Ibarra Corretgé | ./configure --enable-shared --disable-avs --disable-lavf --disable-ffms --disable-gpac --prefix=$SIPSIMPLE_FFMPEG_PATH |
53 | 1 | Saúl Ibarra Corretgé | make |
54 | 8 | Saúl Ibarra Corretgé | make install |
55 | 37 | Saúl Ibarra Corretgé | </pre> |
56 | 1 | Saúl Ibarra Corretgé | |
57 | 3 | Saúl Ibarra Corretgé | h3. ffmpeg |
58 | |||
59 | 35 | Saúl Ibarra Corretgé | <pre> |
60 | # Some exports |
||
61 | 41 | Saúl Ibarra Corretgé | export PKG_CONFIG_PATH=$SIPSIMPLE_FFMPEG_PATH/lib/pkgconfig |
62 | 35 | Saúl Ibarra Corretgé | |
63 | 43 | Saúl Ibarra Corretgé | ./configure --enable-shared --disable-static --disable-lzma --enable-memalign-hack --enable-gpl --enable-libx264 --prefix=$SIPSIMPLE_FFMPEG_PATH --extra-cflags="`pkg-config --cflags x264`" --extra-ldflags="`pkg-config --libs x264`" |
64 | 4 | Saúl Ibarra Corretgé | make |
65 | make install |
||
66 | </pre> |
||
67 | 12 | Saúl Ibarra Corretgé | |
68 | 41 | Saúl Ibarra Corretgé | h2. API |
69 | 34 | Saúl Ibarra Corretgé | |
70 | 13 | Saúl Ibarra Corretgé | API for video components is based on 2 different types of video capable entities: |
71 | |||
72 | * VideoProducer: a source for video data, for example a video camera or a remote video stream |
||
73 | * VideoConsumer: a sink or destination for video data, for example a video rendering window |
||
74 | |||
75 | h3. Data flow |
||
76 | |||
77 | 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. |
||
78 | |||
79 | h3. VideoProducer |
||
80 | |||
81 | Produces video data. |
||
82 | |||
83 | 18 | Saúl Ibarra Corretgé | Public API: |
84 | 1 | Saúl Ibarra Corretgé | |
85 | * start: start producing video as soon as a consumer is attached |
||
86 | 18 | Saúl Ibarra Corretgé | * stop: immediately stop producing data |
87 | * close: remove all consumers and stop producing video data (also deallocate all C structures) |
||
88 | 29 | Saúl Ibarra Corretgé | * producer_port: pointer to the pjmedia_port object |
89 | 14 | Saúl Ibarra Corretgé | |
90 | h3. VideoConsumer |
||
91 | |||
92 | Consumes video data. |
||
93 | |||
94 | Public API: |
||
95 | |||
96 | 1 | 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 |
97 | * consumer_port: pointer to the pjmedia_port object |
||
98 | 14 | Saúl Ibarra Corretgé | * close: detach from producer and free all resources (also deallocate all C structures) |
99 | 1 | Saúl Ibarra Corretgé | |
100 | 24 | Saúl Ibarra Corretgé | h3. Producer and consumer objects |
101 | 14 | Saúl Ibarra Corretgé | |
102 | 42 | Saúl Ibarra Corretgé | * VideoCamera: Producer, acquires video from a user camera. |
103 | * FrameBufferVideoRenderer: Consumer, calls the user supplied callback with a video frame at a time. |
||
104 | 15 | Saúl Ibarra Corretgé | |
105 | 42 | Saúl Ibarra Corretgé | * LocalVideoStream: Consumer, takes video from a VideoCamera and sends it to the remote party. |
106 | 15 | Saúl Ibarra Corretgé | * RemoteVideoStream: Producer, produces video sent by the remote party. |
107 | |||
108 | 42 | Saúl Ibarra Corretgé | These are just theoretical objects, they are not currently implemented. |
109 | 15 | Saúl Ibarra Corretgé | |
110 | * VideoFileWriter: Consumer, saves incoming video data to a video file. |
||
111 | 17 | Saúl Ibarra Corretgé | * VideoFilePlayer: Producer, produces video data out of a video file. |
112 | 15 | Saúl Ibarra Corretgé | |
113 | * VideoMixer: Producer/Consumer, consumes video from multiple sources and produces aggregated video data. |
||
114 | |||
115 | 42 | Saúl Ibarra Corretgé | NOTE: pjsip does have a AVI file player, which also seems to support audio (this could be used to stream a movie, for example), it doesn't have a writer though. |
116 | 34 | Saúl Ibarra Corretgé | |
117 | 23 | Saúl Ibarra Corretgé | h2. H264 |
118 | |||
119 | Information about H264 profiles: |
||
120 | |||
121 | * http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels |
||
122 | * https://supportforums.cisco.com/blog/149561/video-telepresence-sip-h264-profile-level-id |
||
123 | 28 | Saúl Ibarra Corretgé | |
124 | h2. OpenH264 implementation |
||
125 | |||
126 | PJSIP has an initial version of a wrapper for Cisco's OpenH264 implementation (http://www.openh264.org/). http://trac.pjsip.org/repos/changeset?reponame=&old=4815%40%2F&new=4815%40%2F |
||
127 | |||
128 | 41 | Saúl Ibarra Corretgé | OpenH264 seems to implement SVC, which is better than AVC. In practice it didn't outperform libx264 and it only implements the constrained baseline profile, so it was discarded. |