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

Side by Side Diff: media/base/audio_decoder_config.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: another fix for unreliable ffmpeg channels vs layout Created 3 years, 6 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/base/audio_decoder_config.h ('k') | media/base/fake_audio_renderer_sink.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) 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 "media/base/limits.h" 8 #include "media/base/limits.h"
9 #include "media/base/media_util.h" 9 #include "media/base/media_util.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 codec_ = codec; 44 codec_ = codec;
45 channel_layout_ = channel_layout; 45 channel_layout_ = channel_layout;
46 samples_per_second_ = samples_per_second; 46 samples_per_second_ = samples_per_second;
47 sample_format_ = sample_format; 47 sample_format_ = sample_format;
48 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format); 48 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format);
49 extra_data_ = extra_data; 49 extra_data_ = extra_data;
50 encryption_scheme_ = encryption_scheme; 50 encryption_scheme_ = encryption_scheme;
51 seek_preroll_ = seek_preroll; 51 seek_preroll_ = seek_preroll;
52 codec_delay_ = codec_delay; 52 codec_delay_ = codec_delay;
53 53
54 int channels = ChannelLayoutToChannelCount(channel_layout_); 54 // If |channel_layout_| is CHANNEL_LAYOUT_DISCRETE, |channels_| and
55 bytes_per_frame_ = channels * bytes_per_channel_; 55 // |bytes_per_frame_| will be overwritten in SetChannelsForDiscrete()
56 channels_ = ChannelLayoutToChannelCount(channel_layout_);
57 bytes_per_frame_ = channels_ * bytes_per_channel_;
56 } 58 }
57 59
58 AudioDecoderConfig::~AudioDecoderConfig() {} 60 AudioDecoderConfig::~AudioDecoderConfig() {}
59 61
60 bool AudioDecoderConfig::IsValidConfig() const { 62 bool AudioDecoderConfig::IsValidConfig() const {
61 return codec_ != kUnknownAudioCodec && 63 return codec_ != kUnknownAudioCodec &&
62 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && 64 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED &&
63 bytes_per_channel_ > 0 && 65 bytes_per_channel_ > 0 &&
64 bytes_per_channel_ <= limits::kMaxBytesPerSample && 66 bytes_per_channel_ <= limits::kMaxBytesPerSample &&
65 samples_per_second_ > 0 && 67 samples_per_second_ > 0 &&
(...skipping 12 matching lines...) Expand all
78 (encryption_scheme().Matches(config.encryption_scheme())) && 80 (encryption_scheme().Matches(config.encryption_scheme())) &&
79 (sample_format() == config.sample_format()) && 81 (sample_format() == config.sample_format()) &&
80 (seek_preroll() == config.seek_preroll()) && 82 (seek_preroll() == config.seek_preroll()) &&
81 (codec_delay() == config.codec_delay())); 83 (codec_delay() == config.codec_delay()));
82 } 84 }
83 85
84 std::string AudioDecoderConfig::AsHumanReadableString() const { 86 std::string AudioDecoderConfig::AsHumanReadableString() const {
85 std::ostringstream s; 87 std::ostringstream s;
86 s << "codec: " << GetCodecName(codec()) 88 s << "codec: " << GetCodecName(codec())
87 << " bytes_per_channel: " << bytes_per_channel() 89 << " bytes_per_channel: " << bytes_per_channel()
88 << " channel_layout: " << channel_layout() 90 << " channel_layout: " << channel_layout() << " channels: " << channels()
89 << " samples_per_second: " << samples_per_second() 91 << " samples_per_second: " << samples_per_second()
90 << " sample_format: " << sample_format() 92 << " sample_format: " << sample_format()
91 << " bytes_per_frame: " << bytes_per_frame() 93 << " bytes_per_frame: " << bytes_per_frame()
92 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" 94 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms"
93 << " codec_delay: " << codec_delay() << " has extra data? " 95 << " codec_delay: " << codec_delay() << " has extra data? "
94 << (extra_data().empty() ? "false" : "true") << " encrypted? " 96 << (extra_data().empty() ? "false" : "true") << " encrypted? "
95 << (is_encrypted() ? "true" : "false"); 97 << (is_encrypted() ? "true" : "false");
96 return s.str(); 98 return s.str();
97 } 99 }
98 100
101 void AudioDecoderConfig::SetChannelsForDiscrete(int channels) {
102 DCHECK(channel_layout_ == CHANNEL_LAYOUT_DISCRETE ||
103 channels == ChannelLayoutToChannelCount(channel_layout_));
104 channels_ = channels;
105 bytes_per_frame_ = channels_ * bytes_per_channel_;
106 }
107
99 void AudioDecoderConfig::SetIsEncrypted(bool is_encrypted) { 108 void AudioDecoderConfig::SetIsEncrypted(bool is_encrypted) {
100 if (!is_encrypted) { 109 if (!is_encrypted) {
101 DCHECK(encryption_scheme_.is_encrypted()) << "Config is already clear."; 110 DCHECK(encryption_scheme_.is_encrypted()) << "Config is already clear.";
102 encryption_scheme_ = Unencrypted(); 111 encryption_scheme_ = Unencrypted();
103 } else { 112 } else {
104 DCHECK(!encryption_scheme_.is_encrypted()) 113 DCHECK(!encryption_scheme_.is_encrypted())
105 << "Config is already encrypted."; 114 << "Config is already encrypted.";
106 // TODO(xhwang): This is only used to guide decoder selection, so set 115 // TODO(xhwang): This is only used to guide decoder selection, so set
107 // a common encryption scheme that should be supported by all decrypting 116 // a common encryption scheme that should be supported by all decrypting
108 // decoders. We should be able to remove this when we support switching 117 // decoders. We should be able to remove this when we support switching
109 // decoders at run time. See http://crbug.com/695595 118 // decoders at run time. See http://crbug.com/695595
110 encryption_scheme_ = AesCtrEncryptionScheme(); 119 encryption_scheme_ = AesCtrEncryptionScheme();
111 } 120 }
112 } 121 }
113 122
114 } // namespace media 123 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_decoder_config.h ('k') | media/base/fake_audio_renderer_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698