OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webm/webm_audio_client.h" | 5 #include "media/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/webm/webm_constants.h" | 9 #include "media/webm/webm_constants.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 WebMAudioClient::WebMAudioClient(const LogCB& log_cb) | 13 WebMAudioClient::WebMAudioClient(const LogCB& log_cb) |
14 : log_cb_(log_cb) { | 14 : log_cb_(log_cb) { |
15 Reset(); | 15 Reset(); |
16 } | 16 } |
17 | 17 |
18 WebMAudioClient::~WebMAudioClient() { | 18 WebMAudioClient::~WebMAudioClient() { |
19 } | 19 } |
20 | 20 |
21 void WebMAudioClient::Reset() { | 21 void WebMAudioClient::Reset() { |
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, const std::vector<uint8>& codec_private, | 28 const std::string& codec_id, const std::vector<uint8>& codec_private, |
29 bool is_encrypted, AudioDecoderConfig* config) { | 29 int64 seek_pre_roll, int64 codec_delay, bool is_encrypted, |
30 AudioDecoderConfig* config) { | |
30 DCHECK(config); | 31 DCHECK(config); |
31 | 32 |
32 AudioCodec audio_codec = kUnknownAudioCodec; | 33 AudioCodec audio_codec = kUnknownAudioCodec; |
33 if (codec_id == "A_VORBIS") { | 34 if (codec_id == "A_VORBIS") { |
34 audio_codec = kCodecVorbis; | 35 audio_codec = kCodecVorbis; |
36 } else if (codec_id == "A_OPUS" || codec_id == "A_OPUS/EXPERIMENTAL") { | |
37 audio_codec = kCodecOpus; | |
35 } else { | 38 } else { |
36 MEDIA_LOG(log_cb_) << "Unsupported audio codec_id " << codec_id; | 39 MEDIA_LOG(log_cb_) << "Unsupported audio codec_id " << codec_id; |
37 return false; | 40 return false; |
38 } | 41 } |
39 | 42 |
40 if (samples_per_second_ <= 0) | 43 if (samples_per_second_ <= 0) |
41 return false; | 44 return false; |
42 | 45 |
43 // Set channel layout default if a Channels element was not present. | 46 // Set channel layout default if a Channels element was not present. |
44 if (channels_ == -1) | 47 if (channels_ == -1) |
(...skipping 11 matching lines...) Expand all Loading... | |
56 samples_per_second = output_samples_per_second_; | 59 samples_per_second = output_samples_per_second_; |
57 | 60 |
58 const uint8* extra_data = NULL; | 61 const uint8* extra_data = NULL; |
59 size_t extra_data_size = 0; | 62 size_t extra_data_size = 0; |
60 if (codec_private.size() > 0) { | 63 if (codec_private.size() > 0) { |
61 extra_data = &codec_private[0]; | 64 extra_data = &codec_private[0]; |
62 extra_data_size = codec_private.size(); | 65 extra_data_size = codec_private.size(); |
63 } | 66 } |
64 | 67 |
65 config->Initialize( | 68 config->Initialize( |
66 audio_codec, kSampleFormatPlanarF32, channel_layout, | 69 audio_codec, |
70 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32, | |
71 channel_layout, | |
67 samples_per_second, extra_data, extra_data_size, is_encrypted, true); | 72 samples_per_second, extra_data, extra_data_size, is_encrypted, true); |
73 config->set_seek_pre_roll(seek_pre_roll); | |
fgalligan1
2013/08/26 21:10:06
All of the other vales are passed in Initialize. A
vignesh
2013/08/26 21:44:23
Initialize is a generic function which is used at
fgalligan1
2013/08/26 22:11:53
It looks like it, but you could wait and see what
| |
74 config->set_codec_delay(codec_delay); | |
68 return config->IsValidConfig(); | 75 return config->IsValidConfig(); |
69 } | 76 } |
70 | 77 |
71 bool WebMAudioClient::OnUInt(int id, int64 val) { | 78 bool WebMAudioClient::OnUInt(int id, int64 val) { |
72 if (id == kWebMIdChannels) { | 79 if (id == kWebMIdChannels) { |
73 if (channels_ != -1) { | 80 if (channels_ != -1) { |
74 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 81 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
75 << " specified. (" << channels_ << " and " << val | 82 << " specified. (" << channels_ << " and " << val |
76 << ")"; | 83 << ")"; |
77 return false; | 84 return false; |
(...skipping 25 matching lines...) Expand all Loading... | |
103 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 110 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
104 << " specified (" << *dst << " and " << val << ")"; | 111 << " specified (" << *dst << " and " << val << ")"; |
105 return false; | 112 return false; |
106 } | 113 } |
107 | 114 |
108 *dst = val; | 115 *dst = val; |
109 return true; | 116 return true; |
110 } | 117 } |
111 | 118 |
112 } // namespace media | 119 } // namespace media |
OLD | NEW |