/* --------------------------------------------------------------------------- ** ** FifoSource.h ** ** live555 source ** ** -------------------------------------------------------------------------*/ #ifndef ZM_RTSP_SERVER_FIFO_SOURCE_H #define ZM_RTSP_SERVER_FIFO_SOURCE_H #include "zm_config.h" #include "zm_define.h" #include #include #include #if HAVE_RTSP_SERVER #include class NAL_Frame; class ZoneMinderFifoSource: public FramedSource { public: static ZoneMinderFifoSource* createNew( UsageEnvironment& env, std::string fifo, unsigned int queueSize ) { return new ZoneMinderFifoSource(env, fifo, queueSize); }; std::string getAuxLine() { return m_auxLine; }; int getWidth() { return m_width; }; int getHeight() { return m_height; }; int setWidth(int width) { return m_width=width; }; int setHeight(int height) { return m_height=height; }; protected: ZoneMinderFifoSource(UsageEnvironment& env, std::string fifo, unsigned int queueSize); virtual ~ZoneMinderFifoSource(); protected: static void* threadStub(void* clientData) { return ((ZoneMinderFifoSource*) clientData)->thread();}; void* thread(); static void deliverFrameStub(void* clientData) {((ZoneMinderFifoSource*) clientData)->deliverFrame();}; void deliverFrame(); static void incomingPacketHandlerStub(void* clientData, int mask) { ((ZoneMinderFifoSource*) clientData)->incomingPacketHandler(); }; void incomingPacketHandler(); int getNextFrame(); void processFrame(char * frame, int frameSize, const timeval &ref); void queueFrame(char * frame, int frameSize, const timeval &tv); // split packet in frames virtual std::list< std::pair > splitFrames(unsigned char* frame, unsigned &frameSize); // overide FramedSource virtual void doGetNextFrame(); virtual void doStopGettingFrames(); virtual unsigned char *extractFrame(unsigned char *data, size_t& size, size_t& outsize); protected: std::list m_captureQueue; EventTriggerId m_eventTriggerId; std::string m_fifo; int m_width; int m_height; unsigned int m_queueSize; pthread_t m_thid; pthread_mutex_t m_mutex; std::string m_auxLine; int stop; int m_fd; #define BUFFER_SIZE 65536 unsigned char m_buffer[BUFFER_SIZE]; unsigned char *m_buffer_ptr; }; #endif // HAVE_RTSP_SERVER #endif // ZM_RTSP_SERVER_FIFO_SOURCE_H