OLD | NEW |
---|---|
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // from any state. If Stop() is ever called, this object will transition to | 109 // from any state. If Stop() is ever called, this object will transition to |
110 // "Stopped" state. | 110 // "Stopped" state. |
111 class MEDIA_EXPORT Pipeline | 111 class MEDIA_EXPORT Pipeline |
112 : public base::RefCountedThreadSafe<Pipeline>, | 112 : public base::RefCountedThreadSafe<Pipeline>, |
113 public FilterHost, | 113 public FilterHost, |
114 public DemuxerHost { | 114 public DemuxerHost { |
115 public: | 115 public: |
116 // Constructs a media pipeline that will execute on |message_loop|. | 116 // Constructs a media pipeline that will execute on |message_loop|. |
117 Pipeline(MessageLoop* message_loop, MediaLog* media_log); | 117 Pipeline(MessageLoop* message_loop, MediaLog* media_log); |
118 | 118 |
119 // Build a pipeline to render the given URL using the given filter collection | 119 // Build a pipeline to using the given filter collection to construct a filter |
120 // to construct a filter chain. | 120 // chain. |
121 // | 121 // |
122 // Pipeline initialization is an inherently asynchronous process. Clients can | 122 // Pipeline initialization is an inherently asynchronous process. Clients can |
123 // either poll the IsInitialized() method (discouraged) or optionally pass in | 123 // either poll the IsInitialized() method (discouraged) or optionally pass in |
124 // |start_cb|, which will be executed when initialization completes. | 124 // |start_cb|, which will be executed when initialization completes. |
125 // | 125 // |
126 // The following permanent callbacks will be executed as follows: | 126 // The following permanent callbacks will be executed as follows: |
127 // |ended_cb| will be executed whenever the media reaches the end. | 127 // |ended_cb| will be executed whenever the media reaches the end. |
128 // |error_cb_| will be executed whenever an error occurs. | 128 // |error_cb_| will be executed whenever an error occurs. |
129 // |network_cb_| will be executed whenever there's a network activity. | 129 // |network_cb_| will be executed whenever there's a network activity. |
130 // | 130 // |
131 // These callbacks are only executed after Start() has been called and until | 131 // These callbacks are only executed after Start() has been called and until |
132 // Stop() has completed. | 132 // Stop() has completed. |
133 // | 133 // |
134 // It is an error to call this method after the pipeline has already started. | 134 // It is an error to call this method after the pipeline has already started. |
135 // | 135 // |
136 // TODO(scherkus): remove IsInitialized() and force clients to use callbacks. | 136 // TODO(scherkus): remove IsInitialized() and force clients to use callbacks. |
137 void Start(scoped_ptr<FilterCollection> filter_collection, | 137 void Start(scoped_ptr<FilterCollection> filter_collection, |
138 const std::string& url, | |
139 const PipelineStatusCB& ended_cb, | 138 const PipelineStatusCB& ended_cb, |
140 const PipelineStatusCB& error_cb, | 139 const PipelineStatusCB& error_cb, |
141 const NetworkEventCB& network_cb, | 140 const NetworkEventCB& network_cb, |
142 const PipelineStatusCB& start_cb); | 141 const PipelineStatusCB& start_cb); |
143 | 142 |
144 // Asynchronously stops the pipeline and resets it to an uninitialized state. | 143 // Asynchronously stops the pipeline and resets it to an uninitialized state. |
145 // | 144 // |
146 // If provided, |stop_cb| will be executed when the pipeline has been | 145 // If provided, |stop_cb| will be executed when the pipeline has been |
147 // completely torn down and reset to an uninitialized state. It is acceptable | 146 // completely torn down and reset to an uninitialized state. It is acceptable |
148 // to call Start() again once the callback has finished executing. | 147 // to call Start() again once the callback has finished executing. |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 // Callback executed by audio renderer to update clock time. | 340 // Callback executed by audio renderer to update clock time. |
342 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); | 341 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); |
343 | 342 |
344 // Callback executed by video renderer to update clock time. | 343 // Callback executed by video renderer to update clock time. |
345 void OnVideoTimeUpdate(base::TimeDelta max_time); | 344 void OnVideoTimeUpdate(base::TimeDelta max_time); |
346 | 345 |
347 // The following "task" methods correspond to the public methods, but these | 346 // The following "task" methods correspond to the public methods, but these |
348 // methods are run as the result of posting a task to the PipelineInternal's | 347 // methods are run as the result of posting a task to the PipelineInternal's |
349 // message loop. | 348 // message loop. |
350 void StartTask(scoped_ptr<FilterCollection> filter_collection, | 349 void StartTask(scoped_ptr<FilterCollection> filter_collection, |
351 const std::string& url, | |
352 const PipelineStatusCB& ended_cb, | 350 const PipelineStatusCB& ended_cb, |
353 const PipelineStatusCB& error_cb, | 351 const PipelineStatusCB& error_cb, |
354 const NetworkEventCB& network_cb, | 352 const NetworkEventCB& network_cb, |
355 const PipelineStatusCB& start_cb); | 353 const PipelineStatusCB& start_cb); |
356 | 354 |
357 // InitializeTask() performs initialization in multiple passes. It is executed | 355 // InitializeTask() performs initialization in multiple passes. It is executed |
358 // as a result of calling Start() or InitializationComplete() that advances | 356 // as a result of calling Start() or InitializationComplete() that advances |
359 // initialization to the next state. It works as a hub of state transition for | 357 // initialization to the next state. It works as a hub of state transition for |
360 // initialization. One stage communicates its status to the next through | 358 // initialization. One stage communicates its status to the next through |
361 // |last_stage_status|. | 359 // |last_stage_status|. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 void FinishDestroyingFiltersTask(); | 397 void FinishDestroyingFiltersTask(); |
400 | 398 |
401 // Internal methods used in the implementation of the pipeline thread. All | 399 // Internal methods used in the implementation of the pipeline thread. All |
402 // of these methods are only called on the pipeline thread. | 400 // of these methods are only called on the pipeline thread. |
403 | 401 |
404 // PrepareFilter() creates the filter's thread and injects a FilterHost and | 402 // PrepareFilter() creates the filter's thread and injects a FilterHost and |
405 // MessageLoop. | 403 // MessageLoop. |
406 bool PrepareFilter(scoped_refptr<Filter> filter); | 404 bool PrepareFilter(scoped_refptr<Filter> filter); |
407 | 405 |
408 // The following initialize methods are used to select a specific type of | 406 // The following initialize methods are used to select a specific type of |
409 // Filter object from FilterCollection and initialize it asynchronously. | 407 // Filter object from FilterCollection and initialize it asynchronously. |
acolwell GONE FROM CHROMIUM
2012/03/30 21:16:39
nit: s/Filter object/object/ ?
scherkus (not reviewing)
2012/03/30 21:40:45
Done.
| |
410 void InitializeDemuxer(); | 408 void InitializeDemuxer(); |
411 void OnDemuxerBuilt(PipelineStatus status, Demuxer* demuxer); | 409 void OnDemuxerInitialized(PipelineStatus status); |
412 | 410 |
413 // Returns true if the asynchronous action of creating decoder has started. | 411 // Returns true if the asynchronous action of creating decoder has started. |
414 // Returns false if this method did nothing because the corresponding | 412 // Returns false if this method did nothing because the corresponding |
415 // audio/video stream does not exist. | 413 // audio/video stream does not exist. |
416 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); | 414 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); |
417 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); | 415 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); |
418 | 416 |
419 // Initializes a renderer and connects it with decoder. Returns true if the | 417 // Initializes a renderer and connects it with decoder. Returns true if the |
420 // asynchronous action of creating renderer has started. Returns | 418 // asynchronous action of creating renderer has started. Returns |
421 // false if this method did nothing because the corresponding audio/video | 419 // false if this method did nothing because the corresponding audio/video |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 bool audio_disabled_; | 563 bool audio_disabled_; |
566 | 564 |
567 // Keep track of the maximum buffered position so the buffering appears | 565 // Keep track of the maximum buffered position so the buffering appears |
568 // smooth. | 566 // smooth. |
569 // TODO(vrk): This is a hack. | 567 // TODO(vrk): This is a hack. |
570 base::TimeDelta max_buffered_time_; | 568 base::TimeDelta max_buffered_time_; |
571 | 569 |
572 // Filter collection as passed in by Start(). | 570 // Filter collection as passed in by Start(). |
573 scoped_ptr<FilterCollection> filter_collection_; | 571 scoped_ptr<FilterCollection> filter_collection_; |
574 | 572 |
575 // URL for the data source as passed in by Start(). | |
576 std::string url_; | |
577 | |
578 // Callbacks for various pipeline operations. | 573 // Callbacks for various pipeline operations. |
579 PipelineStatusCB seek_cb_; | 574 PipelineStatusCB seek_cb_; |
580 PipelineStatusCB stop_cb_; | 575 PipelineStatusCB stop_cb_; |
581 PipelineStatusCB ended_cb_; | 576 PipelineStatusCB ended_cb_; |
582 PipelineStatusCB error_cb_; | 577 PipelineStatusCB error_cb_; |
583 NetworkEventCB network_cb_; | 578 NetworkEventCB network_cb_; |
584 | 579 |
585 // Reference to the filter(s) that constitute the pipeline. | 580 // Reference to the filter(s) that constitute the pipeline. |
586 scoped_refptr<Filter> pipeline_filter_; | 581 scoped_refptr<Filter> pipeline_filter_; |
587 | 582 |
(...skipping 29 matching lines...) Expand all Loading... | |
617 | 612 |
618 // True if the pipeline is actively downloading bytes, false otherwise. | 613 // True if the pipeline is actively downloading bytes, false otherwise. |
619 bool is_downloading_data_; | 614 bool is_downloading_data_; |
620 | 615 |
621 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 616 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
622 }; | 617 }; |
623 | 618 |
624 } // namespace media | 619 } // namespace media |
625 | 620 |
626 #endif // MEDIA_BASE_PIPELINE_H_ | 621 #endif // MEDIA_BASE_PIPELINE_H_ |
OLD | NEW |