From 3225845fee880478e4498c411fb83e5230ddb2cb Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Thu, 3 Mar 2022 20:10:02 +0100 Subject: [PATCH] FIX: Fix the abstract media context compilation Some things where made const with a system upgrade, so take more things as const structs and hop that everything will works. --- src/Lib/AbstractMediaContext.hh | 30 +++++++++++++++--------------- src/Lib/Audio.cc | 4 ++-- src/Lib/Audio.hh | 2 +- src/Lib/Video.cc | 4 ++-- src/Lib/Video.hh | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Lib/AbstractMediaContext.hh b/src/Lib/AbstractMediaContext.hh index 07e7fb40..6bc8faed 100644 --- a/src/Lib/AbstractMediaContext.hh +++ b/src/Lib/AbstractMediaContext.hh @@ -59,8 +59,8 @@ protected: using Super = AbstractMediaStream<AVMEDIA_TYPE>; protected: - AbstractMediaStream(AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, - int index) + AbstractMediaStream(const AVCodec *streamCodec, AVFormatContext *formatArg, + const AVStream *streamArg, int index) : codecId(streamArg->codecpar->codec_id) , codec(streamCodec) , codecParams(streamArg->codecpar) @@ -102,14 +102,14 @@ public: protected: // Codec related informations - AVCodecID codecId{ AV_CODEC_ID_NONE }; - AVCodec *codec{ nullptr }; - AVCodecParameters *codecParams{ nullptr }; - AVCodecContextPtr codecContext{ nullptr }; - AVFormatContext *dataFormat{ nullptr }; + const AVCodecID codecId = AV_CODEC_ID_NONE; + const AVCodec *codec = nullptr; + const AVCodecParameters *codecParams = nullptr; + AVCodecContextPtr codecContext = nullptr; + AVFormatContext *dataFormat = nullptr; // Stream is held by AudioContext - AVStream *stream{ nullptr }; + const AVStream *stream = nullptr; // Store the index of this stream int streamIndexInContext; @@ -151,9 +151,9 @@ public: // Populate all the stream indexes 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 AVStream *itFmt = format->streams[i]; + const AVCodecParameters *params = itFmt->codecpar; + 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)); } @@ -217,13 +217,13 @@ public: private: AVFormatContextPtr format{ avformat_alloc_context(), avFormatContextDeleter }; - const QString filePath; // Usefull information - QMap<uint, StreamPtr> audioStreams{}; // THe audio streams of the file + const QString filePath; // Usefull information + QMap<uint, StreamPtr> audioStreams; // THe audio streams of the file - int defaultStreamIndex{ -1 }; + int defaultStreamIndex = -1; // Spare always null shared pointer, to be used when the audioStream[i] was // not found. - StreamPtr spareNullSreamPtr{ nullptr }; + StreamPtr spareNullSreamPtr = nullptr; }; } diff --git a/src/Lib/Audio.cc b/src/Lib/Audio.cc index 6f02dbee..ec22e604 100644 --- a/src/Lib/Audio.cc +++ b/src/Lib/Audio.cc @@ -26,8 +26,8 @@ AudioContext::getProperties() const noexcept // AudioStream class implementation // Constructor, need an AVFormat and an AVStream -AudioStream::AudioStream(AVCodec *streamCodec, AVFormatContext *formatPtr, AVStream *streamArg, - int index) +AudioStream::AudioStream(const AVCodec *streamCodec, AVFormatContext *formatPtr, + const AVStream *streamArg, int index) : Super(streamCodec, formatPtr, streamArg, index) { SwrContext *s = dataSwrContext.get(); diff --git a/src/Lib/Audio.hh b/src/Lib/Audio.hh index 0c478c67..a9abaef9 100644 --- a/src/Lib/Audio.hh +++ b/src/Lib/Audio.hh @@ -17,7 +17,7 @@ class AudioStream final : public AbstractMediaStream<AVMEDIA_TYPE_AUDIO> { VIVY_UNMOVABLE_OBJECT(AudioStream) public: - AudioStream(AVCodec *, AVFormatContext *, AVStream *, int index); + AudioStream(const AVCodec *, AVFormatContext *, const AVStream *, int index); ~AudioStream() noexcept override; // Decode the stream diff --git a/src/Lib/Video.cc b/src/Lib/Video.cc index db1bd987..13f41b92 100644 --- a/src/Lib/Video.cc +++ b/src/Lib/Video.cc @@ -4,8 +4,8 @@ using namespace Vivy; -VideoStream::VideoStream(AVCodec *streamCodec, AVFormatContext *formatArg, AVStream *streamArg, - int index) +VideoStream::VideoStream(const AVCodec *streamCodec, AVFormatContext *formatArg, + const AVStream *streamArg, int index) : Super(streamCodec, formatArg, streamArg, index) { } diff --git a/src/Lib/Video.hh b/src/Lib/Video.hh index 765f5691..395fc22b 100644 --- a/src/Lib/Video.hh +++ b/src/Lib/Video.hh @@ -15,7 +15,7 @@ class VideoStream final : public AbstractMediaStream<AVMEDIA_TYPE_VIDEO> { VIVY_UNMOVABLE_OBJECT(VideoStream) public: - VideoStream(AVCodec *, AVFormatContext *, AVStream *, int index); + VideoStream(const AVCodec *, AVFormatContext *, const AVStream *, int index); ~VideoStream() noexcept override = default; int getWidth() const noexcept; -- GitLab