mFormatContextPtr doesn't need to be a class member

This commit is contained in:
Isaac Connor 2021-04-20 13:58:23 -04:00
parent 45247c4d59
commit b62e8f7a81
2 changed files with 6 additions and 7 deletions

View File

@ -194,6 +194,7 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
start_read_time = time(nullptr);
int ret;
AVFormatContext *formatContextPtr;
if ( mSecondFormatContext and
(
@ -202,23 +203,23 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
av_rescale_q(mLastVideoPTS, mVideoStream->time_base, AV_TIME_BASE_Q)
) ) {
// if audio stream is behind video stream, then read from audio, otherwise video
mFormatContextPtr = mSecondFormatContext;
formatContextPtr = mSecondFormatContext;
Debug(4, "Using audio input because audio PTS %" PRId64 " < video PTS %" PRId64,
av_rescale_q(mLastAudioPTS, mAudioStream->time_base, AV_TIME_BASE_Q),
av_rescale_q(mLastVideoPTS, mVideoStream->time_base, AV_TIME_BASE_Q)
);
} else {
mFormatContextPtr = mFormatContext;
formatContextPtr = mFormatContext;
Debug(4, "Using video input because %" PRId64 " >= %" PRId64,
(mAudioStream?av_rescale_q(mLastAudioPTS, mAudioStream->time_base, AV_TIME_BASE_Q):0),
av_rescale_q(mLastVideoPTS, mVideoStream->time_base, AV_TIME_BASE_Q)
);
}
if ( (ret = av_read_frame(mFormatContextPtr, &packet)) < 0 ) {
if ((ret = av_read_frame(formatContextPtr, &packet)) < 0) {
if (
// Check if EOF.
(ret == AVERROR_EOF || (mFormatContextPtr->pb && mFormatContextPtr->pb->eof_reached)) ||
(ret == AVERROR_EOF || (formatContextPtr->pb && formatContextPtr->pb->eof_reached)) ||
// Check for Connection failure.
(ret == -110)
) {
@ -231,8 +232,7 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
return -1;
}
AVStream *stream = mFormatContextPtr->streams[packet.stream_index];
AVStream *stream = formatContextPtr->streams[packet.stream_index];
ZM_DUMP_STREAM_PACKET(stream, packet, "ffmpeg_camera in");
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)

View File

@ -45,7 +45,6 @@ class FfmpegCamera : public Camera {
int frameCount;
_AVPIXELFORMAT imagePixFormat;
AVFormatContext *mFormatContextPtr;
bool use_hwaccel; //will default to on if hwaccel specified, will get turned off if there is a failure
#if HAVE_LIBAVUTIL_HWCONTEXT_H