Skip to content

Commit 5edacbb

Browse files
committed
Revoke the unecessary change. Set channels as nil in AAC struct if they are AOT_specific
1 parent a060e18 commit 5edacbb

3 files changed

Lines changed: 17 additions & 19 deletions

File tree

lib/membrane/aac/parser/audio_specific_config.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Membrane.AAC.Parser.AudioSpecificConfig do
2323
depends_on_core_coder::1, extension_flag::1>>
2424
end
2525

26-
@spec parse_audio_specific_config(binary()) :: map()
26+
@spec parse_audio_specific_config(binary()) :: AAC.t()
2727
def parse_audio_specific_config(audio_specific_config) do
2828
<<profile::5, frequency_id::4, audio_specific_config_rest::bitstring>> = audio_specific_config
2929

@@ -37,11 +37,15 @@ defmodule Membrane.AAC.Parser.AudioSpecificConfig do
3737
do: custom_frequency,
3838
else: AAC.sampling_frequency_id_to_sample_rate(frequency_id)
3939

40-
%{
40+
%AAC{
4141
profile: AAC.aot_id_to_profile(profile),
4242
mpeg_version: 4,
4343
sample_rate: sample_rate,
44-
channels: AAC.channel_config_id_to_channels(channel_config_id),
44+
channels:
45+
case AAC.channel_config_id_to_channels(channel_config_id) do
46+
:AOT_specific -> nil
47+
channels -> channels
48+
end,
4549
encapsulation: :none,
4650
samples_per_frame: AAC.frame_length_id_to_samples_per_frame(frame_length_id),
4751
config: {:audio_specific_config, audio_specific_config}

lib/membrane/aac/parser/config.ex

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,17 @@ defmodule Membrane.AAC.Parser.Config do
3939
""")
4040
end)
4141

42-
esds_stream_format =
43-
if esds_stream_format.channels == :AOT_specific do
44-
# It means that the set of channels is described
45-
# in the channel configutation, as specified by
46-
# MPEG-4 p. 3, section 4.4.1.1.
47-
# In our case it's sufficient
48-
# to just read the number of channels
49-
%{esds_stream_format | channels: stream_format.channels}
50-
else
51-
esds_stream_format
52-
end
53-
54-
struct(AAC, esds_stream_format)
42+
if is_nil(esds_stream_format.channels) do
43+
# channels == nil means the channel config ID was 0 (AOT_specific),
44+
# meaning the channel layout is described in the bitstream per
45+
# MPEG-4 p. 3, section 4.4.1.1. Fall back to the outer stream_format.
46+
%{esds_stream_format | channels: stream_format.channels}
47+
else
48+
esds_stream_format
49+
end
5550

5651
{:audio_specific_config, audio_specific_config} ->
57-
format = AudioSpecificConfig.parse_audio_specific_config(audio_specific_config)
58-
struct(AAC, format)
52+
AudioSpecificConfig.parse_audio_specific_config(audio_specific_config)
5953

6054
nil ->
6155
stream_format

lib/membrane/aac/parser/esds.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule Membrane.AAC.Parser.Esds do
4040
<<section_no, type_tag::binary, byte_size(payload), payload::binary>>
4141
end
4242

43-
@spec parse_esds(binary()) :: map()
43+
@spec parse_esds(binary()) :: AAC.t()
4444
def parse_esds(esds) do
4545
{section_3, <<>>} = unpack_esds_section(esds, 3)
4646

0 commit comments

Comments
 (0)