@@ -15,6 +15,7 @@ extern "C"
1515#include < libavutil/frame.h>
1616#include < libavutil/pixdesc.h>
1717#include < libavutil/bprint.h>
18+ #include < libavutil/version.h>
1819#include < libavformat/avformat.h>
1920#include < libavcodec/avcodec.h>
2021}
@@ -62,7 +63,11 @@ AudioStreamStats::AudioStreamStats(XMLElement *streamElement) : CommonStreamStat
6263AudioStreamStats::AudioStreamStats (QAVStream* stream) : CommonStreamStats(stream),
6364 sample_fmt_string(" " ),
6465 sample_rate(stream != NULL ? stream->stream ()->codecpar->sample_rate : 0),
66+ #if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 23, 0)
6567 channels (stream != NULL ? stream->stream ()->codecpar->channels : 0),
68+ #else
69+ channels (stream != NULL ? stream->stream ()->codecpar->ch_layout.nb_channels : 0),
70+ #endif
6671 channel_layout (" " ),
6772 bits_per_sample(stream != NULL ? av_get_bits_per_sample(stream->stream ()->codecpar->codec_id) : 0)
6873{
@@ -81,9 +86,15 @@ AudioStreamStats::AudioStreamStats(QAVStream* stream) : CommonStreamStats(stream
8186 AVBPrint pbuf;
8287 av_bprint_init (&pbuf, 1 , AV_BPRINT_SIZE_UNLIMITED);
8388
89+ #if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 23, 0)
8490 if (stream->stream ()->codecpar ->channel_layout ) {
8591 av_bprint_clear (&pbuf);
8692 av_bprint_channel_layout (&pbuf, stream->stream ()->codecpar ->channels , stream->stream ()->codecpar ->channel_layout );
93+ #else
94+ if (av_channel_layout_check (&stream->stream ()->codecpar ->ch_layout )) {
95+ av_bprint_clear (&pbuf);
96+ av_channel_layout_describe_bprint (&stream->stream ()->codecpar ->ch_layout , &pbuf);
97+ #endif
8798 channel_layout = pbuf.str ;
8899 } else {
89100 channel_layout = " unknown" ;
0 commit comments