Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.h

Issue 1293253003: Fix autoplay during prerendering for media elements on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@defer_media
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 6 #define CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "content/public/renderer/render_frame_observer.h" 21 #include "content/public/renderer/render_frame_observer.h"
22 #include "content/renderer/media/android/media_info_loader.h" 22 #include "content/renderer/media/android/media_info_loader.h"
23 #include "content/renderer/media/android/media_source_delegate.h" 23 #include "content/renderer/media/android/media_source_delegate.h"
24 #include "content/renderer/media/android/stream_texture_factory.h" 24 #include "content/renderer/media/android/stream_texture_factory.h"
25 #include "gpu/command_buffer/common/mailbox.h" 25 #include "gpu/command_buffer/common/mailbox.h"
26 #include "media/base/android/media_player_android.h" 26 #include "media/base/android/media_player_android.h"
27 #include "media/base/cdm_context.h" 27 #include "media/base/cdm_context.h"
28 #include "media/base/demuxer_stream.h" 28 #include "media/base/demuxer_stream.h"
29 #include "media/base/media_keys.h" 29 #include "media/base/media_keys.h"
30 #include "media/base/time_delta_interpolator.h" 30 #include "media/base/time_delta_interpolator.h"
31 #include "media/blink/webmediaplayer_params.h"
31 #include "media/blink/webmediaplayer_util.h" 32 #include "media/blink/webmediaplayer_util.h"
32 #include "media/cdm/proxy_decryptor.h" 33 #include "media/cdm/proxy_decryptor.h"
33 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 34 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
34 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 35 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
35 #include "third_party/WebKit/public/platform/WebSize.h" 36 #include "third_party/WebKit/public/platform/WebSize.h"
36 #include "third_party/WebKit/public/platform/WebURL.h" 37 #include "third_party/WebKit/public/platform/WebURL.h"
37 #include "third_party/skia/include/core/SkBitmap.h" 38 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "ui/gfx/geometry/rect_f.h" 39 #include "ui/gfx/geometry/rect_f.h"
39 40
40 namespace base { 41 namespace base {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // player can enter fullscreen. This logic should probably be moved into 88 // player can enter fullscreen. This logic should probably be moved into
88 // blink, so that enterFullscreen() will not be called if another video is 89 // blink, so that enterFullscreen() will not be called if another video is
89 // already in fullscreen. 90 // already in fullscreen.
90 WebMediaPlayerAndroid( 91 WebMediaPlayerAndroid(
91 blink::WebFrame* frame, 92 blink::WebFrame* frame,
92 blink::WebMediaPlayerClient* client, 93 blink::WebMediaPlayerClient* client,
93 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, 94 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
94 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, 95 base::WeakPtr<media::WebMediaPlayerDelegate> delegate,
95 RendererMediaPlayerManager* player_manager, 96 RendererMediaPlayerManager* player_manager,
96 media::CdmFactory* cdm_factory, 97 media::CdmFactory* cdm_factory,
97 media::MediaPermission* media_permission,
98 blink::WebContentDecryptionModule* initial_cdm,
99 scoped_refptr<StreamTextureFactory> factory, 98 scoped_refptr<StreamTextureFactory> factory,
100 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 99 const media::WebMediaPlayerParams& params);
101 media::MediaLog* media_log);
102 virtual ~WebMediaPlayerAndroid(); 100 virtual ~WebMediaPlayerAndroid();
103 101
104 // blink::WebMediaPlayer implementation. 102 // blink::WebMediaPlayer implementation.
105 virtual bool supportsOverlayFullscreenVideo(); 103 virtual bool supportsOverlayFullscreenVideo();
106 virtual void enterFullscreen(); 104 virtual void enterFullscreen();
107 105
108 // Resource loading. 106 // Resource loading.
109 virtual void load(LoadType load_type, 107 virtual void load(LoadType load_type,
110 const blink::WebURL& url, 108 const blink::WebURL& url,
111 CORSMode cors_mode); 109 CORSMode cors_mode);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // pipeline/decoders. 334 // pipeline/decoders.
337 void ContentDecryptionModuleAttached( 335 void ContentDecryptionModuleAttached(
338 blink::WebContentDecryptionModuleResult result, 336 blink::WebContentDecryptionModuleResult result,
339 bool success); 337 bool success);
340 338
341 bool IsHLSStream() const; 339 bool IsHLSStream() const;
342 // Report whether the loaded url, after following redirects, points to a HLS 340 // Report whether the loaded url, after following redirects, points to a HLS
343 // playlist, and record the origin of the player. 341 // playlist, and record the origin of the player.
344 void ReportHLSMetrics() const; 342 void ReportHLSMetrics() const;
345 343
344 // Called after |defer_load_cb_| has decided to allow the load. If
345 // |defer_load_cb_| is null this is called immediately.
346 void DoLoad(LoadType load_type, const blink::WebURL& url, CORSMode cors_mode);
347
346 blink::WebFrame* const frame_; 348 blink::WebFrame* const frame_;
347 349
348 blink::WebMediaPlayerClient* const client_; 350 blink::WebMediaPlayerClient* const client_;
349 blink::WebMediaPlayerEncryptedMediaClient* const encrypted_client_; 351 blink::WebMediaPlayerEncryptedMediaClient* const encrypted_client_;
350 352
351 // |delegate_| is used to notify the browser process of the player status, so 353 // |delegate_| is used to notify the browser process of the player status, so
352 // that the browser process can control screen locks. 354 // that the browser process can control screen locks.
353 // TODO(qinmin): Currently android mediaplayer takes care of the screen 355 // TODO(qinmin): Currently android mediaplayer takes care of the screen
354 // lock. So this is only used for media source. Will apply this to regular 356 // lock. So this is only used for media source. Will apply this to regular
355 // media tag once http://crbug.com/247892 is fixed. 357 // media tag once http://crbug.com/247892 is fixed.
356 base::WeakPtr<media::WebMediaPlayerDelegate> delegate_; 358 base::WeakPtr<media::WebMediaPlayerDelegate> delegate_;
357 359
360 media::WebMediaPlayerParams::DeferLoadCB defer_load_cb_;
Charlie Reis 2015/08/18 23:57:42 Maybe add a comment using the word "callback," to
DaleCurtis 2015/08/20 18:47:10 Done.
361
358 // Save the list of buffered time ranges. 362 // Save the list of buffered time ranges.
359 blink::WebTimeRanges buffered_; 363 blink::WebTimeRanges buffered_;
360 364
361 // Size of the video. 365 // Size of the video.
362 blink::WebSize natural_size_; 366 blink::WebSize natural_size_;
363 367
364 // Size that has been sent to StreamTexture. 368 // Size that has been sent to StreamTexture.
365 blink::WebSize cached_stream_texture_size_; 369 blink::WebSize cached_stream_texture_size_;
366 370
367 // The video frame object used for rendering by the compositor. 371 // The video frame object used for rendering by the compositor.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 436
433 // Whether the media player is playing. 437 // Whether the media player is playing.
434 bool is_playing_; 438 bool is_playing_;
435 439
436 // Whether media player needs to re-establish the surface texture peer. 440 // Whether media player needs to re-establish the surface texture peer.
437 bool needs_establish_peer_; 441 bool needs_establish_peer_;
438 442
439 // Whether the video size info is available. 443 // Whether the video size info is available.
440 bool has_size_info_; 444 bool has_size_info_;
441 445
442 const scoped_refptr<base::SingleThreadTaskRunner> compositor_loop_; 446 const scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
443 447
444 // Object for allocating stream textures. 448 // Object for allocating stream textures.
445 scoped_refptr<StreamTextureFactory> stream_texture_factory_; 449 scoped_refptr<StreamTextureFactory> stream_texture_factory_;
446 450
447 // Object for calling back the compositor thread to repaint the video when a 451 // Object for calling back the compositor thread to repaint the video when a
448 // frame available. It should be initialized on the compositor thread. 452 // frame available. It should be initialized on the compositor thread.
449 // Accessed on main thread and on compositor thread when main thread is 453 // Accessed on main thread and on compositor thread when main thread is
450 // blocked. 454 // blocked.
451 ScopedStreamTextureProxy stream_texture_proxy_; 455 ScopedStreamTextureProxy stream_texture_proxy_;
452 456
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 528
525 // NOTE: Weak pointers must be invalidated before all other member variables. 529 // NOTE: Weak pointers must be invalidated before all other member variables.
526 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; 530 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_;
527 531
528 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); 532 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
529 }; 533 };
530 534
531 } // namespace content 535 } // namespace content
532 536
533 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 537 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698