Manages stream decoding and sends it to the computing part of the application This class is intended to be rewritten for more specific usages (spectrum analysis, feature extraction, aso.). Its the interface between libVLC (which reads the media, decodes, resamples, and does all the hard DSP) and the using of the data. More...
#include <streamplayer.h>
Public Member Functions | |
StreamPlayer (bool live=false, bool verbose=true) | |
Default constructor. Starts VLC instance. | |
~StreamPlayer () | |
Default destructor. Frees memory and closes VLC. | |
string | url () |
Returns URL of the currently playing stream. | |
void | setUrl (string url) |
Defines the URL of the stream to play. | |
void | setOverlapping (float factor) |
Turns on / off audio chunk overlapping. | |
void | setChunkSize (int size) |
Changes the audio chunk size. | |
int | chunkSize () |
Get the current chunk size. | |
void | play () |
Plays the media. | |
libvlc_time_t | playingTime () |
Returns the playing time. | |
libvlc_time_t | totalTime () |
Returns the total time (played + to be played) | |
void | stop () |
Stops playing. | |
bool | isLive () |
Are we playing a live stream ? | |
void | setVolume (int vol) |
Changes the volume (between 0 and 100) | |
int | volume () |
Gets the current volume. | |
virtual void | sequenceStarts () |
Callback called when we start playing a file. | |
virtual void | useBuffer () |
Callback called when the data is ready in the buffer (miam). The user don't have to manage the memory. | |
virtual void | sequenceEnds () |
Callback called when the file ended. | |
void | watch () |
Watching thread. | |
uint16_t | buffer (int i) |
Buffer acces (for the user) | |
int | bufferSize () |
Current buffer size (internal) | |
void | fillBuffer (uint16_t value) |
Fill buffer with a new value (internal) | |
void | flushBuffer () |
Flush buffer (just keep the overlapping part) |
Static Public Member Functions | |
static uint16_t * | convert8to16 (const uint8_t *source, int size) |
Converts an array of uint8_t to another array of uint16_t (assuming the values are coded on two bytes) The returned pointer has to be deleted by the user. | |
static uint16_t * | average (uint16_t *source, int size, int passes, int scale=1) |
Computes the average value of the stream, on a given frequency The returned pointer has to be deleted by the user. | |
static void | reduce (uint16_t *source, uint16_t *dest, int size, int passes, int scale=1) |
Reduces the stream, keeping only the extreme values. | |
static void | addOffset (uint16_t *source, uint16_t *dest, int size, int offset) |
Adds an offset to each value of the array. | |
static int | pow2 (int n) |
Get 2^n. |
Public Attributes | |
std::deque< uint16_t > | mBuffer |
Feature extraction : those variables need to be public (I know, I can write accessors...) | |
QMutex | mLock |
char * | mAudioData |
unsigned int | mAudioDataSize |
unsigned int | mFrequency |
Protected Attributes | |
bool | mVerbose |
Manages stream decoding and sends it to the computing part of the application This class is intended to be rewritten for more specific usages (spectrum analysis, feature extraction, aso.). Its the interface between libVLC (which reads the media, decodes, resamples, and does all the hard DSP) and the using of the data.
When using overlapping, two audio chunks have some audio data in common : their size time the overlapping factor.