Overlay/net-im/telegram-desktop/files/tdesktop-3.6.0-support-ffmp...

76 lines
3.1 KiB
Diff
Raw Normal View History

Support FFmpeg 5
I'm not comfortable changing the _durationInMilliseconds formula on older
versions of ffmpeg. Doing that only for newer versions also reduces the amount
of testing this patch needs (of which it'll get very minimal amounts, this is a
job better left for upstream when they get to it).
Also it doesn't compile under ffmpeg 4 if the variables are constants :/
--- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartInternal.cpp
+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartInternal.cpp
@@ -104,7 +104,11 @@
_frame = av_frame_alloc();
+#if LIBAVFORMAT_VERSION_MAJOR >= 59
+ const AVInputFormat *inputFormat = av_find_input_format(container.c_str());
+#else
AVInputFormat *inputFormat = av_find_input_format(container.c_str());
+#endif
if (!inputFormat) {
_didReadToEnd = true;
return;
@@ -144,7 +148,11 @@
_streamId = i;
+#if LIBAVFORMAT_VERSION_MAJOR >= 59
+ _durationInMilliseconds = inStream->duration * 1000 / 48000;
+#else
_durationInMilliseconds = (int)((inStream->duration + inStream->first_dts) * 1000 / 48000);
+#endif
if (inStream->metadata) {
AVDictionaryEntry *entry = av_dict_get(inStream->metadata, "TG_META", nullptr, 0);
--- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp
+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp
@@ -32,7 +32,11 @@
AudioStreamingPartPersistentDecoderState(AVCodecParameters const *codecParameters, AVRational timeBase) :
_codecParameters(codecParameters),
_timeBase(timeBase) {
+#ifdef LIBAVCODEC_VERSION_MAJOR >= 59
+ const AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id);
+#else
AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id);
+#endif
if (codec) {
_codecContext = avcodec_alloc_context3(codec);
int ret = avcodec_parameters_to_context(_codecContext, codecParameters);
--- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp
+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp
@@ -280,7 +280,11 @@
int ret = 0;
+#if LIBAVFORMAT_VERSION_MAJOR >= 59
+ const AVInputFormat *inputFormat = av_find_input_format(container.c_str());
+#else
AVInputFormat *inputFormat = av_find_input_format(container.c_str());
+#endif
if (!inputFormat) {
_didReadToEnd = true;
return;
@@ -323,7 +327,11 @@
}
if (videoCodecParameters && videoStream) {
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+ const AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id);
+#else
AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id);
+#endif
if (codec) {
_codecContext = avcodec_alloc_context3(codec);
ret = avcodec_parameters_to_context(_codecContext, videoCodecParameters);