Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
| 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, | 188 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, |
| 189 PipelineStatus status); | 189 PipelineStatus status); |
| 190 gfx::Size GetCanvasSize() const; | 190 gfx::Size GetCanvasSize() const; |
| 191 void SetDeviceScaleFactor(float scale_factor); | 191 void SetDeviceScaleFactor(float scale_factor); |
| 192 #endif | 192 #endif |
| 193 | 193 |
| 194 // Called from WebMediaPlayerCast. | 194 // Called from WebMediaPlayerCast. |
| 195 // TODO(hubbe): WMPI_CAST make private. | 195 // TODO(hubbe): WMPI_CAST make private. |
| 196 void OnPipelineSeeked(bool time_updated); | 196 void OnPipelineSeeked(bool time_updated); |
| 197 | 197 |
| 198 // Distinct states that |delegate_| can be in. | |
| 199 // TODO(sandersd): This should move into WebMediaPlayerDelegate. | |
| 200 // (Public for testing.) | |
| 201 enum class DelegateState { | |
| 202 GONE, | |
| 203 PLAYING, | |
| 204 PAUSED, | |
| 205 ENDED, | |
| 206 }; | |
| 207 | |
| 208 // Playback state variables computed together in UpdatePlayState(). | |
| 209 // (Public for testing.) | |
| 210 struct PlayState { | |
| 211 DelegateState delegate_state; | |
| 212 bool is_memory_reporting_enabled; | |
| 213 bool is_suspended; | |
| 214 }; | |
| 215 | |
| 198 private: | 216 private: |
| 217 friend class WebMediaPlayerImplTest; | |
| 218 | |
| 199 void OnPipelineSuspended(); | 219 void OnPipelineSuspended(); |
| 200 void OnPipelineResumed(); | |
| 201 void OnPipelineEnded(); | 220 void OnPipelineEnded(); |
| 202 void OnPipelineError(PipelineStatus error); | 221 void OnPipelineError(PipelineStatus error); |
| 203 void OnPipelineMetadata(PipelineMetadata metadata); | 222 void OnPipelineMetadata(PipelineMetadata metadata); |
| 204 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | 223 void OnPipelineBufferingStateChanged(BufferingState buffering_state); |
| 205 void OnDemuxerOpened(); | 224 void OnDemuxerOpened(); |
| 206 void OnAddTextTrack(const TextTrackConfig& config, | 225 void OnAddTextTrack(const TextTrackConfig& config, |
| 207 const AddTextTrackDoneCB& done_cb); | 226 const AddTextTrackDoneCB& done_cb); |
| 208 | 227 |
| 209 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when | 228 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when |
| 210 // |time_updated| is false. | 229 // |time_updated| is false. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 // is not available. | 286 // is not available. |
| 268 void OnWaitingForDecryptionKey(); | 287 void OnWaitingForDecryptionKey(); |
| 269 | 288 |
| 270 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 289 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
| 271 // Parameter order is reversed for easy binding. | 290 // Parameter order is reversed for easy binding. |
| 272 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 291 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
| 273 | 292 |
| 274 // Called when a CDM has been attached to the |pipeline_|. | 293 // Called when a CDM has been attached to the |pipeline_|. |
| 275 void OnCdmAttached(bool success); | 294 void OnCdmAttached(bool success); |
| 276 | 295 |
| 277 // Notifies |delegate_| that playback has started or was paused; also starts | 296 // Inspects the current playback state and: |
| 278 // or stops the memory usage reporting timer respectively. | 297 // - notifies |delegate_|, |
| 279 void NotifyPlaybackStarted(); | 298 // - toggles the memory usage reporting timer, and |
| 280 void NotifyPlaybackPaused(); | 299 // - toggles suspend/resume as necessary. |
| 300 // | |
| 301 // This method should be called any time its dependend values change. These | |
|
DaleCurtis
2016/04/01 18:25:48
Dependent. Instead of trying to enforce this via a
sandersd (OOO until July 31)
2016/04/01 21:22:11
Acknowledged.
| |
| 302 // are: | |
| 303 // - isRemote(), | |
| 304 // - hasVideo(), | |
| 305 // - delegate_->IsHidden(), | |
| 306 // - network_state_, ready_state_, | |
| 307 // - is_idle_, must_suspend_, | |
| 308 // - paused_, ended_, | |
| 309 // - pending_suspend_resume_cycle_. | |
| 310 void UpdatePlayState(); | |
| 311 | |
| 312 // Methods internal to UpdatePlayState(). | |
| 313 PlayState UpdatePlayState_ComputePlayState(bool is_remote, | |
| 314 bool is_backgrounded); | |
| 315 void SetDelegateState(DelegateState new_state); | |
| 316 void SetMemoryReportingState(bool is_memory_reporting_enabled); | |
| 317 void SetSuspendState(bool is_suspended); | |
| 281 | 318 |
| 282 // Called at low frequency to tell external observers how much memory we're | 319 // Called at low frequency to tell external observers how much memory we're |
| 283 // using for video playback. Called by |memory_usage_reporting_timer_|. | 320 // using for video playback. Called by |memory_usage_reporting_timer_|. |
| 284 // Memory usage reporting is done in two steps, because |demuxer_| must be | 321 // Memory usage reporting is done in two steps, because |demuxer_| must be |
| 285 // accessed on the media thread. | 322 // accessed on the media thread. |
| 286 void ReportMemoryUsage(); | 323 void ReportMemoryUsage(); |
| 287 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); | 324 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); |
| 288 | 325 |
| 289 // Indicates if automatic resumption of a suspended playback is allowed. | 326 blink::WebLocalFrame* frame_; |
| 290 bool IsAutomaticResumeAllowed(); | |
| 291 | 327 |
| 292 blink::WebLocalFrame* frame_; | 328 // The playback state last reported to |delegate_|, to avoid setting duplicate |
| 329 // states. (Which can have undesired effects like resetting the idle timer.) | |
| 330 DelegateState delegate_state_; | |
| 331 | |
| 332 // Set when OnSuspendRequested() is called with |must_suspend| unset. | |
| 333 bool is_idle_; | |
| 334 | |
| 335 // Set when OnSuspendRequested() is called with |must_suspend| set. | |
| 336 bool must_suspend_; | |
| 293 | 337 |
| 294 // TODO(hclam): get rid of these members and read from the pipeline directly. | 338 // TODO(hclam): get rid of these members and read from the pipeline directly. |
|
DaleCurtis
2016/04/01 18:25:48
Delete? :)
sandersd (OOO until July 31)
2016/04/01 21:22:11
Done.
| |
| 295 blink::WebMediaPlayer::NetworkState network_state_; | 339 blink::WebMediaPlayer::NetworkState network_state_; |
| 296 blink::WebMediaPlayer::ReadyState ready_state_; | 340 blink::WebMediaPlayer::ReadyState ready_state_; |
| 341 blink::WebMediaPlayer::ReadyState highest_ready_state_; | |
| 297 | 342 |
| 298 // Preload state for when |data_source_| is created after setPreload(). | 343 // Preload state for when |data_source_| is created after setPreload(). |
| 299 BufferedDataSource::Preload preload_; | 344 BufferedDataSource::Preload preload_; |
| 300 | 345 |
| 301 // Buffering strategy for when |data_source_| is created after | 346 // Buffering strategy for when |data_source_| is created after |
| 302 // setBufferingStrategy(). | 347 // setBufferingStrategy(). |
| 303 BufferedDataSource::BufferingStrategy buffering_strategy_; | 348 BufferedDataSource::BufferingStrategy buffering_strategy_; |
| 304 | 349 |
| 305 // Task runner for posting tasks on Chrome's main thread. Also used | 350 // Task runner for posting tasks on Chrome's main thread. Also used |
| 306 // for DCHECKs so methods calls won't execute in the wrong thread. | 351 // for DCHECKs so methods calls won't execute in the wrong thread. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 // started; prevents us from spuriously logging errors that are transient or | 484 // started; prevents us from spuriously logging errors that are transient or |
| 440 // unimportant. | 485 // unimportant. |
| 441 bool suppress_destruction_errors_; | 486 bool suppress_destruction_errors_; |
| 442 | 487 |
| 443 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 488 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
| 444 }; | 489 }; |
| 445 | 490 |
| 446 } // namespace media | 491 } // namespace media |
| 447 | 492 |
| 448 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 493 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
| OLD | NEW |