UtiLite
0.2.14
A lite utilities library
|
#include <UAudioRecorder.h>
Inherits UThreadNode.
Inherited by UAudioRecorderFile, and UAudioRecorderMic.
Public Member Functions | |
bool | getNextFrame (std::vector< char > &frame, bool removeOldFrames=false) |
bool | getNextFrame (std::vector< char > &frame, int &frameId) |
bool | getMultiFrame (std::vector< char > &frame, int frameIdBeg, int frameIdEnd) |
bool | getFrame (std::vector< char > &frame, int frameId) |
void | removeFrames (int frameIdBeg, int frameIdEnd) |
Protected Member Functions | |
virtual void | mainLoopEnd () |
This is the base class for all recorders. A recorder is used to get fixed frame length from a stream. It is configured with the length of the frame wanted. The main methods are Start, stop, and getNextFrame.
Example :
UAudioRecorder* recorder = <<SeeInheritedClasses>>; Frame frame; unsigned int frameId = 0; recorder->start(); while(recorder->getNextFrame(frame, frameId)) { ...process the frame... ... break when a condition is reached... } recorder->stop(); delete recorder;
bool UAudioRecorder::getFrame | ( | std::vector< char > & | frame, |
int | frameId | ||
) |
Get a specific frame from the stream. If the id is higher than the last frame recorded, the caller will wait until enough data is recorded.
frame | the result frame |
frameId | the id of the frame |
bool UAudioRecorder::getMultiFrame | ( | std::vector< char > & | frame, |
int | frameIdBeg, | ||
int | frameIdEnd | ||
) |
Get the multiple frames from the stream. The caller will wait until enough data is recorded.
frame | the result frame |
frameIdBeg | the id of the begin frame |
frameIdEnd | the id of the end frame |
bool UAudioRecorder::getNextFrame | ( | std::vector< char > & | frame, |
bool | removeOldFrames = false |
||
) |
Get the next frame from the stream. The caller will wait until the length of the frame required is reached. The parameter removeOldFrames can be used to clean the memory after each call. When removeOldFrames = true, the frame id is reseted.
frame | the result frame |
removeOldFrames | true to remove old frames |
bool UAudioRecorder::getNextFrame | ( | std::vector< char > & | frame, |
int & | frameId | ||
) |
Get the next frame from the stream. The caller will wait until the length of the frame required is reached.
frame | the result frame |
frameId | the id of the frame |
virtual void UAudioRecorder::mainLoopEnd | ( | ) | [protected, virtual] |
Virtual method mainLoopEnd(). User can implement this function to add a behavior after the thread is killed (after exiting the mainLoop(), work is still done in the thread before exiting).
Reimplemented from UThreadNode.
Reimplemented in UAudioRecorderMic, and UAudioRecorderFile.
void UAudioRecorder::removeFrames | ( | int | frameIdBeg, |
int | frameIdEnd | ||
) |
Used to clean the memory.
frameIdBeg | the id of the begin frame |
frameIdEnd | the id of the end frame |