| 1 | /* --------------------------------------------------------------------------- |
| 2 | ** This software is in the public domain, furnished "as is", without technical |
| 3 | ** support, and with no warranty, express or implied, as to its usefulness for |
| 4 | ** any purpose. |
| 5 | ** |
| 6 | ** H264_V4l2DeviceSource.h |
| 7 | ** |
| 8 | ** H264 V4L2 live555 source |
| 9 | ** |
| 10 | ** -------------------------------------------------------------------------*/ |
| 11 | |
| 12 | |
| 13 | #ifndef H264_V4L2_DEVICE_SOURCE |
| 14 | #define H264_V4L2_DEVICE_SOURCE |
| 15 | |
| 16 | // project |
| 17 | #include "DeviceSource.h" |
| 18 | |
| 19 | // --------------------------------- |
| 20 | // H264 V4L2 FramedSource |
| 21 | // --------------------------------- |
| 22 | const char H264marker[] = {0,0,0,1}; |
| 23 | const char H264shortmarker[] = {0,0,1}; |
| 24 | |
| 25 | class H26X_V4L2DeviceSource : public V4L2DeviceSource |
| 26 | { |
| 27 | protected: |
| 28 | H26X_V4L2DeviceSource(UsageEnvironment& env, DeviceInterface * device, int outputFd, unsigned int queueSize, bool useThread, bool repeatConfig, bool keepMarker) |
| 29 | : V4L2DeviceSource(env, device, outputFd, queueSize, useThread), m_repeatConfig(repeatConfig), m_keepMarker(keepMarker) {} |
| 30 | |
| 31 | virtual ~H26X_V4L2DeviceSource() {} |
| 32 | |
| 33 | unsigned char* (unsigned char* frame, size_t& size, size_t& outsize, int& frameType); |
| 34 | |
| 35 | protected: |
| 36 | std::string m_sps; |
| 37 | std::string m_pps; |
| 38 | bool m_repeatConfig; |
| 39 | bool m_keepMarker; |
| 40 | }; |
| 41 | |
| 42 | class H264_V4L2DeviceSource : public H26X_V4L2DeviceSource |
| 43 | { |
| 44 | public: |
| 45 | static H264_V4L2DeviceSource* createNew(UsageEnvironment& env, DeviceInterface * device, int outputFd, unsigned int queueSize, bool useThread, bool repeatConfig, bool keepMarker) { |
| 46 | return new H264_V4L2DeviceSource(env, device, outputFd, queueSize, useThread, repeatConfig, keepMarker); |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | H264_V4L2DeviceSource(UsageEnvironment& env, DeviceInterface * device, int outputFd, unsigned int queueSize, bool useThread, bool repeatConfig, bool keepMarker) |
| 51 | : H26X_V4L2DeviceSource(env, device, outputFd, queueSize, useThread, repeatConfig, keepMarker) {} |
| 52 | |
| 53 | // overide V4L2DeviceSource |
| 54 | virtual std::list< std::pair<unsigned char*,size_t> > splitFrames(unsigned char* frame, unsigned frameSize); |
| 55 | }; |
| 56 | |
| 57 | class H265_V4L2DeviceSource : public H26X_V4L2DeviceSource |
| 58 | { |
| 59 | public: |
| 60 | static H265_V4L2DeviceSource* createNew(UsageEnvironment& env, DeviceInterface * device, int outputFd, unsigned int queueSize, bool useThread, bool repeatConfig, bool keepMarker) { |
| 61 | return new H265_V4L2DeviceSource(env, device, outputFd, queueSize, useThread, repeatConfig, keepMarker); |
| 62 | } |
| 63 | |
| 64 | protected: |
| 65 | H265_V4L2DeviceSource(UsageEnvironment& env, DeviceInterface * device, int outputFd, unsigned int queueSize, bool useThread, bool repeatConfig, bool keepMarker) |
| 66 | : H26X_V4L2DeviceSource(env, device, outputFd, queueSize, useThread, repeatConfig, keepMarker) {} |
| 67 | |
| 68 | // overide V4L2DeviceSource |
| 69 | virtual std::list< std::pair<unsigned char*,size_t> > splitFrames(unsigned char* frame, unsigned frameSize); |
| 70 | |
| 71 | protected: |
| 72 | std::string m_vps; |
| 73 | }; |
| 74 | |
| 75 | #endif |
| 76 | |