diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 062796a19..eca415cad 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -532,7 +532,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi AVPacket packet; AVPacket* queuedpacket; uint8_t* directbuffer; - zm_packetqueue packetqueue("testqueue"); + zm_packetqueue packetqueue; /* Request a writeable buffer of the target image */ directbuffer = image.WriteBuffer(width, height, colours, subpixelorder); diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index 12b3f8fc0..1b95a9eb5 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -22,25 +22,11 @@ #define VIDEO_QUEUESIZE 200 #define AUDIO_QUEUESIZE 50 -using namespace boost::interprocess; +using namespace std; -zm_packetqueue::zm_packetqueue(const std::string &name) -: m_name(name), -msm(open_or_create, m_name.c_str(), 65536), -alloc(msm.get_segment_manager()) { - - try { - - //Construct a shared memory map. - //Note that the first parameter is the comparison function, - //and the second one the allocator. - //This the same signature as std::map's constructor taking an allocator - ptr = msm.find_or_construct(m_name.c_str())(alloc); - } catch (...) { - shared_memory_object::remove("MySharedMemory"); - throw; - } - shared_memory_object::remove("MySharedMemory"); +zm_packetqueue::zm_packetqueue() + : MaxVideoQueueSize(VIDEO_QUEUESIZE) +, MaxAudioQueueSize(AUDIO_QUEUESIZE) { } zm_packetqueue::~zm_packetqueue() { @@ -55,7 +41,7 @@ bool zm_packetqueue::queueAudioPacket(AVPacket* packet) return queuePacket(AudioQueue, packet); } -bool zm_packetqueue::queuePacket(std::queue& pktQueue, AVPacket* packet) { +bool zm_packetqueue::queuePacket(queue& pktQueue, AVPacket* packet){ AVPacket input_ref = { 0 }; if (av_packet_ref(&input_ref, packet) < 0){ @@ -66,7 +52,7 @@ bool zm_packetqueue::queuePacket(std::queue& pktQueue, AVPacket* packe return true; } -bool zm_packetqueue::popPacket(std::queue& pktQueue, AVPacket* packet) +bool zm_packetqueue::popPacket(queue& pktQueue, AVPacket* packet) { if (pktQueue.empty()) { diff --git a/src/zm_packetqueue.h b/src/zm_packetqueue.h index 7778fdbe5..2314e7925 100644 --- a/src/zm_packetqueue.h +++ b/src/zm_packetqueue.h @@ -21,7 +21,7 @@ #define ZM_PACKETQUEUE_H #include -#include +#include #include #include @@ -29,31 +29,26 @@ extern "C" { #include } +typedef queue > QueueType; + class zm_packetqueue { public: - zm_packetqueue(const std::string &name); - virtual ~zm_packetqueue(); - bool queuePacket(std::queue& pktQueue, AVPacket* packet); - bool queueVideoPacket(AVPacket* packet); - bool queueAudioPacket(AVPacket* packet); - bool popPacket(std::queue& pktQueue, AVPacket* packet); - bool popVideoPacket(AVPacket* packet); - bool popAudioPacket(AVPacket* packet); - void clearQueues(); - void clearQueue(std::queue& pktQueue); + zm_packetqueue(); + zm_packetqueue(const zm_packetqueue& orig); + virtual ~zm_packetqueue(); + bool queuePacket(std::queue& pktQueue, AVPacket* packet); + bool queueVideoPacket(AVPacket* packet); + bool queueAudioPacket(AVPacket* packet); + bool popPacket(std::queue& pktQueue, AVPacket* packet); + bool popVideoPacket(AVPacket* packet); + bool popAudioPacket(AVPacket* packet); + void clearQueues(); + void clearQueue(std::queue& pktQueue); private: - typedef boost::interprocess::allocator - QueueShmemAllocator; - typedef std::queue > - QueueType; - std::string m_name; - boost::interprocess::managed_shared_memory msm; - QueueShmemAllocator alloc; - int MaxVideoQueueSize; - int MaxAudioQueueSize; - std::queue VideoQueue; - std::queue AudioQueue; + int MaxVideoQueueSize; + int MaxAudioQueueSize; + std::queue VideoQueue; + std::queue AudioQueue; };