OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/audio_decoder_config.h" | 5 #include "media/base/audio_decoder_config.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/audio/sample_rates.h" | 10 #include "media/audio/sample_rates.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 (!extra_data() || !memcmp(extra_data(), config.extra_data(), | 101 (!extra_data() || !memcmp(extra_data(), config.extra_data(), |
102 extra_data_size())) && | 102 extra_data_size())) && |
103 (is_encrypted() == config.is_encrypted()) && | 103 (is_encrypted() == config.is_encrypted()) && |
104 (sample_format() == config.sample_format()) && | 104 (sample_format() == config.sample_format()) && |
105 (seek_preroll() == config.seek_preroll()) && | 105 (seek_preroll() == config.seek_preroll()) && |
106 (codec_delay() == config.codec_delay())); | 106 (codec_delay() == config.codec_delay())); |
107 } | 107 } |
108 | 108 |
109 std::string AudioDecoderConfig::AsHumanReadableString() const { | 109 std::string AudioDecoderConfig::AsHumanReadableString() const { |
110 std::ostringstream s; | 110 std::ostringstream s; |
111 s << "codec: " << codec() | 111 s << "codec: " << GetHumanReadableCodecName() |
112 << " bytes_per_channel: " << bytes_per_channel() | 112 << " bytes_per_channel: " << bytes_per_channel() |
113 << " channel_layout: " << channel_layout() | 113 << " channel_layout: " << channel_layout() |
114 << " samples_per_second: " << samples_per_second() | 114 << " samples_per_second: " << samples_per_second() |
115 << " sample_format: " << sample_format() | 115 << " sample_format: " << sample_format() |
116 << " bytes_per_frame: " << bytes_per_frame() | 116 << " bytes_per_frame: " << bytes_per_frame() |
117 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" | 117 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" |
118 << " codec_delay: " << codec_delay() | 118 << " codec_delay: " << codec_delay() |
119 << " has extra data? " << (extra_data() ? "true" : "false") | 119 << " has extra data? " << (extra_data() ? "true" : "false") |
120 << " encrypted? " << (is_encrypted() ? "true" : "false"); | 120 << " encrypted? " << (is_encrypted() ? "true" : "false"); |
121 return s.str(); | 121 return s.str(); |
122 } | 122 } |
123 | 123 |
| 124 // These names come from src/third_party/ffmpeg/libavcodec/codec_desc.c |
| 125 std::string AudioDecoderConfig::GetHumanReadableCodecName() const { |
| 126 switch (codec()) { |
| 127 case kUnknownAudioCodec: |
| 128 return "unknown"; |
| 129 case kCodecAAC: |
| 130 return "aac"; |
| 131 case kCodecMP3: |
| 132 return "mp3"; |
| 133 case kCodecPCM: |
| 134 case kCodecPCM_S16BE: |
| 135 case kCodecPCM_S24BE: |
| 136 return "pcm"; |
| 137 case kCodecVorbis: |
| 138 return "vorbis"; |
| 139 case kCodecFLAC: |
| 140 return "flac"; |
| 141 case kCodecAMR_NB: |
| 142 return "amr_nb"; |
| 143 case kCodecAMR_WB: |
| 144 return "amr_wb"; |
| 145 case kCodecGSM_MS: |
| 146 return "gsm_ms"; |
| 147 case kCodecPCM_ALAW: |
| 148 return "pcm_alaw"; |
| 149 case kCodecPCM_MULAW: |
| 150 return "pcm_mulaw"; |
| 151 case kCodecOpus: |
| 152 return "opus"; |
| 153 } |
| 154 NOTREACHED(); |
| 155 return ""; |
| 156 } |
| 157 |
124 } // namespace media | 158 } // namespace media |
OLD | NEW |