14 #ifndef _MprFromFile_h_ 15 #define _MprFromFile_h_ 21 #include "os/OsProtectEvent.h" 70 static OsStatus
playBuffer(
const UtlString& namedResource,
72 const char* audioBuffer,
73 unsigned long bufSize,
74 uint32_t inRate, uint32_t fgRate,
75 int type, UtlBoolean repeat,
76 OsProtectedEvent* notify,
77 UtlBoolean autoStopAfterFinish =
TRUE);
95 static OsStatus
playFile(
const UtlString& namedResource,
98 uint32_t fgSampleRate,
99 const UtlString& filename,
100 const UtlBoolean& repeat,
101 UtlBoolean autoStopAfterFinish =
TRUE);
124 static OsStatus
stopFile(
const UtlString& namedResource,
139 static OsStatus
pauseFile(
const UtlString& namedResource,
154 static OsStatus
resumeFile(
const UtlString& namedResource,
172 int32_t updatePeriodMS);
191 UtlString*& audioBuffer,
192 const char* audioFileName);
278 UtlString*& fgAudioBuf,
279 const char* audioBuffer,
280 unsigned long bufSize,
303 const uint32_t inAudBufSz,
304 const uint32_t inRate,
306 uint32_t& outAudBufSz,
307 const uint32_t outRate);
332 UtlBoolean
handlePlay(UtlString* pBuffer, UtlBoolean repeat,
333 UtlBoolean autoStopAfterFinish);
363 #endif // _MprFromFile_h_ Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
Playing has finished, but stopFile() hasn't called yet.
Definition: MprFromFile.h:257
Playing is in process.
Definition: MprFromFile.h:255
The "Play audio from file" media processing resource.
Definition: MprFromFile.h:37
UtlBoolean handleSetUpdatePeriod(int32_t periodMS)
Set an update period for sending progress updates.
Definition: MprFromFile.cpp:936
AddlMsgTypes
Definition: MprFromFile.h:241
static OsStatus playFile(const UtlString &namedResource, OsMsgQ &fgQ, uint32_t fgSampleRate, const UtlString &filename, const UtlBoolean &repeat, UtlBoolean autoStopAfterFinish=TRUE)
Sends an MPRM_FROMFILE_START message to the named MprFromFile resource.
Definition: MprFromFile.cpp:125
UtlBoolean handlePause()
Pause playback upon receiving request to pause.
Definition: MprFromFile.cpp:904
int mFileBufferIndex
Definition: MprFromFile.h:263
virtual UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handle resource messages for this resource (new messaging model - 2007).
Definition: MprFromFile.cpp:947
static OsStatus pauseFile(const UtlString &namedResource, OsMsgQ &fgQ)
Sends an MPRM_FROMFILE_PAUSE message to the named MprFromFile resource.
Definition: MprFromFile.cpp:165
UtlString * mpFileBuffer
Definition: MprFromFile.h:262
Definition: MpResourceMsg.h:56
static const unsigned int sFromFileReadBufferSize
Definition: MprFromFile.h:260
static OsStatus stopFile(const UtlString &namedResource, OsMsgQ &fgQ)
Sends an MPRM_FROMFILE_STOP message to the named MprFromFile resource.
Definition: MprFromFile.cpp:157
OsTime mLastProgressUpdate
Definition: MprFromFile.h:271
Definition: MprFromFile.h:59
MprFromFile(const UtlString &rName)
Constructor.
Definition: MprFromFile.cpp:67
Start playing.
Definition: MprFromFile.h:243
Completion
Definition: MprFromFile.h:53
UtlBoolean handlePlay(UtlString *pBuffer, UtlBoolean repeat, UtlBoolean autoStopAfterFinish)
Initialize things to start playing the given buffer, upon receiving request to start.
Definition: MprFromFile.cpp:817
Definition: MprFromFile.h:56
UtlBoolean mFileRepeat
Definition: MprFromFile.h:264
Stop playing.
Definition: MprFromFile.h:248
State mState
Definition: MprFromFile.h:265
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
Pause playing.
Definition: MprFromFile.h:245
Definition: MprFromFile.h:58
MprFromFile & operator=(const MprFromFile &rhs)
Assignment operator (not implemented for this class)
Resume playing that was paused.
Definition: MprFromFile.h:246
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: MprFromFile.cpp:698
static OsStatus sendProgressPeriod(const UtlString &namedResource, OsMsgQ &fgQ, int32_t updatePeriodMS)
Sends an MPRM_FROMFILE_SEND_PROGRESS message to the named MprFromFile resource.
Definition: MprFromFile.cpp:181
State
Definition: MprFromFile.h:252
Playing is stopped.
Definition: MprFromFile.h:254
UtlBoolean handleResume()
Resume playback upon receiving request to resume.
Definition: MprFromFile.cpp:920
static OsStatus resumeFile(const UtlString &namedResource, OsMsgQ &fgQ)
Sends an MPRM_FROMFILE_RESUME message to the named MprFromFile resource.
Definition: MprFromFile.cpp:173
static UtlBoolean allocateAndResample(const char *inAudBuf, const uint32_t inAudBufSz, const uint32_t inRate, char *&outAudBuf, uint32_t &outAudBufSz, const uint32_t outRate)
allocate enough space for the resampled data, and resample data passed in.
Definition: MprFromFile.cpp:646
Definition: MprFromFile.h:60
static OsStatus playBuffer(const UtlString &namedResource, OsMsgQ &fgQ, const char *audioBuffer, unsigned long bufSize, uint32_t inRate, uint32_t fgRate, int type, UtlBoolean repeat, OsProtectedEvent *notify, UtlBoolean autoStopAfterFinish=TRUE)
Play sound from buffer w/repeat option.
Definition: MprFromFile.cpp:84
Smart pointer to MpBuf.
Definition: MpBuf.h:160
Definition: MprFromFile.h:55
UtlBoolean handleStop()
Perform resetting of state, etc. upon receiving request to stop playing.
Definition: MprFromFile.cpp:880
Playing is in process, but paused.
Definition: MprFromFile.h:256
UtlBoolean mAutoStopAfterFinish
Definition: MprFromFile.h:266
static OsStatus genericAudioBufToFGAudioBuf(UtlString *&fgAudioBuf, const char *audioBuffer, unsigned long bufSize, uint32_t inRate, uint32_t fgRate, int type)
Convert generic audio data into flowgraph audio data.
Definition: MprFromFile.cpp:202
virtual ~MprFromFile()
Destructor.
Definition: MprFromFile.cpp:77
Report failed operation.
Definition: MprFromFile.h:249
#define TRUE
Definition: PlgDefsV1.h:41
Set progress updates period.
Definition: MprFromFile.h:247
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
static OsStatus readAudioFile(uint32_t fgSampleRate, UtlString *&audioBuffer, const char *audioFileName)
Read in an audio file into a new UtlString audio buffer.
Definition: MprFromFile.cpp:263
Definition: MprFromFile.h:57
int32_t mProgressIntervalMS
Definition: MprFromFile.h:272
UtlBoolean handleFinish()
Handle playback finish when the end of file/buffer is reached.
Definition: MprFromFile.cpp:847