Fix xenial builds. Fixes #3130

This commit is contained in:
Isaac Connor 2021-02-05 12:30:51 -05:00
parent 885efc27ee
commit 7f99635763
4 changed files with 32 additions and 4 deletions

View File

@ -340,7 +340,13 @@ int FfmpegCamera::OpenFfmpeg() {
mVideoStreamId, mAudioStreamId);
AVCodec *mVideoCodec = nullptr;
if ( mVideoStream->codecpar->codec_id == AV_CODEC_ID_H264 ) {
if ( mVideoStream->
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->codec_id == AV_CODEC_ID_H264 ) {
if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == nullptr ) {
Debug(1, "Failed to find decoder (h264_mmal)");
} else {
@ -349,7 +355,13 @@ int FfmpegCamera::OpenFfmpeg() {
}
if ( !mVideoCodec ) {
mVideoCodec = avcodec_find_decoder(mVideoStream->codecpar->codec_id);
mVideoCodec = avcodec_find_decoder(mVideoStream->
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->codec_id);
if ( !mVideoCodec ) {
// Try and get the codec from the codec context
Error("Can't find codec for video stream from %s", mPath.c_str());

View File

@ -287,12 +287,25 @@ int RemoteCameraRtsp::Capture(ZMPacket &zm_packet) {
buffer -= packet->size;
if ( bytes_consumed ) {
zm_dump_video_frame(zm_packet.in_frame, "remote_rtsp_decode");
if ( ! mVideoStream->codecpar->width ) {
if ( ! mVideoStream->
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->width ) {
zm_dump_codec(mVideoCodecContext);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(mVideoStream->codecpar);
mVideoStream->codecpar->width = zm_packet.in_frame->width;
mVideoStream->codecpar->height = zm_packet.in_frame->height;
#else
mVideoStream->codec->width = zm_packet.in_frame->width;
mVideoStream->codec->height = zm_packet.in_frame->height;
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(mVideoStream->codecpar);
#endif
}
zm_packet.codec_type = mVideoCodecContext->codec_type;
frameComplete = true;

View File

@ -24,6 +24,7 @@
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <cmath>
StreamBase::~StreamBase() {
#if HAVE_LIBAVCODEC
@ -80,7 +81,7 @@ bool StreamBase::checkInitialised() {
void StreamBase::updateFrameRate(double fps) {
frame_mod = 1;
if ( (fps < 0) || !fps || isinf(fps) ) {
if ( (fps < 0) || !fps || std::isinf(fps) ) {
Debug(1, "Zero or negative fps %f in updateFrameRate. Setting frame_mod=1 and effective_fps=0.0", fps);
effective_fps = 0.0;
base_fps = 0.0;

View File

@ -120,7 +120,9 @@ bool VideoStore::open() {
out_format->flags |= AVFMT_TS_NONSTRICT; // allow non increasing dts
if ( video_in_stream ) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(video_in_stream->codecpar);
#endif
video_in_stream_index = video_in_stream->index;
if ( monitor->GetOptVideoWriter() == Monitor::PASSTHROUGH ) {