| 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> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // from any state. If Stop() is ever called, this object will transition to | 62 // from any state. If Stop() is ever called, this object will transition to |
| 63 // "Stopped" state. | 63 // "Stopped" state. |
| 64 class PipelineImpl : public Pipeline, public FilterHost { | 64 class PipelineImpl : public Pipeline, public FilterHost { |
| 65 public: | 65 public: |
| 66 explicit PipelineImpl(MessageLoop* message_loop); | 66 explicit PipelineImpl(MessageLoop* message_loop); |
| 67 | 67 |
| 68 // Pipeline implementation. | 68 // Pipeline implementation. |
| 69 virtual void Init(PipelineCallback* ended_callback, | 69 virtual void Init(PipelineCallback* ended_callback, |
| 70 PipelineCallback* error_callback, | 70 PipelineCallback* error_callback, |
| 71 PipelineCallback* network_callback); | 71 PipelineCallback* network_callback); |
| 72 virtual bool Start(MediaFilterCollection* filter_collection, | 72 virtual bool Start(FilterCollection* filter_collection, |
| 73 const std::string& uri, | 73 const std::string& uri, |
| 74 PipelineCallback* start_callback); | 74 PipelineCallback* start_callback); |
| 75 virtual void Stop(PipelineCallback* stop_callback); | 75 virtual void Stop(PipelineCallback* stop_callback); |
| 76 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback); | 76 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback); |
| 77 virtual bool IsRunning() const; | 77 virtual bool IsRunning() const; |
| 78 virtual bool IsInitialized() const; | 78 virtual bool IsInitialized() const; |
| 79 virtual bool IsNetworkActive() const; | 79 virtual bool IsNetworkActive() const; |
| 80 virtual bool IsRendered(const std::string& major_mime_type) const; | 80 virtual bool IsRendered(const std::string& major_mime_type) const; |
| 81 virtual float GetPlaybackRate() const; | 81 virtual float GetPlaybackRate() const; |
| 82 virtual void SetPlaybackRate(float playback_rate); | 82 virtual void SetPlaybackRate(float playback_rate); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Callback executed by filters upon completing initialization. | 178 // Callback executed by filters upon completing initialization. |
| 179 void OnFilterInitialize(); | 179 void OnFilterInitialize(); |
| 180 | 180 |
| 181 // Callback executed by filters upon completing Play(), Pause(), Seek(), | 181 // Callback executed by filters upon completing Play(), Pause(), Seek(), |
| 182 // or Stop(). | 182 // or Stop(). |
| 183 void OnFilterStateTransition(); | 183 void OnFilterStateTransition(); |
| 184 | 184 |
| 185 // The following "task" methods correspond to the public methods, but these | 185 // The following "task" methods correspond to the public methods, but these |
| 186 // methods are run as the result of posting a task to the PipelineInternal's | 186 // methods are run as the result of posting a task to the PipelineInternal's |
| 187 // message loop. | 187 // message loop. |
| 188 void StartTask(MediaFilterCollection* filter_collection, | 188 void StartTask(FilterCollection* filter_collection, |
| 189 const std::string& url, | 189 const std::string& url, |
| 190 PipelineCallback* start_callback); | 190 PipelineCallback* start_callback); |
| 191 | 191 |
| 192 // InitializeTask() performs initialization in multiple passes. It is executed | 192 // InitializeTask() performs initialization in multiple passes. It is executed |
| 193 // as a result of calling Start() or InitializationComplete() that advances | 193 // as a result of calling Start() or InitializationComplete() that advances |
| 194 // initialization to the next state. It works as a hub of state transition for | 194 // initialization to the next state. It works as a hub of state transition for |
| 195 // initialization. | 195 // initialization. |
| 196 void InitializeTask(); | 196 void InitializeTask(); |
| 197 | 197 |
| 198 // Stops and destroys all filters, placing the pipeline in the kStopped state. | 198 // Stops and destroys all filters, placing the pipeline in the kStopped state. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 227 // appropriate callbacks, and setting the appropriate pipeline state | 227 // appropriate callbacks, and setting the appropriate pipeline state |
| 228 // depending on whether we performing Stop() or SetError(). | 228 // depending on whether we performing Stop() or SetError(). |
| 229 // Called after all filters have been stopped. | 229 // Called after all filters have been stopped. |
| 230 void FinishDestroyingFiltersTask(); | 230 void FinishDestroyingFiltersTask(); |
| 231 | 231 |
| 232 // Internal methods used in the implementation of the pipeline thread. All | 232 // Internal methods used in the implementation of the pipeline thread. All |
| 233 // of these methods are only called on the pipeline thread. | 233 // of these methods are only called on the pipeline thread. |
| 234 | 234 |
| 235 // PrepareFilter() creates the filter's thread and injects a FilterHost and | 235 // PrepareFilter() creates the filter's thread and injects a FilterHost and |
| 236 // MessageLoop. | 236 // MessageLoop. |
| 237 bool PrepareFilter(scoped_refptr<MediaFilter> filter); | 237 bool PrepareFilter(scoped_refptr<Filter> filter); |
| 238 | 238 |
| 239 // The following initialize methods are used to select a specific type of | 239 // The following initialize methods are used to select a specific type of |
| 240 // MediaFilter object from MediaFilterCollection and initialize it | 240 // Filter object from FilterCollection and initialize it asynchronously. |
| 241 // asynchronously. | |
| 242 void InitializeDataSource(); | 241 void InitializeDataSource(); |
| 243 void InitializeDemuxer(const scoped_refptr<DataSource>& data_source); | 242 void InitializeDemuxer(const scoped_refptr<DataSource>& data_source); |
| 244 | 243 |
| 245 // Returns true if the asynchronous action of creating decoder has started. | 244 // Returns true if the asynchronous action of creating decoder has started. |
| 246 // Returns false if this method did nothing because the corresponding | 245 // Returns false if this method did nothing because the corresponding |
| 247 // audio/video stream does not exist. | 246 // audio/video stream does not exist. |
| 248 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); | 247 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); |
| 249 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); | 248 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); |
| 250 | 249 |
| 251 // Initializes a renderer and connects it with decoder. Returns true if the | 250 // Initializes a renderer and connects it with decoder. Returns true if the |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 369 |
| 371 // Set to true in DisableAudioRendererTask(). | 370 // Set to true in DisableAudioRendererTask(). |
| 372 bool audio_disabled_; | 371 bool audio_disabled_; |
| 373 | 372 |
| 374 // Keep track of the maximum buffered position so the buffering appears | 373 // Keep track of the maximum buffered position so the buffering appears |
| 375 // smooth. | 374 // smooth. |
| 376 // TODO(vrk): This is a hack. | 375 // TODO(vrk): This is a hack. |
| 377 base::TimeDelta max_buffered_time_; | 376 base::TimeDelta max_buffered_time_; |
| 378 | 377 |
| 379 // Filter collection as passed in by Start(). | 378 // Filter collection as passed in by Start(). |
| 380 scoped_ptr<MediaFilterCollection> filter_collection_; | 379 scoped_ptr<FilterCollection> filter_collection_; |
| 381 | 380 |
| 382 // URL for the data source as passed in by Start(). | 381 // URL for the data source as passed in by Start(). |
| 383 std::string url_; | 382 std::string url_; |
| 384 | 383 |
| 385 // Callbacks for various pipeline operations. | 384 // Callbacks for various pipeline operations. |
| 386 scoped_ptr<PipelineCallback> seek_callback_; | 385 scoped_ptr<PipelineCallback> seek_callback_; |
| 387 scoped_ptr<PipelineCallback> stop_callback_; | 386 scoped_ptr<PipelineCallback> stop_callback_; |
| 388 scoped_ptr<PipelineCallback> ended_callback_; | 387 scoped_ptr<PipelineCallback> ended_callback_; |
| 389 scoped_ptr<PipelineCallback> error_callback_; | 388 scoped_ptr<PipelineCallback> error_callback_; |
| 390 scoped_ptr<PipelineCallback> network_callback_; | 389 scoped_ptr<PipelineCallback> network_callback_; |
| 391 | 390 |
| 392 // Vector of our filters and map maintaining the relationship between the | 391 // Vector of our filters and map maintaining the relationship between the |
| 393 // FilterType and the filter itself. | 392 // FilterType and the filter itself. |
| 394 typedef std::vector<scoped_refptr<MediaFilter> > FilterVector; | 393 typedef std::vector<scoped_refptr<Filter> > FilterVector; |
| 395 FilterVector filters_; | 394 FilterVector filters_; |
| 396 | 395 |
| 397 // Renderer references used for setting the volume and determining | 396 // Renderer references used for setting the volume and determining |
| 398 // when playback has finished. | 397 // when playback has finished. |
| 399 scoped_refptr<AudioRenderer> audio_renderer_; | 398 scoped_refptr<AudioRenderer> audio_renderer_; |
| 400 scoped_refptr<VideoRenderer> video_renderer_; | 399 scoped_refptr<VideoRenderer> video_renderer_; |
| 401 | 400 |
| 402 // Vector of threads owned by the pipeline and being used by filters. | 401 // Vector of threads owned by the pipeline and being used by filters. |
| 403 typedef std::vector<base::Thread*> FilterThreadVector; | 402 typedef std::vector<base::Thread*> FilterThreadVector; |
| 404 FilterThreadVector filter_threads_; | 403 FilterThreadVector filter_threads_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 417 | 416 |
| 418 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); | 417 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); |
| 419 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, AudioStreamShorterThanVideo); | 418 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, AudioStreamShorterThanVideo); |
| 420 | 419 |
| 421 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 420 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 422 }; | 421 }; |
| 423 | 422 |
| 424 } // namespace media | 423 } // namespace media |
| 425 | 424 |
| 426 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 425 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |