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 12 matching lines...) Expand all Loading... | |
| 23 #include "media/base/surface_manager.h" | 23 #include "media/base/surface_manager.h" |
| 24 #include "media/base/text_track.h" | 24 #include "media/base/text_track.h" |
| 25 #include "media/blink/buffered_data_source.h" | 25 #include "media/blink/buffered_data_source.h" |
| 26 #include "media/blink/buffered_data_source_host_impl.h" | 26 #include "media/blink/buffered_data_source_host_impl.h" |
| 27 #include "media/blink/media_blink_export.h" | 27 #include "media/blink/media_blink_export.h" |
| 28 #include "media/blink/multibuffer_data_source.h" | 28 #include "media/blink/multibuffer_data_source.h" |
| 29 #include "media/blink/video_frame_compositor.h" | 29 #include "media/blink/video_frame_compositor.h" |
| 30 #include "media/blink/webmediaplayer_delegate.h" | 30 #include "media/blink/webmediaplayer_delegate.h" |
| 31 #include "media/blink/webmediaplayer_params.h" | 31 #include "media/blink/webmediaplayer_params.h" |
| 32 #include "media/blink/webmediaplayer_util.h" | 32 #include "media/blink/webmediaplayer_util.h" |
| 33 #include "media/filters/pipeline_controller.h" | |
| 33 #include "media/renderers/skcanvas_video_renderer.h" | 34 #include "media/renderers/skcanvas_video_renderer.h" |
| 34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" | 35 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" |
| 35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 36 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 37 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
| 37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 38 | 39 |
| 39 #if defined(OS_ANDROID) // WMPI_CAST | 40 #if defined(OS_ANDROID) // WMPI_CAST |
| 40 // Delete this file when WMPI_CAST is no longer needed. | 41 // Delete this file when WMPI_CAST is no longer needed. |
| 41 #include "media/blink/webmediaplayer_cast_android.h" | 42 #include "media/blink/webmediaplayer_cast_android.h" |
| 42 #endif | 43 #endif |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 | 159 |
| 159 blink::WebAudioSourceProvider* audioSourceProvider() override; | 160 blink::WebAudioSourceProvider* audioSourceProvider() override; |
| 160 | 161 |
| 161 void setContentDecryptionModule( | 162 void setContentDecryptionModule( |
| 162 blink::WebContentDecryptionModule* cdm, | 163 blink::WebContentDecryptionModule* cdm, |
| 163 blink::WebContentDecryptionModuleResult result) override; | 164 blink::WebContentDecryptionModuleResult result) override; |
| 164 | 165 |
| 165 void enteredFullscreen() override; | 166 void enteredFullscreen() override; |
| 166 void exitedFullscreen() override; | 167 void exitedFullscreen() override; |
| 167 | 168 |
| 168 void OnPipelineSeeked(bool time_changed, PipelineStatus status); | |
| 169 void OnPipelineSuspended(PipelineStatus status); | |
| 170 void OnPipelineEnded(); | |
| 171 void OnPipelineError(PipelineStatus error); | |
| 172 void OnPipelineMetadata(PipelineMetadata metadata); | |
| 173 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | |
| 174 void OnDemuxerOpened(); | |
| 175 void OnAddTextTrack(const TextTrackConfig& config, | |
| 176 const AddTextTrackDoneCB& done_cb); | |
| 177 | |
| 178 // WebMediaPlayerDelegate::Observer implementation. | 169 // WebMediaPlayerDelegate::Observer implementation. |
| 179 void OnHidden(bool must_suspend) override; | 170 void OnHidden(bool must_suspend) override; |
| 180 void OnShown() override; | 171 void OnShown() override; |
| 181 void OnPlay() override; | 172 void OnPlay() override; |
| 182 void OnPause() override; | 173 void OnPause() override; |
| 183 void OnVolumeMultiplierUpdate(double multiplier) override; | 174 void OnVolumeMultiplierUpdate(double multiplier) override; |
| 184 | 175 |
| 185 #if defined(OS_ANDROID) // WMPI_CAST | 176 #if defined(OS_ANDROID) // WMPI_CAST |
| 186 bool isRemote() const override; | 177 bool isRemote() const override; |
| 187 void requestRemotePlayback() override; | 178 void requestRemotePlayback() override; |
| 188 void requestRemotePlaybackControl() override; | 179 void requestRemotePlaybackControl() override; |
| 189 | 180 |
| 190 void SetMediaPlayerManager( | 181 void SetMediaPlayerManager( |
| 191 RendererMediaPlayerManagerInterface* media_player_manager); | 182 RendererMediaPlayerManagerInterface* media_player_manager); |
| 192 void OnRemotePlaybackEnded(); | 183 void OnRemotePlaybackEnded(); |
| 193 void OnDisconnectedFromRemoteDevice(double t); | 184 void OnDisconnectedFromRemoteDevice(double t); |
| 194 void SuspendForRemote(); | 185 void SuspendForRemote(); |
| 195 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, | 186 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, |
| 196 PipelineStatus status); | 187 PipelineStatus status); |
| 197 gfx::Size GetCanvasSize() const; | 188 gfx::Size GetCanvasSize() const; |
| 198 void SetDeviceScaleFactor(float scale_factor); | 189 void SetDeviceScaleFactor(float scale_factor); |
| 199 #endif | 190 #endif |
| 200 | 191 |
| 201 private: | 192 private: |
| 202 // Ask for the pipeline to be suspended, will call Suspend() when ready. | 193 void OnPipelineSeeked(bool time_updated); |
| 203 // (Possibly immediately.) | 194 void OnPipelineSuspended(); |
| 204 void ScheduleSuspend(); | |
| 205 | 195 |
| 206 // Initiate suspending the pipeline. | 196 void OnPipelineEnded(); |
| 207 void Suspend(); | 197 void OnPipelineError(PipelineStatus error); |
| 198 void OnPipelineMetadata(PipelineMetadata metadata); | |
| 199 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | |
| 200 void OnDemuxerOpened(); | |
| 201 void OnAddTextTrack(const TextTrackConfig& config, | |
| 202 const AddTextTrackDoneCB& done_cb); | |
| 208 | 203 |
| 209 // Ask for the pipeline to be resumed, will call Resume() when ready. | 204 // Actually seek. This is a regular seek if |time_updated| is true, and a |
|
DaleCurtis
2016/02/24 01:48:24
It's not clear on why you would call this |time_up
sandersd (OOO until July 31)
2016/02/25 00:16:26
Done.
Would it make sense to plumb this change al
DaleCurtis
2016/02/25 01:58:29
Do renderer's initiate seeks these day? On second
sandersd (OOO until July 31)
2016/02/25 20:33:45
They do, in two cases: On Resume() and when ending
DaleCurtis
2016/02/26 02:54:24
That's not a media::Renderer initiated seek tough.
sandersd (OOO until July 31)
2016/02/26 22:10:48
I believe this was done.
| |
| 210 // (Possibly immediately.) | 205 // renderer-initiated seek otherwise. |
| 211 void ScheduleResume(); | 206 void DoSeek(base::TimeDelta time, bool time_updated); |
| 212 | |
| 213 // Initiate resuming the pipeline. | |
| 214 void Resume(); | |
| 215 | 207 |
| 216 // Ask for the renderer to be restarted (destructed and recreated). | 208 // Ask for the renderer to be restarted (destructed and recreated). |
| 217 void ScheduleRestart(); | 209 void ScheduleRestart(); |
| 218 | 210 |
| 219 // Called after |defer_load_cb_| has decided to allow the load. If | 211 // Called after |defer_load_cb_| has decided to allow the load. If |
| 220 // |defer_load_cb_| is null this is called immediately. | 212 // |defer_load_cb_| is null this is called immediately. |
| 221 void DoLoad(LoadType load_type, | 213 void DoLoad(LoadType load_type, |
| 222 const blink::WebURL& url, | 214 const blink::WebURL& url, |
| 223 CORSMode cors_mode); | 215 CORSMode cors_mode); |
| 224 | 216 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 // is not available. | 257 // is not available. |
| 266 void OnWaitingForDecryptionKey(); | 258 void OnWaitingForDecryptionKey(); |
| 267 | 259 |
| 268 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 260 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
| 269 // Parameter order is reversed for easy binding. | 261 // Parameter order is reversed for easy binding. |
| 270 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 262 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
| 271 | 263 |
| 272 // Called when a CDM has been attached to the |pipeline_|. | 264 // Called when a CDM has been attached to the |pipeline_|. |
| 273 void OnCdmAttached(bool success); | 265 void OnCdmAttached(bool success); |
| 274 | 266 |
| 275 // Updates |paused_time_| to the current media time with consideration for the | |
| 276 // |ended_| state by clamping current time to duration upon |ended_|. | |
| 277 void UpdatePausedTime(); | |
| 278 | |
| 279 // Notifies |delegate_| that playback has started or was paused; also starts | 267 // Notifies |delegate_| that playback has started or was paused; also starts |
| 280 // or stops the memory usage reporting timer respectively. | 268 // or stops the memory usage reporting timer respectively. |
| 281 void NotifyPlaybackStarted(); | 269 void NotifyPlaybackStarted(); |
| 282 void NotifyPlaybackPaused(); | 270 void NotifyPlaybackPaused(); |
| 283 | 271 |
| 284 // Called at low frequency to tell external observers how much memory we're | 272 // Called at low frequency to tell external observers how much memory we're |
| 285 // using for video playback. Called by |memory_usage_reporting_timer_|. | 273 // using for video playback. Called by |memory_usage_reporting_timer_|. |
| 286 // Memory usage reporting is done in two steps, because |demuxer_| must be | 274 // Memory usage reporting is done in two steps, because |demuxer_| must be |
| 287 // accessed on the media thread. | 275 // accessed on the media thread. |
| 288 void ReportMemoryUsage(); | 276 void ReportMemoryUsage(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 302 BufferedDataSource::BufferingStrategy buffering_strategy_; | 290 BufferedDataSource::BufferingStrategy buffering_strategy_; |
| 303 | 291 |
| 304 // Task runner for posting tasks on Chrome's main thread. Also used | 292 // Task runner for posting tasks on Chrome's main thread. Also used |
| 305 // for DCHECKs so methods calls won't execute in the wrong thread. | 293 // for DCHECKs so methods calls won't execute in the wrong thread. |
| 306 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 294 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 307 | 295 |
| 308 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 296 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 309 scoped_refptr<base::TaskRunner> worker_task_runner_; | 297 scoped_refptr<base::TaskRunner> worker_task_runner_; |
| 310 scoped_refptr<MediaLog> media_log_; | 298 scoped_refptr<MediaLog> media_log_; |
| 311 PipelineImpl pipeline_; | 299 PipelineImpl pipeline_; |
| 300 PipelineController pipeline_controller_; | |
| 312 | 301 |
| 313 // The LoadType passed in the |load_type| parameter of the load() call. | 302 // The LoadType passed in the |load_type| parameter of the load() call. |
| 314 LoadType load_type_; | 303 LoadType load_type_; |
| 315 | 304 |
| 316 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). | 305 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). |
| 317 PipelineMetadata pipeline_metadata_; | 306 PipelineMetadata pipeline_metadata_; |
| 318 | 307 |
| 319 // Whether the video is known to be opaque or not. | 308 // Whether the video is known to be opaque or not. |
| 320 bool opaque_; | 309 bool opaque_; |
| 321 | 310 |
| 322 // Playback state. | 311 // Playback state. |
| 323 // | 312 // |
| 324 // TODO(scherkus): we have these because Pipeline favours the simplicity of a | 313 // TODO(scherkus): we have these because Pipeline favours the simplicity of a |
| 325 // single "playback rate" over worrying about paused/stopped etc... It forces | 314 // single "playback rate" over worrying about paused/stopped etc... It forces |
| 326 // all clients to manage the pause+playback rate externally, but is that | 315 // all clients to manage the pause+playback rate externally, but is that |
| 327 // really a bad thing? | 316 // really a bad thing? |
| 328 // | 317 // |
| 329 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want | 318 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want |
| 330 // to hang the render thread during pause(), we record the time at the same | 319 // to hang the render thread during pause(), we record the time at the same |
| 331 // time we pause and then return that value in currentTime(). Otherwise our | 320 // time we pause and then return that value in currentTime(). Otherwise our |
| 332 // clock can creep forward a little bit while the asynchronous | 321 // clock can creep forward a little bit while the asynchronous |
| 333 // SetPlaybackRate(0) is being executed. | 322 // SetPlaybackRate(0) is being executed. |
| 334 double playback_rate_; | 323 double playback_rate_; |
| 324 | |
| 325 // Set while paused. |paused_time_| is only valid when |paused_| is true. | |
| 335 bool paused_; | 326 bool paused_; |
| 336 base::TimeDelta paused_time_; | 327 base::TimeDelta paused_time_; |
| 328 | |
| 329 // Set when starting, seeking, and resuming (all of which require a Pipeline | |
| 330 // seek). |seek_time_| is only valid when |seeking_| is true. | |
| 337 bool seeking_; | 331 bool seeking_; |
| 338 | |
| 339 // Set when seeking (|seeking_| is true) or resuming. | |
| 340 base::TimeDelta seek_time_; | 332 base::TimeDelta seek_time_; |
| 341 | 333 |
| 342 // Set when a suspend is required but another suspend or seek is in progress. | |
| 343 bool pending_suspend_; | |
| 344 | |
| 345 // Set when suspending immediately after a seek. The time change will happen | |
| 346 // after Resume(). | |
| 347 bool pending_time_change_; | |
| 348 | |
| 349 // Set when a resume is required but suspending is in progress. | |
| 350 bool pending_resume_; | |
| 351 | |
| 352 // Set for the entire period between suspend starting and resume completing. | |
| 353 bool suspending_; | |
| 354 | |
| 355 // Set while suspending to detect double-suspend. | |
| 356 bool suspended_; | |
| 357 | |
| 358 // Set while resuming to detect double-resume. | |
| 359 bool resuming_; | |
| 360 | |
| 361 // Set when doing a restart (a suspend and resume in sequence) of the pipeline | 334 // Set when doing a restart (a suspend and resume in sequence) of the pipeline |
| 362 // in order to destruct and reinitialize the decoders. This is separate from | 335 // in order to destruct and reinitialize the decoders. This is separate from |
| 363 // |pending_resume_| and |pending_suspend_| because they can be elided in | 336 // |pending_resume_| and |pending_suspend_| because they can be elided in |
| 364 // certain cases, whereas for a restart they must happen. | 337 // certain cases, whereas for a restart they must happen. |
| 365 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart. | 338 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart. |
| 366 bool pending_suspend_resume_cycle_; | 339 bool pending_suspend_resume_cycle_; |
| 367 | 340 |
| 368 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, | 341 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, |
| 369 // see http://crbug.com/409280 | 342 // see http://crbug.com/409280 |
| 370 bool ended_; | 343 bool ended_; |
| 371 | 344 |
| 372 // Indicates that a seek is queued after the current seek completes or, if the | |
| 373 // pipeline is suspended, after it resumes. Only the last queued seek will | |
| 374 // have any effect. | |
| 375 bool pending_seek_; | |
| 376 | |
| 377 // |pending_seek_time_| is meaningless when |pending_seek_| is false. | |
| 378 base::TimeDelta pending_seek_time_; | |
| 379 | |
| 380 // Tracks whether to issue time changed notifications during buffering state | 345 // Tracks whether to issue time changed notifications during buffering state |
| 381 // changes. | 346 // changes. |
| 382 bool should_notify_time_changed_; | 347 bool should_notify_time_changed_; |
| 383 | 348 |
| 384 bool fullscreen_; | 349 bool fullscreen_; |
| 385 | 350 |
| 386 // Whether the current decoder requires a restart on fullscreen transitions. | 351 // Whether the current decoder requires a restart on fullscreen transitions. |
| 387 bool decoder_requires_restart_for_fullscreen_; | 352 bool decoder_requires_restart_for_fullscreen_; |
| 388 | 353 |
| 389 blink::WebMediaPlayerClient* client_; | 354 blink::WebMediaPlayerClient* client_; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. | 418 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. |
| 454 // This will be null everywhere but Android. | 419 // This will be null everywhere but Android. |
| 455 SurfaceManager* surface_manager_; | 420 SurfaceManager* surface_manager_; |
| 456 | 421 |
| 457 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 422 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
| 458 }; | 423 }; |
| 459 | 424 |
| 460 } // namespace media | 425 } // namespace media |
| 461 | 426 |
| 462 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 427 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
| OLD | NEW |