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

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

Issue 10837206: Rewrite media::Pipeline state transition machinery and simplify shutdown. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fixes Created 8 years, 3 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 (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_PIPELINE_H_ 5 #ifndef MEDIA_BASE_PIPELINE_H_
6 #define MEDIA_BASE_PIPELINE_H_ 6 #define MEDIA_BASE_PIPELINE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/synchronization/condition_variable.h" 11 #include "base/synchronization/condition_variable.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h"
13 #include "media/base/audio_renderer.h" 14 #include "media/base/audio_renderer.h"
14 #include "media/base/demuxer.h" 15 #include "media/base/demuxer.h"
15 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
16 #include "media/base/pipeline_status.h" 17 #include "media/base/pipeline_status.h"
17 #include "media/base/ranges.h" 18 #include "media/base/ranges.h"
18 #include "media/base/serial_runner.h" 19 #include "media/base/serial_runner.h"
19 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
20 21
21 class MessageLoop; 22 class MessageLoop;
22 23
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 60
60 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification); 61 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification);
61 }; 62 };
62 63
63 // Pipeline runs the media pipeline. Filters are created and called on the 64 // Pipeline runs the media pipeline. Filters are created and called on the
64 // message loop injected into this object. Pipeline works like a state 65 // message loop injected into this object. Pipeline works like a state
65 // machine to perform asynchronous initialization, pausing, seeking and playing. 66 // machine to perform asynchronous initialization, pausing, seeking and playing.
66 // 67 //
67 // Here's a state diagram that describes the lifetime of this object. 68 // Here's a state diagram that describes the lifetime of this object.
68 // 69 //
69 // [ *Created ] [ Stopped ] 70 // [ *Created ] [ Any State ]
70 // | Start() ^ 71 // | Start() | Stop() / SetError()
71 // V SetError() | 72 // V V
72 // [ InitXXX (for each filter) ] -------->[ Stopping (for each filter) ] 73 // [ InitXXX (for each filter) ] [ Stopping ]
73 // | ^ 74 // | |
74 // V | if Stop 75 // V V
75 // [ Seeking (for each filter) ] <--------[ Flushing (for each filter) ] 76 // [ InitPreroll ] [ Stopped ]
76 // | if Seek ^ 77 // |
77 // V | 78 // V
78 // [ Starting (for each filter) ] | 79 // [ Starting ] <-- [ Seeking ]
79 // | | 80 // | ^
80 // V Seek()/Stop() | 81 // V |
81 // [ Started ] -------------------------> [ Pausing (for each filter) ] 82 // [ Started ] ----------'
82 // ^ SetError() 83 // Seek()
83 // |
84 // [ Any State Other Than InitXXX ]
85 // 84 //
86 // Initialization is a series of state transitions from "Created" through each 85 // Initialization is a series of state transitions from "Created" through each
87 // filter initialization state. When all filter initialization states have 86 // filter initialization state. When all filter initialization states have
88 // completed, we are implicitly in a "Paused" state. At that point we simulate 87 // completed, we are implicitly in a "Paused" state. At that point we simulate
89 // a Seek() to the beginning of the media to give filters a chance to preroll. 88 // a Seek() to the beginning of the media to give filters a chance to preroll.
90 // From then on the normal Seek() transitions are carried out and we start 89 // From then on the normal Seek() transitions are carried out and we start
91 // playing the media. 90 // playing the media.
92 // 91 //
93 // If any error ever happens, this object will transition to the "Error" state 92 // If any error ever happens, this object will transition to the "Error" state
94 // from any state. If Stop() is ever called, this object will transition to 93 // from any state. If Stop() is ever called, this object will transition to
(...skipping 17 matching lines...) Expand all
112 111
113 typedef base::Callback<void(BufferingState)> BufferingStateCB; 112 typedef base::Callback<void(BufferingState)> BufferingStateCB;
114 113
115 // Constructs a media pipeline that will execute on |message_loop|. 114 // Constructs a media pipeline that will execute on |message_loop|.
116 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, 115 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
117 MediaLog* media_log); 116 MediaLog* media_log);
118 117
119 // Build a pipeline to using the given filter collection to construct a filter 118 // Build a pipeline to using the given filter collection to construct a filter
120 // chain, executing |seek_cb| when the initial seek/preroll has completed. 119 // chain, executing |seek_cb| when the initial seek/preroll has completed.
121 // 120 //
121 // |filter_collection| must contain a demuxer as well as audio/video decoders
122 // and renderers if such streams are present. Failing to do so will result in
Ami GONE FROM CHROMIUM 2012/09/07 13:19:41 In reality the collection is constructed by client
123 // a crash.
124 //
122 // The following permanent callbacks will be executed as follows up until 125 // The following permanent callbacks will be executed as follows up until
123 // Stop() has completed: 126 // Stop() has completed:
124 // |ended_cb| will be executed whenever the media reaches the end. 127 // |ended_cb| will be executed whenever the media reaches the end.
125 // |error_cb| will be executed whenever an error occurs but hasn't 128 // |error_cb| will be executed whenever an error occurs but hasn't
126 // been reported already through another callback. 129 // been reported already through another callback.
127 // |buffering_state_cb| Optional callback that will be executed whenever the 130 // |buffering_state_cb| Optional callback that will be executed whenever the
128 // pipeline's buffering state changes. 131 // pipeline's buffering state changes.
129 // It is an error to call this method after the pipeline has already started. 132 // It is an error to call this method after the pipeline has already started.
130 void Start(scoped_ptr<FilterCollection> filter_collection, 133 void Start(scoped_ptr<FilterCollection> filter_collection,
131 const PipelineStatusCB& ended_cb, 134 const PipelineStatusCB& ended_cb,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 friend class base::RefCountedThreadSafe<Pipeline>; 228 friend class base::RefCountedThreadSafe<Pipeline>;
226 virtual ~Pipeline(); 229 virtual ~Pipeline();
227 230
228 // Pipeline states, as described above. 231 // Pipeline states, as described above.
229 enum State { 232 enum State {
230 kCreated, 233 kCreated,
231 kInitDemuxer, 234 kInitDemuxer,
232 kInitAudioDecoder, 235 kInitAudioDecoder,
233 kInitAudioRenderer, 236 kInitAudioRenderer,
234 kInitVideoRenderer, 237 kInitVideoRenderer,
235 kPausing, 238 kInitPrerolling,
236 kSeeking, 239 kSeeking,
237 kFlushing,
238 kStarting, 240 kStarting,
239 kStarted, 241 kStarted,
240 kStopping, 242 kStopping,
241 kStopped, 243 kStopped,
242 }; 244 };
243 245
244 // Updates |state_|. All state transitions should use this call. 246 // Updates |state_|. All state transitions should use this call.
245 void SetState(State next_state); 247 void SetState(State next_state);
246 248
247 // Simple method used to make sure the pipeline is running normally. 249 static const char* GetStateString(State state);
248 bool IsPipelineOk(); 250 State GetNextState() const;
249
250 // Helper method to tell whether we are in transition to seek state.
251 bool IsPipelineSeeking();
252 251
253 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_| 252 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_|
254 // and |seek_pending_|. 253 // and |seek_pending_|.
255 void FinishSeek(); 254 void FinishSeek();
256 255
257 // Returns true if the given state is one that transitions to a new state
258 // after iterating through each filter.
259 static bool TransientState(State state);
260
261 // Given the current state, returns the next state.
262 State FindNextState(State current);
263
264 // DataSourceHost (by way of DemuxerHost) implementation. 256 // DataSourceHost (by way of DemuxerHost) implementation.
265 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; 257 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
266 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; 258 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
267 virtual void AddBufferedTimeRange(base::TimeDelta start, 259 virtual void AddBufferedTimeRange(base::TimeDelta start,
268 base::TimeDelta end) OVERRIDE; 260 base::TimeDelta end) OVERRIDE;
269 261
270 // DemuxerHost implementaion. 262 // DemuxerHost implementaion.
271 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; 263 virtual void SetDuration(base::TimeDelta duration) OVERRIDE;
272 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; 264 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE;
273 265
274 // Initiates teardown sequence in response to a runtime error. 266 // Initiates teardown sequence in response to a runtime error.
275 // 267 //
276 // Safe to call from any thread. 268 // Safe to call from any thread.
277 void SetError(PipelineStatus error); 269 void SetError(PipelineStatus error);
278 270
279 // Callback executed when the natural size of the video has changed. 271 // Callback executed when the natural size of the video has changed.
280 void OnNaturalVideoSizeChanged(const gfx::Size& size); 272 void OnNaturalVideoSizeChanged(const gfx::Size& size);
281 273
282 // Callbacks executed when a renderer has ended. 274 // Callbacks executed when a renderer has ended.
283 void OnAudioRendererEnded(); 275 void OnAudioRendererEnded();
284 void OnVideoRendererEnded(); 276 void OnVideoRendererEnded();
285 277
286 // Callbacks executed by filters upon completing initialization.
287 void OnFilterInitialize(PipelineStatus status);
288
289 // Callback executed by filters upon completing Play(), Pause(), Flush(),
290 // Seek() or Stop().
291 void OnFilterStateTransition(PipelineStatus status);
292
293 // Callback executed by filters when completing teardown operations.
294 void OnTeardownStateTransition(PipelineStatus status);
295
296 // Callback executed by filters to update statistics. 278 // Callback executed by filters to update statistics.
297 void OnUpdateStatistics(const PipelineStatistics& stats); 279 void OnUpdateStatistics(const PipelineStatistics& stats);
298 280
299 // Callback executed by audio renderer when it has been disabled. 281 // Callback executed by audio renderer when it has been disabled.
300 void OnAudioDisabled(); 282 void OnAudioDisabled();
301 283
302 // Callback executed by audio renderer to update clock time. 284 // Callback executed by audio renderer to update clock time.
303 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); 285 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time);
304 286
305 // Callback executed by video renderer to update clock time. 287 // Callback executed by video renderer to update clock time.
306 void OnVideoTimeUpdate(base::TimeDelta max_time); 288 void OnVideoTimeUpdate(base::TimeDelta max_time);
307 289
308 // The following "task" methods correspond to the public methods, but these 290 // The following "task" methods correspond to the public methods, but these
309 // methods are run as the result of posting a task to the PipelineInternal's 291 // methods are run as the result of posting a task to the PipelineInternal's
310 // message loop. 292 // message loop.
311 void StartTask(scoped_ptr<FilterCollection> filter_collection, 293 void StartTask(scoped_ptr<FilterCollection> filter_collection,
312 const PipelineStatusCB& ended_cb, 294 const PipelineStatusCB& ended_cb,
313 const PipelineStatusCB& error_cb, 295 const PipelineStatusCB& error_cb,
314 const PipelineStatusCB& seek_cb, 296 const PipelineStatusCB& seek_cb,
315 const BufferingStateCB& buffering_state_cb); 297 const BufferingStateCB& buffering_state_cb);
316 298
317 // InitializeTask() performs initialization in multiple passes. It is executed
318 // as a result of calling Start() or InitializationComplete() that advances
319 // initialization to the next state. It works as a hub of state transition for
320 // initialization. One stage communicates its status to the next through
321 // |last_stage_status|.
322 void InitializeTask(PipelineStatus last_stage_status);
323
324 // Stops and destroys all filters, placing the pipeline in the kStopped state. 299 // Stops and destroys all filters, placing the pipeline in the kStopped state.
325 void StopTask(const base::Closure& stop_cb); 300 void StopTask(const base::Closure& stop_cb);
326 301
327 // Carries out stopping and destroying all filters, placing the pipeline in 302 // Carries out stopping and destroying all filters, placing the pipeline in
328 // the kStopped state. 303 // the kStopped state.
329 void ErrorChangedTask(PipelineStatus error); 304 void ErrorChangedTask(PipelineStatus error);
330 305
331 // Carries out notifying filters that the playback rate has changed. 306 // Carries out notifying filters that the playback rate has changed.
332 void PlaybackRateChangedTask(float playback_rate); 307 void PlaybackRateChangedTask(float playback_rate);
333 308
334 // Carries out notifying filters that the volume has changed. 309 // Carries out notifying filters that the volume has changed.
335 void VolumeChangedTask(float volume); 310 void VolumeChangedTask(float volume);
336 311
337 // Carries out notifying filters that we are seeking to a new timestamp. 312 // Carries out notifying filters that we are seeking to a new timestamp.
338 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); 313 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb);
339 314
340 // Handles audio/video ended logic and running |ended_cb_|. 315 // Handles audio/video ended logic and running |ended_cb_|.
341 void DoAudioRendererEnded(); 316 void DoAudioRendererEnded();
342 void DoVideoRendererEnded(); 317 void DoVideoRendererEnded();
343 void RunEndedCallbackIfNeeded(); 318 void RunEndedCallbackIfNeeded();
344 319
345 // Carries out disabling the audio renderer. 320 // Carries out disabling the audio renderer.
346 void AudioDisabledTask(); 321 void AudioDisabledTask();
347 322
348 // Carries out advancing to the next filter during Play()/Pause()/Seek(). 323 // Kicks off initialization for each media object, executing |done_cb| with
349 void FilterStateTransitionTask(); 324 // the result when completed.
350 325 void InitializeDemuxer(const PipelineStatusCB& done_cb);
351 // Carries out advancing to the next teardown operation. 326 void InitializeAudioDecoder(const PipelineStatusCB& done_cb);
352 void TeardownStateTransitionTask(); 327 void InitializeAudioRenderer(const PipelineStatusCB& done_cb);
353 328 void InitializeVideoRenderer(const PipelineStatusCB& done_cb);
354 // Carries out stopping filter threads, deleting filters, running
355 // appropriate callbacks, and setting the appropriate pipeline state
356 // depending on whether we performing Stop() or SetError().
357 // Called after all filters have been stopped.
358 void FinishDestroyingFiltersTask();
359
360 // Internal methods used in the implementation of the pipeline thread. All
361 // of these methods are only called on the pipeline thread.
362
363 // The following initialize methods are used to select a specific type of
364 // object from FilterCollection and initialize it asynchronously.
365 void InitializeDemuxer();
366 void OnDemuxerInitialized(PipelineStatus status);
367
368 // Returns true if the asynchronous action of creating decoder has started.
369 // Returns false if this method did nothing because the corresponding
370 // audio stream does not exist.
371 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer);
372
373 // Initializes a renderer and connects it with decoder. Returns true if the
374 // asynchronous action of creating renderer has started. Returns
375 // false if this method did nothing because the corresponding audio/video
376 // stream does not exist.
377 bool InitializeAudioRenderer(const scoped_refptr<AudioDecoder>& decoder);
378 bool InitializeVideoRenderer(
379 const scoped_refptr<DemuxerStream>& stream);
380 329
381 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask(). 330 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask().
382 // When we start to tear down the pipeline, we will consider two cases: 331 // When we start to tear down the pipeline, we will consider two cases:
383 // 1. when pipeline has not been initialized, we will transit to stopping 332 // 1. when pipeline has not been initialized, we will transit to stopping
384 // state first. 333 // state first.
385 // 2. when pipeline has been initialized, we will first transit to pausing 334 // 2. when pipeline has been initialized, we will first transit to pausing
386 // => flushing => stopping => stopped state. 335 // => flushing => stopping => stopped state.
387 // This will remove the race condition during stop between filters. 336 // This will remove the race condition during stop between filters.
388 void TearDownPipeline(); 337 void TearDownPipeline();
389 338
390 // Compute the time corresponding to a byte offset. 339 // Compute the time corresponding to a byte offset.
391 base::TimeDelta TimeForByteOffset_Locked(int64 byte_offset) const; 340 base::TimeDelta TimeForByteOffset_Locked(int64 byte_offset) const;
392 341
393 // Initiates an asynchronous Pause/Seek/Play/Stop() call sequence executing 342 void OnStateTransition(PipelineStatus status);
394 // |done_cb| when completed. 343 void StateTransitionTask(PipelineStatus status);
395 void DoPause(const PipelineStatusCB& done_cb);
396 void DoFlush(const PipelineStatusCB& done_cb);
397 void DoPlay(const PipelineStatusCB& done_cb);
398 void DoStop(const PipelineStatusCB& done_cb);
399 344
400 // Initiates an asynchronous Seek() and preroll call sequence executing 345 // Initiates an asynchronous preroll call sequence executing |done_cb|
401 // |done_cb| with the final status when completed. If |skip_demuxer_seek| is 346 // with the final status when completed.
402 // true then only renderers will attempt to preroll. 347 void DoInitialPreroll(const PipelineStatusCB& done_cb);
348
349 // Initiates an asynchronous pause-flush-seek-preroll call sequence
350 // executing |done_cb| with the final status when completed.
403 // 351 //
404 // TODO(scherkus): Prerolling should be separate from seeking so we can report 352 // TODO(scherkus): Prerolling should be separate from seeking so we can report
405 // finer grained ready states (HAVE_CURRENT_DATA vs. HAVE_FUTURE_DATA) 353 // finer grained ready states (HAVE_CURRENT_DATA vs. HAVE_FUTURE_DATA)
406 // indepentent from seeking. 354 // indepentent from seeking.
407 void DoSeek(base::TimeDelta seek_timestamp, bool skip_demuxer_seek, 355 void DoSeek(base::TimeDelta seek_timestamp, const PipelineStatusCB& done_cb);
408 const PipelineStatusCB& done_cb); 356
357 // Updates playback rate and volume and initiates an asynchronous play call
358 // sequence executing |done_cb| with the final status when completed.
359 void DoPlay(const PipelineStatusCB& done_cb);
360
361 // Initiates an asynchronous pause-flush-stop call sequence executing
362 // |done_cb| when completed.
363 void DoStop(const PipelineStatusCB& done_cb);
364 void OnStopCompleted(PipelineStatus status);
409 365
410 void OnAudioUnderflow(); 366 void OnAudioUnderflow();
411 367
412 void StartClockIfWaitingForTimeUpdate_Locked(); 368 void StartClockIfWaitingForTimeUpdate_Locked();
413 369
414 // Report pipeline |status| through |cb| avoiding duplicate error reporting.
415 void ReportStatus(const PipelineStatusCB& cb, PipelineStatus status);
416
417 // Message loop used to execute pipeline tasks. 370 // Message loop used to execute pipeline tasks.
418 scoped_refptr<base::MessageLoopProxy> message_loop_; 371 scoped_refptr<base::MessageLoopProxy> message_loop_;
419 372
420 // MediaLog to which to log events. 373 // MediaLog to which to log events.
421 scoped_refptr<MediaLog> media_log_; 374 scoped_refptr<MediaLog> media_log_;
422 375
423 // Lock used to serialize access for the following data members. 376 // Lock used to serialize access for the following data members.
424 mutable base::Lock lock_; 377 mutable base::Lock lock_;
425 378
426 // Whether or not the pipeline is running. 379 // Whether or not the pipeline is running.
427 bool running_; 380 bool running_;
428 381
429 // Whether or not the pipeline is in transition for a seek operation.
430 bool seek_pending_;
431
432 // Whether or not the pipeline is perform a stop operation.
433 bool tearing_down_;
434
435 // Whether or not a playback rate change should be done once seeking is done.
436 bool playback_rate_change_pending_;
437
438 // Amount of available buffered data. Set by filters. 382 // Amount of available buffered data. Set by filters.
439 Ranges<int64> buffered_byte_ranges_; 383 Ranges<int64> buffered_byte_ranges_;
440 Ranges<base::TimeDelta> buffered_time_ranges_; 384 Ranges<base::TimeDelta> buffered_time_ranges_;
441 385
442 // True when AddBufferedByteRange() has been called more recently than 386 // True when AddBufferedByteRange() has been called more recently than
443 // DidLoadingProgress(). 387 // DidLoadingProgress().
444 mutable bool did_loading_progress_; 388 mutable bool did_loading_progress_;
445 389
446 // Total size of the media. Set by filters. 390 // Total size of the media. Set by filters.
447 int64 total_bytes_; 391 int64 total_bytes_;
448 392
449 // Video's natural width and height. Set by filters. 393 // Video's natural width and height. Set by filters.
450 gfx::Size natural_size_; 394 gfx::Size natural_size_;
451 395
452 // Current volume level (from 0.0f to 1.0f). This value is set immediately 396 // Current volume level (from 0.0f to 1.0f). This value is set immediately
453 // via SetVolume() and a task is dispatched on the message loop to notify the 397 // via SetVolume() and a task is dispatched on the message loop to notify the
454 // filters. 398 // filters.
455 float volume_; 399 float volume_;
456 400
457 // Current playback rate (>= 0.0f). This value is set immediately via 401 // Current playback rate (>= 0.0f). This value is set immediately via
458 // SetPlaybackRate() and a task is dispatched on the message loop to notify 402 // SetPlaybackRate() and a task is dispatched on the message loop to notify
459 // the filters. 403 // the filters.
460 float playback_rate_; 404 float playback_rate_;
461 405
462 // Playback rate to set when the current seek has finished.
463 float pending_playback_rate_;
464
465 // Reference clock. Keeps track of current playback time. Uses system 406 // Reference clock. Keeps track of current playback time. Uses system
466 // clock and linear interpolation, but can have its time manually set 407 // clock and linear interpolation, but can have its time manually set
467 // by filters. 408 // by filters.
468 scoped_ptr<Clock> clock_; 409 scoped_ptr<Clock> clock_;
469 410
470 // If this value is set to true, then |clock_| is paused and we are waiting 411 // If this value is set to true, then |clock_| is paused and we are waiting
471 // for an update of the clock greater than or equal to the elapsed time to 412 // for an update of the clock greater than or equal to the elapsed time to
472 // start the clock. 413 // start the clock.
473 bool waiting_for_clock_update_; 414 bool waiting_for_clock_update_;
474 415
475 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that 416 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that
476 // the pipeline is operating correctly. Any other value indicates that the 417 // the pipeline is operating correctly. Any other value indicates that the
477 // pipeline is stopped or is stopping. Clients can call the Stop() method to 418 // pipeline is stopped or is stopping. Clients can call the Stop() method to
478 // reset the pipeline state, and restore this to PIPELINE_OK. 419 // reset the pipeline state, and restore this to PIPELINE_OK.
479 PipelineStatus status_; 420 PipelineStatus status_;
480 421
481 // Whether the media contains rendered audio and video streams. 422 // Whether the media contains rendered audio and video streams.
482 // TODO(fischman,scherkus): replace these with checks for 423 // TODO(fischman,scherkus): replace these with checks for
483 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the 424 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the
484 // Filter heirarchy is done. 425 // Filter heirarchy is done.
485 bool has_audio_; 426 bool has_audio_;
486 bool has_video_; 427 bool has_video_;
487 428
488 // The following data members are only accessed by tasks posted to 429 // The following data members are only accessed by tasks posted to
489 // |message_loop_|. 430 // |message_loop_|.
490 431
491 // Member that tracks the current state. 432 // Member that tracks the current state.
492 State state_; 433 State state_;
493 434
494 // For kSeeking we need to remember where we're seeking between filter
495 // replies.
496 base::TimeDelta seek_timestamp_;
497
498 // Whether we've received the audio/video ended events. 435 // Whether we've received the audio/video ended events.
499 bool audio_ended_; 436 bool audio_ended_;
500 bool video_ended_; 437 bool video_ended_;
501 438
502 // Set to true in DisableAudioRendererTask(). 439 // Set to true in DisableAudioRendererTask().
503 bool audio_disabled_; 440 bool audio_disabled_;
504 441
505 // Filter collection as passed in by Start().
506 scoped_ptr<FilterCollection> filter_collection_; 442 scoped_ptr<FilterCollection> filter_collection_;
507 443
508 // Callbacks for various pipeline operations. 444 // Temporary callback used for Start() and Seek().
509 PipelineStatusCB seek_cb_; 445 PipelineStatusCB seek_cb_;
446
447 // Temporary callback used for Stop().
510 base::Closure stop_cb_; 448 base::Closure stop_cb_;
449
450 // Permanent callbacks passed in via Start().
511 PipelineStatusCB ended_cb_; 451 PipelineStatusCB ended_cb_;
512 PipelineStatusCB error_cb_; 452 PipelineStatusCB error_cb_;
513 BufferingStateCB buffering_state_cb_; 453 BufferingStateCB buffering_state_cb_;
514 454
515 // Audio renderer reference used for setting the volume and determining 455 // Audio renderer reference used for setting the volume and determining
516 // when playback has finished. 456 // when playback has finished.
517 scoped_refptr<AudioRenderer> audio_renderer_; 457 scoped_refptr<AudioRenderer> audio_renderer_;
518 458
519 // Video Renderer reference used for determining when playback has finished 459 // Video Renderer reference used for determining when playback has finished
520 // and for signalling imminent shutdown. 460 // and for signalling imminent shutdown.
521 // The signalling imminent shutdown is a HACK necessary because 461 // The signalling imminent shutdown is a HACK necessary because
522 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage 462 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage
523 // until PipelineImpl::Stop() calls its callback. 463 // until PipelineImpl::Stop() calls its callback.
524 // http://crbug.com/110228 tracks removing this hack. 464 // http://crbug.com/110228 tracks removing this hack.
525 scoped_refptr<VideoRenderer> video_renderer_; 465 scoped_refptr<VideoRenderer> video_renderer_;
526 466
527 // Demuxer reference used for setting the preload value. 467 // Demuxer reference used for setting the preload value.
528 scoped_refptr<Demuxer> demuxer_; 468 scoped_refptr<Demuxer> demuxer_;
529 469
530 // Helper class that stores filter references during pipeline 470 // Audio decoder reference used during initialization.
531 // initialization. 471 //
532 struct PipelineInitState; 472 // TODO(scherkus): Remove after renderers do initialization, see
533 scoped_ptr<PipelineInitState> pipeline_init_state_; 473 // http://crbug.com/145635
474 scoped_refptr<AudioDecoder> audio_decoder_;
534 475
535 // Statistics.
536 PipelineStatistics statistics_; 476 PipelineStatistics statistics_;
477
537 // Time of pipeline creation; is non-zero only until the pipeline first 478 // Time of pipeline creation; is non-zero only until the pipeline first
538 // reaches "kStarted", at which point it is used & zeroed out. 479 // reaches "kStarted", at which point it is used & zeroed out.
539 base::Time creation_time_; 480 base::Time creation_time_;
540 481
541 scoped_ptr<SerialRunner> pending_callbacks_; 482 scoped_ptr<SerialRunner> pending_callbacks_;
542 483
484 base::ThreadChecker thread_checker_;
485
543 DISALLOW_COPY_AND_ASSIGN(Pipeline); 486 DISALLOW_COPY_AND_ASSIGN(Pipeline);
544 }; 487 };
545 488
546 } // namespace media 489 } // namespace media
547 490
548 #endif // MEDIA_BASE_PIPELINE_H_ 491 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/media_log.cc ('k') | media/base/pipeline.cc » ('j') | media/base/pipeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698