|
|
audioStreamer.h
Reference Number: AA-01511 Views: 7131 |
0 Rating/ Voters
|
|
C++ Code
-
#include "HeaderClasses.h" -
#ifndef AUDIO_STREAMER_H -
#define AUDIO_STREAMER_H -
typedef bool (*AudioStreamCB)(char* audio_chunk, int chunk_size, void* user_data); -
/** -
class AudioStreamer -
Mimics live audio being streamed. -
It reads audio a bit at a time from a file, -
periodically calling a user provided callback -
function to transmit the audio. -
It stops transmitting audio when the user -
callback function returns false. -
If it reaches the end of file before the callback -
tells it to stop, then it just sends silence. -
The audio is assumed to be a headerless u-Law -
audio file at 8Khz -
**/ -
class AudioStreamer: Demo::Thread -
{ -
public: -
AudioStreamer(const char* filename); -
void StartStream(AudioStreamCB _cb, void* _user_data); -
void StopStream(); -
~AudioStreamer(); -
private: -
char* audio_buffer; -
char* end_buffer; -
int audio_buffer_size; -
int increment_ms; -
AudioStreamCB cb; -
void* user_data; -
virtual void ThreadAction(); -
}; -
#endif//AUDIO_STREAMER_H
|
|
|