14 #ifndef _MprRecorder_h_ 15 #define _MprRecorder_h_ 22 #if defined(_WIN32) && !defined(WINCE) 27 #include "os/OsMutex.h" 30 #include "utl/CircularBufferPtr.h" 31 #include "os/OsProtectEvent.h" 35 #ifndef MAXIMUM_RECORDER_CHANNELS 36 # define MAXIMUM_RECORDER_CHANNELS 4 49 struct SipxOpusWriteObject;
91 static OsStatus
startFile(
const UtlString& namedResource,
96 int silenceLength = -1,
97 UtlBoolean append =
FALSE,
124 static OsStatus
startBuffer(
const UtlString& namedResource,
130 int silenceLength = -1,
131 int numChannels = 1);
145 static OsStatus
pause(
const UtlString& namedResource, OsMsgQ& flowgraphQueue);
152 static OsStatus
resume(
const UtlString& namedResource, OsMsgQ& flowgraphQueue);
162 CircularBufferPtr & buffer,
164 unsigned long recordingBufferNotificationWatermark,
165 int numChannels = 1);
174 static OsStatus
stop(
const UtlString& namedResource, OsMsgQ& fgQ);
311 int silenceLength,
int numChannels);
316 unsigned long recordingBufferNotificationWatermark,
332 UtlBoolean
finish(FinishCause cause);
335 void closeFile(
const char* fromWhereLabel);
357 int16_t numChannels = 1);
387 int writeFile(
const char* channelData[],
int dataSize);
390 void createEncoder(
const char * mimeSubtype,
unsigned int codecSampleRate);
399 static int interlaceSamples(
const char* samplesArrays[],
int samplesPerChannel,
int bytesPerSample,
int channels,
char* interlacedChannelSamplesArray,
int interlacedArrayMaximum);
404 #endif // _MprRecorder_h_ Definition: MprRecorder.h:205
Definition: MprRecorder.h:61
void prepareEncoder(RecordFileFormat recFormat, unsigned int &codecSampleRate)
Definition: MprRecorder.cpp:1060
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
Recording is running.
Definition: MprRecorder.h:220
Definition: MprRecorder.h:207
static UtlBoolean updateWaveHeaderLengths(int handle, RecordFileFormat format)
Update WAV-file's header with correct recorded length.
Definition: MprRecorder.cpp:2081
void startRecording(int time, int silenceLength)
Prepare for recording.
Definition: MprRecorder.cpp:1422
virtual UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handle messages for this resource.
Definition: MprRecorder.cpp:1301
unsigned long mRecordingBufferNotificationWatermark
Definition: MprRecorder.h:278
Generic audio resampler.
Definition: MpResampler.h:34
Definition: MpResourceMsg.h:56
int(MprRecorder::* WriteMethod)(const char *channelBuffers[], int)
Definition: MprRecorder.h:337
Definition: MprRecorder.h:237
MpResamplerBase * mpResampler
Resampler for encoding to file.
Definition: MprRecorder.h:272
virtual UtlBoolean handleDisable()
perform the disable operation on the resource
Definition: MprRecorder.cpp:1289
static int16_t getBytesPerSample(RecordFileFormat format)
Definition: MprRecorder.cpp:1906
int mConsecutiveInactive
Definition: MprRecorder.h:246
Definition: MprRecorder.h:204
UtlBoolean finish(FinishCause cause)
Recording has been stopped with given cause.
Definition: MprRecorder.cpp:1457
static int interlaceSamples(const char *samplesArrays[], int samplesPerChannel, int bytesPerSample, int channels, char *interlacedChannelSamplesArray, int interlacedArrayMaximum)
Definition: MprRecorder.cpp:1846
void trimSilenceFromEndOfRecording()
Definition: MprRecorder.cpp:1014
int mLastEncodedFrameSize
Size in bytes of last encoded frame recorded.
Definition: MprRecorder.h:264
void deleteOpusEncoder()
Definition: MprRecorder.cpp:952
int mSamplesPerSecond
Cache sample rate of last processed buffer.
Definition: MprRecorder.h:282
int writeFile(const char *channelData[], int dataSize)
Definition: MprRecorder.cpp:1796
Recording is not running.
Definition: MprRecorder.h:219
Definition: MprRecorder.h:236
Record to a file.
Definition: MprRecorder.h:228
Base class for all media processing encoders.
Definition: MpEncoderBase.h:35
CircularBufferPtr * mpCircularBuffer
Definition: MprRecorder.h:277
RecordDestination
Definition: MprRecorder.h:225
int mNumFramesProcessed
Definition: MprRecorder.h:244
void * mpOpusEncoder
Definition: MprRecorder.h:266
virtual ~MprRecorder()
Destructor.
Definition: MprRecorder.cpp:88
SampleInterlaceStage
Definition: MprRecorder.h:233
UtlBoolean handleStartCircularBuffer(CircularBufferPtr *buffer, RecordFileFormat recordingFormat, unsigned long recordingBufferNotificationWatermark, int numChannels)
Handle MPRM_START_CIRCULAR_BUFFER message.
Definition: MprRecorder.cpp:1253
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.
Definition: MprRecorder.cpp:410
MprRecorder & operator=(const MprRecorder &rhs)
Assignment operator (not implemented for this class)
int writeBufferSpeech(const MpAudioSample *pBuffer, int numSamples)
Write given speech data to the buffer.
Definition: MprRecorder.cpp:1887
Recording has finished automatically.
Definition: MprRecorder.h:212
Definition: MprRecorder.h:235
UtlBoolean handleStartFile(int file, RecordFileFormat recFormat, int time, int silenceLength, UtlBoolean append, int numChannels)
Handle MPRM_START_FILE message.
Definition: MprRecorder.cpp:1169
int mBufferSize
mpBuffer size.
Definition: MprRecorder.h:259
Definition: MprRecorder.h:60
void createEncoder(const char *mimeSubtype, unsigned int codecSampleRate)
Definition: MprRecorder.cpp:681
int16_t MpAudioSample
Definition: MpTypes.h:44
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 de...
Definition: MprRecorder.cpp:471
int mSilenceLength
Definition: MprRecorder.h:247
int writeSamples(const MpAudioSample *pBuffer[], int numSamples, WriteMethod writeMethod)
Write given data to the specified target.
Definition: MprRecorder.cpp:1598
State
Definition: MprRecorder.h:217
Record to a buffer.
Definition: MprRecorder.h:229
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.
Definition: MprRecorder.cpp:122
RecordFileFormat mRecFormat
Should data be written in WAV or RAW PCM format.
Definition: MprRecorder.h:252
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.
Definition: MprRecorder.cpp:382
int mSamplesPerLastFrame
Cache frame size of last processed buffer.
Definition: MprRecorder.h:281
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
Definition: MprRecorder.h:70
Recording is running, but paused.
Definition: MprRecorder.h:221
Definition: MprRecorder.h:227
RecordFileFormat
These match the WAVE compression format codes in the RIFF header for convenience. ...
Definition: MprRecorder.h:59
static OsStatus resume(const UtlString &namedResource, OsMsgQ &flowgraphQueue)
Resume recording if it is already recording.
Definition: MprRecorder.cpp:441
The "Recorder" media processing resource.
Definition: MprRecorder.h:53
Record to a buffer.
Definition: MprRecorder.h:230
OsStatus createOpusEncoder(int channels, const char *artist, const char *title)
Definition: MprRecorder.cpp:859
static OsStatus validateOpusHeader(int inFileFd, OpusHead &opusHeader)
int writeCircularBuffer(const char *channelData[], int dataSize)
Definition: MprRecorder.cpp:640
int writeBufferSilence(int numSamples)
Write silence to the buffer.
Definition: MprRecorder.cpp:1880
FinishCause
Definition: MprRecorder.h:210
Definition: MprRecorder.h:203
int mSamplesRecorded
Definition: MprRecorder.h:245
int writeCircularBufferSilence(int numSamples)
Write silence to the circular buffer.
Definition: MprRecorder.cpp:1894
Definition: MprRecorder.h:67
void * mpOpusComments
Definition: MprRecorder.h:267
Definition: MprRecorder.h:64
Recording has stopped because of error.
Definition: MprRecorder.h:214
void notifyCircularBufferWatermark()
Definition: MprRecorder.cpp:672
int writeFileSilence(int numSamples)
Write silence to the file.
Definition: MprRecorder.cpp:1586
AddlMsgTypes
Definition: MprRecorder.h:200
Definition: MprRecorder.h:65
RecordDestination mRecordDestination
Where to store recorded samples.
Definition: MprRecorder.h:241
static OsStatus readWaveHeader(int fileHandle, RecordFileFormat &format, uint16_t &samplesPerSecond, uint16_t &channels)
Read wave header info.
Definition: MprRecorder.cpp:1929
Smart pointer to MpBuf.
Definition: MpBuf.h:160
SampleInterlaceStage mWhenToInterlace
Definition: MprRecorder.h:270
int mEncodedFrames
number of audio (flowgraph) frames encoded
Definition: MprRecorder.h:263
static OsStatus pause(const UtlString &namedResource, OsMsgQ &flowgraphQueue)
Pause recording if it is already recording.
Definition: MprRecorder.cpp:435
int mChannels
Definition: MprRecorder.h:242
struct SipxOpusWriteObject * mpOpusStreamObject
Definition: MprRecorder.h:268
State mState
Internal recorder state.
Definition: MprRecorder.h:240
MpEncoderBase * mpEncoder
encoder for non-PCM formats saved to file
Definition: MprRecorder.h:262
static OsStatus stop(const UtlString &namedResource, OsMsgQ &fgQ)
Stop recording if it has not stopped automatically yet.
Definition: MprRecorder.cpp:447
MprRecorder(const UtlString &rName)
Constructor.
Definition: MprRecorder.cpp:58
Recording has stopped manually.
Definition: MprRecorder.h:213
static int getMaximumRecoderChannels()
Definition: MprRecorder.cpp:115
UtlBoolean handleStop()
Handle MPRM_STOP message.
Definition: MprRecorder.cpp:1283
void closeFile(const char *fromWhereLabel)
Close file if it is opened and update WAV header if needed.
Definition: MprRecorder.cpp:1503
MpAudioSample * mpBuffer
Definition: MprRecorder.h:257
#define FALSE
Definition: PlgDefsV1.h:37
static UtlBoolean writeWaveHeader(int handle, RecordFileFormat format, uint32_t samplesPerSecond=8000, int16_t numChannels=1)
Write out standard 16bit WAV Header.
Definition: MprRecorder.cpp:1981
int mFileDescriptor
File descriptor to write to.
Definition: MprRecorder.h:251
UtlBoolean handleStartBuffer(MpAudioSample *pBuffer, int bufferSize, int time, int silenceLength, int numChannels)
Handle MPRM_START_BUFFER message.
Definition: MprRecorder.cpp:1227
int mFramesToRecord
Definition: MprRecorder.h:243
Definition: MprRecorder.h:206
Definition: MprRecorder.h:66
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
Definition: MprRecorder.h:202