| 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 WEBKIT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 5 #ifndef WEBKIT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| 6 #define WEBKIT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 6 #define WEBKIT_RENDERER_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 #include "cc/layers/video_frame_provider.h" | 15 #include "cc/layers/video_frame_provider.h" |
| 16 #include "media/base/android/media_player_android.h" |
| 16 #include "media/base/demuxer_stream.h" | 17 #include "media/base/demuxer_stream.h" |
| 17 #include "media/base/media_keys.h" | 18 #include "media/base/media_keys.h" |
| 18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 19 #include "third_party/WebKit/public/platform/WebSize.h" | 20 #include "third_party/WebKit/public/platform/WebSize.h" |
| 20 #include "third_party/WebKit/public/platform/WebURL.h" | 21 #include "third_party/WebKit/public/platform/WebURL.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
| 22 #include "ui/gfx/rect_f.h" | 23 #include "ui/gfx/rect_f.h" |
| 23 #include "webkit/renderer/media/android/media_source_delegate.h" | 24 #include "webkit/renderer/media/android/media_source_delegate.h" |
| 24 #include "webkit/renderer/media/android/stream_texture_factory_android.h" | 25 #include "webkit/renderer/media/android/stream_texture_factory_android.h" |
| 25 #include "webkit/renderer/media/crypto/proxy_decryptor.h" | 26 #include "webkit/renderer/media/crypto/proxy_decryptor.h" |
| 26 | 27 |
| 27 namespace media { | 28 namespace media { |
| 29 class Demuxer; |
| 28 class MediaLog; | 30 class MediaLog; |
| 29 } | 31 } |
| 30 | 32 |
| 31 namespace WebKit { | 33 namespace WebKit { |
| 32 class WebFrame; | 34 class WebFrame; |
| 33 } | 35 } |
| 34 | 36 |
| 35 namespace webkit { | 37 namespace webkit { |
| 36 class WebLayerImpl; | 38 class WebLayerImpl; |
| 37 } | 39 } |
| 38 | 40 |
| 39 namespace webkit_media { | 41 namespace webkit_media { |
| 42 |
| 43 class MediaStreamClient; |
| 40 class WebMediaPlayerManagerAndroid; | 44 class WebMediaPlayerManagerAndroid; |
| 41 class WebMediaPlayerProxyAndroid; | 45 class WebMediaPlayerProxyAndroid; |
| 42 | 46 |
| 47 #if defined(GOOGLE_TV) |
| 48 class MediaStreamAudioRenderer; |
| 49 #endif |
| 50 |
| 43 // This class implements WebKit::WebMediaPlayer by keeping the android | 51 // This class implements WebKit::WebMediaPlayer by keeping the android |
| 44 // media player in the browser process. It listens to all the status changes | 52 // media player in the browser process. It listens to all the status changes |
| 45 // sent from the browser process and sends playback controls to the media | 53 // sent from the browser process and sends playback controls to the media |
| 46 // player. | 54 // player. |
| 47 class WebMediaPlayerAndroid | 55 class WebMediaPlayerAndroid |
| 48 : public WebKit::WebMediaPlayer, | 56 : public WebKit::WebMediaPlayer, |
| 49 public cc::VideoFrameProvider, | 57 public cc::VideoFrameProvider, |
| 50 public base::MessageLoop::DestructionObserver { | 58 public base::MessageLoop::DestructionObserver { |
| 51 public: | 59 public: |
| 52 // Construct a WebMediaPlayerAndroid object. This class communicates | 60 // Construct a WebMediaPlayerAndroid object. This class communicates |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 212 |
| 205 void OnKeyAdded(const std::string& key_system, const std::string& session_id); | 213 void OnKeyAdded(const std::string& key_system, const std::string& session_id); |
| 206 void OnKeyError(const std::string& key_system, | 214 void OnKeyError(const std::string& key_system, |
| 207 const std::string& session_id, | 215 const std::string& session_id, |
| 208 media::MediaKeys::KeyError error_code, | 216 media::MediaKeys::KeyError error_code, |
| 209 int system_code); | 217 int system_code); |
| 210 void OnKeyMessage(const std::string& key_system, | 218 void OnKeyMessage(const std::string& key_system, |
| 211 const std::string& session_id, | 219 const std::string& session_id, |
| 212 const std::string& message, | 220 const std::string& message, |
| 213 const std::string& default_url); | 221 const std::string& default_url); |
| 222 |
| 223 bool InjectMediaStream(MediaStreamClient* media_stream_client, |
| 224 media::Demuxer* demuxer, |
| 225 const base::Closure& destroy_demuxer_cb); |
| 214 #endif | 226 #endif |
| 215 | 227 |
| 216 void OnNeedKey(const std::string& key_system, | 228 void OnNeedKey(const std::string& key_system, |
| 217 const std::string& type, | 229 const std::string& type, |
| 218 const std::string& session_id, | 230 const std::string& session_id, |
| 219 scoped_ptr<uint8[]> init_data, | 231 scoped_ptr<uint8[]> init_data, |
| 220 int init_data_size); | 232 int init_data_size); |
| 221 | 233 |
| 222 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | 234 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. |
| 223 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); | 235 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); |
| 224 | 236 |
| 225 protected: | 237 protected: |
| 226 // Helper method to update the playing state. | 238 // Helper method to update the playing state. |
| 227 void UpdatePlayingState(bool is_playing_); | 239 void UpdatePlayingState(bool is_playing_); |
| 228 | 240 |
| 229 // Helper methods for posting task for setting states and update WebKit. | 241 // Helper methods for posting task for setting states and update WebKit. |
| 230 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); | 242 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); |
| 231 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); | 243 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); |
| 232 | 244 |
| 233 // Helper method to reestablish the surface texture peer for android | 245 // Helper method to reestablish the surface texture peer for android |
| 234 // media player. | 246 // media player. |
| 235 void EstablishSurfaceTexturePeer(); | 247 void EstablishSurfaceTexturePeer(); |
| 236 | 248 |
| 237 // Requesting whether the surface texture peer needs to be reestablished. | 249 // Requesting whether the surface texture peer needs to be reestablished. |
| 238 void SetNeedsEstablishPeer(bool needs_establish_peer); | 250 void SetNeedsEstablishPeer(bool needs_establish_peer); |
| 239 | 251 |
| 252 void InitializeMediaPlayer( |
| 253 const WebKit::WebURL& url, |
| 254 media::MediaPlayerAndroid::SourceType source_type); |
| 255 |
| 240 #if defined(GOOGLE_TV) | 256 #if defined(GOOGLE_TV) |
| 241 // Request external surface for out-of-band composition. | 257 // Request external surface for out-of-band composition. |
| 242 void RequestExternalSurface(); | 258 void RequestExternalSurface(); |
| 243 #endif | 259 #endif |
| 244 | 260 |
| 245 private: | 261 private: |
| 246 void ReallocateVideoFrame(); | 262 void ReallocateVideoFrame(); |
| 247 | 263 |
| 248 #if defined(GOOGLE_TV) | 264 #if defined(GOOGLE_TV) |
| 249 // Actually do the work for generateKeyRequest/addKey so they can easily | 265 // Actually do the work for generateKeyRequest/addKey so they can easily |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // A pointer back to the compositor to inform it about state changes. This is | 351 // A pointer back to the compositor to inform it about state changes. This is |
| 336 // not NULL while the compositor is actively using this webmediaplayer. | 352 // not NULL while the compositor is actively using this webmediaplayer. |
| 337 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 353 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 338 | 354 |
| 339 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; | 355 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 340 | 356 |
| 341 #if defined(GOOGLE_TV) | 357 #if defined(GOOGLE_TV) |
| 342 // A rectangle represents the geometry of video frame, when computed last | 358 // A rectangle represents the geometry of video frame, when computed last |
| 343 // time. | 359 // time. |
| 344 gfx::RectF last_computed_rect_; | 360 gfx::RectF last_computed_rect_; |
| 361 |
| 362 // Media Stream related fields. |
| 363 media::Demuxer* demuxer_; |
| 364 base::Closure destroy_demuxer_cb_; |
| 345 #endif | 365 #endif |
| 346 | 366 |
| 347 scoped_ptr<MediaSourceDelegate, | 367 scoped_ptr<MediaSourceDelegate, |
| 348 MediaSourceDelegate::Destroyer> media_source_delegate_; | 368 MediaSourceDelegate::Destroyer> media_source_delegate_; |
| 349 | 369 |
| 350 // Proxy object that delegates method calls on Render Thread. | 370 // Proxy object that delegates method calls on Render Thread. |
| 351 // This object is created on the Render Thread and is only called in the | 371 // This object is created on the Render Thread and is only called in the |
| 352 // destructor. | 372 // destructor. |
| 353 WebMediaPlayerProxyAndroid* proxy_; | 373 WebMediaPlayerProxyAndroid* proxy_; |
| 354 | 374 |
| 355 // The current playing time. Because the media player is in the browser | 375 // The current playing time. Because the media player is in the browser |
| 356 // process, it will regularly update the |current_time_| by calling | 376 // process, it will regularly update the |current_time_| by calling |
| 357 // OnTimeUpdate(). | 377 // OnTimeUpdate(). |
| 358 double current_time_; | 378 double current_time_; |
| 359 | 379 |
| 360 media::MediaLog* media_log_; | 380 media::MediaLog* media_log_; |
| 381 MediaStreamClient* media_stream_client_; |
| 361 | 382 |
| 362 // The currently selected key system. Empty string means that no key system | 383 // The currently selected key system. Empty string means that no key system |
| 363 // has been selected. | 384 // has been selected. |
| 364 WebKit::WebString current_key_system_; | 385 WebKit::WebString current_key_system_; |
| 365 | 386 |
| 366 // Temporary for EME v0.1. In the future the init data type should be passed | 387 // Temporary for EME v0.1. In the future the init data type should be passed |
| 367 // through GenerateKeyRequest() directly from WebKit. | 388 // through GenerateKeyRequest() directly from WebKit. |
| 368 std::string init_data_type_; | 389 std::string init_data_type_; |
| 369 | 390 |
| 370 // The decryptor that manages decryption keys and decrypts encrypted frames. | 391 // The decryptor that manages decryption keys and decrypts encrypted frames. |
| 371 scoped_ptr<ProxyDecryptor> decryptor_; | 392 scoped_ptr<ProxyDecryptor> decryptor_; |
| 372 | 393 |
| 373 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 394 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 374 }; | 395 }; |
| 375 | 396 |
| 376 } // namespace webkit_media | 397 } // namespace webkit_media |
| 377 | 398 |
| 378 #endif // WEBKIT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 399 #endif // WEBKIT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |