: input_(in)
, format_desc_(format_desc)
, buffer_(480000 * 4)
- , channel_layout_(get_audio_channel_layout(*codec_context_, channel_layout_spec))
+ , channel_layout_(get_audio_channel_layout(
+ codec_context_->channels,
+ codec_context_->channel_layout,
+ channel_layout_spec))
{
if(!swr_)
CASPAR_THROW_EXCEPTION(bad_alloc());
return L"";
}
-core::audio_channel_layout get_audio_channel_layout(const AVCodecContext& codec_context, const std::wstring& channel_layout_spec)
+core::audio_channel_layout get_audio_channel_layout(int num_channels, std::uint64_t layout, const std::wstring& channel_layout_spec)
{
- auto num_channels = codec_context.channels;
-
if (!channel_layout_spec.empty())
{
if (boost::contains(channel_layout_spec, L":")) // Custom on the fly layout specified.
}
else // Preconfigured named channel layout selected.
{
- auto layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_spec);
+ auto channel_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_spec);
- if (!layout)
+ if (!channel_layout)
CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No channel layout with name " + channel_layout_spec + L" registered"));
- layout->num_channels = num_channels;
+ channel_layout->num_channels = num_channels;
- return *layout;
+ return *channel_layout;
}
}
- if (!codec_context.channel_layout)
+ if (!layout)
{
if (num_channels == 1)
return core::audio_channel_layout(num_channels, L"mono", L"FC");
// than the most common (5.1, mono and stereo) types.
// Based on information in https://ffmpeg.org/ffmpeg-utils.html#Channel-Layout
- switch (codec_context.channel_layout)
+ switch (layout)
{
case AV_CH_LAYOUT_MONO:
return core::audio_channel_layout(num_channels, L"mono", L"FC");
bool is_valid_file(const std::wstring& filename, bool only_video);
bool try_get_duration(const std::wstring filename, std::int64_t& duration, boost::rational<std::int64_t>& time_base);
-core::audio_channel_layout get_audio_channel_layout(const AVCodecContext& codec_context, const std::wstring& channel_layout_spec);
+core::audio_channel_layout get_audio_channel_layout(int num_channels, std::uint64_t layout, const std::wstring& channel_layout_spec);
// av_get_default_channel_layout does not work for layouts not predefined in ffmpeg. This is needed to support > 8 channels.
std::int64_t create_channel_layout_bitmask(int num_channels);