summaryrefslogtreecommitdiff
blob: 32959acd5482321df789f83016c2461b55e8dcc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);