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

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

Issue 1786733004: Revert of media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/BUILD.gn ('k') | media/base/audio_decoder_config.cc » ('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 #ifndef MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ 5 #ifndef MEDIA_BASE_AUDIO_DECODER_CONFIG_H_
6 #define MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ 6 #define MEDIA_BASE_AUDIO_DECODER_CONFIG_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/base/audio_codecs.h" 15 #include "media/base/audio_codecs.h"
16 #include "media/base/channel_layout.h" 16 #include "media/base/channel_layout.h"
17 #include "media/base/encryption_scheme.h"
18 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
19 #include "media/base/sample_format.h" 18 #include "media/base/sample_format.h"
20 19
21 namespace media { 20 namespace media {
22 21
23 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of 22 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of
24 // |bits_per_channel|, we should switch over since bits are generally confusing 23 // |bits_per_channel|, we should switch over since bits are generally confusing
25 // to work with. 24 // to work with.
26 class MEDIA_EXPORT AudioDecoderConfig { 25 class MEDIA_EXPORT AudioDecoderConfig {
27 public: 26 public:
28 // Constructs an uninitialized object. Clients should call Initialize() with 27 // Constructs an uninitialized object. Clients should call Initialize() with
29 // appropriate values before using. 28 // appropriate values before using.
30 AudioDecoderConfig(); 29 AudioDecoderConfig();
31 30
32 // Constructs an initialized object. 31 // Constructs an initialized object.
33 AudioDecoderConfig(AudioCodec codec, 32 AudioDecoderConfig(AudioCodec codec,
34 SampleFormat sample_format, 33 SampleFormat sample_format,
35 ChannelLayout channel_layout, 34 ChannelLayout channel_layout,
36 int samples_per_second, 35 int samples_per_second,
37 const std::vector<uint8_t>& extra_data, 36 const std::vector<uint8_t>& extra_data,
38 const EncryptionScheme& encryption_scheme); 37 bool is_encrypted);
39 38
40 AudioDecoderConfig(const AudioDecoderConfig& other); 39 AudioDecoderConfig(const AudioDecoderConfig& other);
41 40
42 ~AudioDecoderConfig(); 41 ~AudioDecoderConfig();
43 42
44 // Resets the internal state of this object. |codec_delay| is in frames. 43 // Resets the internal state of this object. |codec_delay| is in frames.
45 void Initialize(AudioCodec codec, 44 void Initialize(AudioCodec codec,
46 SampleFormat sample_format, 45 SampleFormat sample_format,
47 ChannelLayout channel_layout, 46 ChannelLayout channel_layout,
48 int samples_per_second, 47 int samples_per_second,
49 const std::vector<uint8_t>& extra_data, 48 const std::vector<uint8_t>& extra_data,
50 const EncryptionScheme& encryption_scheme, 49 bool is_encrypted,
51 base::TimeDelta seek_preroll, 50 base::TimeDelta seek_preroll,
52 int codec_delay); 51 int codec_delay);
53 52
54 // Returns true if this object has appropriate configuration values, false 53 // Returns true if this object has appropriate configuration values, false
55 // otherwise. 54 // otherwise.
56 bool IsValidConfig() const; 55 bool IsValidConfig() const;
57 56
58 // Returns true if all fields in |config| match this config. 57 // Returns true if all fields in |config| match this config.
59 // Note: The contents of |extra_data_| are compared not the raw pointers. 58 // Note: The contents of |extra_data_| are compared not the raw pointers.
60 bool Matches(const AudioDecoderConfig& config) const; 59 bool Matches(const AudioDecoderConfig& config) const;
(...skipping 12 matching lines...) Expand all
73 base::TimeDelta seek_preroll() const { return seek_preroll_; } 72 base::TimeDelta seek_preroll() const { return seek_preroll_; }
74 int codec_delay() const { return codec_delay_; } 73 int codec_delay() const { return codec_delay_; }
75 74
76 // Optional byte data required to initialize audio decoders such as Vorbis 75 // Optional byte data required to initialize audio decoders such as Vorbis
77 // codebooks. 76 // codebooks.
78 const std::vector<uint8_t>& extra_data() const { return extra_data_; } 77 const std::vector<uint8_t>& extra_data() const { return extra_data_; }
79 78
80 // Whether the audio stream is potentially encrypted. 79 // Whether the audio stream is potentially encrypted.
81 // Note that in a potentially encrypted audio stream, individual buffers 80 // Note that in a potentially encrypted audio stream, individual buffers
82 // can be encrypted or not encrypted. 81 // can be encrypted or not encrypted.
83 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } 82 bool is_encrypted() const { return is_encrypted_; }
84
85 // Encryption scheme used for encrypted buffers.
86 const EncryptionScheme& encryption_scheme() const {
87 return encryption_scheme_;
88 }
89 83
90 private: 84 private:
91 AudioCodec codec_; 85 AudioCodec codec_;
92 SampleFormat sample_format_; 86 SampleFormat sample_format_;
93 int bytes_per_channel_; 87 int bytes_per_channel_;
94 ChannelLayout channel_layout_; 88 ChannelLayout channel_layout_;
95 int samples_per_second_; 89 int samples_per_second_;
96 int bytes_per_frame_; 90 int bytes_per_frame_;
97 std::vector<uint8_t> extra_data_; 91 std::vector<uint8_t> extra_data_;
98 EncryptionScheme encryption_scheme_; 92 bool is_encrypted_;
99 93
100 // |seek_preroll_| is the duration of the data that the decoder must decode 94 // |seek_preroll_| is the duration of the data that the decoder must decode
101 // before the decoded data is valid. 95 // before the decoded data is valid.
102 base::TimeDelta seek_preroll_; 96 base::TimeDelta seek_preroll_;
103 97
104 // |codec_delay_| is the number of frames the decoder should discard before 98 // |codec_delay_| is the number of frames the decoder should discard before
105 // returning decoded data. This value can include both decoder delay as well 99 // returning decoded data. This value can include both decoder delay as well
106 // as padding added during encoding. 100 // as padding added during encoding.
107 int codec_delay_; 101 int codec_delay_;
108 102
109 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler 103 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
110 // generated copy constructor and assignment operator. Since the extra data is 104 // generated copy constructor and assignment operator. Since the extra data is
111 // typically small, the performance impact is minimal. 105 // typically small, the performance impact is minimal.
112 }; 106 };
113 107
114 } // namespace media 108 } // namespace media
115 109
116 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ 110 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_
OLDNEW
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/audio_decoder_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698