| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "content/renderer/media/android/renderer_media_player_manager.h" | 23 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 24 #include "content/renderer/media/android/stream_texture_factory.h" | 24 #include "content/renderer/media/android/stream_texture_factory.h" |
| 25 #include "gpu/command_buffer/common/mailbox.h" | 25 #include "gpu/command_buffer/common/mailbox.h" |
| 26 #include "media/base/android/media_player_android.h" | 26 #include "media/base/android/media_player_android.h" |
| 27 #include "media/base/cdm_context.h" | 27 #include "media/base/cdm_context.h" |
| 28 #include "media/base/demuxer_stream.h" | 28 #include "media/base/demuxer_stream.h" |
| 29 #include "media/base/media_keys.h" | 29 #include "media/base/media_keys.h" |
| 30 #include "media/base/time_delta_interpolator.h" | 30 #include "media/base/time_delta_interpolator.h" |
| 31 #include "media/blink/webmediaplayer_delegate.h" | 31 #include "media/blink/webmediaplayer_delegate.h" |
| 32 #include "media/blink/webmediaplayer_params.h" | 32 #include "media/blink/webmediaplayer_params.h" |
| 33 #include "media/cdm/proxy_decryptor.h" | |
| 34 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 33 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 35 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 34 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
| 36 #include "third_party/WebKit/public/platform/WebSetSinkIdCallbacks.h" | 35 #include "third_party/WebKit/public/platform/WebSetSinkIdCallbacks.h" |
| 37 #include "third_party/WebKit/public/platform/WebSize.h" | 36 #include "third_party/WebKit/public/platform/WebSize.h" |
| 38 #include "third_party/WebKit/public/platform/WebURL.h" | 37 #include "third_party/WebKit/public/platform/WebURL.h" |
| 39 #include "third_party/skia/include/core/SkBitmap.h" | 38 #include "third_party/skia/include/core/SkBitmap.h" |
| 40 #include "ui/gfx/geometry/rect_f.h" | 39 #include "ui/gfx/geometry/rect_f.h" |
| 41 | 40 |
| 42 namespace base { | 41 namespace base { |
| 43 class SingleThreadTaskRunner; | 42 class SingleThreadTaskRunner; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 namespace cc_blink { | 54 namespace cc_blink { |
| 56 class WebLayerImpl; | 55 class WebLayerImpl; |
| 57 } | 56 } |
| 58 | 57 |
| 59 namespace gpu { | 58 namespace gpu { |
| 60 struct MailboxHolder; | 59 struct MailboxHolder; |
| 61 } | 60 } |
| 62 | 61 |
| 63 namespace media { | 62 namespace media { |
| 64 class CdmContext; | 63 class CdmContext; |
| 65 class CdmFactory; | |
| 66 class MediaLog; | 64 class MediaLog; |
| 67 class MediaPermission; | |
| 68 class WebContentDecryptionModuleImpl; | 65 class WebContentDecryptionModuleImpl; |
| 69 } | 66 } |
| 70 | 67 |
| 71 namespace content { | 68 namespace content { |
| 72 | 69 |
| 73 class RendererCdmManager; | |
| 74 class RendererMediaPlayerManager; | 70 class RendererMediaPlayerManager; |
| 75 | 71 |
| 76 // This class implements blink::WebMediaPlayer by keeping the android | 72 // This class implements blink::WebMediaPlayer by keeping the android |
| 77 // media player in the browser process. It listens to all the status changes | 73 // media player in the browser process. It listens to all the status changes |
| 78 // sent from the browser process and sends playback controls to the media | 74 // sent from the browser process and sends playback controls to the media |
| 79 // player. | 75 // player. |
| 80 class WebMediaPlayerAndroid | 76 class WebMediaPlayerAndroid |
| 81 : public blink::WebMediaPlayer, | 77 : public blink::WebMediaPlayer, |
| 82 public cc::VideoFrameProvider, | 78 public cc::VideoFrameProvider, |
| 83 public StreamTextureFactoryContextObserver, | 79 public StreamTextureFactoryContextObserver, |
| 84 public media::RendererMediaPlayerInterface, | 80 public media::RendererMediaPlayerInterface, |
| 85 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer) { | 81 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer) { |
| 86 public: | 82 public: |
| 87 // Construct a WebMediaPlayerAndroid object. This class communicates with the | 83 // Construct a WebMediaPlayerAndroid object. This class communicates with the |
| 88 // MediaPlayerAndroid object in the browser process through |proxy|. | 84 // MediaPlayerAndroid object in the browser process through |proxy|. |
| 89 // TODO(qinmin): |frame| argument is used to determine whether the current | 85 // TODO(qinmin): |frame| argument is used to determine whether the current |
| 90 // player can enter fullscreen. This logic should probably be moved into | 86 // player can enter fullscreen. This logic should probably be moved into |
| 91 // blink, so that enteredFullscreen() will not be called if another video is | 87 // blink, so that enteredFullscreen() will not be called if another video is |
| 92 // already in fullscreen. | 88 // already in fullscreen. |
| 93 WebMediaPlayerAndroid( | 89 WebMediaPlayerAndroid( |
| 94 blink::WebFrame* frame, | 90 blink::WebFrame* frame, |
| 95 blink::WebMediaPlayerClient* client, | 91 blink::WebMediaPlayerClient* client, |
| 96 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 92 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 97 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 93 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
| 98 RendererMediaPlayerManager* player_manager, | 94 RendererMediaPlayerManager* player_manager, |
| 99 media::CdmFactory* cdm_factory, | |
| 100 scoped_refptr<StreamTextureFactory> factory, | 95 scoped_refptr<StreamTextureFactory> factory, |
| 101 int frame_id, | 96 int frame_id, |
| 102 bool enable_texture_copy, | 97 bool enable_texture_copy, |
| 103 const media::WebMediaPlayerParams& params); | 98 const media::WebMediaPlayerParams& params); |
| 104 ~WebMediaPlayerAndroid() override; | 99 ~WebMediaPlayerAndroid() override; |
| 105 | 100 |
| 106 // blink::WebMediaPlayer implementation. | 101 // blink::WebMediaPlayer implementation. |
| 107 bool supportsOverlayFullscreenVideo() override; | 102 bool supportsOverlayFullscreenVideo() override; |
| 108 void enteredFullscreen() override; | 103 void enteredFullscreen() override; |
| 109 | 104 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 223 |
| 229 #if defined(VIDEO_HOLE) | 224 #if defined(VIDEO_HOLE) |
| 230 // Calculate the boundary rectangle of the media player (i.e. location and | 225 // Calculate the boundary rectangle of the media player (i.e. location and |
| 231 // size of the video frame). | 226 // size of the video frame). |
| 232 // Returns true if the geometry has been changed since the last call. | 227 // Returns true if the geometry has been changed since the last call. |
| 233 bool UpdateBoundaryRectangle() override; | 228 bool UpdateBoundaryRectangle() override; |
| 234 | 229 |
| 235 const gfx::RectF GetBoundaryRectangle() override; | 230 const gfx::RectF GetBoundaryRectangle() override; |
| 236 #endif // defined(VIDEO_HOLE) | 231 #endif // defined(VIDEO_HOLE) |
| 237 | 232 |
| 238 MediaKeyException generateKeyRequest(const blink::WebString& key_system, | |
| 239 const unsigned char* init_data, | |
| 240 unsigned init_data_length) override; | |
| 241 MediaKeyException addKey(const blink::WebString& key_system, | |
| 242 const unsigned char* key, | |
| 243 unsigned key_length, | |
| 244 const unsigned char* init_data, | |
| 245 unsigned init_data_length, | |
| 246 const blink::WebString& session_id) override; | |
| 247 MediaKeyException cancelKeyRequest( | |
| 248 const blink::WebString& key_system, | |
| 249 const blink::WebString& session_id) override; | |
| 250 | |
| 251 void setContentDecryptionModule( | 233 void setContentDecryptionModule( |
| 252 blink::WebContentDecryptionModule* cdm, | 234 blink::WebContentDecryptionModule* cdm, |
| 253 blink::WebContentDecryptionModuleResult result) override; | 235 blink::WebContentDecryptionModuleResult result) override; |
| 254 | 236 |
| 255 void OnKeyAdded(const std::string& session_id); | |
| 256 void OnKeyError(const std::string& session_id, | |
| 257 media::MediaKeys::KeyError error_code, | |
| 258 uint32_t system_code); | |
| 259 void OnKeyMessage(const std::string& session_id, | |
| 260 const std::vector<uint8_t>& message, | |
| 261 const GURL& destination_url); | |
| 262 | |
| 263 void OnMediaSourceOpened(blink::WebMediaSource* web_media_source); | 237 void OnMediaSourceOpened(blink::WebMediaSource* web_media_source); |
| 264 | 238 |
| 265 void OnEncryptedMediaInitData(media::EmeInitDataType init_data_type, | 239 void OnEncryptedMediaInitData(media::EmeInitDataType init_data_type, |
| 266 const std::vector<uint8_t>& init_data); | 240 const std::vector<uint8_t>& init_data); |
| 267 | 241 |
| 268 // Called when a decoder detects that the key needed to decrypt the stream | 242 // Called when a decoder detects that the key needed to decrypt the stream |
| 269 // is not available. | 243 // is not available. |
| 270 void OnWaitingForDecryptionKey() override; | 244 void OnWaitingForDecryptionKey() override; |
| 271 | 245 |
| 272 // WebMediaPlayerDelegate::Observer implementation. | 246 // WebMediaPlayerDelegate::Observer implementation. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 303 void ReallocateVideoFrame(); | 277 void ReallocateVideoFrame(); |
| 304 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame); | 278 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame); |
| 305 void RemoveSurfaceTextureAndProxy(); | 279 void RemoveSurfaceTextureAndProxy(); |
| 306 void DidLoadMediaInfo(MediaInfoLoader::Status status, | 280 void DidLoadMediaInfo(MediaInfoLoader::Status status, |
| 307 const GURL& redirected_url, | 281 const GURL& redirected_url, |
| 308 const GURL& first_party_for_cookies, | 282 const GURL& first_party_for_cookies, |
| 309 bool allow_stored_credentials); | 283 bool allow_stored_credentials); |
| 310 bool IsKeySystemSupported(const std::string& key_system); | 284 bool IsKeySystemSupported(const std::string& key_system); |
| 311 bool IsLocalResource(); | 285 bool IsLocalResource(); |
| 312 | 286 |
| 313 // Actually do the work for generateKeyRequest/addKey so they can easily | |
| 314 // report results to UMA. | |
| 315 MediaKeyException GenerateKeyRequestInternal(const std::string& key_system, | |
| 316 const unsigned char* init_data, | |
| 317 unsigned init_data_length); | |
| 318 MediaKeyException AddKeyInternal(const std::string& key_system, | |
| 319 const unsigned char* key, | |
| 320 unsigned key_length, | |
| 321 const unsigned char* init_data, | |
| 322 unsigned init_data_length, | |
| 323 const std::string& session_id); | |
| 324 MediaKeyException CancelKeyRequestInternal(const std::string& key_system, | |
| 325 const std::string& session_id); | |
| 326 | |
| 327 // Called when |cdm_context| is ready. | 287 // Called when |cdm_context| is ready. |
| 328 void OnCdmContextReady(media::CdmContext* cdm_context); | 288 void OnCdmContextReady(media::CdmContext* cdm_context); |
| 329 | 289 |
| 330 // Sets the CDM. Should only be called when |is_player_initialized_| is true | 290 // Sets the CDM. Should only be called when |is_player_initialized_| is true |
| 331 // and a new non-null |cdm_context_| is available. Fires |cdm_attached_cb_| on | 291 // and a new non-null |cdm_context_| is available. Fires |cdm_attached_cb_| on |
| 332 // the main thread with the result after the CDM is attached. | 292 // the main thread with the result after the CDM is attached. |
| 333 void SetCdmInternal(const media::CdmAttachedCB& cdm_attached_cb); | 293 void SetCdmInternal(const media::CdmAttachedCB& cdm_attached_cb); |
| 334 | 294 |
| 335 // Called when the CDM is attached. | 295 // Called when the CDM is attached. |
| 336 void OnCdmAttached(const media::CdmAttachedCB& cdm_attached_cb, bool success); | 296 void OnCdmAttached(const media::CdmAttachedCB& cdm_attached_cb, bool success); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 bool seeking_; | 374 bool seeking_; |
| 415 base::TimeDelta seek_time_; | 375 base::TimeDelta seek_time_; |
| 416 | 376 |
| 417 // Whether loading has progressed since the last call to didLoadingProgress. | 377 // Whether loading has progressed since the last call to didLoadingProgress. |
| 418 bool did_loading_progress_; | 378 bool did_loading_progress_; |
| 419 | 379 |
| 420 // Manages this object and delegates player calls to the browser process. | 380 // Manages this object and delegates player calls to the browser process. |
| 421 // Owned by RenderFrameImpl. | 381 // Owned by RenderFrameImpl. |
| 422 RendererMediaPlayerManager* const player_manager_; | 382 RendererMediaPlayerManager* const player_manager_; |
| 423 | 383 |
| 424 // TODO(xhwang): Remove |cdm_factory_| when prefixed EME is deprecated. See | |
| 425 // http://crbug.com/249976 | |
| 426 media::CdmFactory* const cdm_factory_; | |
| 427 | |
| 428 media::MediaPermission* media_permission_; | |
| 429 | |
| 430 // Player ID assigned by the |player_manager_|. | 384 // Player ID assigned by the |player_manager_|. |
| 431 int player_id_; | 385 int player_id_; |
| 432 | 386 |
| 433 // Current player states. | 387 // Current player states. |
| 434 blink::WebMediaPlayer::NetworkState network_state_; | 388 blink::WebMediaPlayer::NetworkState network_state_; |
| 435 blink::WebMediaPlayer::ReadyState ready_state_; | 389 blink::WebMediaPlayer::ReadyState ready_state_; |
| 436 | 390 |
| 437 // GL texture ID allocated to the video. | 391 // GL texture ID allocated to the video. |
| 438 unsigned int texture_id_; | 392 unsigned int texture_id_; |
| 439 | 393 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 448 |
| 495 MediaPlayerHostMsg_Initialize_Type player_type_; | 449 MediaPlayerHostMsg_Initialize_Type player_type_; |
| 496 | 450 |
| 497 // Whether the browser is currently connected to a remote media player. | 451 // Whether the browser is currently connected to a remote media player. |
| 498 bool is_remote_; | 452 bool is_remote_; |
| 499 | 453 |
| 500 scoped_refptr<media::MediaLog> media_log_; | 454 scoped_refptr<media::MediaLog> media_log_; |
| 501 | 455 |
| 502 scoped_ptr<MediaInfoLoader> info_loader_; | 456 scoped_ptr<MediaInfoLoader> info_loader_; |
| 503 | 457 |
| 504 // The currently selected key system. Empty string means that no key system | |
| 505 // has been selected. | |
| 506 std::string current_key_system_; | |
| 507 | |
| 508 // Temporary for EME v0.1. Not needed for unprefixed EME, and can be removed | |
| 509 // when prefixed EME is removed. | |
| 510 media::EmeInitDataType init_data_type_; | |
| 511 | |
| 512 // Manages decryption keys and decrypts encrypted frames. | |
| 513 scoped_ptr<media::ProxyDecryptor> proxy_decryptor_; | |
| 514 | |
| 515 // Non-owned pointer to the CdmContext. Updated in the constructor, | 458 // Non-owned pointer to the CdmContext. Updated in the constructor, |
| 516 // generateKeyRequest() or setContentDecryptionModule(). | 459 // generateKeyRequest() or setContentDecryptionModule(). |
| 517 media::CdmContext* cdm_context_; | 460 media::CdmContext* cdm_context_; |
| 518 | 461 |
| 519 // This is only Used by Clear Key key system implementation, where a renderer | 462 // This is only Used by Clear Key key system implementation, where a renderer |
| 520 // side CDM will be used. This is similar to WebMediaPlayerImpl. For other key | 463 // side CDM will be used. This is similar to WebMediaPlayerImpl. For other key |
| 521 // systems, a browser side CDM will be used and we set CDM by calling | 464 // systems, a browser side CDM will be used and we set CDM by calling |
| 522 // player_manager_->SetCdm() directly. | 465 // player_manager_->SetCdm() directly. |
| 523 media::CdmReadyCB cdm_ready_cb_; | 466 media::CdmReadyCB cdm_ready_cb_; |
| 524 | 467 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 503 |
| 561 // NOTE: Weak pointers must be invalidated before all other member variables. | 504 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 562 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; | 505 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; |
| 563 | 506 |
| 564 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 507 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 565 }; | 508 }; |
| 566 | 509 |
| 567 } // namespace content | 510 } // namespace content |
| 568 | 511 |
| 569 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 512 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |