Add isPrimed to camera class instead of it just being in ffmpeg_camera. Rename mCanCapture to isPrimed in ffmpeg_camera.
parent
ffc111f1e7
commit
db135cba46
|
@ -59,7 +59,8 @@ Camera::Camera(
|
|||
mFirstAudioPTS(0),
|
||||
mLastVideoPTS(0),
|
||||
mLastAudioPTS(0),
|
||||
bytes(0)
|
||||
bytes(0),
|
||||
mIsPrimed(false)
|
||||
{
|
||||
linesize = width * colours;
|
||||
pixels = width * height;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -68,7 +68,6 @@ class FfmpegCamera : public Camera {
|
|||
|
||||
int OpenFfmpeg();
|
||||
int Close() override;
|
||||
bool mCanCapture;
|
||||
|
||||
struct SwsContext *mConvertContext;
|
||||
|
||||
|
|
Loading…
Reference in New Issue