2021-01-07 00:26:08 +08:00
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** DeviceSource.h
|
|
|
|
**
|
|
|
|
** live555 source
|
|
|
|
**
|
|
|
|
** -------------------------------------------------------------------------*/
|
|
|
|
|
2021-02-04 11:59:03 +08:00
|
|
|
#ifndef ZM_RTSP_SERVER_DEVICE_SOURCE_H
|
|
|
|
#define ZM_RTSP_SERVER_DEVICE_SOURCE_H
|
|
|
|
|
2021-02-04 11:47:28 +08:00
|
|
|
#include "zm_config.h"
|
2021-02-05 02:58:29 +08:00
|
|
|
#include "zm_define.h"
|
2021-02-04 11:47:28 +08:00
|
|
|
#include "zm_monitor.h"
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2021-01-27 23:50:07 +08:00
|
|
|
|
|
|
|
#if HAVE_RTSP_SERVER
|
2021-01-07 00:26:08 +08:00
|
|
|
#include <liveMedia.hh>
|
|
|
|
|
2021-02-04 11:47:28 +08:00
|
|
|
class NAL_Frame;
|
2021-01-07 00:26:08 +08:00
|
|
|
|
|
|
|
class ZoneMinderDeviceSource: public FramedSource {
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ZoneMinderDeviceSource* createNew(
|
|
|
|
UsageEnvironment& env,
|
2021-02-08 02:12:39 +08:00
|
|
|
std::shared_ptr<Monitor> monitor,
|
2021-01-21 23:23:30 +08:00
|
|
|
AVStream * stream,
|
2021-01-23 08:26:00 +08:00
|
|
|
unsigned int queueSize
|
|
|
|
) {
|
|
|
|
return new ZoneMinderDeviceSource(env, monitor, stream, queueSize);
|
|
|
|
};
|
2021-01-07 00:26:08 +08:00
|
|
|
std::string getAuxLine() { return m_auxLine; };
|
|
|
|
int getWidth() { return m_monitor->Width(); };
|
|
|
|
int getHeight() { return m_monitor->Height(); };
|
|
|
|
|
|
|
|
protected:
|
2021-02-08 02:12:39 +08:00
|
|
|
ZoneMinderDeviceSource(UsageEnvironment& env, std::shared_ptr<Monitor> monitor, AVStream * stream, unsigned int queueSize);
|
2021-01-07 00:26:08 +08:00
|
|
|
virtual ~ZoneMinderDeviceSource();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void* threadStub(void* clientData) { return ((ZoneMinderDeviceSource*) clientData)->thread();};
|
|
|
|
void* thread();
|
|
|
|
static void deliverFrameStub(void* clientData) {((ZoneMinderDeviceSource*) clientData)->deliverFrame();};
|
|
|
|
void deliverFrame();
|
|
|
|
static void incomingPacketHandlerStub(void* clientData, int mask) { ((ZoneMinderDeviceSource*) 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<unsigned char*, size_t> > splitFrames(unsigned char* frame, unsigned frameSize);
|
|
|
|
|
|
|
|
// overide FramedSource
|
|
|
|
virtual void doGetNextFrame();
|
|
|
|
virtual void doStopGettingFrames();
|
2021-01-23 08:26:00 +08:00
|
|
|
virtual unsigned char *extractFrame(unsigned char *data, size_t& size, size_t& outsize);
|
2021-01-07 00:26:08 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::list<NAL_Frame*> m_captureQueue;
|
|
|
|
EventTriggerId m_eventTriggerId;
|
2021-01-21 23:23:30 +08:00
|
|
|
AVStream *m_stream;
|
2021-02-08 02:12:39 +08:00
|
|
|
std::shared_ptr<Monitor> m_monitor;
|
2021-02-01 10:31:20 +08:00
|
|
|
PacketQueue *m_packetqueue;
|
2021-01-07 00:26:08 +08:00
|
|
|
std::list<ZMPacket *>::iterator *m_packetqueue_it;
|
|
|
|
|
|
|
|
unsigned int m_queueSize;
|
|
|
|
pthread_t m_thid;
|
|
|
|
pthread_mutex_t m_mutex;
|
|
|
|
std::string m_auxLine;
|
2021-01-21 23:23:30 +08:00
|
|
|
int stop;
|
2021-01-07 00:26:08 +08:00
|
|
|
};
|
2021-02-04 11:59:03 +08:00
|
|
|
#endif // HAVE_RTSP_SERVER
|
2021-01-07 00:26:08 +08:00
|
|
|
|
2021-02-04 11:59:03 +08:00
|
|
|
#endif // ZM_RTSP_SERVER_DEVICE_SOURCE_H
|