Add isPrimed to camera class instead of it just being in ffmpeg_camera. Rename mCanCapture to isPrimed in ffmpeg_camera.

pull/3793/head
Isaac Connor 2023-12-06 09:38:38 -05:00
parent ffc111f1e7
commit db135cba46
4 changed files with 8 additions and 7 deletions

View File

@ -59,7 +59,8 @@ Camera::Camera(
mFirstAudioPTS(0),
mLastVideoPTS(0),
mLastAudioPTS(0),
bytes(0)
bytes(0),
mIsPrimed(false)
{
linesize = width * colours;
pixels = width * height;

View File

@ -65,6 +65,7 @@ protected:
int64_t mLastVideoPTS;
int64_t mLastAudioPTS;
unsigned int bytes;
bool mIsPrimed;
public:
Camera(
@ -84,6 +85,7 @@ public:
virtual ~Camera();
SourceType Type() const { return type; }
bool isPrimed() const { return mIsPrimed; }
bool IsLocal() const { return type == LOCAL_SRC; }
bool IsRemote() const { return type == REMOTE_SRC; }
bool IsFile() const { return type == FILE_SRC; }

View File

@ -127,7 +127,6 @@ FfmpegCamera::FfmpegCamera(
mSecondInput(nullptr),
frameCount(0),
use_hwaccel(true),
mCanCapture(false),
mConvertContext(nullptr),
error_count(0),
stream_width(0),
@ -172,7 +171,7 @@ FfmpegCamera::~FfmpegCamera() {
int FfmpegCamera::PrimeCapture() {
start_read_time = std::chrono::steady_clock::now();
if ( mCanCapture ) {
if ( mIsPrimed ) {
Debug(1, "Priming capture from %s, Closing", mMaskedPath.c_str());
Close();
}
@ -188,7 +187,7 @@ int FfmpegCamera::PreCapture() {
}
int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
if (!mCanCapture) return -1;
if (!mIsPrimed) return -1;
start_read_time = std::chrono::steady_clock::now();
int ret;
@ -562,13 +561,13 @@ int FfmpegCamera::OpenFfmpeg() {
width, height, mVideoCodecContext->width, mVideoCodecContext->height);
}
mCanCapture = true;
mIsPrimed = true;
return 1;
} // int FfmpegCamera::OpenFfmpeg()
int FfmpegCamera::Close() {
mCanCapture = false;
mIsPrimed = false;
if (mVideoCodecContext) {
avcodec_close(mVideoCodecContext);

View File

@ -68,7 +68,6 @@ class FfmpegCamera : public Camera {
int OpenFfmpeg();
int Close() override;
bool mCanCapture;
struct SwsContext *mConvertContext;