2017-05-17 00:04:56 +08:00
|
|
|
//ZoneMinder Packet Wrapper Class
|
|
|
|
//Copyright 2017 ZoneMinder LLC
|
|
|
|
//
|
|
|
|
//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_PACKET_H
|
|
|
|
#define ZM_PACKET_H
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
}
|
|
|
|
|
2017-06-22 22:14:24 +08:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif // __FreeBSD__
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2017-10-10 21:36:56 +08:00
|
|
|
#include "zm_image.h"
|
2017-12-04 00:09:01 +08:00
|
|
|
#include "zm_thread.h"
|
2017-06-22 22:14:24 +08:00
|
|
|
|
2017-05-17 00:04:56 +08:00
|
|
|
class ZMPacket {
|
|
|
|
public:
|
|
|
|
|
2017-12-04 00:09:01 +08:00
|
|
|
Mutex mutex;
|
2017-11-13 00:42:34 +08:00
|
|
|
int keyframe;
|
2017-10-10 03:32:09 +08:00
|
|
|
AVPacket packet; // Input packet, undecoded
|
2017-11-15 05:16:07 +08:00
|
|
|
AVFrame *in_frame; // Input image, decoded Theoretically only filled if needed.
|
2017-11-18 07:19:37 +08:00
|
|
|
AVFrame *out_frame; // Input image, decoded Theoretically only filled if needed.
|
2017-11-22 08:55:40 +08:00
|
|
|
uint8_t *buffer;
|
|
|
|
Image *image; // Our internal image object representing this frame
|
|
|
|
Image *analysis_image; // Our internal image object representing this frame
|
|
|
|
int score;
|
|
|
|
struct timeval *timestamp;
|
2017-11-21 00:48:56 +08:00
|
|
|
AVMediaType codec_type;
|
2017-11-22 08:55:40 +08:00
|
|
|
int image_index;
|
2018-12-27 01:02:00 +08:00
|
|
|
int codec_imgsize;
|
2017-12-01 03:37:36 +08:00
|
|
|
|
2017-05-17 00:04:56 +08:00
|
|
|
public:
|
|
|
|
AVPacket *av_packet() { return &packet; }
|
2017-11-13 00:42:34 +08:00
|
|
|
AVPacket *set_packet( AVPacket *p ) ;
|
2017-11-18 07:19:37 +08:00
|
|
|
AVFrame *av_frame() { return out_frame; }
|
2017-11-15 05:16:07 +08:00
|
|
|
Image *get_image( Image *i=NULL );
|
2017-11-13 00:42:34 +08:00
|
|
|
Image *set_image( Image * );
|
|
|
|
|
|
|
|
int is_keyframe() { return keyframe; };
|
|
|
|
int decode( AVCodecContext *ctx );
|
2017-11-14 01:14:57 +08:00
|
|
|
void reset();
|
2020-11-13 01:36:36 +08:00
|
|
|
explicit ZMPacket(Image *image);
|
|
|
|
explicit ZMPacket(ZMPacket &packet);
|
2017-11-13 00:42:34 +08:00
|
|
|
ZMPacket();
|
2017-05-17 00:04:56 +08:00
|
|
|
~ZMPacket();
|
2019-02-25 23:21:43 +08:00
|
|
|
void lock() {
|
|
|
|
Debug(2,"Locking packet %d", this->image_index);
|
|
|
|
mutex.lock();
|
|
|
|
Debug(2,"packet %d locked", this->image_index);
|
|
|
|
};
|
2020-09-26 04:20:19 +08:00
|
|
|
void unlock() {
|
|
|
|
Debug(2,"packet %d unlocked", this->image_index);
|
|
|
|
mutex.unlock();
|
|
|
|
};
|
2018-11-21 22:46:14 +08:00
|
|
|
AVFrame *get_out_frame( const AVCodecContext *ctx );
|
2018-12-27 01:02:00 +08:00
|
|
|
int get_codec_imgsize() { return codec_imgsize; };
|
2017-05-17 00:04:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ZM_PACKET_H */
|