Skip to content

Commit

Permalink
Fix ffmpeg 5 const errors
Browse files Browse the repository at this point in the history
  • Loading branch information
exuvo committed Mar 11, 2022
1 parent 9fd0a94 commit d1395da
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/zm_ffmpeg.cpp
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/zm_ffmpeg.h
Expand Up @@ -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 *);
Expand Down
4 changes: 2 additions & 2 deletions src/zm_ffmpeg_camera.cpp
Expand Up @@ -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)");
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/zm_ffmpeg_input.h
Expand Up @@ -41,7 +41,7 @@ class FFmpeg_Input {
private:
typedef struct {
AVCodecContext *context;
AVCodec *codec;
const AVCodec *codec;
int frame_count;
} stream;

Expand Down
7 changes: 1 addition & 6 deletions src/zm_mpeg.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/zm_mpeg.h
Expand Up @@ -40,11 +40,11 @@ class VideoStream {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/zm_remote_camera_rtsp.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/zm_videostore.cpp
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/zm_videostore.h
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit d1395da

Please sign in to comment.