Revert "WIP packetqueue shared memory"

This reverts commit 8aa1cb6bf6.
This commit is contained in:
Steve Gilvarry 2016-05-08 15:25:18 +10:00
parent a3eabe9c72
commit 1f3b3d1203
3 changed files with 25 additions and 44 deletions

View File

@ -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);

View File

@ -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<AVPacket>(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<AVPacket>& pktQueue, AVPacket* packet) {
bool zm_packetqueue::queuePacket(queue<AVPacket>& 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<AVPacket>& pktQueue, AVPacket* packe
return true;
}
bool zm_packetqueue::popPacket(std::queue<AVPacket>& pktQueue, AVPacket* packet)
bool zm_packetqueue::popPacket(queue<AVPacket>& pktQueue, AVPacket* packet)
{
if (pktQueue.empty())
{

View File

@ -21,7 +21,7 @@
#define ZM_PACKETQUEUE_H
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/deque.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <queue>
@ -29,9 +29,12 @@ extern "C" {
#include <libavformat/avformat.h>
}
typedef queue<AVPacket, deque<AVPacket, QueueShmemAllocator> > QueueType;
class zm_packetqueue {
public:
zm_packetqueue(const std::string &name);
zm_packetqueue();
zm_packetqueue(const zm_packetqueue& orig);
virtual ~zm_packetqueue();
bool queuePacket(std::queue<AVPacket>& pktQueue, AVPacket* packet);
bool queueVideoPacket(AVPacket* packet);
@ -42,14 +45,6 @@ public:
void clearQueues();
void clearQueue(std::queue<AVPacket>& pktQueue);
private:
typedef boost::interprocess::allocator <AVPacket,
boost::interprocess::managed_shared_memory::segment_manager>
QueueShmemAllocator;
typedef std::queue<AVPacket, std::deque<AVPacket, QueueShmemAllocator> >
QueueType;
std::string m_name;
boost::interprocess::managed_shared_memory msm;
QueueShmemAllocator alloc;
int MaxVideoQueueSize;
int MaxAudioQueueSize;
std::queue<AVPacket> VideoQueue;