From 842af10c28e6385223f5c3a973c0c6719cef3b71 Mon Sep 17 00:00:00 2001 From: Elliu <elliu@hashi.re> Date: Thu, 28 Apr 2022 21:58:57 +0200 Subject: [PATCH] FIX: avcodec_find_decoder() now return pointer to constant --- src/Lib/AbstractMediaContext.hh | 6 +++--- src/Lib/Audio.cc | 2 +- src/Lib/Audio.hh | 2 +- src/Lib/Video.cc | 2 +- src/Lib/Video.hh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Lib/AbstractMediaContext.hh b/src/Lib/AbstractMediaContext.hh index 4bdd3d32..94d8f815 100644 --- a/src/Lib/AbstractMediaContext.hh +++ b/src/Lib/AbstractMediaContext.hh @@ -58,7 +58,7 @@ protected: using Super = AbstractMediaStream<AVMEDIA_TYPE>; protected: - AbstractMediaStream(AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, + AbstractMediaStream(const AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, int index) : codecId(streamArg->codecpar->codec_id) , codec(streamCodec) @@ -109,7 +109,7 @@ public: protected: // Codec related informations AVCodecID codecId{ AV_CODEC_ID_NONE }; - AVCodec *codec{ nullptr }; + const AVCodec *codec{ nullptr }; AVCodecParameters *codecParams{ nullptr }; AVCodecContextPtr codecContext{ nullptr }; AVFormatContext *dataFormat{ nullptr }; @@ -159,7 +159,7 @@ public: for (uint i = 0; i < format->nb_streams; ++i) { AVStream *itFmt = format->streams[i]; AVCodecParameters *params = itFmt->codecpar; - AVCodec *streamCodec = avcodec_find_decoder(params->codec_id); + const AVCodec *streamCodec = avcodec_find_decoder(params->codec_id); if (streamCodec && streamCodec->type == avMediaType) audioStreams.insert(i, std::make_shared<Stream>(streamCodec, formatPtr, itFmt, i)); } diff --git a/src/Lib/Audio.cc b/src/Lib/Audio.cc index 15521c87..2842e538 100644 --- a/src/Lib/Audio.cc +++ b/src/Lib/Audio.cc @@ -25,7 +25,7 @@ AudioContext::getProperties() const noexcept // AudioStream class implementation // Constructor, need an AVFormat and an AVStream -AudioStream::AudioStream(AVCodec *streamCodec, AVFormatContext *formatPtr, AVStream *streamArg, +AudioStream::AudioStream(const AVCodec *streamCodec, AVFormatContext *formatPtr, AVStream *streamArg, int index) : Super(streamCodec, formatPtr, streamArg, index) { diff --git a/src/Lib/Audio.hh b/src/Lib/Audio.hh index 2bf00f7e..bc6ae381 100644 --- a/src/Lib/Audio.hh +++ b/src/Lib/Audio.hh @@ -16,7 +16,7 @@ class AudioStream final : public AbstractMediaStream<AVMEDIA_TYPE_AUDIO> { VIVY_UNMOVABLE_OBJECT(AudioStream) public: - AudioStream(AVCodec *, AVFormatContext *, AVStream *, int index); + AudioStream(const AVCodec *, AVFormatContext *, AVStream *, int index); ~AudioStream() noexcept override; // Decode the stream diff --git a/src/Lib/Video.cc b/src/Lib/Video.cc index 72d894f4..78455486 100644 --- a/src/Lib/Video.cc +++ b/src/Lib/Video.cc @@ -3,7 +3,7 @@ using namespace Vivy; -VideoStream::VideoStream(AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, +VideoStream::VideoStream(const AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, int index) : Super(streamCodec, formatArg, streamArg, index) { diff --git a/src/Lib/Video.hh b/src/Lib/Video.hh index 4092908f..79ac20ce 100644 --- a/src/Lib/Video.hh +++ b/src/Lib/Video.hh @@ -14,7 +14,7 @@ class VideoStream final : public AbstractMediaStream<AVMEDIA_TYPE_VIDEO> { VIVY_UNMOVABLE_OBJECT(VideoStream) public: - VideoStream(AVCodec *, AVFormatContext *, AVStream *, int index); + VideoStream(const AVCodec *, AVFormatContext *, AVStream *, int index); ~VideoStream() noexcept override = default; int getWidth() const noexcept; -- GitLab