Add Packet Queue
This commit is contained in:
parent
24ebc33ea4
commit
966fbb1a10
|
@ -4,7 +4,7 @@
|
||||||
configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY)
|
configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY)
|
||||||
|
|
||||||
# Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc)
|
# Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc)
|
||||||
set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp)
|
set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_packetqueue.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp)
|
||||||
|
|
||||||
# A fix for cmake recompiling the source files for every target.
|
# A fix for cmake recompiling the source files for every target.
|
||||||
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,7 @@
|
||||||
//#include "zm_utils.h"
|
//#include "zm_utils.h"
|
||||||
#include "zm_ffmpeg.h"
|
#include "zm_ffmpeg.h"
|
||||||
#include "zm_videostore.h"
|
#include "zm_videostore.h"
|
||||||
|
#include "zm_packetqueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Class representing 'ffmpeg' cameras, i.e. those which are
|
// Class representing 'ffmpeg' cameras, i.e. those which are
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
//ZoneMinder Packet Queue Implementation Class
|
||||||
|
//Copyright 2016 Steve Gilvarry
|
||||||
|
//
|
||||||
|
//This file is part of ZoneMinder.
|
||||||
|
//
|
||||||
|
//ZoneMinder is free software: you can redistribute it and/or modify
|
||||||
|
//it under the terms of the GNU General Public License as published by
|
||||||
|
//the Free Software Foundation, either version 3 of the License, or
|
||||||
|
//(at your option) any later version.
|
||||||
|
//
|
||||||
|
//ZoneMinder is distributed in the hope that it will be useful,
|
||||||
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
//GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
//You should have received a copy of the GNU General Public License
|
||||||
|
//along with ZoneMinder. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
#include "zm_packetqueue.h"
|
||||||
|
|
||||||
|
#define VIDEO_QUEUESIZE 200
|
||||||
|
#define AUDIO_QUEUESIZE 50
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
zm_packetqueue::zm_packetqueue() {
|
||||||
|
}
|
||||||
|
|
||||||
|
zm_packetqueue::zm_packetqueue(const zm_packetqueue& orig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
zm_packetqueue::~zm_packetqueue() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::queueVideoPacket(AVPacket* packet){
|
||||||
|
return queuePacket(m_VideoQueue, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::queueAudioPacket(AVPacket* packet)
|
||||||
|
{
|
||||||
|
return queuePacket(m_AudioQueue, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::queuePacket(queue<AVPacket>& packetQueue, AVPacket* packet){
|
||||||
|
|
||||||
|
AVPacket input_ref = { 0 };
|
||||||
|
if (av_packet_ref(&input_ref, packet) < 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
packetQueue.push(*packet);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::popPacket(queue<AVPacket>& packetQueue, AVPacket* packet)
|
||||||
|
{
|
||||||
|
if (packetQueue.empty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*packet = packetQueue.front();
|
||||||
|
packetQueue.pop();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zm_packetqueue::clearQueue(std::queue<AVPacket>& packetQueue)
|
||||||
|
{
|
||||||
|
while(!packetQueue.empty())
|
||||||
|
{
|
||||||
|
packetQueue.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void zm_packetqueue::clearQueues()
|
||||||
|
{
|
||||||
|
clearQueue(m_VideoQueue);
|
||||||
|
clearQueue(m_AudioQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::popAudioPacket(AVPacket* packet)
|
||||||
|
{
|
||||||
|
return popPacket(m_AudioQueue, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zm_packetqueue::popVideoPacket(AVPacket* packet)
|
||||||
|
{
|
||||||
|
return popPacket(m_VideoQueue, packet);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
//ZoneMinder Packet Queue Interface Class
|
||||||
|
//Copyright 2016 Steve Gilvarry
|
||||||
|
//
|
||||||
|
//This file is part of ZoneMinder.
|
||||||
|
//
|
||||||
|
//ZoneMinder is free software: you can redistribute it and/or modify
|
||||||
|
//it under the terms of the GNU General Public License as published by
|
||||||
|
//the Free Software Foundation, either version 3 of the License, or
|
||||||
|
//(at your option) any later version.
|
||||||
|
//
|
||||||
|
//ZoneMinder is distributed in the hope that it will be useful,
|
||||||
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
//GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
//You should have received a copy of the GNU General Public License
|
||||||
|
//along with ZoneMinder. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ZM_PACKETQUEUE_H
|
||||||
|
#define ZM_PACKETQUEUE_H
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
class zm_packetqueue {
|
||||||
|
public:
|
||||||
|
zm_packetqueue();
|
||||||
|
zm_packetqueue(const zm_packetqueue& orig);
|
||||||
|
virtual ~zm_packetqueue();
|
||||||
|
bool queuePacket(std::queue<AVPacket>& packetQueue, AVPacket* packet);
|
||||||
|
bool queueVideoPacket(AVPacket* packet);
|
||||||
|
bool queueAudioPacket(AVPacket* packet);
|
||||||
|
bool popPacket(std::queue<AVPacket>& packetQueue, AVPacket* packet);
|
||||||
|
bool popVideoPacket(AVPacket* packet);
|
||||||
|
bool popAudioPacket(AVPacket* packet);
|
||||||
|
void clearQueues();
|
||||||
|
void clearQueue(std::queue<AVPacket>& packetQueue);
|
||||||
|
private:
|
||||||
|
int m_MaxVideoQueueSize;
|
||||||
|
int m_MaxAudioQueueSize;
|
||||||
|
std::queue<AVPacket> m_VideoQueue;
|
||||||
|
std::queue<AVPacket> m_AudioQueue;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ZM_PACKETQUEUE_H */
|
||||||
|
|
Loading…
Reference in New Issue