Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: media/formats/webm/webm_audio_client.cc

Issue 1235793005: Deprecate LogCB in favor of using MediaLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and attempt to fix Android compilation Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/webm/webm_audio_client.h ('k') | media/formats/webm/webm_cluster_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 namespace media { 11 namespace media {
12 12
13 WebMAudioClient::WebMAudioClient(const LogCB& log_cb) 13 WebMAudioClient::WebMAudioClient(const scoped_refptr<MediaLog>& media_log)
14 : log_cb_(log_cb) { 14 : media_log_(media_log) {
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 int64 seek_preroll, int64 codec_delay, bool is_encrypted, 29 int64 seek_preroll, int64 codec_delay, bool is_encrypted,
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(ERROR, log_cb_) << "Unsupported audio codec_id " << codec_id; 40 MEDIA_LOG(ERROR, media_log_) << "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(ERROR, log_cb_) << "Unsupported channel count " << channels_; 54 MEDIA_LOG(ERROR, media_log_) << "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
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(ERROR, log_cb_) << "Multiple values for id " << std::hex << id 103 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex
104 << " specified. (" << channels_ << " and " 104 << id << " specified. (" << channels_
105 << val << ")"; 105 << " and " << 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(ERROR, log_cb_) << "Multiple values for id " << std::hex << id 132 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex << id
133 << " specified (" << *dst << " and " << val 133 << " specified (" << *dst << " and " << val
134 << ")"; 134 << ")";
135 return false; 135 return false;
136 } 136 }
137 137
138 *dst = val; 138 *dst = val;
139 return true; 139 return true;
140 } 140 }
141 141
142 } // namespace media 142 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/webm/webm_audio_client.h ('k') | media/formats/webm/webm_cluster_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698