Commit 01b8230d authored by d.basulto's avatar d.basulto

reconnect functionality added

parent c9ad4f92
This diff is collapsed.
...@@ -11,62 +11,83 @@ ...@@ -11,62 +11,83 @@
#ifndef STREAMRECORDER_H #ifndef STREAMRECORDER_H
#define STREAMRECORDER_H #define STREAMRECORDER_H
// your public header include
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Your public header include */
#include <gst/gst.h> #include <gst/gst.h>
#include <jmorecfg.h> #include <jmorecfg.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define STREAMRECORDER_SAMPLERATE 44100 #define STREAMRECORDER_SAMPLERATE 44100
#define READSIZE 1152 //For MPEG1, frame_size = 1152 samples/frame #define READSIZE 1152 //For MPEG1, frame_size = 1152 samples/frame
#define STREAMRECORDER_BYTESPERSAMPLE 2 #define STREAMRECORDER_BYTESPERSAMPLE 2
// the declaration of your class...
#define ERROR_MSG_SIZE 50
#define DST_URI_SIZE 80
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Class declaration */
class StreamRecorder class StreamRecorder
{ {
private: private:
unsigned char* audioBuffer;
unsigned char* audioBufferPosition;
char errorMessage[ERROR_MSG_SIZE];
char pluginUri[DST_URI_SIZE];
unsigned int nBytes;
unsigned int bufferSize;
unsigned int nBytes; int recordTime;
unsigned int bufferSize; int audioFileDuration;
unsigned char* audioBuffer;
unsigned char* audioBufferPosition; /** Audio filename */
int recordTime; long int timestamp = 0;
bool isConnectionLost; bool isConnectionLost;
char * pluginUri; //char* sourceName;
//char* sourceName; //GstElement* audioResample;
GstElement* streamSrc; //GstElement* tempBin;
GstElement* audioConvert; //GstElement* audioSink;
//GstElement* audioResample;
GstElement* filterCaps;
GstElement* queue0;
GstElement* queue1;
GstElement* filter;
GstElement* fakeSink;
//GstElement* audioSink;
GstElement* mainPipeline;
//GstElement* tempBin;
int createMainPipeline(); GstElement* streamSrc;
int connect(const char *uri); GstElement* audioConvert;
int disconnect(); GstElement* filterCaps;
GstElement* queue0;
GstElement* queue1;
GstElement* filter;
GstElement* fakeSink;
GstElement* mainPipeline;
// callbacks int createMainPipeline();
int connect();
int disconnect();
/** add data to buffer */
int addToBuffer(unsigned char* data, int length);
int compressBuffer();
/** plugin's callbacks */
static void srcNewPad_callback(GstElement *element, GstPad *pad, void *data); static void srcNewPad_callback(GstElement *element, GstPad *pad, void *data);
static int bus_callback(GstBus *bus, GstMessage *message, void *data); static int bus_callback(GstBus *bus, GstMessage *message, void *data);
static int filter_handoff_callback(GstElement* filter, GstBuffer* buffer, void* user_data); static int filter_handoff_callback(GstElement *filter, GstBuffer* buffer, void* user_data);
// add data to buffer /** Save audio*/
int addToBuffer(unsigned char* data, int length); static void saveBuffer(void *user_data);
int compressBuffer();
/** Restart the pipeline */
static gboolean reconnectURIStream(void* data);
// Save information when connection fails public:
static void savePartialBuffer(void *user_data);
// Restart the pipeline
static gboolean reconnectURIStream(void *data);
public: StreamRecorder(const char* source, int time);
StreamRecorder(const char* source, int time);
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment