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