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

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

Issue 10854151: Allow transitioning to HAVE_METADATA before pipeline initialization completes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 8 years, 4 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
« no previous file with comments | « no previous file | media/base/pipeline.cc » ('j') | media/base/pipeline.cc » ('J')
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_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"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // From then on the normal Seek() transitions are carried out and we start 90 // From then on the normal Seek() transitions are carried out and we start
91 // playing the media. 91 // playing the media.
92 // 92 //
93 // If any error ever happens, this object will transition to the "Error" state 93 // 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 94 // from any state. If Stop() is ever called, this object will transition to
95 // "Stopped" state. 95 // "Stopped" state.
96 class MEDIA_EXPORT Pipeline 96 class MEDIA_EXPORT Pipeline
97 : public base::RefCountedThreadSafe<Pipeline>, 97 : public base::RefCountedThreadSafe<Pipeline>,
98 public DemuxerHost { 98 public DemuxerHost {
99 public: 99 public:
100 // Ready states indicating pipeline progress.
101 // kHaveMetadata : Indicates that the following things are known:
scherkus (not reviewing) 2012/08/16 01:36:02 OCD nits: no space before :, and don't worry about
acolwell GONE FROM CHROMIUM 2012/08/16 16:36:03 Fixed space before: Changed to a 2 space indent fo
102 // content duration, natural size, start time, and
103 // whether the content has audio and/or video in supported
104 // formats.
105 // kHavePrerolled : All renderers have successfully prerolled are are ready to
106 // start playback.
107 enum ReadyState {
108 kHaveMetadata,
109 kHavePrerolled,
Ami GONE FROM CHROMIUM 2012/08/16 03:31:56 Unfortunate that both of these use "Have" but in d
acolwell GONE FROM CHROMIUM 2012/08/16 16:36:03 Agreed.. Changed it to kPrerollCompleted
110 };
111
112 typedef base::Callback<void(ReadyState)> ReadyStateCB;
113
100 // Constructs a media pipeline that will execute on |message_loop|. 114 // Constructs a media pipeline that will execute on |message_loop|.
101 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, 115 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
102 MediaLog* media_log); 116 MediaLog* media_log);
103 117
104 // 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
105 // chain, executing |start_cb| when initialization has completed. 119 // chain, executing |seek_cb| when the initial seek/preroll has completed.
106 // 120 //
107 // The following permanent callbacks will be executed as follows up until 121 // The following permanent callbacks will be executed as follows up until
108 // Stop() has completed: 122 // Stop() has completed:
109 // |ended_cb| will be executed whenever the media reaches the end. 123 // |ended_cb| will be executed whenever the media reaches the end.
110 // |error_cb| will be executed whenever an error occurs but hasn't 124 // |error_cb| will be executed whenever an error occurs but hasn't
111 // been reported already through another callback. 125 // been reported already through another callback.
112 // 126 // |ready_state_cb| Optional callback that will be executed whenever the
127 // pipeline's ready state changes.
113 // It is an error to call this method after the pipeline has already started. 128 // It is an error to call this method after the pipeline has already started.
114 void Start(scoped_ptr<FilterCollection> filter_collection, 129 void Start(scoped_ptr<FilterCollection> filter_collection,
115 const PipelineStatusCB& ended_cb, 130 const PipelineStatusCB& ended_cb,
116 const PipelineStatusCB& error_cb, 131 const PipelineStatusCB& error_cb,
117 const PipelineStatusCB& start_cb); 132 const PipelineStatusCB& seek_cb,
133 const ReadyStateCB& ready_state_cb);
118 134
119 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline 135 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline
120 // teardown has completed. 136 // teardown has completed.
121 // 137 //
122 // Stop() must complete before destroying the pipeline. It it permissible to 138 // Stop() must complete before destroying the pipeline. It it permissible to
123 // call Stop() at any point during the lifetime of the pipeline. 139 // call Stop() at any point during the lifetime of the pipeline.
124 void Stop(const base::Closure& stop_cb); 140 void Stop(const base::Closure& stop_cb);
125 141
126 // Attempt to seek to the position specified by time. |seek_cb| will be 142 // Attempt to seek to the position specified by time. |seek_cb| will be
127 // executed when the all filters in the pipeline have processed the seek. 143 // executed when the all filters in the pipeline have processed the seek.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 242
227 // Updates |state_|. All state transitions should use this call. 243 // Updates |state_|. All state transitions should use this call.
228 void SetState(State next_state); 244 void SetState(State next_state);
229 245
230 // Simple method used to make sure the pipeline is running normally. 246 // Simple method used to make sure the pipeline is running normally.
231 bool IsPipelineOk(); 247 bool IsPipelineOk();
232 248
233 // Helper method to tell whether we are in transition to seek state. 249 // Helper method to tell whether we are in transition to seek state.
234 bool IsPipelineSeeking(); 250 bool IsPipelineSeeking();
235 251
236 // Helper method to execute callback from Start() and reset 252 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_|
237 // |filter_collection_|. Called when initialization completes 253 // and |seek_pending_|.
238 // normally or when pipeline is stopped or error occurs during 254 void FinishSeek();
239 // initialization.
240 void FinishInitialization();
241 255
242 // Returns true if the given state is one that transitions to a new state 256 // Returns true if the given state is one that transitions to a new state
243 // after iterating through each filter. 257 // after iterating through each filter.
244 static bool TransientState(State state); 258 static bool TransientState(State state);
245 259
246 // Given the current state, returns the next state. 260 // Given the current state, returns the next state.
247 State FindNextState(State current); 261 State FindNextState(State current);
248 262
249 // DataSourceHost (by way of DemuxerHost) implementation. 263 // DataSourceHost (by way of DemuxerHost) implementation.
250 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; 264 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 303
290 // Callback executed by video renderer to update clock time. 304 // Callback executed by video renderer to update clock time.
291 void OnVideoTimeUpdate(base::TimeDelta max_time); 305 void OnVideoTimeUpdate(base::TimeDelta max_time);
292 306
293 // The following "task" methods correspond to the public methods, but these 307 // The following "task" methods correspond to the public methods, but these
294 // methods are run as the result of posting a task to the PipelineInternal's 308 // methods are run as the result of posting a task to the PipelineInternal's
295 // message loop. 309 // message loop.
296 void StartTask(scoped_ptr<FilterCollection> filter_collection, 310 void StartTask(scoped_ptr<FilterCollection> filter_collection,
297 const PipelineStatusCB& ended_cb, 311 const PipelineStatusCB& ended_cb,
298 const PipelineStatusCB& error_cb, 312 const PipelineStatusCB& error_cb,
299 const PipelineStatusCB& start_cb); 313 const PipelineStatusCB& seek_cb,
314 const ReadyStateCB& ready_state_cb);
300 315
301 // InitializeTask() performs initialization in multiple passes. It is executed 316 // InitializeTask() performs initialization in multiple passes. It is executed
302 // as a result of calling Start() or InitializationComplete() that advances 317 // as a result of calling Start() or InitializationComplete() that advances
303 // initialization to the next state. It works as a hub of state transition for 318 // initialization to the next state. It works as a hub of state transition for
304 // initialization. One stage communicates its status to the next through 319 // initialization. One stage communicates its status to the next through
305 // |last_stage_status|. 320 // |last_stage_status|.
306 void InitializeTask(PipelineStatus last_stage_status); 321 void InitializeTask(PipelineStatus last_stage_status);
307 322
308 // Stops and destroys all filters, placing the pipeline in the kStopped state. 323 // Stops and destroys all filters, placing the pipeline in the kStopped state.
309 void StopTask(const base::Closure& stop_cb); 324 void StopTask(const base::Closure& stop_cb);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bool audio_disabled_; 502 bool audio_disabled_;
488 503
489 // Filter collection as passed in by Start(). 504 // Filter collection as passed in by Start().
490 scoped_ptr<FilterCollection> filter_collection_; 505 scoped_ptr<FilterCollection> filter_collection_;
491 506
492 // Callbacks for various pipeline operations. 507 // Callbacks for various pipeline operations.
493 PipelineStatusCB seek_cb_; 508 PipelineStatusCB seek_cb_;
494 base::Closure stop_cb_; 509 base::Closure stop_cb_;
495 PipelineStatusCB ended_cb_; 510 PipelineStatusCB ended_cb_;
496 PipelineStatusCB error_cb_; 511 PipelineStatusCB error_cb_;
512 ReadyStateCB ready_state_cb_;
497 513
498 // Audio renderer reference used for setting the volume and determining 514 // Audio renderer reference used for setting the volume and determining
499 // when playback has finished. 515 // when playback has finished.
500 scoped_refptr<AudioRenderer> audio_renderer_; 516 scoped_refptr<AudioRenderer> audio_renderer_;
501 517
502 // Video Renderer reference used for determining when playback has finished 518 // Video Renderer reference used for determining when playback has finished
503 // and for signalling imminent shutdown. 519 // and for signalling imminent shutdown.
504 // The signalling imminent shutdown is a HACK necessary because 520 // The signalling imminent shutdown is a HACK necessary because
505 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage 521 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage
506 // until PipelineImpl::Stop() calls its callback. 522 // until PipelineImpl::Stop() calls its callback.
(...skipping 15 matching lines...) Expand all
522 base::Time creation_time_; 538 base::Time creation_time_;
523 539
524 scoped_ptr<SerialRunner> pending_callbacks_; 540 scoped_ptr<SerialRunner> pending_callbacks_;
525 541
526 DISALLOW_COPY_AND_ASSIGN(Pipeline); 542 DISALLOW_COPY_AND_ASSIGN(Pipeline);
527 }; 543 };
528 544
529 } // namespace media 545 } // namespace media
530 546
531 #endif // MEDIA_BASE_PIPELINE_H_ 547 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/pipeline.cc » ('j') | media/base/pipeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698