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

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

Issue 23014009: media: Opus support for WebM in Media Source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing errors causing try bot failure Created 7 years, 3 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/webm/webm_audio_client.h ('k') | media/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 (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_preroll, 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") {
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
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,
67 samples_per_second, extra_data, extra_data_size, is_encrypted, true); 70 (audio_codec == kCodecOpus) ? kSampleFormatS16 : kSampleFormatPlanarF32,
71 channel_layout,
72 samples_per_second, extra_data, extra_data_size, is_encrypted, true,
73 base::TimeDelta::FromMicroseconds(
74 (seek_preroll != -1 ? seek_preroll : 0) / 1000),
75 base::TimeDelta::FromMicroseconds(
76 (codec_delay != -1 ? codec_delay : 0) / 1000));
68 return config->IsValidConfig(); 77 return config->IsValidConfig();
69 } 78 }
70 79
71 bool WebMAudioClient::OnUInt(int id, int64 val) { 80 bool WebMAudioClient::OnUInt(int id, int64 val) {
72 if (id == kWebMIdChannels) { 81 if (id == kWebMIdChannels) {
73 if (channels_ != -1) { 82 if (channels_ != -1) {
74 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id 83 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id
75 << " specified. (" << channels_ << " and " << val 84 << " specified. (" << channels_ << " and " << val
76 << ")"; 85 << ")";
77 return false; 86 return false;
(...skipping 25 matching lines...) Expand all
103 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id 112 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id
104 << " specified (" << *dst << " and " << val << ")"; 113 << " specified (" << *dst << " and " << val << ")";
105 return false; 114 return false;
106 } 115 }
107 116
108 *dst = val; 117 *dst = val;
109 return true; 118 return true;
110 } 119 }
111 120
112 } // namespace media 121 } // namespace media
OLDNEW
« no previous file with comments | « media/webm/webm_audio_client.h ('k') | media/webm/webm_cluster_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698