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

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

Issue 532993002: work-in-progress patch to fix context lost black video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: post to impl Created 6 years, 3 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 class RendererCdmManager; 63 class RendererCdmManager;
64 class RendererMediaPlayerManager; 64 class RendererMediaPlayerManager;
65 class WebContentDecryptionModuleImpl; 65 class WebContentDecryptionModuleImpl;
66 66
67 // This class implements blink::WebMediaPlayer by keeping the android 67 // This class implements blink::WebMediaPlayer by keeping the android
68 // media player in the browser process. It listens to all the status changes 68 // media player in the browser process. It listens to all the status changes
69 // sent from the browser process and sends playback controls to the media 69 // sent from the browser process and sends playback controls to the media
70 // player. 70 // player.
71 class WebMediaPlayerAndroid : public blink::WebMediaPlayer, 71 class WebMediaPlayerAndroid : public blink::WebMediaPlayer,
72 public cc::VideoFrameProvider, 72 public cc::VideoFrameProvider,
73 public RenderFrameObserver { 73 public RenderFrameObserver,
74 public StreamTextureFactoryContextObserver {
74 public: 75 public:
75 // Construct a WebMediaPlayerAndroid object. This class communicates with the 76 // Construct a WebMediaPlayerAndroid object. This class communicates with the
76 // MediaPlayerAndroid object in the browser process through |proxy|. 77 // MediaPlayerAndroid object in the browser process through |proxy|.
77 // TODO(qinmin): |frame| argument is used to determine whether the current 78 // TODO(qinmin): |frame| argument is used to determine whether the current
78 // player can enter fullscreen. This logic should probably be moved into 79 // player can enter fullscreen. This logic should probably be moved into
79 // blink, so that enterFullscreen() will not be called if another video is 80 // blink, so that enterFullscreen() will not be called if another video is
80 // already in fullscreen. 81 // already in fullscreen.
81 WebMediaPlayerAndroid( 82 WebMediaPlayerAndroid(
82 blink::WebFrame* frame, 83 blink::WebFrame* frame,
83 blink::WebMediaPlayerClient* client, 84 blink::WebMediaPlayerClient* client,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 190
190 // Functions called when media player status changes. 191 // Functions called when media player status changes.
191 void OnConnectedToRemoteDevice(const std::string& remote_playback_message); 192 void OnConnectedToRemoteDevice(const std::string& remote_playback_message);
192 void OnDisconnectedFromRemoteDevice(); 193 void OnDisconnectedFromRemoteDevice();
193 void OnDidEnterFullscreen(); 194 void OnDidEnterFullscreen();
194 void OnDidExitFullscreen(); 195 void OnDidExitFullscreen();
195 void OnMediaPlayerPlay(); 196 void OnMediaPlayerPlay();
196 void OnMediaPlayerPause(); 197 void OnMediaPlayerPause();
197 void OnRequestFullscreen(); 198 void OnRequestFullscreen();
198 199
200 // StreamTextureFactoryContextObserver implementation.
201 virtual void ResetStreamTextureProxy() OVERRIDE;
202
199 // Called when the player is released. 203 // Called when the player is released.
200 virtual void OnPlayerReleased(); 204 virtual void OnPlayerReleased();
201 205
202 // This function is called by the RendererMediaPlayerManager to pause the 206 // This function is called by the RendererMediaPlayerManager to pause the
203 // video and release the media player and surface texture when we switch tabs. 207 // video and release the media player and surface texture when we switch tabs.
204 // However, the actual GlTexture is not released to keep the video screenshot. 208 // However, the actual GlTexture is not released to keep the video screenshot.
205 virtual void ReleaseMediaResources(); 209 virtual void ReleaseMediaResources();
206 210
207 // RenderFrameObserver implementation. 211 // RenderFrameObserver implementation.
208 virtual void OnDestruct() OVERRIDE; 212 virtual void OnDestruct() OVERRIDE;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 279
276 private: 280 private:
277 void InitializePlayer(const GURL& url, 281 void InitializePlayer(const GURL& url,
278 const GURL& first_party_for_cookies, 282 const GURL& first_party_for_cookies,
279 bool allowed_stored_credentials, 283 bool allowed_stored_credentials,
280 int demuxer_client_id); 284 int demuxer_client_id);
281 void Pause(bool is_media_related_action); 285 void Pause(bool is_media_related_action);
282 void DrawRemotePlaybackText(const std::string& remote_playback_message); 286 void DrawRemotePlaybackText(const std::string& remote_playback_message);
283 void ReallocateVideoFrame(); 287 void ReallocateVideoFrame();
284 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame); 288 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame);
289 void UpdateFrameOnClientThread();
285 void DidLoadMediaInfo(MediaInfoLoader::Status status, 290 void DidLoadMediaInfo(MediaInfoLoader::Status status,
286 const GURL& redirected_url, 291 const GURL& redirected_url,
287 const GURL& first_party_for_cookies, 292 const GURL& first_party_for_cookies,
288 bool allow_stored_credentials); 293 bool allow_stored_credentials);
289 bool IsKeySystemSupported(const std::string& key_system); 294 bool IsKeySystemSupported(const std::string& key_system);
290 bool IsLocalResource(); 295 bool IsLocalResource();
291 296
292 // Actually do the work for generateKeyRequest/addKey so they can easily 297 // Actually do the work for generateKeyRequest/addKey so they can easily
293 // report results to UMA. 298 // report results to UMA.
294 MediaKeyException GenerateKeyRequestInternal(const std::string& key_system, 299 MediaKeyException GenerateKeyRequestInternal(const std::string& key_system,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 blink::WebTimeRanges buffered_; 342 blink::WebTimeRanges buffered_;
338 343
339 // Size of the video. 344 // Size of the video.
340 blink::WebSize natural_size_; 345 blink::WebSize natural_size_;
341 346
342 // Size that has been sent to StreamTexture. 347 // Size that has been sent to StreamTexture.
343 blink::WebSize cached_stream_texture_size_; 348 blink::WebSize cached_stream_texture_size_;
344 349
345 // The video frame object used for rendering by the compositor. 350 // The video frame object used for rendering by the compositor.
346 scoped_refptr<media::VideoFrame> current_frame_; 351 scoped_refptr<media::VideoFrame> current_frame_;
347 base::Lock current_frame_lock_; 352 // Whether |stream_texture_proxy_| is initialized.
353 bool stream_texture_proxy_initialized_;
354 scoped_refptr<base::MessageLoopProxy> client_bound_loop_;
355 base::Lock current_frame_lock_; // TODO(boliu): Rename this var.
348 356
349 base::ThreadChecker main_thread_checker_; 357 base::ThreadChecker main_thread_checker_;
350 358
351 // Message loop for media thread. 359 // Message loop for media thread.
352 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 360 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
353 361
354 // URL of the media file to be fetched. 362 // URL of the media file to be fetched.
355 GURL url_; 363 GURL url_;
356 364
357 // URL of the media file after |media_info_loader_| resolves all the 365 // URL of the media file after |media_info_loader_| resolves all the
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 411
404 // Stream texture ID allocated to the video. 412 // Stream texture ID allocated to the video.
405 unsigned int stream_id_; 413 unsigned int stream_id_;
406 414
407 // Whether the mediaplayer is playing. 415 // Whether the mediaplayer is playing.
408 bool is_playing_; 416 bool is_playing_;
409 417
410 // Whether media player needs to re-establish the surface texture peer. 418 // Whether media player needs to re-establish the surface texture peer.
411 bool needs_establish_peer_; 419 bool needs_establish_peer_;
412 420
413 // Whether |stream_texture_proxy_| is initialized.
414 bool stream_texture_proxy_initialized_;
415
416 // Whether the video size info is available. 421 // Whether the video size info is available.
417 bool has_size_info_; 422 bool has_size_info_;
418 423
419 // Object for allocating stream textures. 424 // Object for allocating stream textures.
420 scoped_refptr<StreamTextureFactory> stream_texture_factory_; 425 scoped_refptr<StreamTextureFactory> stream_texture_factory_;
421 426
422 // Object for calling back the compositor thread to repaint the video when a 427 // Object for calling back the compositor thread to repaint the video when a
423 // frame available. It should be initialized on the compositor thread. 428 // frame available. It should be initialized on the compositor thread.
424 ScopedStreamTextureProxy stream_texture_proxy_; 429 ScopedStreamTextureProxy stream_texture_proxy_;
425 430
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 500
496 // NOTE: Weak pointers must be invalidated before all other member variables. 501 // NOTE: Weak pointers must be invalidated before all other member variables.
497 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; 502 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_;
498 503
499 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); 504 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
500 }; 505 };
501 506
502 } // namespace content 507 } // namespace content
503 508
504 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 509 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698