1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
media / mojo / mojom / audio_decoder_config_mojom_traits.cc [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/mojo/mojom/audio_decoder_config_mojom_traits.h"
#include "base/time/time.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
namespace mojo {
// static
bool StructTraits<media::mojom::AudioDecoderConfigDataView,
media::AudioDecoderConfig>::
Read(media::mojom::AudioDecoderConfigDataView input,
media::AudioDecoderConfig* output) {
media::AudioCodec codec;
if (!input.ReadCodec(&codec))
return false;
media::SampleFormat sample_format;
if (!input.ReadSampleFormat(&sample_format))
return false;
media::ChannelLayout channel_layout;
if (!input.ReadChannelLayout(&channel_layout))
return false;
std::vector<uint8_t> extra_data;
if (!input.ReadExtraData(&extra_data))
return false;
media::EncryptionScheme encryption_scheme;
if (!input.ReadEncryptionScheme(&encryption_scheme))
return false;
base::TimeDelta seek_preroll;
if (!input.ReadSeekPreroll(&seek_preroll))
return false;
media::AudioCodecProfile profile;
if (!input.ReadProfile(&profile))
return false;
media::ChannelLayout target_output_channel_layout;
if (!input.ReadTargetOutputChannelLayout(&target_output_channel_layout))
return false;
media::SampleFormat target_output_sample_format;
if (!input.ReadTargetOutputSampleFormat(&target_output_sample_format))
return false;
std::vector<uint8_t> aac_extra_data;
if (!input.ReadAacExtraData(&aac_extra_data))
return false;
output->Initialize(codec, sample_format, channel_layout,
input.samples_per_second(), std::move(extra_data),
encryption_scheme, seek_preroll, input.codec_delay());
output->set_profile(profile);
output->set_target_output_channel_layout(target_output_channel_layout);
output->set_target_output_sample_format(target_output_sample_format);
output->set_aac_extra_data(std::move(aac_extra_data));
if (!input.should_discard_decoder_delay())
output->disable_discard_decoder_delay();
return output->IsValidConfig();
}
} // namespace mojo