Add a mp3 module to the rtspd server
The design of this mp3 module consisting of two major functions
- Parsing the mp3 file into frames and extracting the header info
for each frame.
- Using the frame info gathered in the above step to provide for
some callback functions for the existing rtspd server.
Parsing MP3 file
An Mp3 file is divided into several frames, each frame has its own header.
Hence mp3 frames can support variable bit rates, but the frame length are more
more or less static for mpeg layer III. First four bytes of every frame contains the header information which includes layer, bitrate, version and sampling frequency. This header information can be used to calculate how long the frame takes when it is played.
The file rtspd/mp3/mp3FormatReader.cpp parses the mp3 files, extracting frame after frame, and associated header information in a structure.
Streaming Mp3 Frames
RTSP server uses some call back functions to support various operations. Some of these are presented below with a brief description of what they do :-
-
Mp3Describe
This function performs the same functions as SndDescribe in snd.c except
for the following changes :-
- Does not handle payload types other than mp3->pt (which is maintained at 14)
- Does not store track information
- Bitrate information may be set to 44.1 if no headers have been read as yet. Since mp3
supports bitrate switching and bitrate makes sense only if a header has been
read, this seems a reasonable thing to do.
This above function is called in response to a DESCRIBE method request from the client.
- Mp3Open
This functions opens a mp3 file and returns a pointer to the structure containing information about the file opened. Called in response to OPEN request from the client.
- Mp3Read
This file provides the streaming server with mp3 frames according to the timing parameters passed. Coupled with Mp3Seek which positions the player to some specific location(temporal) in the Mp3 file forms the crux of mp3 module.