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

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 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; 95 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_;
103 base::WeakPtr<DecryptingAudioDecoder> weak_this_; 96 base::WeakPtr<DecryptingAudioDecoder> weak_this_;
104 97
105 State state_; 98 State state_;
106 99
(...skipping 15 matching lines...) Expand all
122 115
123 // Indicates the situation where new key is added during pending decode 116 // Indicates the situation where new key is added during pending decode
124 // (in other words, this variable can only be set in state kPendingDecode). 117 // (in other words, this variable can only be set in state kPendingDecode).
125 // If this variable is true and kNoKey is returned then we need to try 118 // If this variable is true and kNoKey is returned then we need to try
126 // decrypting/decoding again in case the newly added key is the correct 119 // decrypting/decoding again in case the newly added key is the correct
127 // decryption key. 120 // decryption key.
128 bool key_added_while_decode_pending_; 121 bool key_added_while_decode_pending_;
129 122
130 Decryptor::AudioBuffers queued_audio_frames_; 123 Decryptor::AudioBuffers queued_audio_frames_;
131 124
132 // Decoded audio format.
133 int bits_per_channel_;
134 ChannelLayout channel_layout_;
135 int samples_per_second_;
136
137 scoped_ptr<AudioTimestampHelper> timestamp_helper_; 125 scoped_ptr<AudioTimestampHelper> timestamp_helper_;
138 126
139 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); 127 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder);
140 }; 128 };
141 129
142 } // namespace media 130 } // namespace media
143 131
144 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 132 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698