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

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

Issue 239893002: Allow multiple concurrent Decode() requests in VideoDecoder interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_DECODER_STREAM_H_ 5 #ifndef MEDIA_FILTERS_DECODER_STREAM_H_
6 #define MEDIA_FILTERS_DECODER_STREAM_H_ 6 #define MEDIA_FILTERS_DECODER_STREAM_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // it is stopped. This method can be called at any time but not during another 80 // it is stopped. This method can be called at any time but not during another
81 // pending Stop(). 81 // pending Stop().
82 void Stop(const base::Closure& closure); 82 void Stop(const base::Closure& closure);
83 83
84 // Returns true if the decoder currently has the ability to decode and return 84 // Returns true if the decoder currently has the ability to decode and return
85 // an Output. 85 // an Output.
86 // TODO(rileya): Remove the need for this by refactoring Decoder queueing 86 // TODO(rileya): Remove the need for this by refactoring Decoder queueing
87 // behavior. 87 // behavior.
88 bool CanReadWithoutStalling() const; 88 bool CanReadWithoutStalling() const;
89 89
90 // Returns true if one more decode request can be submitted to the decoder.
91 bool CanDecodeAnotherBuffer() const;
xhwang 2014/04/25 00:36:03 nit: how about CanDecodeMore()?
Sergey Ulanov 2014/04/26 00:59:29 Done.
92
90 // Allows callers to register for notification of splice buffers from the 93 // Allows callers to register for notification of splice buffers from the
91 // demuxer. I.e., DecoderBuffer::splice_timestamp() is not kNoTimestamp(). 94 // demuxer. I.e., DecoderBuffer::splice_timestamp() is not kNoTimestamp().
92 // 95 //
93 // The observer will be notified of all buffers with a splice_timestamp() and 96 // The observer will be notified of all buffers with a splice_timestamp() and
94 // the first buffer after which has a splice_timestamp() of kNoTimestamp(). 97 // the first buffer after which has a splice_timestamp() of kNoTimestamp().
95 typedef base::Callback<void(base::TimeDelta)> SpliceObserverCB; 98 typedef base::Callback<void(base::TimeDelta)> SpliceObserverCB;
96 void set_splice_observer(const SpliceObserverCB& splice_observer) { 99 void set_splice_observer(const SpliceObserverCB& splice_observer) {
97 splice_observer_cb_ = splice_observer; 100 splice_observer_cb_ = splice_observer;
98 } 101 }
99 102
(...skipping 22 matching lines...) Expand all
122 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream 125 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
123 // is created to help decrypt the encrypted stream. 126 // is created to help decrypt the encrypted stream.
124 void OnDecoderSelected( 127 void OnDecoderSelected(
125 scoped_ptr<Decoder> selected_decoder, 128 scoped_ptr<Decoder> selected_decoder,
126 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); 129 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream);
127 130
128 // Satisfy pending |read_cb_| with |status| and |output|. 131 // Satisfy pending |read_cb_| with |status| and |output|.
129 void SatisfyRead(Status status, 132 void SatisfyRead(Status status,
130 const scoped_refptr<Output>& output); 133 const scoped_refptr<Output>& output);
131 134
132 // Abort pending |read_cb_|.
133 void AbortRead();
134
135 // Decodes |buffer| and returns the result via OnDecodeOutputReady(). 135 // Decodes |buffer| and returns the result via OnDecodeOutputReady().
136 void Decode(const scoped_refptr<DecoderBuffer>& buffer); 136 void Decode(const scoped_refptr<DecoderBuffer>& buffer);
137 137
138 // Flushes the decoder with an EOS buffer to retrieve internally buffered 138 // Flushes the decoder with an EOS buffer to retrieve internally buffered
139 // decoder output. 139 // decoder output.
140 void FlushDecoder(); 140 void FlushDecoder();
141 141
142 // Callback for Decoder::Decode(). 142 // Callback for Decoder::Decode().
143 void OnDecodeOutputReady(int buffer_size, 143 void OnDecodeOutputReady(int buffer_size,
144 DecoderStatus status, 144 DecoderStatus status,
(...skipping 13 matching lines...) Expand all
158 158
159 void ResetDecoder(); 159 void ResetDecoder();
160 void OnDecoderReset(); 160 void OnDecoderReset();
161 161
162 void StopDecoder(); 162 void StopDecoder();
163 163
164 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 164 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
165 165
166 State state_; 166 State state_;
167 167
168 // Error code when state_ == STATE_ERROR.
169 Status error_;
xhwang 2014/04/25 00:36:03 DECRYPT_ERROR is going to be deprecated. When stat
Sergey Ulanov 2014/04/26 00:59:29 Done.
170
168 StatisticsCB statistics_cb_; 171 StatisticsCB statistics_cb_;
169 InitCB init_cb_; 172 InitCB init_cb_;
170 173
171 ReadCB read_cb_; 174 ReadCB read_cb_;
172 base::Closure reset_cb_; 175 base::Closure reset_cb_;
173 base::Closure stop_cb_; 176 base::Closure stop_cb_;
174 177
175 DemuxerStream* stream_; 178 DemuxerStream* stream_;
176 179
177 scoped_ptr<DecoderSelector<StreamType> > decoder_selector_; 180 scoped_ptr<DecoderSelector<StreamType> > decoder_selector_;
178 181
179 // These two will be set by DecoderSelector::SelectDecoder(). 182 // These two will be set by DecoderSelector::SelectDecoder().
180 scoped_ptr<Decoder> decoder_; 183 scoped_ptr<Decoder> decoder_;
181 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 184 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
182 185
183 SpliceObserverCB splice_observer_cb_; 186 SpliceObserverCB splice_observer_cb_;
184 ConfigChangeObserverCB config_change_observer_cb_; 187 ConfigChangeObserverCB config_change_observer_cb_;
185 188
186 // If a splice_timestamp() has been seen, this is true until a 189 // If a splice_timestamp() has been seen, this is true until a
187 // splice_timestamp() of kNoTimestamp() is encountered. 190 // splice_timestamp() of kNoTimestamp() is encountered.
188 bool active_splice_; 191 bool active_splice_;
189 192
193 // Decoded buffers that haven't been read yet. Used when the decoder supports
194 // parallel decoding.
195 std::list<scoped_refptr<Output> > ready_outputs_;
196 int pending_decode_requests_;
xhwang 2014/04/25 00:36:03 This worth a separate comment.
Sergey Ulanov 2014/04/26 00:59:29 Done.
197
190 // NOTE: Weak pointers must be invalidated before all other member variables. 198 // NOTE: Weak pointers must be invalidated before all other member variables.
191 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_; 199 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_;
192 200
193 // This is required so the VideoFrameStream can access private members in 201 // This is required so the VideoFrameStream can access private members in
194 // FinishInitialization() and ReportStatistics(). 202 // FinishInitialization() and ReportStatistics().
195 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderStream); 203 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderStream);
196 }; 204 };
197 205
198 template <> 206 template <>
199 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const; 207 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const;
200 208
209 template <>
210 bool DecoderStream<DemuxerStream::AUDIO>::CanDecodeAnotherBuffer() const;
211
201 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; 212 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream;
202 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; 213 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream;
203 214
204 } // namespace media 215 } // namespace media
205 216
206 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ 217 #endif // MEDIA_FILTERS_DECODER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698