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/formats/webm/webm_constants.h" | 9 #include "media/formats/webm/webm_constants.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 channels_ = -1; | 22 channels_ = -1; |
23 samples_per_second_ = -1; | 23 samples_per_second_ = -1; |
24 output_samples_per_second_ = -1; | 24 output_samples_per_second_ = -1; |
25 } | 25 } |
26 | 26 |
27 bool WebMAudioClient::InitializeConfig( | 27 bool WebMAudioClient::InitializeConfig( |
28 const std::string& codec_id, | 28 const std::string& codec_id, |
29 const std::vector<uint8_t>& codec_private, | 29 const std::vector<uint8_t>& codec_private, |
30 int64_t seek_preroll, | 30 int64_t seek_preroll, |
31 int64_t codec_delay, | 31 int64_t codec_delay, |
32 bool is_encrypted, | 32 const EncryptionScheme& encryption_scheme, |
33 AudioDecoderConfig* config) { | 33 AudioDecoderConfig* config) { |
34 DCHECK(config); | 34 DCHECK(config); |
35 SampleFormat sample_format = kSampleFormatPlanarF32; | 35 SampleFormat sample_format = kSampleFormatPlanarF32; |
36 | 36 |
37 AudioCodec audio_codec = kUnknownAudioCodec; | 37 AudioCodec audio_codec = kUnknownAudioCodec; |
38 if (codec_id == "A_VORBIS") { | 38 if (codec_id == "A_VORBIS") { |
39 audio_codec = kCodecVorbis; | 39 audio_codec = kCodecVorbis; |
40 } else if (codec_id == "A_OPUS") { | 40 } else if (codec_id == "A_OPUS") { |
41 audio_codec = kCodecOpus; | 41 audio_codec = kCodecOpus; |
42 } else { | 42 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
71 | 71 |
72 // Convert |codec_delay| from nanoseconds into frames. | 72 // Convert |codec_delay| from nanoseconds into frames. |
73 int codec_delay_in_frames = 0; | 73 int codec_delay_in_frames = 0; |
74 if (codec_delay != -1) { | 74 if (codec_delay != -1) { |
75 codec_delay_in_frames = | 75 codec_delay_in_frames = |
76 0.5 + | 76 0.5 + |
77 samples_per_second * (static_cast<double>(codec_delay) / | 77 samples_per_second * (static_cast<double>(codec_delay) / |
78 base::Time::kNanosecondsPerSecond); | 78 base::Time::kNanosecondsPerSecond); |
79 } | 79 } |
80 | 80 |
81 config->Initialize( | 81 config->Initialize(audio_codec, sample_format, channel_layout, |
82 audio_codec, | 82 samples_per_second, codec_private, encryption_scheme, |
83 sample_format, | 83 base::TimeDelta::FromMicroseconds( |
84 channel_layout, | 84 (seek_preroll != -1 ? seek_preroll : 0) / 1000), |
85 samples_per_second, | 85 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(); | 86 return config->IsValidConfig(); |
92 } | 87 } |
93 | 88 |
94 bool WebMAudioClient::OnUInt(int id, int64_t val) { | 89 bool WebMAudioClient::OnUInt(int id, int64_t val) { |
95 if (id == kWebMIdChannels) { | 90 if (id == kWebMIdChannels) { |
96 if (channels_ != -1) { | 91 if (channels_ != -1) { |
97 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex | 92 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex |
98 << id << " specified. (" << channels_ | 93 << id << " specified. (" << channels_ |
99 << " and " << val << ")"; | 94 << " and " << val << ")"; |
100 return false; | 95 return false; |
(...skipping 26 matching lines...) Expand all Loading... |
127 << " specified (" << *dst << " and " << val | 122 << " specified (" << *dst << " and " << val |
128 << ")"; | 123 << ")"; |
129 return false; | 124 return false; |
130 } | 125 } |
131 | 126 |
132 *dst = val; | 127 *dst = val; |
133 return true; | 128 return true; |
134 } | 129 } |
135 | 130 |
136 } // namespace media | 131 } // namespace media |
OLD | NEW |