| 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 frames. | |
| 69 int codec_delay_in_frames = 0; | |
| 70 if (codec_delay != -1) { | |
| 71 codec_delay_in_frames = | |
| 72 0.5 + | |
| 73 samples_per_second * (static_cast<double>(codec_delay) / | |
| 74 base::Time::kNanosecondsPerSecond); | |
| 75 } | |
| 76 | |
| 77 config->Initialize( | 68 config->Initialize( |
| 78 audio_codec, | 69 audio_codec, |
| 79 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32, | 70 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32, |
| 80 channel_layout, | 71 channel_layout, |
| 81 samples_per_second, | 72 samples_per_second, extra_data, extra_data_size, is_encrypted, true, |
| 82 extra_data, | |
| 83 extra_data_size, | |
| 84 is_encrypted, | |
| 85 true, | |
| 86 base::TimeDelta::FromMicroseconds( | 73 base::TimeDelta::FromMicroseconds( |
| 87 (seek_preroll != -1 ? seek_preroll : 0) / 1000), | 74 (seek_preroll != -1 ? seek_preroll : 0) / 1000), |
| 88 codec_delay_in_frames); | 75 base::TimeDelta::FromMicroseconds( |
| 76 (codec_delay != -1 ? codec_delay : 0) / 1000)); |
| 89 return config->IsValidConfig(); | 77 return config->IsValidConfig(); |
| 90 } | 78 } |
| 91 | 79 |
| 92 bool WebMAudioClient::OnUInt(int id, int64 val) { | 80 bool WebMAudioClient::OnUInt(int id, int64 val) { |
| 93 if (id == kWebMIdChannels) { | 81 if (id == kWebMIdChannels) { |
| 94 if (channels_ != -1) { | 82 if (channels_ != -1) { |
| 95 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 83 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
| 96 << " specified. (" << channels_ << " and " << val | 84 << " specified. (" << channels_ << " and " << val |
| 97 << ")"; | 85 << ")"; |
| 98 return false; | 86 return false; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 124 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 112 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
| 125 << " specified (" << *dst << " and " << val << ")"; | 113 << " specified (" << *dst << " and " << val << ")"; |
| 126 return false; | 114 return false; |
| 127 } | 115 } |
| 128 | 116 |
| 129 *dst = val; | 117 *dst = val; |
| 130 return true; | 118 return true; |
| 131 } | 119 } |
| 132 | 120 |
| 133 } // namespace media | 121 } // namespace media |
| OLD | NEW |