Gecko:RTSPProtocol

From MozillaWiki
Jump to: navigation, search

Support RTSPProtocol in B2G and other platforms(?) WEB content can use rtsp://... URL at the src attribute of MediaElement to play a RTSP stream. For browser, user type a RTSP URL to launch a simple player to play the stream.

Design

Current design of seek of the MediaResource supports only seeking by byte offsets, but for RTSP or other streaming services we need to support seeking by time offset. We should add a new function MediaResource::SeekTime() for seeking by time offset instead of Seek(). We also need additional functions for retrieving meta-data; for example, number of channels, codec for each channel, ..., etc. For reading data from MediaResource we need to add another function to read data with track handler for distinguishing what the track is the data from.

    bool SeekEnabled();
    bool SeekTimeEnabled();
    nsresult SeekTime(int64_t timeOffset);
    uint64_t TellTime();
    bool ReadChannelEnabled();
    nsresult ReadChannel(char *buffer, uint32_t aCount, uint32_t *aBytes, uint32_t *aTrack);
    // Meta-data
    int GetTrackNumbers();
    void GetTrackMeta(Meta *aMeta);

RTSP is a special protocol running with multiple network sessions, one for RTSP, and two for RTP protocol, for audio track and video track respectively. RTSPController is responsible for handling these sessions, it is initialized with an nsIChannel object for RTSP session, then communicate with the RTSP server given by the nsIChannel object. RTSPController provides basic funtions of RTSP protocol, seek, play, pause, stop, and others. These functions are common among streaming services, so MediaStreamController is defined for generalizing.

MediaResourceRTSP is a subclass of MediaResource, and collaborate with RTSPController. It implements the new added function SeekTime(). The MediaElement passes an nsIChannel instance to MediaResourceRTSP, then it create an RTSPController initialized with the nsIChannel object. The MediaResourceRTSP leverages RTSPController to handle RTSP protocol.

RtspDesignArchitecture.png
Figure 1: Original design on white board.
Translate into UML diagram. RTSP ArchitectureDraft 20130206.png
Figure 2: Original design.

The reason that we need MediaDecoderRTSP is because container parser is involved inside MediaDecoder. By move out demultiplexer from MediaDecocder, MediaDecoderRTSP is not needed. Please refer to Fig 3. RTSP ArchitectureDraft2.png
Figure 3: Design with move out contain parser from MediaDecoder.

Updated RTSP Architecture Draft RtspDraftArchitecture.v0.1.png
Figure 4: Current design in Bug 831645.