UtiLite  0.2.14
A lite utilities library
Public Member Functions | Protected Member Functions
UAudioRecorder Class Reference

#include <UAudioRecorder.h>

Inherits UThreadNode.

Inherited by UAudioRecorderFile, and UAudioRecorderMic.

List of all members.

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 ()

Detailed Description

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;
See also:
UAudioRecorder::start
UAudioRecorder::stop
UAudioRecorder::getNextFrame

Member Function Documentation

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.

Parameters:
framethe result frame
frameIdthe id of the frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
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.

Parameters:
framethe result frame
frameIdBegthe id of the begin frame
frameIdEndthe id of the end frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
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.

Parameters:
framethe result frame
removeOldFramestrue to remove old frames
Returns:
true on success, this method failed when the end of the stream is reached.
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.

Parameters:
framethe result frame
frameIdthe id of the frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
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.

Parameters:
frameIdBegthe id of the begin frame
frameIdEndthe id of the end frame
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Friends Defines