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 14 matching lines...) Expand all Loading... | |
25 #include "media/base/text_track.h" | 25 #include "media/base/text_track.h" |
26 #include "media/blink/buffered_data_source.h" | 26 #include "media/blink/buffered_data_source.h" |
27 #include "media/blink/buffered_data_source_host_impl.h" | 27 #include "media/blink/buffered_data_source_host_impl.h" |
28 #include "media/blink/encrypted_media_player_support.h" | 28 #include "media/blink/encrypted_media_player_support.h" |
29 #include "media/blink/media_blink_export.h" | 29 #include "media/blink/media_blink_export.h" |
30 #include "media/blink/multibuffer_data_source.h" | 30 #include "media/blink/multibuffer_data_source.h" |
31 #include "media/blink/video_frame_compositor.h" | 31 #include "media/blink/video_frame_compositor.h" |
32 #include "media/blink/webmediaplayer_delegate.h" | 32 #include "media/blink/webmediaplayer_delegate.h" |
33 #include "media/blink/webmediaplayer_params.h" | 33 #include "media/blink/webmediaplayer_params.h" |
34 #include "media/blink/webmediaplayer_util.h" | 34 #include "media/blink/webmediaplayer_util.h" |
35 #include "media/filters/pipeline_controller.h" | |
35 #include "media/renderers/skcanvas_video_renderer.h" | 36 #include "media/renderers/skcanvas_video_renderer.h" |
36 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" | 37 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" |
37 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 38 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
38 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 39 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
39 #include "url/gurl.h" | 40 #include "url/gurl.h" |
40 | 41 |
41 #if defined(OS_ANDROID) // WMPI_CAST | 42 #if defined(OS_ANDROID) // WMPI_CAST |
42 // Delete this file when WMPI_CAST is no longer needed. | 43 // Delete this file when WMPI_CAST is no longer needed. |
43 #include "media/blink/webmediaplayer_cast_android.h" | 44 #include "media/blink/webmediaplayer_cast_android.h" |
44 #endif | 45 #endif |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 const blink::WebString& key_system, | 178 const blink::WebString& key_system, |
178 const blink::WebString& session_id) override; | 179 const blink::WebString& session_id) override; |
179 | 180 |
180 void setContentDecryptionModule( | 181 void setContentDecryptionModule( |
181 blink::WebContentDecryptionModule* cdm, | 182 blink::WebContentDecryptionModule* cdm, |
182 blink::WebContentDecryptionModuleResult result) override; | 183 blink::WebContentDecryptionModuleResult result) override; |
183 | 184 |
184 void enteredFullscreen() override; | 185 void enteredFullscreen() override; |
185 void exitedFullscreen() override; | 186 void exitedFullscreen() override; |
186 | 187 |
187 void OnPipelineSeeked(bool time_changed, PipelineStatus status); | |
188 void OnPipelineSuspended(PipelineStatus status); | |
189 void OnPipelineEnded(); | 188 void OnPipelineEnded(); |
190 void OnPipelineError(PipelineStatus error); | 189 void OnPipelineError(PipelineStatus error); |
191 void OnPipelineMetadata(PipelineMetadata metadata); | 190 void OnPipelineMetadata(PipelineMetadata metadata); |
192 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | 191 void OnPipelineBufferingStateChanged(BufferingState buffering_state); |
193 void OnDemuxerOpened(); | 192 void OnDemuxerOpened(); |
194 void OnAddTextTrack(const TextTrackConfig& config, | 193 void OnAddTextTrack(const TextTrackConfig& config, |
195 const AddTextTrackDoneCB& done_cb); | 194 const AddTextTrackDoneCB& done_cb); |
196 | 195 |
196 void OnPipelineSeeked(bool time_updated); | |
DaleCurtis
2016/02/19 23:28:30
Why are these public? Ditto for the rest of the On
sandersd (OOO until July 31)
2016/02/24 00:09:56
Done.
| |
197 void OnPipelineSuspended(); | |
198 | |
197 // WebMediaPlayerDelegate::Observer implementation. | 199 // WebMediaPlayerDelegate::Observer implementation. |
198 void OnHidden(bool must_suspend) override; | 200 void OnHidden(bool must_suspend) override; |
199 void OnShown() override; | 201 void OnShown() override; |
200 void OnPlay() override; | 202 void OnPlay() override; |
201 void OnPause() override; | 203 void OnPause() override; |
202 void OnVolumeMultiplierUpdate(double multiplier) override; | 204 void OnVolumeMultiplierUpdate(double multiplier) override; |
203 | 205 |
204 #if defined(OS_ANDROID) // WMPI_CAST | 206 #if defined(OS_ANDROID) // WMPI_CAST |
205 bool isRemote() const override; | 207 bool isRemote() const override; |
206 void requestRemotePlayback() override; | 208 void requestRemotePlayback() override; |
207 void requestRemotePlaybackControl() override; | 209 void requestRemotePlaybackControl() override; |
208 | 210 |
209 void SetMediaPlayerManager( | 211 void SetMediaPlayerManager( |
210 RendererMediaPlayerManagerInterface* media_player_manager); | 212 RendererMediaPlayerManagerInterface* media_player_manager); |
211 void OnRemotePlaybackEnded(); | 213 void OnRemotePlaybackEnded(); |
212 void OnDisconnectedFromRemoteDevice(double t); | 214 void OnDisconnectedFromRemoteDevice(double t); |
213 void SuspendForRemote(); | 215 void SuspendForRemote(); |
214 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, | 216 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, |
215 PipelineStatus status); | 217 PipelineStatus status); |
216 gfx::Size GetCanvasSize() const; | 218 gfx::Size GetCanvasSize() const; |
217 void SetDeviceScaleFactor(float scale_factor); | 219 void SetDeviceScaleFactor(float scale_factor); |
218 #endif | 220 #endif |
219 | 221 |
220 private: | 222 private: |
221 // Ask for the pipeline to be suspended, will call Suspend() when ready. | 223 void DoSeek(base::TimeDelta time, bool time_updated); |
222 // (Possibly immediately.) | |
223 void ScheduleSuspend(); | |
224 | |
225 // Initiate suspending the pipeline. | |
226 void Suspend(); | |
227 | |
228 // Ask for the pipeline to be resumed, will call Resume() when ready. | |
229 // (Possibly immediately.) | |
230 void ScheduleResume(); | |
231 | |
232 // Initiate resuming the pipeline. | |
233 void Resume(); | |
234 | 224 |
235 // Ask for the renderer to be restarted (destructed and recreated). | 225 // Ask for the renderer to be restarted (destructed and recreated). |
236 void ScheduleRestart(); | 226 void ScheduleRestart(); |
237 | 227 |
238 // Called after |defer_load_cb_| has decided to allow the load. If | 228 // Called after |defer_load_cb_| has decided to allow the load. If |
239 // |defer_load_cb_| is null this is called immediately. | 229 // |defer_load_cb_| is null this is called immediately. |
240 void DoLoad(LoadType load_type, | 230 void DoLoad(LoadType load_type, |
241 const blink::WebURL& url, | 231 const blink::WebURL& url, |
242 CORSMode cors_mode); | 232 CORSMode cors_mode); |
243 | 233 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 // is not available. | 274 // is not available. |
285 void OnWaitingForDecryptionKey(); | 275 void OnWaitingForDecryptionKey(); |
286 | 276 |
287 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 277 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
288 // Parameter order is reversed for easy binding. | 278 // Parameter order is reversed for easy binding. |
289 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 279 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
290 | 280 |
291 // Called when a CDM has been attached to the |pipeline_|. | 281 // Called when a CDM has been attached to the |pipeline_|. |
292 void OnCdmAttached(bool success); | 282 void OnCdmAttached(bool success); |
293 | 283 |
294 // Updates |paused_time_| to the current media time with consideration for the | |
295 // |ended_| state by clamping current time to duration upon |ended_|. | |
296 void UpdatePausedTime(); | |
297 | |
298 // Notifies |delegate_| that playback has started or was paused; also starts | 284 // Notifies |delegate_| that playback has started or was paused; also starts |
299 // or stops the memory usage reporting timer respectively. | 285 // or stops the memory usage reporting timer respectively. |
300 void NotifyPlaybackStarted(); | 286 void NotifyPlaybackStarted(); |
301 void NotifyPlaybackPaused(); | 287 void NotifyPlaybackPaused(); |
302 | 288 |
303 // Called at low frequency to tell external observers how much memory we're | 289 // Called at low frequency to tell external observers how much memory we're |
304 // using for video playback. Called by |memory_usage_reporting_timer_|. | 290 // using for video playback. Called by |memory_usage_reporting_timer_|. |
305 // Memory usage reporting is done in two steps, because |demuxer_| must be | 291 // Memory usage reporting is done in two steps, because |demuxer_| must be |
306 // accessed on the media thread. | 292 // accessed on the media thread. |
307 void ReportMemoryUsage(); | 293 void ReportMemoryUsage(); |
(...skipping 13 matching lines...) Expand all Loading... | |
321 BufferedDataSource::BufferingStrategy buffering_strategy_; | 307 BufferedDataSource::BufferingStrategy buffering_strategy_; |
322 | 308 |
323 // Task runner for posting tasks on Chrome's main thread. Also used | 309 // Task runner for posting tasks on Chrome's main thread. Also used |
324 // for DCHECKs so methods calls won't execute in the wrong thread. | 310 // for DCHECKs so methods calls won't execute in the wrong thread. |
325 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 311 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
326 | 312 |
327 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 313 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
328 scoped_refptr<base::TaskRunner> worker_task_runner_; | 314 scoped_refptr<base::TaskRunner> worker_task_runner_; |
329 scoped_refptr<MediaLog> media_log_; | 315 scoped_refptr<MediaLog> media_log_; |
330 PipelineImpl pipeline_; | 316 PipelineImpl pipeline_; |
317 PipelineController pipeline_controller_; | |
331 | 318 |
332 // The LoadType passed in the |load_type| parameter of the load() call. | 319 // The LoadType passed in the |load_type| parameter of the load() call. |
333 LoadType load_type_; | 320 LoadType load_type_; |
334 | 321 |
335 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). | 322 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). |
336 PipelineMetadata pipeline_metadata_; | 323 PipelineMetadata pipeline_metadata_; |
337 | 324 |
338 // Whether the video is known to be opaque or not. | 325 // Whether the video is known to be opaque or not. |
339 bool opaque_; | 326 bool opaque_; |
340 | 327 |
341 // Playback state. | 328 // Playback state. |
342 // | 329 // |
343 // TODO(scherkus): we have these because Pipeline favours the simplicity of a | 330 // TODO(scherkus): we have these because Pipeline favours the simplicity of a |
344 // single "playback rate" over worrying about paused/stopped etc... It forces | 331 // single "playback rate" over worrying about paused/stopped etc... It forces |
345 // all clients to manage the pause+playback rate externally, but is that | 332 // all clients to manage the pause+playback rate externally, but is that |
346 // really a bad thing? | 333 // really a bad thing? |
347 // | 334 // |
348 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want | 335 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want |
349 // to hang the render thread during pause(), we record the time at the same | 336 // to hang the render thread during pause(), we record the time at the same |
350 // time we pause and then return that value in currentTime(). Otherwise our | 337 // time we pause and then return that value in currentTime(). Otherwise our |
351 // clock can creep forward a little bit while the asynchronous | 338 // clock can creep forward a little bit while the asynchronous |
352 // SetPlaybackRate(0) is being executed. | 339 // SetPlaybackRate(0) is being executed. |
353 double playback_rate_; | 340 double playback_rate_; |
341 | |
342 // Set while paused. |paused_time_| is only valid when |paused_| is true. | |
354 bool paused_; | 343 bool paused_; |
355 base::TimeDelta paused_time_; | 344 base::TimeDelta paused_time_; |
345 | |
346 // Set when starting, seeking, and resuming (all of which require a Pipeline | |
347 // seek). |seek_time_| is only valid when |seeking_| is true. | |
356 bool seeking_; | 348 bool seeking_; |
357 | |
358 // Set when seeking (|seeking_| is true) or resuming. | |
359 base::TimeDelta seek_time_; | 349 base::TimeDelta seek_time_; |
360 | 350 |
361 // Set when a suspend is required but another suspend or seek is in progress. | |
362 bool pending_suspend_; | |
363 | |
364 // Set when suspending immediately after a seek. The time change will happen | |
365 // after Resume(). | |
366 bool pending_time_change_; | |
367 | |
368 // Set when a resume is required but suspending is in progress. | |
369 bool pending_resume_; | |
370 | |
371 // Set for the entire period between suspend starting and resume completing. | |
372 bool suspending_; | |
373 | |
374 // Set while suspending to detect double-suspend. | |
375 bool suspended_; | |
376 | |
377 // Set while resuming to detect double-resume. | |
378 bool resuming_; | |
379 | |
380 // Set when doing a restart (a suspend and resume in sequence) of the pipeline | 351 // Set when doing a restart (a suspend and resume in sequence) of the pipeline |
381 // in order to destruct and reinitialize the decoders. This is separate from | 352 // in order to destruct and reinitialize the decoders. This is separate from |
382 // |pending_resume_| and |pending_suspend_| because they can be elided in | 353 // |pending_resume_| and |pending_suspend_| because they can be elided in |
383 // certain cases, whereas for a restart they must happen. | 354 // certain cases, whereas for a restart they must happen. |
384 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart. | 355 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart. |
385 bool pending_suspend_resume_cycle_; | 356 bool pending_suspend_resume_cycle_; |
386 | 357 |
387 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, | 358 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, |
388 // see http://crbug.com/409280 | 359 // see http://crbug.com/409280 |
389 bool ended_; | 360 bool ended_; |
390 | 361 |
391 // Indicates that a seek is queued after the current seek completes or, if the | |
392 // pipeline is suspended, after it resumes. Only the last queued seek will | |
393 // have any effect. | |
394 bool pending_seek_; | |
395 | |
396 // |pending_seek_time_| is meaningless when |pending_seek_| is false. | |
397 base::TimeDelta pending_seek_time_; | |
398 | |
399 // Tracks whether to issue time changed notifications during buffering state | 362 // Tracks whether to issue time changed notifications during buffering state |
400 // changes. | 363 // changes. |
401 bool should_notify_time_changed_; | 364 bool should_notify_time_changed_; |
402 | 365 |
403 bool fullscreen_; | 366 bool fullscreen_; |
404 | 367 |
405 // Whether the current decoder requires a restart on fullscreen transitions. | 368 // Whether the current decoder requires a restart on fullscreen transitions. |
406 bool decoder_requires_restart_for_fullscreen_; | 369 bool decoder_requires_restart_for_fullscreen_; |
407 | 370 |
408 blink::WebMediaPlayerClient* client_; | 371 blink::WebMediaPlayerClient* client_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. | 437 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. |
475 // This will be null everywhere but Android. | 438 // This will be null everywhere but Android. |
476 SurfaceManager* surface_manager_; | 439 SurfaceManager* surface_manager_; |
477 | 440 |
478 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 441 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
479 }; | 442 }; |
480 | 443 |
481 } // namespace media | 444 } // namespace media |
482 | 445 |
483 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 446 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |