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 19 matching lines...) Expand all Loading... |
30 AudioDecoderConfig* config) { | 30 AudioDecoderConfig* config) { |
31 DCHECK(config); | 31 DCHECK(config); |
32 SampleFormat sample_format = kSampleFormatPlanarF32; | 32 SampleFormat sample_format = kSampleFormatPlanarF32; |
33 | 33 |
34 AudioCodec audio_codec = kUnknownAudioCodec; | 34 AudioCodec audio_codec = kUnknownAudioCodec; |
35 if (codec_id == "A_VORBIS") { | 35 if (codec_id == "A_VORBIS") { |
36 audio_codec = kCodecVorbis; | 36 audio_codec = kCodecVorbis; |
37 } else if (codec_id == "A_OPUS") { | 37 } else if (codec_id == "A_OPUS") { |
38 audio_codec = kCodecOpus; | 38 audio_codec = kCodecOpus; |
39 } else { | 39 } else { |
40 MEDIA_LOG(log_cb_) << "Unsupported audio codec_id " << codec_id; | 40 MEDIA_LOG(ERROR, log_cb_) << "Unsupported audio codec_id " << codec_id; |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 if (samples_per_second_ <= 0) | 44 if (samples_per_second_ <= 0) |
45 return false; | 45 return false; |
46 | 46 |
47 // Set channel layout default if a Channels element was not present. | 47 // Set channel layout default if a Channels element was not present. |
48 if (channels_ == -1) | 48 if (channels_ == -1) |
49 channels_ = 1; | 49 channels_ = 1; |
50 | 50 |
51 ChannelLayout channel_layout = GuessChannelLayout(channels_); | 51 ChannelLayout channel_layout = GuessChannelLayout(channels_); |
52 | 52 |
53 if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) { | 53 if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) { |
54 MEDIA_LOG(log_cb_) << "Unsupported channel count " << channels_; | 54 MEDIA_LOG(ERROR, log_cb_) << "Unsupported channel count " << channels_; |
55 return false; | 55 return false; |
56 } | 56 } |
57 | 57 |
58 int samples_per_second = samples_per_second_; | 58 int samples_per_second = samples_per_second_; |
59 if (output_samples_per_second_ > 0) | 59 if (output_samples_per_second_ > 0) |
60 samples_per_second = output_samples_per_second_; | 60 samples_per_second = output_samples_per_second_; |
61 | 61 |
62 // Always use 48kHz for OPUS. See the "Input Sample Rate" section of the | 62 // Always use 48kHz for OPUS. See the "Input Sample Rate" section of the |
63 // spec: http://tools.ietf.org/html/draft-terriberry-oggopus-01#page-11 | 63 // spec: http://tools.ietf.org/html/draft-terriberry-oggopus-01#page-11 |
64 if (audio_codec == kCodecOpus) { | 64 if (audio_codec == kCodecOpus) { |
(...skipping 28 matching lines...) Expand all Loading... |
93 true, | 93 true, |
94 base::TimeDelta::FromMicroseconds( | 94 base::TimeDelta::FromMicroseconds( |
95 (seek_preroll != -1 ? seek_preroll : 0) / 1000), | 95 (seek_preroll != -1 ? seek_preroll : 0) / 1000), |
96 codec_delay_in_frames); | 96 codec_delay_in_frames); |
97 return config->IsValidConfig(); | 97 return config->IsValidConfig(); |
98 } | 98 } |
99 | 99 |
100 bool WebMAudioClient::OnUInt(int id, int64 val) { | 100 bool WebMAudioClient::OnUInt(int id, int64 val) { |
101 if (id == kWebMIdChannels) { | 101 if (id == kWebMIdChannels) { |
102 if (channels_ != -1) { | 102 if (channels_ != -1) { |
103 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 103 MEDIA_LOG(ERROR, log_cb_) << "Multiple values for id " << std::hex << id |
104 << " specified. (" << channels_ << " and " << val | 104 << " specified. (" << channels_ << " and " |
105 << ")"; | 105 << val << ")"; |
106 return false; | 106 return false; |
107 } | 107 } |
108 | 108 |
109 channels_ = val; | 109 channels_ = val; |
110 } | 110 } |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 bool WebMAudioClient::OnFloat(int id, double val) { | 114 bool WebMAudioClient::OnFloat(int id, double val) { |
115 double* dst = NULL; | 115 double* dst = NULL; |
116 | 116 |
117 switch (id) { | 117 switch (id) { |
118 case kWebMIdSamplingFrequency: | 118 case kWebMIdSamplingFrequency: |
119 dst = &samples_per_second_; | 119 dst = &samples_per_second_; |
120 break; | 120 break; |
121 case kWebMIdOutputSamplingFrequency: | 121 case kWebMIdOutputSamplingFrequency: |
122 dst = &output_samples_per_second_; | 122 dst = &output_samples_per_second_; |
123 break; | 123 break; |
124 default: | 124 default: |
125 return true; | 125 return true; |
126 } | 126 } |
127 | 127 |
128 if (val <= 0) | 128 if (val <= 0) |
129 return false; | 129 return false; |
130 | 130 |
131 if (*dst != -1) { | 131 if (*dst != -1) { |
132 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 132 MEDIA_LOG(ERROR, log_cb_) << "Multiple values for id " << std::hex << id |
133 << " specified (" << *dst << " and " << val << ")"; | 133 << " specified (" << *dst << " and " << val |
| 134 << ")"; |
134 return false; | 135 return false; |
135 } | 136 } |
136 | 137 |
137 *dst = val; | 138 *dst = val; |
138 return true; | 139 return true; |
139 } | 140 } |
140 | 141 |
141 } // namespace media | 142 } // namespace media |
OLD | NEW |