Chromium Code Reviews| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // Carries out notifying filters that the preload value has changed. | 254 // Carries out notifying filters that the preload value has changed. |
| 255 void PreloadChangedTask(Preload preload); | 255 void PreloadChangedTask(Preload preload); |
| 256 | 256 |
| 257 // Carries out notifying filters that we are seeking to a new timestamp. | 257 // Carries out notifying filters that we are seeking to a new timestamp. |
| 258 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_callback); | 258 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_callback); |
| 259 | 259 |
| 260 // Carries out handling a notification from a filter that it has ended. | 260 // Carries out handling a notification from a filter that it has ended. |
| 261 void NotifyEndedTask(); | 261 void NotifyEndedTask(); |
| 262 | 262 |
| 263 // Carries out handling a notification of network event. | 263 // Carries out handling a notification of network event. |
| 264 void NotifyNetworkEventTask(bool is_downloading_data); | 264 void NotifyNetworkEventTask(NetworkEvent type); |
| 265 | 265 |
| 266 // Carries out disabling the audio renderer. | 266 // Carries out disabling the audio renderer. |
| 267 void DisableAudioRendererTask(); | 267 void DisableAudioRendererTask(); |
| 268 | 268 |
| 269 // Carries out advancing to the next filter during Play()/Pause()/Seek(). | 269 // Carries out advancing to the next filter during Play()/Pause()/Seek(). |
| 270 void FilterStateTransitionTask(); | 270 void FilterStateTransitionTask(); |
| 271 | 271 |
| 272 // Carries out advancing to the next teardown operation. | 272 // Carries out advancing to the next teardown operation. |
| 273 void TeardownStateTransitionTask(); | 273 void TeardownStateTransitionTask(); |
| 274 | 274 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 // state first. | 309 // state first. |
| 310 // 2. when pipeline has been initialized, we will first transit to pausing | 310 // 2. when pipeline has been initialized, we will first transit to pausing |
| 311 // => flushing => stopping => stopped state. | 311 // => flushing => stopping => stopped state. |
| 312 // This will remove the race condition during stop between filters. | 312 // This will remove the race condition during stop between filters. |
| 313 void TearDownPipeline(); | 313 void TearDownPipeline(); |
| 314 | 314 |
| 315 // Compute the current time. Assumes that the lock has been acquired by the | 315 // Compute the current time. Assumes that the lock has been acquired by the |
| 316 // caller. | 316 // caller. |
| 317 base::TimeDelta GetCurrentTime_Locked() const; | 317 base::TimeDelta GetCurrentTime_Locked() const; |
| 318 | 318 |
| 319 // Compute the buffered time. Assumes that the lock has been acquired by the | |
| 320 // caller. | |
| 321 base::TimeDelta GetBufferedTime_Locked(); | |
| 322 | |
| 319 // Initiates a Stop() on |demuxer_| & |pipeline_filter_|. |callback| | 323 // Initiates a Stop() on |demuxer_| & |pipeline_filter_|. |callback| |
| 320 // is called once both objects have been stopped. | 324 // is called once both objects have been stopped. |
| 321 void DoStop(const base::Closure& callback); | 325 void DoStop(const base::Closure& callback); |
| 322 | 326 |
| 323 // Called when |demuxer_| has stopped. This method calls Stop() | 327 // Called when |demuxer_| has stopped. This method calls Stop() |
| 324 // on |pipeline_filter_|. | 328 // on |pipeline_filter_|. |
| 325 void OnDemuxerStopDone(const base::Closure& callback); | 329 void OnDemuxerStopDone(const base::Closure& callback); |
| 326 | 330 |
| 327 // Initiates a Seek() on the |demuxer_| & |pipeline_filter_|. | 331 // Initiates a Seek() on the |demuxer_| & |pipeline_filter_|. |
| 328 void DoSeek(base::TimeDelta seek_timestamp); | 332 void DoSeek(base::TimeDelta seek_timestamp); |
| 329 | 333 |
| 330 // Called when |demuxer_| finishes seeking. If seeking was successful, | 334 // Called when |demuxer_| finishes seeking. If seeking was successful, |
| 331 // then Seek() is called on |pipeline_filter_|. | 335 // then Seek() is called on |pipeline_filter_|. |
| 332 void OnDemuxerSeekDone(base::TimeDelta seek_timestamp, | 336 void OnDemuxerSeekDone(base::TimeDelta seek_timestamp, |
| 333 PipelineStatus status); | 337 PipelineStatus status); |
| 334 | 338 |
| 339 // If the media can be played through to the end without pausing for | |
| 340 // buffering, sends a notification saying such. | |
| 341 void NotifyCanPlayThroughIfNeeded(); | |
| 342 | |
| 343 // Returns an approximation of the download speed of the resource loader in | |
|
acolwell GONE FROM CHROMIUM
2011/10/28 18:24:13
Remove "of the resource loader" since that is an i
vrk (LEFT CHROMIUM)
2011/11/01 21:57:34
Done.
| |
| 344 // bytes per second. Returns -1 if an approximation cannot be determined. | |
| 345 // Assumes that the lock has been acquired by the caller. | |
| 346 int ApproximateDownloadRate_Locked(); | |
|
acolwell GONE FROM CHROMIUM
2011/10/28 18:24:13
Might want to change this to ApproximateDownloadBy
vrk (LEFT CHROMIUM)
2011/11/01 21:57:34
That's a good idea. Done.
| |
| 347 | |
| 348 // Returns true when the pipeline believes the media can be played through to | |
| 349 // the end without pausing for buffering; returns false otherwise. | |
| 350 // Assumes that the lock has been acquired by the caller. | |
| 351 bool ShouldNotifyCanPlayThrough_Locked(); | |
| 352 | |
| 335 // Message loop used to execute pipeline tasks. | 353 // Message loop used to execute pipeline tasks. |
| 336 MessageLoop* message_loop_; | 354 MessageLoop* message_loop_; |
| 337 | 355 |
| 338 // MediaLog to which to log events. | 356 // MediaLog to which to log events. |
| 339 scoped_refptr<MediaLog> media_log_; | 357 scoped_refptr<MediaLog> media_log_; |
| 340 | 358 |
| 341 // Lock used to serialize access for the following data members. | 359 // Lock used to serialize access for the following data members. |
| 342 mutable base::Lock lock_; | 360 mutable base::Lock lock_; |
| 343 | 361 |
| 344 // Whether or not the pipeline is running. | 362 // Whether or not the pipeline is running. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 scoped_refptr<Demuxer> demuxer_; | 485 scoped_refptr<Demuxer> demuxer_; |
| 468 | 486 |
| 469 // Helper class that stores filter references during pipeline | 487 // Helper class that stores filter references during pipeline |
| 470 // initialization. | 488 // initialization. |
| 471 class PipelineInitState; | 489 class PipelineInitState; |
| 472 scoped_ptr<PipelineInitState> pipeline_init_state_; | 490 scoped_ptr<PipelineInitState> pipeline_init_state_; |
| 473 | 491 |
| 474 // Statistics. | 492 // Statistics. |
| 475 PipelineStatistics statistics_; | 493 PipelineStatistics statistics_; |
| 476 | 494 |
| 495 // Number of bytes downloaded since download began. Is reset every time | |
| 496 // download continues from a previous defer. Used to approximate download | |
| 497 // speed. | |
| 498 unsigned long long starting_bytes_loaded_; | |
|
acolwell GONE FROM CHROMIUM
2011/10/28 18:24:13
how about making this int64
vrk (LEFT CHROMIUM)
2011/11/01 21:57:34
Done.
| |
| 499 | |
| 500 // Time at which download began. Is reset every time download continues | |
| 501 // from a previous defer. Used to approximate download speed. | |
| 502 base::Time starting_time_; | |
| 503 | |
| 504 // Indicates whether the pipeline has sent a notification to its client that | |
| 505 // the media can play through to the end. | |
| 506 bool has_notified_can_play_through_; | |
| 507 | |
| 508 // True if the pipeline is actively downloading bytes, false otherwise. | |
| 509 bool is_downloading_data_; | |
| 510 | |
| 511 // An approximation of the download speed in bytes per second. -1 means the | |
| 512 // download speed is unknown. | |
| 513 int last_approximate_download_rate_; | |
| 514 | |
| 477 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); | 515 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); |
| 478 | 516 |
| 479 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 517 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 480 }; | 518 }; |
| 481 | 519 |
| 482 } // namespace media | 520 } // namespace media |
| 483 | 521 |
| 484 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 522 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |