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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 if (output_samples_per_second_ > 0) | 58 if (output_samples_per_second_ > 0) |
59 samples_per_second = output_samples_per_second_; | 59 samples_per_second = output_samples_per_second_; |
60 | 60 |
61 const uint8* extra_data = NULL; | 61 const uint8* extra_data = NULL; |
62 size_t extra_data_size = 0; | 62 size_t extra_data_size = 0; |
63 if (codec_private.size() > 0) { | 63 if (codec_private.size() > 0) { |
64 extra_data = &codec_private[0]; | 64 extra_data = &codec_private[0]; |
65 extra_data_size = codec_private.size(); | 65 extra_data_size = codec_private.size(); |
66 } | 66 } |
67 | 67 |
68 // Convert |codec_delay| from nanoseconds into samples. | |
69 int codec_delay_in_samples = 0; | |
70 if (codec_delay != -1) { | |
71 codec_delay_in_samples = | |
acolwell GONE FROM CHROMIUM
2014/04/17 21:11:24
nit: s/samples/frames/ ?
DaleCurtis
2014/04/17 21:42:49
Done.
| |
72 0.5 + samples_per_second * (static_cast<double>(codec_delay) / | |
73 base::Time::kNanosecondsPerSecond); | |
74 } | |
75 | |
68 config->Initialize( | 76 config->Initialize( |
69 audio_codec, | 77 audio_codec, |
70 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32, | 78 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32, |
71 channel_layout, | 79 channel_layout, |
72 samples_per_second, extra_data, extra_data_size, is_encrypted, true, | 80 samples_per_second, extra_data, extra_data_size, is_encrypted, true, |
73 base::TimeDelta::FromMicroseconds( | 81 base::TimeDelta::FromMicroseconds( |
74 (seek_preroll != -1 ? seek_preroll : 0) / 1000), | 82 (seek_preroll != -1 ? seek_preroll : 0) / 1000), |
75 base::TimeDelta::FromMicroseconds( | 83 codec_delay_in_samples); |
76 (codec_delay != -1 ? codec_delay : 0) / 1000)); | |
77 return config->IsValidConfig(); | 84 return config->IsValidConfig(); |
78 } | 85 } |
79 | 86 |
80 bool WebMAudioClient::OnUInt(int id, int64 val) { | 87 bool WebMAudioClient::OnUInt(int id, int64 val) { |
81 if (id == kWebMIdChannels) { | 88 if (id == kWebMIdChannels) { |
82 if (channels_ != -1) { | 89 if (channels_ != -1) { |
83 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 90 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
84 << " specified. (" << channels_ << " and " << val | 91 << " specified. (" << channels_ << " and " << val |
85 << ")"; | 92 << ")"; |
86 return false; | 93 return false; |
(...skipping 25 matching lines...) Expand all Loading... | |
112 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 119 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
113 << " specified (" << *dst << " and " << val << ")"; | 120 << " specified (" << *dst << " and " << val << ")"; |
114 return false; | 121 return false; |
115 } | 122 } |
116 | 123 |
117 *dst = val; | 124 *dst = val; |
118 return true; | 125 return true; |
119 } | 126 } |
120 | 127 |
121 } // namespace media | 128 } // namespace media |
OLD | NEW |