| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 5 #ifndef WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #if defined(GOOGLE_TV) | |
| 16 #include "media/base/demuxer_stream.h" | |
| 17 #endif | |
| 18 #include "cc/layers/video_frame_provider.h" | 15 #include "cc/layers/video_frame_provider.h" |
| 16 #include "media/base/android/media_player_bridge.h" |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
| 23 #include "ui/gfx/rect_f.h" | 21 #include "ui/gfx/rect_f.h" |
| 24 #include "webkit/media/android/stream_texture_factory_android.h" | 22 #include "webkit/media/android/stream_texture_factory_android.h" |
| 25 | 23 |
| 24 #if defined(GOOGLE_TV) |
| 25 #include "webkit/media/android/media_source_delegate.h" |
| 26 #endif |
| 27 |
| 26 namespace media { | 28 namespace media { |
| 29 class Demuxer; |
| 27 class MediaLog; | 30 class MediaLog; |
| 28 } | 31 } |
| 29 | 32 |
| 30 namespace WebKit { | 33 namespace WebKit { |
| 31 class WebFrame; | 34 class WebFrame; |
| 32 } | 35 } |
| 33 | 36 |
| 34 namespace webkit { | 37 namespace webkit { |
| 35 class WebLayerImpl; | 38 class WebLayerImpl; |
| 36 } | 39 } |
| 37 | 40 |
| 38 namespace webkit_media { | 41 namespace webkit_media { |
| 39 | 42 |
| 40 #if defined(GOOGLE_TV) | 43 #if defined(GOOGLE_TV) |
| 41 class MediaSourceDelegate; | 44 class MediaStreamAudioRenderer; |
| 42 #endif | 45 #endif |
| 46 class MediaStreamClient; |
| 43 class WebMediaPlayerManagerAndroid; | 47 class WebMediaPlayerManagerAndroid; |
| 44 class WebMediaPlayerProxyAndroid; | 48 class WebMediaPlayerProxyAndroid; |
| 45 | 49 |
| 46 // This class implements WebKit::WebMediaPlayer by keeping the android | 50 // This class implements WebKit::WebMediaPlayer by keeping the android |
| 47 // media player in the browser process. It listens to all the status changes | 51 // media player in the browser process. It listens to all the status changes |
| 48 // sent from the browser process and sends playback controls to the media | 52 // sent from the browser process and sends playback controls to the media |
| 49 // player. | 53 // player. |
| 50 class WebMediaPlayerAndroid | 54 class WebMediaPlayerAndroid |
| 51 : public WebKit::WebMediaPlayer, | 55 : public WebKit::WebMediaPlayer, |
| 52 public cc::VideoFrameProvider, | 56 public cc::VideoFrameProvider, |
| 53 public base::MessageLoop::DestructionObserver { | 57 public base::MessageLoop::DestructionObserver { |
| 54 public: | 58 public: |
| 55 // Construct a WebMediaPlayerAndroid object. This class communicates | 59 // Construct a WebMediaPlayerAndroid object. This class communicates |
| 56 // with the MediaPlayerBridge object in the browser process through | 60 // with the MediaPlayerBridge object in the browser process through |
| 57 // |proxy|. | 61 // |proxy|. |
| 58 // TODO(qinmin): |frame| argument is used to determine whether the current | 62 // TODO(qinmin): |frame| argument is used to determine whether the current |
| 59 // player can enter fullscreen. This logic should probably be moved into | 63 // player can enter fullscreen. This logic should probably be moved into |
| 60 // blink, so that enterFullscreen() will not be called if another video is | 64 // blink, so that enterFullscreen() will not be called if another video is |
| 61 // already in fullscreen. | 65 // already in fullscreen. |
| 62 WebMediaPlayerAndroid(WebKit::WebFrame* frame, | 66 WebMediaPlayerAndroid(WebKit::WebFrame* frame, |
| 63 WebKit::WebMediaPlayerClient* client, | 67 WebKit::WebMediaPlayerClient* client, |
| 64 WebMediaPlayerManagerAndroid* manager, | 68 WebMediaPlayerManagerAndroid* manager, |
| 65 WebMediaPlayerProxyAndroid* proxy, | 69 WebMediaPlayerProxyAndroid* proxy, |
| 66 StreamTextureFactory* factory, | 70 StreamTextureFactory* factory, |
| 67 media::MediaLog* media_log); | 71 media::MediaLog* media_log, |
| 72 MediaStreamClient* media_stream_client, |
| 73 media::Demuxer* remote_stream_demuxer); |
| 68 virtual ~WebMediaPlayerAndroid(); | 74 virtual ~WebMediaPlayerAndroid(); |
| 69 | 75 |
| 70 // WebKit::WebMediaPlayer implementation. | 76 // WebKit::WebMediaPlayer implementation. |
| 71 virtual void enterFullscreen(); | 77 virtual void enterFullscreen(); |
| 72 virtual void exitFullscreen(); | 78 virtual void exitFullscreen(); |
| 73 virtual bool canEnterFullscreen() const; | 79 virtual bool canEnterFullscreen() const; |
| 74 | 80 |
| 75 // Resource loading. | 81 // Resource loading. |
| 76 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); | 82 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); |
| 77 virtual void load(const WebKit::WebURL& url, | 83 virtual void load(const WebKit::WebURL& url, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 const WebKit::WebString& key_system, | 201 const WebKit::WebString& key_system, |
| 196 const unsigned char* key, | 202 const unsigned char* key, |
| 197 unsigned key_length, | 203 unsigned key_length, |
| 198 const unsigned char* init_data, | 204 const unsigned char* init_data, |
| 199 unsigned init_data_length, | 205 unsigned init_data_length, |
| 200 const WebKit::WebString& session_id) OVERRIDE; | 206 const WebKit::WebString& session_id) OVERRIDE; |
| 201 virtual MediaKeyException cancelKeyRequest( | 207 virtual MediaKeyException cancelKeyRequest( |
| 202 const WebKit::WebString& key_system, | 208 const WebKit::WebString& key_system, |
| 203 const WebKit::WebString& session_id) OVERRIDE; | 209 const WebKit::WebString& session_id) OVERRIDE; |
| 204 | 210 |
| 205 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | 211 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. |
| 206 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); | 212 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); |
| 213 |
| 214 void SetDestroyDemuxerCB( |
| 215 const MediaSourceDelegate::DestroyDemuxerCB& destroy_demuxer_cb); |
| 207 #endif | 216 #endif |
| 208 | 217 |
| 209 protected: | 218 protected: |
| 210 // Helper method to update the playing state. | 219 // Helper method to update the playing state. |
| 211 void UpdatePlayingState(bool is_playing_); | 220 void UpdatePlayingState(bool is_playing_); |
| 212 | 221 |
| 213 // Helper methods for posting task for setting states and update WebKit. | 222 // Helper methods for posting task for setting states and update WebKit. |
| 214 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); | 223 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); |
| 215 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); | 224 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); |
| 216 | 225 |
| 217 // Helper method to reestablish the surface texture peer for android | 226 // Helper method to reestablish the surface texture peer for android |
| 218 // media player. | 227 // media player. |
| 219 void EstablishSurfaceTexturePeer(); | 228 void EstablishSurfaceTexturePeer(); |
| 220 | 229 |
| 221 // Requesting whether the surface texture peer needs to be reestablished. | 230 // Requesting whether the surface texture peer needs to be reestablished. |
| 222 void SetNeedsEstablishPeer(bool needs_establish_peer); | 231 void SetNeedsEstablishPeer(bool needs_establish_peer); |
| 223 | 232 |
| 233 void InitializeMediaPlayer( |
| 234 const WebKit::WebURL& url, |
| 235 media::MediaPlayerBridge::MediaSource media_source); |
| 236 |
| 224 #if defined(GOOGLE_TV) | 237 #if defined(GOOGLE_TV) |
| 225 // Request external surface for out-of-band composition. | 238 // Request external surface for out-of-band composition. |
| 226 void RequestExternalSurface(); | 239 void RequestExternalSurface(); |
| 227 #endif | 240 #endif |
| 228 | 241 |
| 229 private: | 242 private: |
| 230 void ReallocateVideoFrame(); | 243 void ReallocateVideoFrame(); |
| 231 | 244 |
| 232 WebKit::WebFrame* const frame_; | 245 WebKit::WebFrame* const frame_; |
| 233 | 246 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // not NULL while the compositor is actively using this webmediaplayer. | 312 // not NULL while the compositor is actively using this webmediaplayer. |
| 300 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 313 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 301 | 314 |
| 302 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; | 315 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 303 | 316 |
| 304 #if defined(GOOGLE_TV) | 317 #if defined(GOOGLE_TV) |
| 305 // A rectangle represents the geometry of video frame, when computed last | 318 // A rectangle represents the geometry of video frame, when computed last |
| 306 // time. | 319 // time. |
| 307 gfx::RectF last_computed_rect_; | 320 gfx::RectF last_computed_rect_; |
| 308 | 321 |
| 322 // Media Source / Media Stream related fields. |
| 309 scoped_ptr<MediaSourceDelegate> media_source_delegate_; | 323 scoped_ptr<MediaSourceDelegate> media_source_delegate_; |
| 324 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; |
| 325 MediaSourceDelegate::DestroyDemuxerCB destroy_demuxer_cb_; |
| 310 #endif | 326 #endif |
| 311 | 327 |
| 312 // Proxy object that delegates method calls on Render Thread. | 328 // Proxy object that delegates method calls on Render Thread. |
| 313 // This object is created on the Render Thread and is only called in the | 329 // This object is created on the Render Thread and is only called in the |
| 314 // destructor. | 330 // destructor. |
| 315 WebMediaPlayerProxyAndroid* proxy_; | 331 WebMediaPlayerProxyAndroid* proxy_; |
| 316 | 332 |
| 317 // The current playing time. Because the media player is in the browser | 333 // The current playing time. Because the media player is in the browser |
| 318 // process, it will regularly update the |current_time_| by calling | 334 // process, it will regularly update the |current_time_| by calling |
| 319 // OnTimeUpdate(). | 335 // OnTimeUpdate(). |
| 320 float current_time_; | 336 float current_time_; |
| 321 | 337 |
| 322 media::MediaLog* media_log_; | 338 media::MediaLog* media_log_; |
| 339 MediaStreamClient* media_stream_client_; |
| 340 media::Demuxer* demuxer_; |
| 323 | 341 |
| 324 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 342 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 325 }; | 343 }; |
| 326 | 344 |
| 327 } // namespace webkit_media | 345 } // namespace webkit_media |
| 328 | 346 |
| 329 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 347 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |