rtspserver
Class RtspFile

Direct Known Subclasses:
RtspFileAu, RtspFileRaw, RtspFileRtp, RtspFileWav

abstract class RtspFile

Base class for all the file types ( *.au, *.wav, *.raw, *.rtp ). Handles reading and writing to audio file and audio header.


Constructor Summary
RtspFile(const string & shortFilename)
          constructor

Destructor Summary
 virtual ~RtspFile()
          deconstructor

Method Summary
 boolappendSdpFile(const char * data, const int len)
          Append data to *.sdp file.
 abstract boolclose()
          Close audio file and updates audio header.
 booldeleteLineSdpFile(const char * data)
          Delete line from *.sdp file.
 abstract const stringfileExtensionString()
          File extension string.
 const Datafilename()
          Filename string.
 abstract boolloadHeader(int * ftIndex, int * lengthInMs)
          Load audio header codec information.
 const DatalocalFilename()
          Local filename string.
 abstract boolopen(bool bReadWrite, int ftIndex)
          Opens audio file for reading or writing.
 abstract intread(void * data, int max, unsigned short * pSeqNum, unsigned int * pTS)
          Read from audio file.
 boolreadSdpFile(RtspSdp & rtspSdp)
          Reads rtspSdp from *.sdp file.
 abstract boolsaveHeader(const int ftIndex, RtspSdp & rtspSdp)
          Save sdp block into audio header.
 abstract longseek(const long seekToMs, const int whence)
          Seek read/write pointer into file.
 const string &shortFilename()
          Filename sting only.
 abstract intwrite(void * data, int max, unsigned short uSeqNum, unsigned int uTS)
          Write to audio file.
 boolwriteSdpFile(RtspSdp & rtspSdp)
          Writes rtspSdp to *.sdp file.

Constructor Detail

RtspFile

public RtspFile(const string & shortFilename)
constructor
Parameters:
shortFilename - rtsp based filename of audio file
Method Detail

~RtspFile

public virtual ~RtspFile()
deconstructor
Method Detail

appendSdpFile

public bool appendSdpFile(const char * data, const int len)
Append data to *.sdp file. Data should end with "\n".
Parameters:
data - new line to be writen to file
len - length of new data
Returns: false on failure

close

public abstract bool close()
Close audio file and updates audio header.
Returns: false on failure. (ie file not open)

deleteLineSdpFile

public bool deleteLineSdpFile(const char * data)
Delete line from *.sdp file. (TODO function not completed!)
Parameters:
data - beginning of which line to delete (null terminated)
Returns: false on failure (ie can't match line)

fileExtensionString

public abstract const string fileExtensionString()
File extension string.
Returns: file extension (ie "*.au")

filename

public const Data filename()
Filename string. Used for rtsp messages.
Returns: file name with rtsp file path and extension. (ie "/samples/foo.au")

loadHeader

public abstract bool loadHeader(int * ftIndex, int * lengthInMs)
Load audio header codec information.
Parameters:
ftIndex - return param of new codec index
lenghtInMs - return param of file length in milliseconds.
Returns: false on failure (ie can't open audio header or fail to read audio header)

localFilename

public const Data localFilename()
Local filename string. Used for local file access.
Returns: filename with local file path and extension. (ie "/usr/local/sounds/foo.au")

open

public abstract bool open(bool bReadWrite, int ftIndex)
Opens audio file for reading or writing.
Parameters:
bReadWrite - true for write; false for reading
ftIndex - codec index of audio file. Value obtainable from loadHeader().
Returns: false on failure (ie can't find audio file)

read

public abstract int read(void * data, int max, unsigned short * pSeqNum, unsigned int * pTS)
Read from audio file.
Parameters:
data - return param preallocationed memory location for new data
max - size of preallocationed memory location in bytes
pSeqNum - rtp sequence number of new data
pTs - rtp time stamp of new data
Returns: bytes of new data read

readSdpFile

public bool readSdpFile(RtspSdp & rtspSdp)
Reads rtspSdp from *.sdp file.
Parameters:
rtspSdp - return param of sdp block
Returns: false on failure

saveHeader

public abstract bool saveHeader(const int ftIndex, RtspSdp & rtspSdp)
Save sdp block into audio header. Child class either uses ftIndex or rtspSdp to determine correct header to write. Overwrite any existing header information.
Parameters:
ftIndex - new codec parameters indexed base on RtpFileTypes
rtspSdp - sdp block to write into sdp file (if configured)

seek

public abstract long seek(const long seekToMs, const int whence)
Seek read/write pointer into file.
Parameters:
seekToMs - new read/write pointer location
whence - relative seek [SEEK_SET|SEEK_CUR]
Returns: actual read/write pointer location in milliseconds

shortFilename

public const string & shortFilename()
Filename sting only. Used for printing or debug messages.
Returns: filename without extension (ie "foo")

write

public abstract int write(void * data, int max, unsigned short uSeqNum, unsigned int uTS)
Write to audio file.
Parameters:
data - new data to write
max - size of new data in bytes
uSeqNum - rtp sequence number of new data
uTs - rtp time stamp of new data
Returns: bytes of new data written

writeSdpFile

public bool writeSdpFile(RtspSdp & rtspSdp)
Writes rtspSdp to *.sdp file.
Parameters:
rtspSdp - sdp block
Returns: false on failure