Commit 06320da7 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

upload files

parents
./streamRecorder http://7329.live.streamtheworld.com:3690/XHMVSFM_SC 5
This diff is collapsed.
////////////////////////////////////////////////////////////////////////////////
// StreamRecorder.h
// Mario Chirinos
// 2014-02-12
//------------------------------------------------------------------------------
// Notes:
// Streaming recorder with GStreamer
//
////////////////////////////////////////////////////////////////////////////////
#ifndef STREAMRECORDER_H
#define STREAMRECORDER_H
// your public header include
//------------------------------------------------------------------------------
#include <gst/gst.h>
//------------------------------------------------------------------------------
#define STREAMRECORDER_SAMPLERATE 44100
#define READSIZE 1152 //For MPEG1, frame_size = 1152 samples/frame
#define STREAMRECORDER_BYTESPERSAMPLE 2
// the declaration of your class...
//------------------------------------------------------------------------------
class StreamRecorder
{
private:
unsigned int nBytes;
unsigned int bufferSize;
unsigned char* audioBuffer;
unsigned char* audioBufferPosition;
int recordTime;
char* sourceName;
GstElement* streamSrc;
GstElement* audioConvert;
GstElement* audioResample;
GstElement* filterCaps;
GstElement* queue0;
GstElement* queue1;
GstElement* filter;
// GstElement* compressor;
// GstElement* queue2;
// GstElement* muxer;
// GstElement* fileSink;
GstElement* fakeSink;
GstElement* audioSink;
GstElement* mainPipeline;
// GstElement* sinkPipeline;
GstElement* tempBin;
int createMainPipeline();
// int createSinkPipeline();
int connect(const char *uri);
int disconnect();
static void srcNewPad_callback(GstElement *element, GstPad *pad, void *data);
static int bus_callback(GstBus *bus, GstMessage *message, void *data);
// static void block_async_cb (GstPad * pad, gboolean blocked, gpointer user_data);
static void buffer_callback(GstElement *fakesink, GstBuffer *buffer, GstPad *pad, gpointer user_data);
static int filter_handoff_callback(GstElement* filter, GstBuffer* buffer, void* user_data);
int addToBuffer(unsigned char* data, int length);
int compressBuffer();
int saveWav(unsigned char* data, int size) const;
void printCaps(GstPad *pad);
public:
StreamRecorder(const char* source, int time);
};
//------------------------------------------------------------------------------
#endif
////////////////////////////////////////////////////////////////////////////////
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include <cstdlib>
#include <iostream>
#include "StreamRecorder.h"
using namespace std;
//------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
if(argc < 2)
{
cerr << "too few arguments" << endl;
return EXIT_FAILURE;
}
gst_init (&argc, &argv);
StreamRecorder myRecorder = StreamRecorder(argv[1],atoi(argv[2]));
GMainLoop* main_loop = NULL;
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run(main_loop);
return 0;
}
//------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
#
# Notes:
#-------------------------------------------------------------------------------
APPNAME = streamRecorder
#Compiler:
CC=g++ -std=c++11
#Compiler flags
CFLAGS=-c -g -Wall
#Directories
DIRlib= /usr/local/lib
incDIR= /usr/local/include
INCLUIDES=$(shell pkg-config --cflags glib-2.0 gstreamer-1.0 gstreamer-plugins-base-1.0 flac)
LIBS=$(shell pkg-config --libs glib-2.0 gstreamer-1.0 gstreamer-plugins-base-1.0 flac)
#main function
mainP= main
#-------------------------------------------------------------------------------
all: Project
Project: mainP.o StreamRecorder.o
$(CC) -o $(APPNAME) \
$(mainP).o \
StreamRecorder.o \
-L $(DIRlib) \
-I $(incDIR) \
$(LIBS)
StreamRecorder.o: StreamRecorder.cpp
$(CC) $(INCLUIDES) $(CFLAGS) \
StreamRecorder.cpp
mainP.o: $(mainP).cpp
$(CC) $(INCLUIDES) $(CFLAGS) \
$(mainP).cpp
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