rtspserver
Class RtspFileHandler


class RtspFileHandler

Interface into RtspFile class. Handles reading and writing to audio file and audio header. Container for parameters used by rtp processor.


Constructor Summary
RtspFileHandler(const Data & filename, const Data & contentBase)
          Opens the specified descriptor file.

Destructor Summary
 virtual ~RtspFileHandler()
          deconstructor

Method Summary
 boolcloseAudioFile()
          Closes audio file.
 const Datafilename()
          Return name of audio file.
 const DatafilenameUrl()
          return contentbase(rtsp file path) + filename + extension
 const intftIndex()
          codec parameters index
 const longlength()
          Return length of audio file in ms, -1 if unknown.
 boolloadAudioHeader()
          Builds myRtspSdp from audio header or *.sdp file.
 boolopenAudioFile(const bool mode, const int packetSize)
          Open file with given mode and sizing.
 const intpacketCodec()
          rtp payload codec
 const intpacketInterval()
          packet interval in milliseconds
 const intpacketSamples()
          samples per rtp packet
 const intpacketSize()
          rtp packet size in bytes
 intread(void * data, size_t max, unsigned short * pSeqNum, unsigned int * pTS)
          Read from audio file.
 RtspSdp &readAudioHeader()
          Read sdp block from audio header or *.sdp file.
 longseek(long npt)
          Seek read/write pointer into file.
 intwrite(void * data, size_t max, unsigned short uSeqNum, unsigned int uTS)
          Write to audio file.
 boolwriteAudioHeader(const Data & sdp)
          Write sdp block into audio header and/or *.sdp file.

Constructor Detail

RtspFileHandler

public RtspFileHandler(const Data & filename, const Data & contentBase)
Opens the specified descriptor file. Parses from filename file extension, has default if not found. Parses from filename myFtIndex(codec type), has default if not found. Note, myFtIndex might not match format type in header of audio file. Sets up the following private data members. - myFileExtension - myFtIndex ( my be incorrect ) - myFilename
Parameters:
filename - filename.[wav|au|raw|...]
contentBase - rtsp file path
Method Detail

~RtspFileHandler

public virtual ~RtspFileHandler()
deconstructor
Method Detail

closeAudioFile

public bool closeAudioFile()
Closes audio file. Updates audio header and *.sdp file
Returns: false on failure

filename

public const Data filename()
Return name of audio file.

filenameUrl

public const Data filenameUrl()
return contentbase(rtsp file path) + filename + extension

ftIndex

public const int ftIndex()
codec parameters index

length

public const long length()
Return length of audio file in ms, -1 if unknown.

loadAudioHeader

public bool loadAudioHeader()
Builds myRtspSdp from audio header or *.sdp file.
Returns: false on failure

openAudioFile

public bool openAudioFile(const bool mode, const int packetSize)
Open file with given mode and sizing.
Parameters:
mode - false read, true>/code>write
packetSize - bytes per packet
Returns: false on failure

packetCodec

public const int packetCodec()
rtp payload codec

packetInterval

public const int packetInterval()
packet interval in milliseconds

packetSamples

public const int packetSamples()
samples per rtp packet

packetSize

public const int packetSize()
rtp packet size in bytes

read

public int read(void * data, size_t 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, -1 if error

readAudioHeader

public RtspSdp & readAudioHeader()
Read sdp block from audio header or *.sdp file.
Returns: sdp block. Can be casted into char* or string - see RtspSdp class.

seek

public long seek(long npt)
Seek read/write pointer into file. # @param npt time in ms
Returns: actual npt in milliseconds, -1 if error

write

public int write(void * data, size_t 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, -1 if error

writeAudioHeader

public bool writeAudioHeader(const Data & sdp)
Write sdp block into audio header and/or *.sdp file. This function will check codec in sdp block is valid and supported. Audio file and header will be created as needed.
Parameters:
sdp - sdp block (ie content body of rtsp ANNOUNCE)

Association Links

to Class RtspSdp

sdp data

to Class RtspFile

RtspFile interface