You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.1 KiB
63 lines
2.1 KiB
#ifndef __MEDIA_NGINX_STREAMER_MANAGER__
|
|
#define __MEDIA_NGINX_STREAMER_MANAGER__
|
|
|
|
#include "../../components/base/basicLogCollection.h"
|
|
#include "../../components/base/basicThread.h"
|
|
#include "../../components/base/basicMutex.h"
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <vector>
|
|
|
|
/* Singletone object */
|
|
|
|
typedef struct S_MEDIA_MANAGER_RECORD{
|
|
uint32_t id;
|
|
char URI[1024];
|
|
char CMD[1024];
|
|
bool tcp_connection;
|
|
char md5[33];
|
|
pthread_t m_sThreadHandler;
|
|
uint8_t ThreadStatus;
|
|
FILE * FID;
|
|
} MEDIA_MANAGER_RECORD;
|
|
|
|
typedef std::vector<MEDIA_MANAGER_RECORD*> vMEDIARECORD;
|
|
|
|
#define NGINX_MEDIA_MANAGER_INTERVAL 300
|
|
#define NGINX_MEDIA_MANAGER_DEFAULT_FEED "rtmp:localhost/live"
|
|
#define NGINX_MEDIA_MANAGER_CMD "ffmpeg %s -re -i \"%s\" -an -tune zerolatency -bsf:v h264_mp4toannexb -c copy -f flv %s/%s 2>/dev/null"
|
|
|
|
class mediaNginxManager: public basicThread{
|
|
private:
|
|
basicLogCollection * m_pLog;
|
|
basicMutex m_oProtector;
|
|
vMEDIARECORD m_vStreams;
|
|
bool restartStream( MEDIA_MANAGER_RECORD * );
|
|
public:
|
|
~mediaNginxManager();
|
|
static mediaNginxManager * getInstance();
|
|
bool attachStream( CSTR URI, bool TCP_CONNECTION, uint32_t id, CSTR md5 );
|
|
|
|
protected:
|
|
// Constructor - protected so users cannot call it.
|
|
mediaNginxManager();
|
|
virtual void m_fThreadProc( void );
|
|
private:
|
|
// private static member referencing the single instance of the object
|
|
// TODO: Replace mediaNginxManager with the type of object you want to
|
|
// return the single instance of
|
|
static mediaNginxManager * _instance;
|
|
|
|
// Copy constructor
|
|
// Declared but not defined to prevent auto-generated
|
|
// copy constructor. Refer to "Effective C++" by Meyers
|
|
mediaNginxManager(const mediaNginxManager& src);
|
|
|
|
// Assignment operator
|
|
// Declared but not defined to prevent auto-generated
|
|
// assignment operator. Refer to "Effective C++" by Meyers
|
|
mediaNginxManager& operator=(const mediaNginxManager& src);
|
|
};
|
|
|
|
|
|
#endif
|