Description: Make build against FFmegep v5.0 Forwarded: https://github.com/telegramdesktop/tdesktop/pull/24044 Bug-Debian: https://bugs.debian.org/1004767 Author: Nicholas Guriev Last-Update: Wed, 09 Feb 2022 00:13:06 +0300 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -154,7 +154,7 @@ void FormatDeleter::operator()(AVFormatC } } -AVCodec *FindDecoder(not_null context) { +const AVCodec *FindDecoder(not_null context) { // Force libvpx-vp9, because we need alpha channel support. return (context->codec_id == AV_CODEC_ID_VP9) ? avcodec_find_decoder_by_name("libvpx-vp9") --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h @@ -158,7 +158,7 @@ using SwscalePointer = std::unique_ptr context); +[[nodiscard]] const AVCodec *FindDecoder(not_null context); [[nodiscard]] crl::time PtsToTime(int64_t pts, AVRational timeBase); // Used for full duration conversion. [[nodiscard]] crl::time PtsToTimeCeil(int64_t pts, AVRational timeBase); --- a/Telegram/SourceFiles/media/audio/media_audio_capture.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio_capture.cpp @@ -147,7 +147,7 @@ struct Instance::Inner::Private { AVIOContext *ioContext = nullptr; AVFormatContext *fmtContext = nullptr; AVStream *stream = nullptr; - AVCodec *codec = nullptr; + const AVCodec *codec = nullptr; AVCodecContext *codecContext = nullptr; bool opened = false; bool processing = false; --- a/Telegram/SourceFiles/media/audio/media_audio_ffmpeg_loader.h +++ b/Telegram/SourceFiles/media/audio/media_audio_ffmpeg_loader.h @@ -60,6 +60,9 @@ protected: uchar *ioBuffer = nullptr; AVIOContext *ioContext = nullptr; AVFormatContext *fmtContext = nullptr; +#if LIBAVFORMAT_VERSION_MAJOR >= 59 + const +#endif AVCodec *codec = nullptr; int32 streamId = 0; --- a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp @@ -23,8 +23,8 @@ constexpr auto kMaxQueuedPackets = 1024; not_null stream, Mode mode) { return (mode == Mode::Video || mode == Mode::Inspection) - && stream->codec - && (stream->codec->codec_id == AV_CODEC_ID_VP9) + && stream->codecpar + && (stream->codecpar->codec_id == AV_CODEC_ID_VP9) && format->iformat && format->iformat->name && QString::fromLatin1( --- a/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPart.cpp +++ b/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPart.cpp @@ -170,6 +170,9 @@ public: _frame = av_frame_alloc(); +#if LIBAVFORMAT_VERSION_MAJOR >= 59 + const +#endif AVInputFormat *inputFormat = av_find_input_format("ogg"); if (!inputFormat) { _didReadToEnd = true; @@ -209,7 +212,7 @@ public: audioCodecParameters = inCodecpar; audioStream = inStream; - _durationInMilliseconds = (int)((inStream->duration + inStream->first_dts) * 1000 / 48000); + _durationInMilliseconds = (int)(inStream->duration * av_q2d(inStream->time_base) * 1000); if (inStream->metadata) { AVDictionaryEntry *entry = av_dict_get(inStream->metadata, "TG_META", nullptr, 0); @@ -255,7 +258,7 @@ public: } if (audioCodecParameters && audioStream) { - AVCodec *codec = avcodec_find_decoder(audioCodecParameters->codec_id); + const AVCodec *codec = avcodec_find_decoder(audioCodecParameters->codec_id); if (codec) { _codecContext = avcodec_alloc_context3(codec); ret = avcodec_parameters_to_context(_codecContext, audioCodecParameters); --- a/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp +++ b/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp @@ -337,6 +337,9 @@ public: int ret = 0; +#if LIBAVFORMAT_VERSION_MAJOR >= 59 + const +#endif AVInputFormat *inputFormat = av_find_input_format(container.c_str()); if (!inputFormat) { _didReadToEnd = true; @@ -380,7 +383,7 @@ public: } if (videoCodecParameters && videoStream) { - AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id); + const AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id); if (codec) { _codecContext = avcodec_alloc_context3(codec); ret = avcodec_parameters_to_context(_codecContext, videoCodecParameters);