sipxmedialib  Version 3.3
Public Types | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
MprRecorder Class Reference

The "Recorder" media processing resource. More...

#include <MprRecorder.h>

Inheritance diagram for MprRecorder:
Inheritance graph
[legend]
Collaboration diagram for MprRecorder:
Collaboration graph
[legend]

Public Types

enum  RecordFileFormat {
  UNINITIALIZED_FORMAT = -1, RAW_PCM_16 = 0, WAV_PCM_16 = 1, WAV_ALAW = 6,
  WAV_MULAW = 7, WAV_GSM = 49
}
 These match the WAVE compression format codes in the RIFF header for convenience. More...
 
- Public Types inherited from MpResource
enum  VisitState { NOT_VISITED, IN_PROGRESS, FINISHED }
 Graph traversal states that are used when running a topological sort to order resources within a flow graph. More...
 
enum  { ASSOCIATED_LATENCY =-1, INF_LATENCY =-1 }
 

Public Member Functions

Creators
 MprRecorder (const UtlString &rName)
 Constructor. More...
 
virtual ~MprRecorder ()
 Destructor. More...
 
- Public Member Functions inherited from MpAudioResource
 MpAudioResource (const UtlString &rName, int minInputs, int maxInputs, int minOutputs, int maxOutputs)
 Constructor. More...
 
virtual ~MpAudioResource ()
 Destructor. More...
 
virtual UtlBoolean processFrame (void)
 Wrapper around doProcessFrame(). More...
 
- Public Member Functions inherited from MpResource
 MpResource (const UtlString &rName, int minInputs, int maxInputs, int minOutputs, int maxOutputs)
 Constructor. More...
 
virtual ~MpResource ()
 Destructor. More...
 
virtual UtlBoolean disable ()
 Disable this resource. More...
 
virtual UtlBoolean enable ()
 Enable this resource. More...
 
virtual void reset ()
 This method is invoked for resources that care about stream discontinuities. More...
 
UtlBoolean handleMessages (OsMsgQ &msgQ)
 Handles a queue full of incoming messages for this media processing object. More...
 
void setVisitState (int newState)
 Sets the visit state for this resource. More...
 
OsStatus sendNotification (MpResNotificationMsg::RNMsgType msgType)
 Send a notification with the given message type if notifications are enabled. More...
 
OsStatus sendNotification (MpResNotificationMsg &msg)
 Send the given notification message if notifications are enabled. More...
 
virtual void setConnectionId (MpConnectionID connectionId)
 Set the ID of a connection this resource belongs to. More...
 
virtual void setStreamId (int streamId)
 Set the ID of a stream inside of the connection this resource belongs to. More...
 
virtual int getStreamId (void)
 Get the ID of a stream within the connection this resource belongs to. More...
 
virtual OsStatus pushBuffer (int inputPort, MpBufPtr &inputBuffer)
 Receive buffer asynchronously from resource at given input port. More...
 
virtual void reassignSSRC (void)
 Broadcast announcement that we are changing our SSRC. More...
 
MpFlowGraphBasegetFlowGraph () const
 Returns parent flowgraph. More...
 
void getInputInfo (int inPortIdx, MpResource *&rpUpstreamResource, int &rUpstreamPortIdx)
 Returns information about the upstream end of a connection. More...
 
const UtlString & getName () const
 Returns the name associated with this resource. More...
 
void getOutputInfo (int outPortIdx, MpResource *&rpDownstreamResource, int &rDownstreamPortIdx)
 Returns information about the downstream end of a connection. More...
 
int getVisitState ()
 Returns the current visit state for this resource. More...
 
int maxInputs () const
 Returns the maximum number of inputs supported by this resource. More...
 
int maxOutputs () const
 Returns the maximum number of outputs supported by this resource. More...
 
int minInputs () const
 Returns the minimum number of inputs required by this resource. More...
 
int minOutputs () const
 Returns the minimum number of outputs required by this resource. More...
 
int numInputs () const
 Returns the number of resource inputs that are currently connected. More...
 
int numOutputs () const
 Returns the number of resource outputs that are currently connected. More...
 
virtual MpConnectionID getConnectionId (void) const
 Get the ID of a connection this resource belongs to. More...
 
int reserveFirstUnconnectedInput ()
 Find the first unconnected input port and reserve it. More...
 
int reserveFirstUnconnectedOutput ()
 Find the first unconnected output port and reserve it. More...
 
UtlContainableType getContainableType () const
 Get the ContainableType for a UtlContainable derived class. More...
 
virtual OsStatus getCurrentLatency (int &latency, int input=0, int output=0) const
 Get current input to output latency (in samples) More...
 
UtlBoolean isEnabled () const
 Returns TRUE is this resource is currently enabled, FALSE otherwise. More...
 
UtlBoolean isInputConnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated input is connected, FALSE otherwise. More...
 
UtlBoolean isInputUnconnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated input is not connected, FALSE otherwise. More...
 
UtlBoolean isOutputConnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated output is connected, FALSE otherwise. More...
 
UtlBoolean isOutputUnconnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated output is not connected, FALSE otherwise. More...
 
UtlBoolean areNotificationsEnabled () const
 Returns TRUE if notification sending is enabled on this resource. More...
 
virtual UtlBoolean isAsynchInput (int inputIndex)
 Takes asynchronous input (pushBuffer). More...
 

Static Public Member Functions

Manipulators
static OsStatus startFile (const UtlString &namedResource, OsMsgQ &fgQ, const char *filename, RecordFileFormat recFormat, int time=0, int silenceLength=-1, UtlBoolean append=FALSE, int numChannels=1)
 Start recording to a file with given parameters. More...
 
static OsStatus startBuffer (const UtlString &namedResource, OsMsgQ &fgQ, MpAudioSample *pBuffer, int bufferSize, int time=0, int silenceLength=-1, int numChannels=1)
 Start recording to a buffer with given parameters. More...
 
static OsStatus pause (const UtlString &namedResource, OsMsgQ &flowgraphQueue)
 Pause recording if it is already recording. More...
 
static OsStatus resume (const UtlString &namedResource, OsMsgQ &flowgraphQueue)
 Resume recording if it is already recording. More...
 
static OsStatus startCircularBuffer (const UtlString &namedResource, OsMsgQ &fgQ, CircularBufferPtr &buffer, RecordFileFormat recordingFormat, unsigned long recordingBufferNotificationWatermark, int numChannels=1)
 Start recording to a circular-buffer with given parameters. More...
 
static OsStatus stop (const UtlString &namedResource, OsMsgQ &fgQ)
 Stop recording if it has not stopped automatically yet. More...
 
- Static Public Member Functions inherited from MpResource
static OsStatus disable (const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to disable the resource named. More...
 
static OsStatus enable (const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to enable the resource named. More...
 
static OsStatus setNotificationsEnabled (UtlBoolean enable, const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to enable or disable resource notifications on the named resource. More...
 
static void resourceInfo (MpResource *pResource, int index)
 Displays information on the console about the specified resource. More...
 

Protected Types

enum  AddlMsgTypes {
  MPRM_START_FILE = MpResourceMsg::MPRM_EXTERNAL_MESSAGE_START, MPRM_START_BUFFER, MPRM_PAUSE, MPRM_RESUME,
  MPRM_START_CIRCULAR_BUFFER, MPRM_STOP
}
 
enum  FinishCause { FINISHED_AUTO, FINISHED_MANUAL, FINISHED_ERROR }
 
enum  State { STATE_IDLE, STATE_RECORDING, STATE_PAUSED }
 
enum  RecordDestination { TO_UNDEFINED = -1, TO_FILE, TO_BUFFER, TO_CIRCULAR_BUFFER }
 
typedef int(MprRecorder::* WriteMethod) (char *channelBuffers[], int)
 

Protected Member Functions

virtual UtlBoolean doProcessFrame (MpBufPtr inBufs[], MpBufPtr outBufs[], int inBufsSize, int outBufsSize, UtlBoolean isEnabled, int samplesPerFrame, int samplesPerSecond)
 This method does the real work for the media processing resource and must be defined in each class derived from this one. More...
 
UtlBoolean handleStartFile (int file, RecordFileFormat recFormat, int time, int silenceLength, UtlBoolean append, int numChannels)
 Handle MPRM_START_FILE message. More...
 
UtlBoolean handleStartBuffer (MpAudioSample *pBuffer, int bufferSize, int time, int silenceLength, int numChannels)
 Handle MPRM_START_BUFFER message. More...
 
UtlBoolean handleStartCircularBuffer (CircularBufferPtr *buffer, RecordFileFormat recordingFormat, unsigned long recordingBufferNotificationWatermark, int numChannels)
 Handle MPRM_START_CIRCULAR_BUFFER message. More...
 
UtlBoolean handleStop ()
 Handle MPRM_STOP message. More...
 
virtual UtlBoolean handleDisable ()
 perform the disable operation on the resource More...
 
virtual UtlBoolean handleMessage (MpResourceMsg &rMsg)
 Handle messages for this resource. More...
 
void startRecording (int time, int silenceLength)
 Prepare for recording. More...
 
UtlBoolean finish (FinishCause cause)
 Recording has been stopped with given cause. More...
 
void closeFile (const char *fromWhereLabel)
 Close file if it is opened and update WAV header if needed. More...
 
int writeFileSilence (int numSamples)
 Write silence to the file. More...
 
int writeSamples (const MpAudioSample *pBuffer[], int numSamples, WriteMethod writeMethod)
 Write given data to the specified target. More...
 
int writeBufferSilence (int numSamples)
 Write silence to the buffer. More...
 
int writeCircularBufferSilence (int numSamples)
 Write silence to the circular buffer. More...
 
int writeBufferSpeech (const MpAudioSample *pBuffer, int numSamples)
 Write given speech data to the buffer. More...
 
- Protected Member Functions inherited from MpResource
virtual UtlBoolean handleMessage (MpFlowGraphMsg &fgMsg)
 Handles an incoming flowgraph message for this media processing object. More...
 
virtual UtlBoolean handleEnable ()
 perform the enable operation on the resource More...
 
void setInputBuffer (int inPortIdx, const MpBufPtr &pBuf)
 If there already is a buffer stored for this input port, delete it. Then store pBuf for the indicated input port. More...
 
OsStatus postMessage (MpFlowGraphMsg &rMsg)
 Post a message from this resource. More...
 
OsStatus postMessage (MpResourceMsg &rMsg)
 Post a message for this resource. More...
 
UtlBoolean pushBufferDownsream (int outPortIdx, const MpBufPtr &pBuf)
 Makes pBuf available to resource connected to the outPortIdx output port of this resource. More...
 
virtual OsStatus setFlowGraph (MpFlowGraphBase *pFlowGraph)
 Associates this resource with the indicated flow graph. More...
 
virtual OsStatus setNotificationsEnabled (UtlBoolean enable)
 Sets whether or not this resource should send notifications. More...
 
virtual UtlBoolean connectInput (MpResource &rFrom, int fromPortIdx, int toPortIdx)
 Connects the toPortIdx input port on this resource to the fromPortIdx output port of the rFrom resource. More...
 
virtual UtlBoolean connectOutput (MpResource &rTo, int toPortIdx, int fromPortIdx)
 Connects the fromPortIdx output port on this resource to the toPortIdx input port of the rTo resource. More...
 
virtual UtlBoolean disconnectInput (int inPortIdx)
 Removes the connection to the inPortIdx input port of this resource. More...
 
virtual UtlBoolean disconnectOutput (int outPortIdx)
 Removes the connection to the outPortIdx output port of this resource. More...
 
void setName (const UtlString &rName)
 Sets the name that is associated with this resource. More...
 

Static Protected Member Functions

static UtlBoolean writeWaveHeader (int handle, RecordFileFormat format, uint32_t samplesPerSecond=8000, int16_t numChannels=1)
 Write out standard 16bit WAV Header. More...
 
static OsStatus readWaveHeader (int fileHandle, RecordFileFormat &format, uint16_t &samplesPerSecond, uint16_t &channels)
 Read wave header info. More...
 
static UtlBoolean updateWaveHeaderLengths (int handle, RecordFileFormat format)
 Update WAV-file's header with correct recorded length. More...
 

Protected Attributes

State mState
 Internal recorder state. More...
 
RecordDestination mRecordDestination
 Where to store recorded samples. More...
 
int mChannels
 
int mFramesToRecord
 
int mNumFramesProcessed
 
int mSamplesRecorded
 
int mConsecutiveInactive
 
int mSilenceLength
 
MpEncoderBasempEncoder
 encoder for non-PCM formats saved to file More...
 
int mEncodedFrames
 number of audio (flowgraph) frames encoded More...
 
int mLastEncodedFrameSize
 Size in bytes of last encoded frame recorded. More...
 
MpResamplerBasempResampler
 Resampler for encoding to file. More...
 
int mSamplesPerLastFrame
 Cache frame size of last processed buffer. More...
 
int mSamplesPerSecond
 Cache sample rate of last processed buffer. More...
 
File-related variables
int mFileDescriptor
 File descriptor to write to. More...
 
RecordFileFormat mRecFormat
 Should data be written in WAV or RAW PCM format. More...
 
Buffer-related variables
MpAudioSamplempBuffer
 
int mBufferSize
 mpBuffer size. More...
 
Circular buffer related variables
CircularBufferPtr * mpCircularBuffer
 
unsigned long mRecordingBufferNotificationWatermark
 
- Protected Attributes inherited from MpResource
MpFlowGraphBasempFlowGraph
 flow graph this resource belongs to More...
 
MpConnectionID mConnectionId
 The ID of connection this resource belongs to. More...
 
int mStreamId
 
UtlBoolean mIsEnabled
 TRUE if resource is enabled, FALSE otherwise. More...
 
OsRWMutex mRWMutex
 reader/writer lock for synchronization More...
 
MpBufPtrmpInBufs
 input buffers for this resource More...
 
MpBufPtrmpOutBufs
 output buffers for this resource More...
 
ConnmpInConns
 input connections for this resource More...
 
ConnmpOutConns
 output connections for this resource More...
 
int mMaxInputs
 maximum number of inputs More...
 
int mMaxOutputs
 maximum number of outputs More...
 
int mMinInputs
 number of required inputs More...
 
int mMinOutputs
 number of required outputs More...
 
int mNumActualInputs
 actual number of connected inputs More...
 
int mNumActualOutputs
 actual number of connected outputs More...
 
int mVisitState
 (used by flow graph topological sort alg.) More...
 
UtlBoolean mNotificationsEnabled
 Whether we should send notifications or not. More...
 
OsBSem mLock
 used mainly to make safe changes to ports More...
 

Private Member Functions

 MprRecorder (const MprRecorder &rMprRecorder)
 Copy constructor (not implemented for this class) More...
 
MprRecorderoperator= (const MprRecorder &rhs)
 Assignment operator (not implemented for this class) More...
 
int writeFile (char *channelData[], int dataSize)
 
int writeCircularBuffer (char *channelData[], int dataSize)
 
void notifyCircularBufferWatermark ()
 
void createEncoder (const char *mimeSubtype, unsigned int codecSampleRate)
 
void prepareEncoder (RecordFileFormat recFormat, unsigned int &codecSampleRate)
 

Static Private Member Functions

static int16_t getBytesPerSample (RecordFileFormat format)
 

Additional Inherited Members

- Static Public Attributes inherited from MpResource
static const UtlContainableType TYPE = "MpResource"
 Class name, used for run-time checks. More...
 
- Static Protected Attributes inherited from MpResource
static const OsTime sOperationQueueTimeout = OsTime::OS_INFINITY
 The timeout for message operations for all resources when posting to the flowgraph queue. More...
 

Detailed Description

The "Recorder" media processing resource.

Member Typedef Documentation

typedef int(MprRecorder::* WriteMethod) (char *channelBuffers[], int)
protected

Member Enumeration Documentation

These match the WAVE compression format codes in the RIFF header for convenience.

Enumerator
UNINITIALIZED_FORMAT 
RAW_PCM_16 
WAV_PCM_16 
WAV_ALAW 
WAV_MULAW 
WAV_GSM 
enum AddlMsgTypes
protected
Enumerator
MPRM_START_FILE 
MPRM_START_BUFFER 
MPRM_PAUSE 
MPRM_RESUME 
MPRM_START_CIRCULAR_BUFFER 
MPRM_STOP 
enum FinishCause
protected
Enumerator
FINISHED_AUTO 

Recording has finished automatically.

FINISHED_MANUAL 

Recording has stopped manually.

FINISHED_ERROR 

Recording has stopped because of error.

enum State
protected
Enumerator
STATE_IDLE 

Recording is not running.

STATE_RECORDING 

Recording is running.

STATE_PAUSED 

Recording is running, but paused.

enum RecordDestination
protected
Enumerator
TO_UNDEFINED 
TO_FILE 

Record to a file.

TO_BUFFER 

Record to a buffer.

TO_CIRCULAR_BUFFER 

Record to a buffer.

Constructor & Destructor Documentation

MprRecorder ( const UtlString &  rName)

Constructor.

~MprRecorder ( )
virtual

Destructor.

MprRecorder ( const MprRecorder rMprRecorder)
private

Copy constructor (not implemented for this class)

Member Function Documentation

OsStatus startFile ( const UtlString &  namedResource,
OsMsgQ &  fgQ,
const char *  filename,
RecordFileFormat  recFormat,
int  time = 0,
int  silenceLength = -1,
UtlBoolean  append = FALSE,
int  numChannels = 1 
)
static

Start recording to a file with given parameters.

Parameters
[in]namedResource- resource name to send command to.
[in]fgQ- flowgraph queue to send command to.
[in]filename- filename to record to.
[in]recFormat- output format type (e.g. WAV_PCM_16)
[in]time- max number of milliseconds to record, or 0 for no limit
[in]silenceLength- length of silence (in milliseconds) after which recording is automatically stopped. This feature is disabled if -1 is passed.
[in]append- TRUE/FALSE if recording file exist, file should be appended as opposed to replaced. NOTE: It is an error condition to append if the record format is not the same as the original file. Note: when stopping and starting in rapid succession, application SHOULD wait for stop notification before starting and appending recording to the same file or there is risk of the multiple file descriptors being open on the same file with unpredictable results.
[in]numChannels- the number of channels to record (>1 not supported for all formats)
Returns
OS_SUCCESS if file was successfully opened (and if append, format is the same) OS_FAILED if existing file was of a different audio format than requested or unable to determine existing file audio format, or error opening file for read and write.
OsStatus startBuffer ( const UtlString &  namedResource,
OsMsgQ &  fgQ,
MpAudioSample pBuffer,
int  bufferSize,
int  time = 0,
int  silenceLength = -1,
int  numChannels = 1 
)
static

Start recording to a buffer with given parameters.

Parameters
[in]namedResource- resource name to send command to.
[in]fgQ- flowgraph queue to send command to.
[in]pBuffer- memory buffer to record to.
[in]bufferSize- pBuffer size (in samples).
[in]time- max number of milliseconds to record, or 0 for no limit
[in]silenceLength- length of silence (in milliseconds) after which recording is automatically stopped. This feature is disabled if -1 is passed.
[in]event- an optional OsEvent to signal on completion (DEPRECATED!).
[in]numChannels- the number of channels to record (>1 not supported for all formats)
OsStatus pause ( const UtlString &  namedResource,
OsMsgQ &  flowgraphQueue 
)
static

Pause recording if it is already recording.

Parameters
[in]namedResource- resource name to send command to.
[in]flowgraphQueue- flowgraph queue to send command to.
OsStatus resume ( const UtlString &  namedResource,
OsMsgQ &  flowgraphQueue 
)
static

Resume recording if it is already recording.

Parameters
[in]namedResource- resource name to send command to.
[in]flowgraphQueue- flowgraph queue to send command to.
OsStatus startCircularBuffer ( const UtlString &  namedResource,
OsMsgQ &  fgQ,
CircularBufferPtr &  buffer,
RecordFileFormat  recordingFormat,
unsigned long  recordingBufferNotificationWatermark,
int  numChannels = 1 
)
static

Start recording to a circular-buffer with given parameters.

Parameters
[in]namedResource- resource name to send command to.
[in]fgQ- flowgraph queue to send command to.
[in]buffer- circular buffer store the samples into.
[in]recordingBufferNotificationWatermark- buffer usage level (in samples) to send notifications for.
[in]numChannels- the number of channels to record (>1 not supported for all formats)
OsStatus stop ( const UtlString &  namedResource,
OsMsgQ &  fgQ 
)
static

Stop recording if it has not stopped automatically yet.

Parameters
[in]namedResource- resource name to send command to.
[in]fgQ- flowgraph queue to send command to.
UtlBoolean doProcessFrame ( MpBufPtr  inBufs[],
MpBufPtr  outBufs[],
int  inBufsSize,
int  outBufsSize,
UtlBoolean  isEnabled,
int  samplesPerFrame,
int  samplesPerSecond 
)
protectedvirtual

This method does the real work for the media processing resource and must be defined in each class derived from this one.

Parameters
inBufs(in) array of pointers to input buffers for the resource
outBufs(out) array of pointers to output buffers produce by the resource
inBufsSize(in) size of the inBufs array
outBufsSize(in) size of the outBufs array
isEnabled(in) indicates whether this resource has been enabled
samplesPerFrame(in) samples to produce per frame processing interval
samplesPerSecond(in) samples to produce per second
Returns
TRUE if successful, FALSE otherwise.

Implements MpAudioResource.

UtlBoolean handleStartFile ( int  file,
RecordFileFormat  recFormat,
int  time,
int  silenceLength,
UtlBoolean  append,
int  numChannels 
)
protected

Handle MPRM_START_FILE message.

UtlBoolean handleStartBuffer ( MpAudioSample pBuffer,
int  bufferSize,
int  time,
int  silenceLength,
int  numChannels 
)
protected

Handle MPRM_START_BUFFER message.

Parameters
[in]file- file handle to record to
[in]recFormat- audio format to use for record file
[in]time- maximum record length in milliseconds (0 means unlimited)
[in]silenceLength- stop recording after this amount of silence in milliseconds (-1 means ignore silence and keep recording).
[in]append- file is being appended
[in]numChannels- channels to record to file
UtlBoolean handleStartCircularBuffer ( CircularBufferPtr *  buffer,
RecordFileFormat  recordingFormat,
unsigned long  recordingBufferNotificationWatermark,
int  numChannels 
)
protected

Handle MPRM_START_CIRCULAR_BUFFER message.

UtlBoolean handleStop ( void  )
protected

Handle MPRM_STOP message.

UtlBoolean handleDisable ( void  )
protectedvirtual

perform the disable operation on the resource

Reimplemented from MpResource.

UtlBoolean handleMessage ( MpResourceMsg rMsg)
protectedvirtual

Handle messages for this resource.

Reimplemented from MpResource.

void startRecording ( int  time,
int  silenceLength 
)
protected

Prepare for recording.

UtlBoolean finish ( FinishCause  cause)
protected

Recording has been stopped with given cause.

void closeFile ( const char *  fromWhereLabel)
protected

Close file if it is opened and update WAV header if needed.

int writeFileSilence ( int  numSamples)
inlineprotected

Write silence to the file.

int writeSamples ( const MpAudioSample pBuffer[],
int  numSamples,
WriteMethod  writeMethod 
)
inlineprotected

Write given data to the specified target.

int writeBufferSilence ( int  numSamples)
inlineprotected

Write silence to the buffer.

int writeCircularBufferSilence ( int  numSamples)
inlineprotected

Write silence to the circular buffer.

int writeBufferSpeech ( const MpAudioSample pBuffer,
int  numSamples 
)
inlineprotected

Write given speech data to the buffer.

UtlBoolean writeWaveHeader ( int  handle,
RecordFileFormat  format,
uint32_t  samplesPerSecond = 8000,
int16_t  numChannels = 1 
)
staticprotected

Write out standard 16bit WAV Header.

OsStatus readWaveHeader ( int  fileHandle,
RecordFileFormat format,
uint16_t &  samplesPerSecond,
uint16_t &  channels 
)
staticprotected

Read wave header info.

UtlBoolean updateWaveHeaderLengths ( int  handle,
RecordFileFormat  format 
)
staticprotected

Update WAV-file's header with correct recorded length.

Parameters
[in]fileHandle- wave file handle opened for read and positioned at begining of file
[out]format- wave file compression codec id
[out]samplesPerSecond- samples per second for encoding per wave header
[out]channels- number of channels of audio per wave header
Returns
OS_SUCCESS if wave header was read successfully and it was valid, OS_FAILED if the file is empty, OS_INVALID if the wave header was invalid (this could be a raw audio file)
MprRecorder& operator= ( const MprRecorder rhs)
private

Assignment operator (not implemented for this class)

int writeFile ( char *  channelData[],
int  dataSize 
)
private
int writeCircularBuffer ( char *  channelData[],
int  dataSize 
)
private
void notifyCircularBufferWatermark ( )
private
void createEncoder ( const char *  mimeSubtype,
unsigned int  codecSampleRate 
)
private
void prepareEncoder ( RecordFileFormat  recFormat,
unsigned int &  codecSampleRate 
)
private
int16_t getBytesPerSample ( RecordFileFormat  format)
staticprivate

Member Data Documentation

State mState
protected

Internal recorder state.

RecordDestination mRecordDestination
protected

Where to store recorded samples.

int mChannels
protected
int mFramesToRecord
protected
int mNumFramesProcessed
protected
int mSamplesRecorded
protected
int mConsecutiveInactive
protected
int mSilenceLength
protected
int mFileDescriptor
protected

File descriptor to write to.

RecordFileFormat mRecFormat
protected

Should data be written in WAV or RAW PCM format.

MpAudioSample* mpBuffer
protected

Buffer to write data to. End of the buffer Is determined by mSamplesRecorded variable.

int mBufferSize
protected

mpBuffer size.

MpEncoderBase* mpEncoder
protected

encoder for non-PCM formats saved to file

int mEncodedFrames
protected

number of audio (flowgraph) frames encoded

int mLastEncodedFrameSize
protected

Size in bytes of last encoded frame recorded.

MpResamplerBase* mpResampler
protected

Resampler for encoding to file.

CircularBufferPtr* mpCircularBuffer
protected
unsigned long mRecordingBufferNotificationWatermark
protected
int mSamplesPerLastFrame
protected

Cache frame size of last processed buffer.

int mSamplesPerSecond
protected

Cache sample rate of last processed buffer.