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

Side by Side Diff: media/filters/decrypting_audio_decoder.h

Issue 177333003: Add support for midstream audio configuration changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ABS
Patch Set: Created 6 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
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_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 virtual ~DecryptingAudioDecoder(); 43 virtual ~DecryptingAudioDecoder();
44 44
45 // AudioDecoder implementation. 45 // AudioDecoder implementation.
46 virtual void Initialize(const AudioDecoderConfig& config, 46 virtual void Initialize(const AudioDecoderConfig& config,
47 const PipelineStatusCB& status_cb) OVERRIDE; 47 const PipelineStatusCB& status_cb) OVERRIDE;
48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
49 const DecodeCB& decode_cb) OVERRIDE; 49 const DecodeCB& decode_cb) OVERRIDE;
50 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE; 50 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE;
51 virtual void Reset(const base::Closure& closure) OVERRIDE; 51 virtual void Reset(const base::Closure& closure) OVERRIDE;
52 virtual void Stop(const base::Closure& closure) OVERRIDE; 52 virtual void Stop(const base::Closure& closure) OVERRIDE;
53 virtual int bits_per_channel() OVERRIDE;
54 virtual ChannelLayout channel_layout() OVERRIDE;
55 virtual int samples_per_second() OVERRIDE;
56 53
57 private: 54 private:
58 // For a detailed state diagram please see this link: http://goo.gl/8jAok 55 // For a detailed state diagram please see this link: http://goo.gl/8jAok
59 // TODO(xhwang): Add a ASCII state diagram in this file after this class 56 // TODO(xhwang): Add a ASCII state diagram in this file after this class
60 // stabilizes. 57 // stabilizes.
61 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. 58 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder.
62 enum State { 59 enum State {
63 kUninitialized = 0, 60 kUninitialized = 0,
64 kDecryptorRequested, 61 kDecryptorRequested,
65 kPendingDecoderInit, 62 kPendingDecoderInit,
(...skipping 17 matching lines...) Expand all
83 Decryptor::Status status, 80 Decryptor::Status status,
84 const Decryptor::AudioBuffers& frames); 81 const Decryptor::AudioBuffers& frames);
85 82
86 // Callback for the |decryptor_| to notify this object that a new key has been 83 // Callback for the |decryptor_| to notify this object that a new key has been
87 // added. 84 // added.
88 void OnKeyAdded(); 85 void OnKeyAdded();
89 86
90 // Resets decoder and calls |reset_cb_|. 87 // Resets decoder and calls |reset_cb_|.
91 void DoReset(); 88 void DoReset();
92 89
93 // Updates audio configs from |demuxer_stream_| and resets
94 // |output_timestamp_base_| and |total_samples_decoded_|.
95 void UpdateDecoderConfig();
96
97 // Sets timestamp and duration for |queued_audio_frames_| to make sure the 90 // Sets timestamp and duration for |queued_audio_frames_| to make sure the
98 // renderer always receives continuous frames without gaps and overlaps. 91 // renderer always receives continuous frames without gaps and overlaps.
99 void EnqueueFrames(const Decryptor::AudioBuffers& frames); 92 void EnqueueFrames(const Decryptor::AudioBuffers& frames);
100 93
101 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 94 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
102 95
103 State state_; 96 State state_;
104 97
105 PipelineStatusCB init_cb_; 98 PipelineStatusCB init_cb_;
106 DecodeCB decode_cb_; 99 DecodeCB decode_cb_;
(...skipping 13 matching lines...) Expand all
120 113
121 // Indicates the situation where new key is added during pending decode 114 // Indicates the situation where new key is added during pending decode
122 // (in other words, this variable can only be set in state kPendingDecode). 115 // (in other words, this variable can only be set in state kPendingDecode).
123 // If this variable is true and kNoKey is returned then we need to try 116 // If this variable is true and kNoKey is returned then we need to try
124 // decrypting/decoding again in case the newly added key is the correct 117 // decrypting/decoding again in case the newly added key is the correct
125 // decryption key. 118 // decryption key.
126 bool key_added_while_decode_pending_; 119 bool key_added_while_decode_pending_;
127 120
128 Decryptor::AudioBuffers queued_audio_frames_; 121 Decryptor::AudioBuffers queued_audio_frames_;
129 122
130 // Decoded audio format.
131 int bits_per_channel_;
132 ChannelLayout channel_layout_;
133 int samples_per_second_;
134
135 scoped_ptr<AudioTimestampHelper> timestamp_helper_; 123 scoped_ptr<AudioTimestampHelper> timestamp_helper_;
136 124
137 // NOTE: Weak pointers must be invalidated before all other member variables. 125 // NOTE: Weak pointers must be invalidated before all other member variables.
138 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; 126 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_;
139 base::WeakPtr<DecryptingAudioDecoder> weak_this_; 127 base::WeakPtr<DecryptingAudioDecoder> weak_this_;
140 128
141 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); 129 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder);
142 }; 130 };
143 131
144 } // namespace media 132 } // namespace media
145 133
146 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 134 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698