OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/formats/webm/webm_audio_client.h" | 5 #include "media/formats/webm/webm_audio_client.h" |
6 | 6 |
7 #include "media/base/audio_decoder_config.h" | 7 #include "media/base/audio_decoder_config.h" |
8 #include "media/base/channel_layout.h" | 8 #include "media/base/channel_layout.h" |
9 #include "media/base/encryption_scheme.h" | |
ddorwin
2016/03/02 23:24:05
This is no longer necessary since we're just passi
dougsteed
2016/03/03 04:45:00
Done.
| |
9 #include "media/formats/webm/webm_constants.h" | 10 #include "media/formats/webm/webm_constants.h" |
10 | 11 |
11 namespace media { | 12 namespace media { |
12 | 13 |
13 WebMAudioClient::WebMAudioClient(const scoped_refptr<MediaLog>& media_log) | 14 WebMAudioClient::WebMAudioClient(const scoped_refptr<MediaLog>& media_log) |
14 : media_log_(media_log) { | 15 : media_log_(media_log) { |
15 Reset(); | 16 Reset(); |
16 } | 17 } |
17 | 18 |
18 WebMAudioClient::~WebMAudioClient() { | 19 WebMAudioClient::~WebMAudioClient() { |
19 } | 20 } |
20 | 21 |
21 void WebMAudioClient::Reset() { | 22 void WebMAudioClient::Reset() { |
22 channels_ = -1; | 23 channels_ = -1; |
23 samples_per_second_ = -1; | 24 samples_per_second_ = -1; |
24 output_samples_per_second_ = -1; | 25 output_samples_per_second_ = -1; |
25 } | 26 } |
26 | 27 |
27 bool WebMAudioClient::InitializeConfig( | 28 bool WebMAudioClient::InitializeConfig( |
28 const std::string& codec_id, | 29 const std::string& codec_id, |
29 const std::vector<uint8_t>& codec_private, | 30 const std::vector<uint8_t>& codec_private, |
30 int64_t seek_preroll, | 31 int64_t seek_preroll, |
31 int64_t codec_delay, | 32 int64_t codec_delay, |
32 bool is_encrypted, | 33 const EncryptionScheme& encryption_scheme, |
33 AudioDecoderConfig* config) { | 34 AudioDecoderConfig* config) { |
34 DCHECK(config); | 35 DCHECK(config); |
35 SampleFormat sample_format = kSampleFormatPlanarF32; | 36 SampleFormat sample_format = kSampleFormatPlanarF32; |
36 | 37 |
37 AudioCodec audio_codec = kUnknownAudioCodec; | 38 AudioCodec audio_codec = kUnknownAudioCodec; |
38 if (codec_id == "A_VORBIS") { | 39 if (codec_id == "A_VORBIS") { |
39 audio_codec = kCodecVorbis; | 40 audio_codec = kCodecVorbis; |
40 } else if (codec_id == "A_OPUS") { | 41 } else if (codec_id == "A_OPUS") { |
41 audio_codec = kCodecOpus; | 42 audio_codec = kCodecOpus; |
42 } else { | 43 } else { |
(...skipping 28 matching lines...) Expand all Loading... | |
71 | 72 |
72 // Convert |codec_delay| from nanoseconds into frames. | 73 // Convert |codec_delay| from nanoseconds into frames. |
73 int codec_delay_in_frames = 0; | 74 int codec_delay_in_frames = 0; |
74 if (codec_delay != -1) { | 75 if (codec_delay != -1) { |
75 codec_delay_in_frames = | 76 codec_delay_in_frames = |
76 0.5 + | 77 0.5 + |
77 samples_per_second * (static_cast<double>(codec_delay) / | 78 samples_per_second * (static_cast<double>(codec_delay) / |
78 base::Time::kNanosecondsPerSecond); | 79 base::Time::kNanosecondsPerSecond); |
79 } | 80 } |
80 | 81 |
81 config->Initialize( | 82 config->Initialize(audio_codec, sample_format, channel_layout, |
82 audio_codec, | 83 samples_per_second, codec_private, encryption_scheme, |
83 sample_format, | 84 base::TimeDelta::FromMicroseconds( |
84 channel_layout, | 85 (seek_preroll != -1 ? seek_preroll : 0) / 1000), |
85 samples_per_second, | 86 codec_delay_in_frames); |
86 codec_private, | |
87 is_encrypted, | |
88 base::TimeDelta::FromMicroseconds( | |
89 (seek_preroll != -1 ? seek_preroll : 0) / 1000), | |
90 codec_delay_in_frames); | |
91 return config->IsValidConfig(); | 87 return config->IsValidConfig(); |
92 } | 88 } |
93 | 89 |
94 bool WebMAudioClient::OnUInt(int id, int64_t val) { | 90 bool WebMAudioClient::OnUInt(int id, int64_t val) { |
95 if (id == kWebMIdChannels) { | 91 if (id == kWebMIdChannels) { |
96 if (channels_ != -1) { | 92 if (channels_ != -1) { |
97 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex | 93 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex |
98 << id << " specified. (" << channels_ | 94 << id << " specified. (" << channels_ |
99 << " and " << val << ")"; | 95 << " and " << val << ")"; |
100 return false; | 96 return false; |
(...skipping 26 matching lines...) Expand all Loading... | |
127 << " specified (" << *dst << " and " << val | 123 << " specified (" << *dst << " and " << val |
128 << ")"; | 124 << ")"; |
129 return false; | 125 return false; |
130 } | 126 } |
131 | 127 |
132 *dst = val; | 128 *dst = val; |
133 return true; | 129 return true; |
134 } | 130 } |
135 | 131 |
136 } // namespace media | 132 } // namespace media |
OLD | NEW |