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