OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Implementation of Pipeline. | 5 // Implementation of Pipeline. |
6 | 6 |
7 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ | 7 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ |
8 #define MEDIA_BASE_PIPELINE_IMPL_H_ | 8 #define MEDIA_BASE_PIPELINE_IMPL_H_ |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
18 #include "base/thread.h" | 18 #include "base/thread.h" |
19 #include "base/time.h" | 19 #include "base/time.h" |
20 #include "media/base/clock.h" | 20 #include "media/base/clock.h" |
21 #include "media/base/composite_filter.h" | |
22 #include "media/base/filter_host.h" | 21 #include "media/base/filter_host.h" |
23 #include "media/base/pipeline.h" | 22 #include "media/base/pipeline.h" |
24 | 23 |
25 namespace media { | 24 namespace media { |
26 | 25 |
27 | 26 |
28 // PipelineImpl runs the media pipeline. Filters are created and called on the | 27 // PipelineImpl runs the media pipeline. Filters are created and called on the |
29 // message loop injected into this object. PipelineImpl works like a state | 28 // message loop injected into this object. PipelineImpl works like a state |
30 // machine to perform asynchronous initialization, pausing, seeking and playing. | 29 // machine to perform asynchronous initialization, pausing, seeking and playing. |
31 // | 30 // |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 kStopped, | 112 kStopped, |
114 kError, | 113 kError, |
115 }; | 114 }; |
116 | 115 |
117 virtual ~PipelineImpl(); | 116 virtual ~PipelineImpl(); |
118 | 117 |
119 // Reset the state of the pipeline object to the initial state. This method | 118 // Reset the state of the pipeline object to the initial state. This method |
120 // is used by the constructor, and the Stop() method. | 119 // is used by the constructor, and the Stop() method. |
121 void ResetState(); | 120 void ResetState(); |
122 | 121 |
123 // Updates |state_|. All state transitions should use this call. | |
124 void set_state(State next_state); | |
125 | |
126 // Simple method used to make sure the pipeline is running normally. | 122 // Simple method used to make sure the pipeline is running normally. |
127 bool IsPipelineOk(); | 123 bool IsPipelineOk(); |
128 | 124 |
129 // Helper method to tell whether we are in the state of initializing. | 125 // Helper method to tell whether we are in the state of initializing. |
130 bool IsPipelineInitializing(); | 126 bool IsPipelineInitializing(); |
131 | 127 |
132 // Helper method to tell whether we are stopped or in error. | 128 // Helper method to tell whether we are stopped or in error. |
133 bool IsPipelineStopped(); | 129 bool IsPipelineStopped(); |
134 | 130 |
135 // Helper method to tell whether we are in transition to stop state. | 131 // Helper method to tell whether we are in transition to stop state. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Vector of major mime types that have been rendered by this pipeline. | 346 // Vector of major mime types that have been rendered by this pipeline. |
351 typedef std::set<std::string> RenderedMimeTypesSet; | 347 typedef std::set<std::string> RenderedMimeTypesSet; |
352 RenderedMimeTypesSet rendered_mime_types_; | 348 RenderedMimeTypesSet rendered_mime_types_; |
353 | 349 |
354 // The following data members are only accessed by tasks posted to | 350 // The following data members are only accessed by tasks posted to |
355 // |message_loop_|. | 351 // |message_loop_|. |
356 | 352 |
357 // Member that tracks the current state. | 353 // Member that tracks the current state. |
358 State state_; | 354 State state_; |
359 | 355 |
| 356 // For kPausing, kSeeking and kStarting, we need to track how many filters |
| 357 // have completed transitioning to the destination state. When |
| 358 // |remaining_transitions_| reaches 0 the pipeline can transition out |
| 359 // of the current state. |
| 360 size_t remaining_transitions_; |
| 361 |
360 // For kSeeking we need to remember where we're seeking between filter | 362 // For kSeeking we need to remember where we're seeking between filter |
361 // replies. | 363 // replies. |
362 base::TimeDelta seek_timestamp_; | 364 base::TimeDelta seek_timestamp_; |
363 | 365 |
364 // For GetCurrentBytes()/SetCurrentBytes() we need to know what byte we are | 366 // For GetCurrentBytes()/SetCurrentBytes() we need to know what byte we are |
365 // currently reading. | 367 // currently reading. |
366 int64 current_bytes_; | 368 int64 current_bytes_; |
367 | 369 |
368 // Set to true in DisableAudioRendererTask(). | 370 // Set to true in DisableAudioRendererTask(). |
369 bool audio_disabled_; | 371 bool audio_disabled_; |
370 | 372 |
371 // Keep track of the maximum buffered position so the buffering appears | 373 // Keep track of the maximum buffered position so the buffering appears |
372 // smooth. | 374 // smooth. |
373 // TODO(vrk): This is a hack. | 375 // TODO(vrk): This is a hack. |
374 base::TimeDelta max_buffered_time_; | 376 base::TimeDelta max_buffered_time_; |
375 | 377 |
376 // Filter collection as passed in by Start(). | 378 // Filter collection as passed in by Start(). |
377 scoped_ptr<FilterCollection> filter_collection_; | 379 scoped_ptr<FilterCollection> filter_collection_; |
378 | 380 |
379 // URL for the data source as passed in by Start(). | 381 // URL for the data source as passed in by Start(). |
380 std::string url_; | 382 std::string url_; |
381 | 383 |
382 // Callbacks for various pipeline operations. | 384 // Callbacks for various pipeline operations. |
383 scoped_ptr<PipelineCallback> seek_callback_; | 385 scoped_ptr<PipelineCallback> seek_callback_; |
384 scoped_ptr<PipelineCallback> stop_callback_; | 386 scoped_ptr<PipelineCallback> stop_callback_; |
385 scoped_ptr<PipelineCallback> ended_callback_; | 387 scoped_ptr<PipelineCallback> ended_callback_; |
386 scoped_ptr<PipelineCallback> error_callback_; | 388 scoped_ptr<PipelineCallback> error_callback_; |
387 scoped_ptr<PipelineCallback> network_callback_; | 389 scoped_ptr<PipelineCallback> network_callback_; |
388 | 390 |
389 // Reference to the filter(s) that constitute the pipeline. | 391 // Vector of our filters and map maintaining the relationship between the |
390 scoped_refptr<Filter> pipeline_filter_; | 392 // FilterType and the filter itself. |
| 393 typedef std::vector<scoped_refptr<Filter> > FilterVector; |
| 394 FilterVector filters_; |
391 | 395 |
392 // Renderer references used for setting the volume and determining | 396 // Renderer references used for setting the volume and determining |
393 // when playback has finished. | 397 // when playback has finished. |
394 scoped_refptr<AudioRenderer> audio_renderer_; | 398 scoped_refptr<AudioRenderer> audio_renderer_; |
395 scoped_refptr<VideoRenderer> video_renderer_; | 399 scoped_refptr<VideoRenderer> video_renderer_; |
396 | 400 |
| 401 // Vector of threads owned by the pipeline and being used by filters. |
| 402 typedef std::vector<base::Thread*> FilterThreadVector; |
| 403 FilterThreadVector filter_threads_; |
| 404 |
397 // Helper class that stores filter references during pipeline | 405 // Helper class that stores filter references during pipeline |
398 // initialization. | 406 // initialization. |
399 class PipelineInitState; | 407 class PipelineInitState; |
400 scoped_ptr<PipelineInitState> pipeline_init_state_; | 408 scoped_ptr<PipelineInitState> pipeline_init_state_; |
401 | 409 |
402 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); | 410 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); |
403 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, AudioStreamShorterThanVideo); | 411 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, AudioStreamShorterThanVideo); |
404 | 412 |
405 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 413 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
406 }; | 414 }; |
407 | 415 |
408 } // namespace media | 416 } // namespace media |
409 | 417 |
410 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 418 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
OLD | NEW |