diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 4fe14051f..548c29412 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -325,7 +325,7 @@ void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output) //dump_sidedata(NULL, st, " "); } -int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) { +int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt) { const enum AVSampleFormat *p = codec->sample_fmts; while (*p != AV_SAMPLE_FMT_NONE) { diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index f3a3296a8..18090098f 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -217,7 +217,7 @@ void zm_dump_codecpar(const AVCodecParameters *par); #define zm_av_frame_alloc() av_frame_alloc() -int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt); +int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt); enum AVPixelFormat fix_deprecated_pix_fmt(enum AVPixelFormat ); bool is_video_stream(const AVStream *); diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 4a0c94ec9..db90ffa42 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -353,7 +353,7 @@ int FfmpegCamera::OpenFfmpeg() { Debug(3, "Found video stream at index %d, audio stream at index %d", mVideoStreamId, mAudioStreamId); - AVCodec *mVideoCodec = nullptr; + const AVCodec *mVideoCodec = nullptr; if (mVideoStream->codecpar->codec_id == AV_CODEC_ID_H264) { if ((mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == nullptr) { Debug(1, "Failed to find decoder (h264_mmal)"); @@ -494,7 +494,7 @@ int FfmpegCamera::OpenFfmpeg() { } // end if have audio stream if ( mAudioStreamId >= 0 ) { - AVCodec *mAudioCodec = nullptr; + const AVCodec *mAudioCodec = nullptr; if (!(mAudioCodec = avcodec_find_decoder(mAudioStream->codecpar->codec_id))) { Debug(1, "Can't find codec for audio stream from %s", mPath.c_str()); } else { diff --git a/src/zm_ffmpeg_input.h b/src/zm_ffmpeg_input.h index 6ccc87682..3f2e5b7e9 100644 --- a/src/zm_ffmpeg_input.h +++ b/src/zm_ffmpeg_input.h @@ -41,7 +41,7 @@ class FFmpeg_Input { private: typedef struct { AVCodecContext *context; - AVCodec *codec; + const AVCodec *codec; int frame_count; } stream; diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index 275e36628..8f367a90c 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -97,16 +97,11 @@ int VideoStream::SetupCodec( // Not sure what this value should be really... ofc->packet_size = width*height; Debug(1,"Setting packet_size to %d", ofc->packet_size); - - if (of->video_codec == AV_CODEC_ID_NONE) { - // RTP does not have a default codec in ffmpeg <= 0.8. - of->video_codec = AV_CODEC_ID_MPEG4; - } } _AVCODECID codec_id = of->video_codec; if (codec_name) { - AVCodec *a = avcodec_find_encoder_by_name(codec_name); + const AVCodec *a = avcodec_find_encoder_by_name(codec_name); if (a) { codec_id = a->id; Debug(1, "Using codec \"%s\"", codec_name); diff --git a/src/zm_mpeg.h b/src/zm_mpeg.h index 552652a1d..231821f2d 100644 --- a/src/zm_mpeg.h +++ b/src/zm_mpeg.h @@ -40,11 +40,11 @@ protected: const char *format; const char *codec_name; enum _AVPIXELFORMAT pf; - AVOutputFormat *of; + const AVOutputFormat *of; AVFormatContext *ofc; AVStream *ost; AVCodecContext *codec_context; - AVCodec *codec; + const AVCodec *codec; AVFrame *opicture; AVFrame *tmp_opicture; uint8_t *video_outbuf; diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index ffb4a061d..eb4e1c8b8 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -181,7 +181,7 @@ int RemoteCameraRtsp::PrimeCapture() { avcodec_parameters_to_context(mVideoCodecContext, mFormatContext->streams[mVideoStreamId]->codecpar); // Find the decoder for the video stream - AVCodec *codec = avcodec_find_decoder(mVideoCodecContext->codec_id); + const AVCodec *codec = avcodec_find_decoder(mVideoCodecContext->codec_id); if ( codec == nullptr ) { Error("Unable to locate codec %d decoder", mVideoCodecContext->codec_id); return -1; diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 777d7a81a..df6ab707d 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -139,7 +139,7 @@ bool VideoStore::open() { oc->metadata = pmetadata; out_format = oc->oformat; out_format->flags |= AVFMT_TS_NONSTRICT; // allow non increasing dts - AVCodec *video_out_codec = nullptr; + const AVCodec *video_out_codec = nullptr; AVDictionary *opts = nullptr; std::string Options = monitor->GetEncoderOptions(); diff --git a/src/zm_videostore.h b/src/zm_videostore.h index c73ed19db..374cc0f26 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -38,7 +38,7 @@ class VideoStore { CodecData *chosen_codec_data; Monitor *monitor; - AVOutputFormat *out_format; + const AVOutputFormat *out_format; AVFormatContext *oc; AVStream *video_out_stream; AVStream *audio_out_stream; @@ -52,7 +52,7 @@ class VideoStore { const AVCodec *audio_in_codec; AVCodecContext *audio_in_ctx; // The following are used when encoding the audio stream to AAC - AVCodec *audio_out_codec; + const AVCodec *audio_out_codec; AVCodecContext *audio_out_ctx; // Move this into the object so that we aren't constantly allocating/deallocating it on the stack AVPacket opkt;