Skip to content

Commit

Permalink
[media] Support for ffmpeg 7
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Apr 10, 2024
1 parent 16d71e4 commit a813921
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/ossia/detail/libav.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ inline bool seek_to_flick(
return true;
}

static inline int avstream_get_audio_channels(AVStream& stream) noexcept
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
return stream.codecpar->ch_layout.nb_channels;
#else
return stream.codecpar->channels;
#endif
}

struct libav_handle
{
AVFormatContext* format{};
Expand Down Expand Up @@ -185,14 +194,7 @@ struct libav_handle
}

int rate() const noexcept { return stream->codecpar->sample_rate; }
int channels() const noexcept
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
return stream->codecpar->ch_layout.nb_channels;
#else
return stream->codecpar->channels;
#endif
}
int channels() const noexcept { return avstream_get_audio_channels(*stream); }

int64_t totalPCMFrameCount() const noexcept
{
Expand Down

0 comments on commit a813921

Please sign in to comment.