From faa62e0c60d51a9df88002a59825b427323259c0 Mon Sep 17 00:00:00 2001 From: Tom Kirchner Date: Mon, 6 Jan 2025 20:53:02 -0800 Subject: Add bitrate info --- src/codecs/vorbis.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/codecs/vorbis.cpp') diff --git a/src/codecs/vorbis.cpp b/src/codecs/vorbis.cpp index ea33a2af..464aa4a2 100644 --- a/src/codecs/vorbis.cpp +++ b/src/codecs/vorbis.cpp @@ -118,6 +118,12 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr input, length = l * info->channels; } + auto b = ov_bitrate(vorbis_.get(), -1); + std::optional bitrate_kbps; + if (b > 0) { + bitrate_kbps = b / 1024; + } + if (offset && ov_time_seek(vorbis_.get(), offset * 1000) != 0) { return cpp::fail(Error::kInternalError); } @@ -126,6 +132,7 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr input, .num_channels = static_cast(info->channels), .sample_rate_hz = static_cast(info->rate), .total_samples = length, + .bitrate_kbps = bitrate_kbps, }; } -- cgit v1.2.3