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.

60 lines
2.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __MEDIA_NGINX_STREAMER_MANAGER__
  2. #define __MEDIA_NGINX_STREAMER_MANAGER__
  3. #include "../../componments/base/basicLogCollection.h"
  4. #include "../../componments/base/basicThread.h"
  5. #include "../../componments/base/basicMutex.h"
  6. #include <vector>
  7. /* Singletone object */
  8. typedef struct S_MEDIA_MANAGER_RECORD{
  9. uint32_t id;
  10. char URI[1024];
  11. char CMD[1024];
  12. bool tcp_connection;
  13. char md5[33];
  14. pthread_t m_sThreadHandler;
  15. uint8_t ThreadStatus;
  16. FILE * FID;
  17. } MEDIA_MANAGER_RECORD;
  18. typedef std::vector<MEDIA_MANAGER_RECORD*> vMEDIARECORD;
  19. #define NGINX_MEDIA_MANAGER_INTERVAL 300
  20. #define NGINX_MEDIA_MANAGER_DEFAULT_FEED "rtmp:localhost/live"
  21. #define NGINX_MEDIA_MANAGER_CMD "ffmpeg %s -re -i \"%s\" -an -tune zerolatency -bsf:v h264_mp4toannexb -c copy -f flv %s/%s"
  22. class mediaNginxManager: public basicThread{
  23. private:
  24. basicLogCollection * m_pLog;
  25. basicMutex m_oProtector;
  26. vMEDIARECORD m_vStreams;
  27. bool restartStream( MEDIA_MANAGER_RECORD * );
  28. public:
  29. virtual ~mediaNginxManager();
  30. mediaNginxManager * getInstance();
  31. bool attachStream( CSTR URI, bool TCP_CONNECTION );
  32. protected:
  33. // Constructor - protected so users cannot call it.
  34. mediaNginxManager();
  35. virtual void m_fThreadProc( void );
  36. private:
  37. // private static member referencing the single instance of the object
  38. // TODO: Replace mediaNginxManager with the type of object you want to
  39. // return the single instance of
  40. static mediaNginxManager * _instance;
  41. // Copy constructor
  42. // Declared but not defined to prevent auto-generated
  43. // copy constructor. Refer to "Effective C++" by Meyers
  44. mediaNginxManager(const mediaNginxManager& src);
  45. // Assignment operator
  46. // Declared but not defined to prevent auto-generated
  47. // assignment operator. Refer to "Effective C++" by Meyers
  48. mediaNginxManager& operator=(const mediaNginxManager& src);
  49. };
  50. #endif