| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 & PipelineStatusNotification (an async-to-sync | 5 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync |
| 6 // callback adapter). | 6 // callback adapter). |
| 7 | 7 |
| 8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ | 8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ |
| 9 #define MEDIA_BASE_PIPELINE_IMPL_H_ | 9 #define MEDIA_BASE_PIPELINE_IMPL_H_ |
| 10 | 10 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; | 201 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; |
| 202 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; | 202 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; |
| 203 virtual void SetStreaming(bool streamed) OVERRIDE; | 203 virtual void SetStreaming(bool streamed) OVERRIDE; |
| 204 virtual void SetLoaded(bool loaded) OVERRIDE; | 204 virtual void SetLoaded(bool loaded) OVERRIDE; |
| 205 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; | 205 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; |
| 206 virtual void NotifyEnded() OVERRIDE; | 206 virtual void NotifyEnded() OVERRIDE; |
| 207 virtual void DisableAudioRenderer() OVERRIDE; | 207 virtual void DisableAudioRenderer() OVERRIDE; |
| 208 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; | 208 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; |
| 209 virtual int64 GetCurrentReadPosition() OVERRIDE; | 209 virtual int64 GetCurrentReadPosition() OVERRIDE; |
| 210 | 210 |
| 211 // Callback executed by filters upon completing initialization. | 211 // Callbacks executed by filters upon completing initialization. |
| 212 void OnFilterInitialize(); | 212 void OnFilterInitialize(PipelineStatus status); |
| 213 | 213 |
| 214 // Callback executed by filters upon completing Play(), Pause(), or Stop(). | 214 // Callback executed by filters upon completing Play(), Pause(), or Stop(). |
| 215 void OnFilterStateTransition(); | 215 void OnFilterStateTransition(); |
| 216 | 216 |
| 217 // Callback executed by filters upon completing Seek(). | 217 // Callback executed by filters upon completing Seek(). |
| 218 void OnFilterStateTransitionWithStatus(PipelineStatus status); | 218 void OnFilterStateTransitionWithStatus(PipelineStatus status); |
| 219 | 219 |
| 220 // Callback executed by filters when completing teardown operations. | 220 // Callback executed by filters when completing teardown operations. |
| 221 void OnTeardownStateTransition(); | 221 void OnTeardownStateTransition(); |
| 222 | 222 |
| 223 // Callback executed by filters to update statistics. | 223 // Callback executed by filters to update statistics. |
| 224 void OnUpdateStatistics(const PipelineStatistics& stats); | 224 void OnUpdateStatistics(const PipelineStatistics& stats); |
| 225 | 225 |
| 226 // The following "task" methods correspond to the public methods, but these | 226 // The following "task" methods correspond to the public methods, but these |
| 227 // methods are run as the result of posting a task to the PipelineInternal's | 227 // methods are run as the result of posting a task to the PipelineInternal's |
| 228 // message loop. | 228 // message loop. |
| 229 void StartTask(FilterCollection* filter_collection, | 229 void StartTask(FilterCollection* filter_collection, |
| 230 const std::string& url, | 230 const std::string& url, |
| 231 const PipelineStatusCB& start_callback); | 231 const PipelineStatusCB& start_callback); |
| 232 | 232 |
| 233 // InitializeTask() performs initialization in multiple passes. It is executed | 233 // InitializeTask() performs initialization in multiple passes. It is executed |
| 234 // as a result of calling Start() or InitializationComplete() that advances | 234 // as a result of calling Start() or InitializationComplete() that advances |
| 235 // initialization to the next state. It works as a hub of state transition for | 235 // initialization to the next state. It works as a hub of state transition for |
| 236 // initialization. | 236 // initialization. One stage communicates its status to the next through |
| 237 void InitializeTask(); | 237 // |last_stage_status|. |
| 238 void InitializeTask(PipelineStatus last_stage_status); |
| 238 | 239 |
| 239 // Stops and destroys all filters, placing the pipeline in the kStopped state. | 240 // Stops and destroys all filters, placing the pipeline in the kStopped state. |
| 240 void StopTask(const PipelineStatusCB& stop_callback); | 241 void StopTask(const PipelineStatusCB& stop_callback); |
| 241 | 242 |
| 242 // Carries out stopping and destroying all filters, placing the pipeline in | 243 // Carries out stopping and destroying all filters, placing the pipeline in |
| 243 // the kError state. | 244 // the kError state. |
| 244 void ErrorChangedTask(PipelineStatus error); | 245 void ErrorChangedTask(PipelineStatus error); |
| 245 | 246 |
| 246 // Carries out notifying filters that the playback rate has changed. | 247 // Carries out notifying filters that the playback rate has changed. |
| 247 void PlaybackRateChangedTask(float playback_rate); | 248 void PlaybackRateChangedTask(float playback_rate); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // Called after all filters have been stopped. | 280 // Called after all filters have been stopped. |
| 280 void FinishDestroyingFiltersTask(); | 281 void FinishDestroyingFiltersTask(); |
| 281 | 282 |
| 282 // Internal methods used in the implementation of the pipeline thread. All | 283 // Internal methods used in the implementation of the pipeline thread. All |
| 283 // of these methods are only called on the pipeline thread. | 284 // of these methods are only called on the pipeline thread. |
| 284 | 285 |
| 285 // PrepareFilter() creates the filter's thread and injects a FilterHost and | 286 // PrepareFilter() creates the filter's thread and injects a FilterHost and |
| 286 // MessageLoop. | 287 // MessageLoop. |
| 287 bool PrepareFilter(scoped_refptr<Filter> filter); | 288 bool PrepareFilter(scoped_refptr<Filter> filter); |
| 288 | 289 |
| 290 // DiscardFilter() undoes PrepareFilter's work. Returns false in case of |
| 291 // error or unknown |filter|. |
| 292 bool DiscardFilter(scoped_refptr<Filter> filter); |
| 293 |
| 289 // The following initialize methods are used to select a specific type of | 294 // The following initialize methods are used to select a specific type of |
| 290 // Filter object from FilterCollection and initialize it asynchronously. | 295 // Filter object from FilterCollection and initialize it asynchronously. |
| 291 void InitializeDemuxer(); | 296 void InitializeDemuxer(); |
| 292 void OnDemuxerBuilt(PipelineStatus status, Demuxer* demuxer); | 297 void OnDemuxerBuilt(PipelineStatus status, Demuxer* demuxer); |
| 293 | 298 |
| 294 // Returns true if the asynchronous action of creating decoder has started. | 299 // Returns true if the asynchronous action of creating decoder has started. |
| 295 // Returns false if this method did nothing because the corresponding | 300 // Returns false if this method did nothing because the corresponding |
| 296 // audio/video stream does not exist. | 301 // audio/video stream does not exist. |
| 297 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); | 302 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); |
| 298 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); | 303 bool InitializeVideoDecoder(const scoped_refptr<Demuxer>& demuxer); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 bool is_downloading_data_; | 500 bool is_downloading_data_; |
| 496 | 501 |
| 497 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); | 502 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); |
| 498 | 503 |
| 499 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 504 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 500 }; | 505 }; |
| 501 | 506 |
| 502 } // namespace media | 507 } // namespace media |
| 503 | 508 |
| 504 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 509 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |