2021-01-07 00:26:08 +08:00
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** DeviceSource.h
|
|
|
|
**
|
|
|
|
** live555 source
|
|
|
|
**
|
|
|
|
** -------------------------------------------------------------------------*/
|
|
|
|
|
2021-01-27 23:50:07 +08:00
|
|
|
#include "zm.h"
|
|
|
|
|
|
|
|
#if HAVE_RTSP_SERVER
|
2021-01-07 00:26:08 +08:00
|
|
|
|
|
|
|
#ifndef DEVICE_SOURCE
|
|
|
|
#define DEVICE_SOURCE
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <liveMedia.hh>
|
|
|
|
|
|
|
|
#include "zm_monitor.h"
|
|
|
|
#include "zm_rtsp_server_frame.h"
|
|
|
|
#include "zm_packetqueue.h"
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
class ZoneMinderDeviceSource: public FramedSource {
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ZoneMinderDeviceSource* createNew(
|
|
|
|
UsageEnvironment& env,
|
|
|
|
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-01-21 23:23:30 +08:00
|
|
|
ZoneMinderDeviceSource(UsageEnvironment& env, 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-01-07 00:26:08 +08:00
|
|
|
Monitor* m_monitor;
|
|
|
|
zm_packetqueue *m_packetqueue;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2021-01-27 23:50:07 +08:00
|
|
|
#endif
|