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.

62 lines
2.1 KiB

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