Skip to content

Commit

Permalink
Fix build against FFmpeg v5.0
Browse files Browse the repository at this point in the history
It has been released on January 17th. This patch keeps source compatibility
with older versions.
  • Loading branch information
mymedia2 authored and john-preston committed Mar 14, 2022
1 parent 34d89a6 commit e89d9ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tgcalls/group/AudioStreamingPartInternal.cpp
Expand Up @@ -104,6 +104,9 @@ _avIoContext(std::move(fileData)) {

_frame = av_frame_alloc();

#if LIBAVFORMAT_VERSION_MAJOR >= 59
const
#endif
AVInputFormat *inputFormat = av_find_input_format(container.c_str());
if (!inputFormat) {
_didReadToEnd = true;
Expand Down Expand Up @@ -144,7 +147,7 @@ _avIoContext(std::move(fileData)) {

_streamId = i;

_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);
Expand Down
2 changes: 1 addition & 1 deletion tgcalls/group/AudioStreamingPartPersistentDecoder.cpp
Expand Up @@ -32,7 +32,7 @@ class AudioStreamingPartPersistentDecoderState {
AudioStreamingPartPersistentDecoderState(AVCodecParameters const *codecParameters, AVRational timeBase) :
_codecParameters(codecParameters),
_timeBase(timeBase) {
AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id);
const AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id);
if (codec) {
_codecContext = avcodec_alloc_context3(codec);
int ret = avcodec_parameters_to_context(_codecContext, codecParameters);
Expand Down
5 changes: 4 additions & 1 deletion tgcalls/group/VideoStreamingPart.cpp
Expand Up @@ -276,6 +276,9 @@ class VideoStreamingPartInternal {

int ret = 0;

#if LIBAVFORMAT_VERSION_MAJOR >= 59
const
#endif
AVInputFormat *inputFormat = av_find_input_format(container.c_str());
if (!inputFormat) {
_didReadToEnd = true;
Expand Down Expand Up @@ -319,7 +322,7 @@ class VideoStreamingPartInternal {
}

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);
Expand Down

0 comments on commit e89d9ca

Please sign in to comment.