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 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 class RendererCdmManager; | 65 class RendererCdmManager; |
66 class RendererMediaPlayerManager; | 66 class RendererMediaPlayerManager; |
67 class WebContentDecryptionModuleImpl; | 67 class WebContentDecryptionModuleImpl; |
68 | 68 |
69 // This class implements blink::WebMediaPlayer by keeping the android | 69 // This class implements blink::WebMediaPlayer by keeping the android |
70 // media player in the browser process. It listens to all the status changes | 70 // media player in the browser process. It listens to all the status changes |
71 // sent from the browser process and sends playback controls to the media | 71 // sent from the browser process and sends playback controls to the media |
72 // player. | 72 // player. |
73 class WebMediaPlayerAndroid : public blink::WebMediaPlayer, | 73 class WebMediaPlayerAndroid : public blink::WebMediaPlayer, |
74 public cc::VideoFrameProvider, | 74 public cc::VideoFrameProvider, |
75 public RenderFrameObserver { | 75 public RenderFrameObserver, |
| 76 public StreamTextureFactoryContextObserver { |
76 public: | 77 public: |
77 // Construct a WebMediaPlayerAndroid object. This class communicates with the | 78 // Construct a WebMediaPlayerAndroid object. This class communicates with the |
78 // MediaPlayerAndroid object in the browser process through |proxy|. | 79 // MediaPlayerAndroid object in the browser process through |proxy|. |
79 // TODO(qinmin): |frame| argument is used to determine whether the current | 80 // TODO(qinmin): |frame| argument is used to determine whether the current |
80 // player can enter fullscreen. This logic should probably be moved into | 81 // player can enter fullscreen. This logic should probably be moved into |
81 // blink, so that enterFullscreen() will not be called if another video is | 82 // blink, so that enterFullscreen() will not be called if another video is |
82 // already in fullscreen. | 83 // already in fullscreen. |
83 WebMediaPlayerAndroid( | 84 WebMediaPlayerAndroid( |
84 blink::WebFrame* frame, | 85 blink::WebFrame* frame, |
85 blink::WebMediaPlayerClient* client, | 86 blink::WebMediaPlayerClient* client, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 193 |
193 // Functions called when media player status changes. | 194 // Functions called when media player status changes. |
194 void OnConnectedToRemoteDevice(const std::string& remote_playback_message); | 195 void OnConnectedToRemoteDevice(const std::string& remote_playback_message); |
195 void OnDisconnectedFromRemoteDevice(); | 196 void OnDisconnectedFromRemoteDevice(); |
196 void OnDidEnterFullscreen(); | 197 void OnDidEnterFullscreen(); |
197 void OnDidExitFullscreen(); | 198 void OnDidExitFullscreen(); |
198 void OnMediaPlayerPlay(); | 199 void OnMediaPlayerPlay(); |
199 void OnMediaPlayerPause(); | 200 void OnMediaPlayerPause(); |
200 void OnRequestFullscreen(); | 201 void OnRequestFullscreen(); |
201 | 202 |
| 203 // StreamTextureFactoryContextObserver implementation. |
| 204 virtual void ResetStreamTextureProxy() OVERRIDE; |
| 205 |
202 // Called when the player is released. | 206 // Called when the player is released. |
203 virtual void OnPlayerReleased(); | 207 virtual void OnPlayerReleased(); |
204 | 208 |
205 // This function is called by the RendererMediaPlayerManager to pause the | 209 // This function is called by the RendererMediaPlayerManager to pause the |
206 // video and release the media player and surface texture when we switch tabs. | 210 // video and release the media player and surface texture when we switch tabs. |
207 // However, the actual GlTexture is not released to keep the video screenshot. | 211 // However, the actual GlTexture is not released to keep the video screenshot. |
208 virtual void ReleaseMediaResources(); | 212 virtual void ReleaseMediaResources(); |
209 | 213 |
210 // RenderFrameObserver implementation. | 214 // RenderFrameObserver implementation. |
211 virtual void OnDestruct() OVERRIDE; | 215 virtual void OnDestruct() OVERRIDE; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 410 |
407 // Stream texture ID allocated to the video. | 411 // Stream texture ID allocated to the video. |
408 unsigned int stream_id_; | 412 unsigned int stream_id_; |
409 | 413 |
410 // Whether the mediaplayer is playing. | 414 // Whether the mediaplayer is playing. |
411 bool is_playing_; | 415 bool is_playing_; |
412 | 416 |
413 // Whether media player needs to re-establish the surface texture peer. | 417 // Whether media player needs to re-establish the surface texture peer. |
414 bool needs_establish_peer_; | 418 bool needs_establish_peer_; |
415 | 419 |
416 // Whether |stream_texture_proxy_| is initialized. | |
417 bool stream_texture_proxy_initialized_; | |
418 | |
419 // Whether the video size info is available. | 420 // Whether the video size info is available. |
420 bool has_size_info_; | 421 bool has_size_info_; |
421 | 422 |
| 423 const scoped_refptr<base::MessageLoopProxy> compositor_loop_; |
| 424 |
422 // Object for allocating stream textures. | 425 // Object for allocating stream textures. |
423 scoped_refptr<StreamTextureFactory> stream_texture_factory_; | 426 scoped_refptr<StreamTextureFactory> stream_texture_factory_; |
424 | 427 |
425 // Object for calling back the compositor thread to repaint the video when a | 428 // Object for calling back the compositor thread to repaint the video when a |
426 // frame available. It should be initialized on the compositor thread. | 429 // frame available. It should be initialized on the compositor thread. |
| 430 // Accessed on main thread and on compositor thread when main thread is |
| 431 // blocked. |
427 ScopedStreamTextureProxy stream_texture_proxy_; | 432 ScopedStreamTextureProxy stream_texture_proxy_; |
428 | 433 |
429 // Whether media player needs external surface. | 434 // Whether media player needs external surface. |
430 // Only used for the VIDEO_HOLE logic. | 435 // Only used for the VIDEO_HOLE logic. |
431 bool needs_external_surface_; | 436 bool needs_external_surface_; |
432 | 437 |
433 // Whether valid metadata are available | 438 // Whether valid metadata are available |
434 bool has_valid_metadata_; | 439 bool has_valid_metadata_; |
435 | 440 |
436 // A pointer back to the compositor to inform it about state changes. This is | 441 // A pointer back to the compositor to inform it about state changes. This is |
437 // not NULL while the compositor is actively using this webmediaplayer. | 442 // not NULL while the compositor is actively using this webmediaplayer. |
| 443 // Accessed on main thread and on compositor thread when main thread is |
| 444 // blocked. |
438 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 445 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
439 | 446 |
440 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; | 447 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
441 | 448 |
442 #if defined(VIDEO_HOLE) | 449 #if defined(VIDEO_HOLE) |
443 // A rectangle represents the geometry of video frame, when computed last | 450 // A rectangle represents the geometry of video frame, when computed last |
444 // time. | 451 // time. |
445 gfx::RectF last_computed_rect_; | 452 gfx::RectF last_computed_rect_; |
446 | 453 |
447 // Whether to use the video overlay for all embedded video. | 454 // Whether to use the video overlay for all embedded video. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 510 |
504 // NOTE: Weak pointers must be invalidated before all other member variables. | 511 // NOTE: Weak pointers must be invalidated before all other member variables. |
505 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; | 512 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; |
506 | 513 |
507 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 514 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
508 }; | 515 }; |
509 | 516 |
510 } // namespace content | 517 } // namespace content |
511 | 518 |
512 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 519 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
OLD | NEW |