DesignVideo

Version 11 (Anonymous, 05/07/2010 04:24 pm)

1 2 Adrian Georgescu
[[TOC(Design*, depth=1)]]
2 2 Adrian Georgescu
3 2 Adrian Georgescu
= Video blueprint =
4 3 Adrian Georgescu
5 3 Adrian Georgescu
Design and implement Ticket [ticket:18]
6 4 Saúl Ibarra Corretgé
7 4 Saúl Ibarra Corretgé
== Goals ==
8 4 Saúl Ibarra Corretgé
9 11 Adrian Georgescu
The goal is to implement the support for video session is the SIPSIMPLE middleware. For the video encoding/decoding VLC library shall be used, which supports H.264 codec (first codec to be supported).
10 1 Adrian Georgescu
11 11 Adrian Georgescu
The video stream should behave like the audio stream at the transport level: SRTP and ICE should be usable. It must comply with the IMediaStream interface, the same way AudioStream does.
12 11 Adrian Georgescu
13 11 Adrian Georgescu
14 11 Adrian Georgescu
== Integration ==
15 11 Adrian Georgescu
16 11 Adrian Georgescu
In the picture below the integration of the video support into SIPSIMPLE is shown divided into it's different components:
17 11 Adrian Georgescu
18 11 Adrian Georgescu
(IMAGE)
19 11 Adrian Georgescu
20 11 Adrian Georgescu
 * PJSIP: a new transport is needed. Instead of creating a whole new transport, which would require to implement SRTP and ICE again, a transport adapter will be implemented. A transport adapter sits between a real transport and a pjmedia_stream. To the stream, this adapter will look like a media transport, and to existing media transport, this adapter will look like a stream. The benefit of this approach is we can use the same adapter for both kind of media transports, that is the UDP and ICE media transport. This is exactly the approach that was taken for SRTP. This transport adapter will be responsible for encoding/decoding the video information.
21 11 Adrian Georgescu
22 11 Adrian Georgescu
 * Middleware:
23 11 Adrian Georgescu
  * VideoTransport: the VideoTransport will use RTPTransport to carry the video data and will be responsible for building the SDP for the video stream. A new option will be added to RTPTransport so that it starts the video transport adapter instead of the regular transport when needed.
24 11 Adrian Georgescu
  * VideoStream: implements IMediaStream interface. Will export a plugable mechanism so that the application layer can access the video data and display it in a window for example, similar to ExternalVNCViewer on MSRP streams.
25 11 Adrian Georgescu
26 11 Adrian Georgescu
 * Application: the application will receive the video data from the stream and 'paint' it on a window.
27 11 Adrian Georgescu
28 11 Adrian Georgescu
== Video acquisition ==
29 4 Saúl Ibarra Corretgé
30 4 Saúl Ibarra Corretgé
== Roadmap ==
31 4 Saúl Ibarra Corretgé
32 4 Saúl Ibarra Corretgé
In order to achive the goal, the following subtasks need to be done:
33 4 Saúl Ibarra Corretgé
  * Implement a wrapper class around the VLC Python bindings. http://wiki.videolan.org/Python_bindings
34 4 Saúl Ibarra Corretgé
  * Create videostream.py implementing IMediaStream interface.
35 4 Saúl Ibarra Corretgé
    * Use the VLC wrapper class to encode/decode the stream.
36 4 Saúl Ibarra Corretgé
  * Bundle the VLC Python wrapper together with SIPSIMPLE so that it get's compiled and installed when installing SIPSIMPLE.
37 1 Adrian Georgescu
  * Create sip_video_session.py script (or modify sip_audio_session_script) so that it uses video capabilities.
38 6 Saúl Ibarra Corretgé
39 6 Saúl Ibarra Corretgé
40 6 Saúl Ibarra Corretgé
At the time of mangling the SDPs, two approaches can be taken in order to add video support:
41 6 Saúl Ibarra Corretgé
  * Modify PJSIP's PJMEDIA component to encode/decode video streams and handle them the same as audio streams from the upper layers.
42 6 Saúl Ibarra Corretgé
  * Just use PJMEDIA to do the SDP negotiation and audio part. Video would be external to the PJMEDIA layer.
43 6 Saúl Ibarra Corretgé
44 6 Saúl Ibarra Corretgé
For this case the second approach seems to be a better one. When receiving an incoming call or making a call, the SDPs will be mangled so that they include H.264 stream information i.e.
45 6 Saúl Ibarra Corretgé
{{{
46 6 Saúl Ibarra Corretgé
...
47 6 Saúl Ibarra Corretgé
m=video 6001 RTP/AVP 98
48 6 Saúl Ibarra Corretgé
a=rtpmap:98 H264/90000
49 6 Saúl Ibarra Corretgé
...
50 6 Saúl Ibarra Corretgé
}}}
51 6 Saúl Ibarra Corretgé
52 6 Saúl Ibarra Corretgé
So in the case of an incoming call, an VLC player instance will be opened for playing the stream at the IP and port specified by the SDP. For an outgoing call, an VLC will stream H.264 video taken from a selected video source (webcam, still picture, ...) from the sipsimpleclient listen IP and will randomly select a port (in a given range) which doesn't interfere with the audio ports.
53 6 Saúl Ibarra Corretgé
54 6 Saúl Ibarra Corretgé
This way audio and video components are sepparate, but it's not necesary to modify the underlying media handling component: pjmedia.
55 4 Saúl Ibarra Corretgé
56 4 Saúl Ibarra Corretgé
57 4 Saúl Ibarra Corretgé
== Components ==
58 4 Saúl Ibarra Corretgé
59 5 Saúl Ibarra Corretgé
[[Image(videostream-components.png)]]
60 4 Saúl Ibarra Corretgé
61 4 Saúl Ibarra Corretgé
62 4 Saúl Ibarra Corretgé
== Classes == 
63 4 Saúl Ibarra Corretgé
64 8 Saúl Ibarra Corretgé
[[Image(videostream-classes.png)]]
65 7 Saúl Ibarra Corretgé
66 7 Saúl Ibarra Corretgé
67 7 Saúl Ibarra Corretgé
== Code mockup == 
68 7 Saúl Ibarra Corretgé
69 9 Saúl Ibarra Corretgé
There are 3 files attached containing a simple code mockup:
70 9 Saúl Ibarra Corretgé
  * videostream.py: Class representing the actual video stream. Contains necessary functions to initialize/stop the stream using VLC as the engine.
71 9 Saúl Ibarra Corretgé
  * vlcw.py: Wrapper class around the VLC python bindings. Provide some higher level functions to be used by the VideoStream class.
72 9 Saúl Ibarra Corretgé
  * sip_video_session.py: Script to test videostream from a console interface.