| 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/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "cc/layers/video_frame_provider.h" | 17 #include "cc/layers/video_frame_provider.h" |
| 18 #include "cc/resources/media/skcanvas_video_renderer.h" |
| 18 #include "content/common/media/media_player_messages_enums_android.h" | 19 #include "content/common/media/media_player_messages_enums_android.h" |
| 19 #include "content/public/renderer/render_frame_observer.h" | 20 #include "content/public/renderer/render_frame_observer.h" |
| 20 #include "content/renderer/media/android/media_info_loader.h" | 21 #include "content/renderer/media/android/media_info_loader.h" |
| 21 #include "content/renderer/media/android/media_source_delegate.h" | 22 #include "content/renderer/media/android/media_source_delegate.h" |
| 22 #include "content/renderer/media/android/stream_texture_factory.h" | 23 #include "content/renderer/media/android/stream_texture_factory.h" |
| 23 #include "content/renderer/media/crypto/proxy_decryptor.h" | 24 #include "content/renderer/media/crypto/proxy_decryptor.h" |
| 24 #include "gpu/command_buffer/common/mailbox.h" | 25 #include "gpu/command_buffer/common/mailbox.h" |
| 25 #include "media/base/android/media_player_android.h" | 26 #include "media/base/android/media_player_android.h" |
| 26 #include "media/base/demuxer_stream.h" | 27 #include "media/base/demuxer_stream.h" |
| 27 #include "media/base/media_keys.h" | 28 #include "media/base/media_keys.h" |
| 28 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
| 29 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 29 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
| 30 #include "third_party/WebKit/public/platform/WebSize.h" | 30 #include "third_party/WebKit/public/platform/WebSize.h" |
| 31 #include "third_party/WebKit/public/platform/WebURL.h" | 31 #include "third_party/WebKit/public/platform/WebURL.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | |
| 33 #include "third_party/skia/include/gpu/GrContext.h" | |
| 34 #include "third_party/skia/include/gpu/SkGrPixelRef.h" | |
| 35 #include "ui/gfx/rect_f.h" | 32 #include "ui/gfx/rect_f.h" |
| 36 | 33 |
| 37 namespace base { | 34 namespace base { |
| 38 class MessageLoopProxy; | 35 class MessageLoopProxy; |
| 39 } | 36 } |
| 40 | 37 |
| 41 namespace blink { | 38 namespace blink { |
| 42 class WebContentDecryptionModule; | 39 class WebContentDecryptionModule; |
| 40 class WebGraphicsContext3D; |
| 43 class WebFrame; | 41 class WebFrame; |
| 44 class WebURL; | 42 class WebURL; |
| 45 } | 43 } |
| 46 | 44 |
| 47 namespace gpu { | 45 namespace gpu { |
| 48 struct MailboxHolder; | 46 struct MailboxHolder; |
| 49 } | 47 } |
| 50 | 48 |
| 51 namespace media { | 49 namespace media { |
| 52 class MediaLog; | 50 class MediaLog; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual bool supportsSave() const; | 97 virtual bool supportsSave() const; |
| 100 virtual void setRate(double rate); | 98 virtual void setRate(double rate); |
| 101 virtual void setVolume(double volume); | 99 virtual void setVolume(double volume); |
| 102 virtual blink::WebTimeRanges buffered() const; | 100 virtual blink::WebTimeRanges buffered() const; |
| 103 virtual double maxTimeSeekable() const; | 101 virtual double maxTimeSeekable() const; |
| 104 | 102 |
| 105 // Poster image, as defined in the <video> element. | 103 // Poster image, as defined in the <video> element. |
| 106 virtual void setPoster(const blink::WebURL& poster) OVERRIDE; | 104 virtual void setPoster(const blink::WebURL& poster) OVERRIDE; |
| 107 | 105 |
| 108 // Methods for painting. | 106 // Methods for painting. |
| 109 // FIXME: This path "only works" on Android. It is a workaround for the | |
| 110 // issue that Skia could not handle Android's GL_TEXTURE_EXTERNAL_OES texture | |
| 111 // internally. It should be removed and replaced by the normal paint path. | |
| 112 // https://code.google.com/p/skia/issues/detail?id=1189 | |
| 113 virtual void paint(blink::WebCanvas* canvas, | 107 virtual void paint(blink::WebCanvas* canvas, |
| 114 const blink::WebRect& rect, | 108 const blink::WebRect& rect, |
| 115 unsigned char alpha); | 109 unsigned char alpha); |
| 116 | 110 |
| 117 virtual bool copyVideoTextureToPlatformTexture( | 111 virtual bool copyVideoTextureToPlatformTexture( |
| 118 blink::WebGraphicsContext3D* web_graphics_context, | 112 blink::WebGraphicsContext3D* web_graphics_context, |
| 119 unsigned int texture, | 113 unsigned int texture, |
| 120 unsigned int level, | 114 unsigned int level, |
| 121 unsigned int internal_format, | 115 unsigned int internal_format, |
| 122 unsigned int type, | 116 unsigned int type, |
| 123 bool premultiply_alpha, | 117 bool premultiply_alpha, |
| 124 bool flip_y); | 118 bool flip_y) OVERRIDE; |
| 125 | 119 |
| 126 // True if the loaded media has a playable video/audio track. | 120 // True if the loaded media has a playable video/audio track. |
| 127 virtual bool hasVideo() const; | 121 virtual bool hasVideo() const; |
| 128 virtual bool hasAudio() const; | 122 virtual bool hasAudio() const; |
| 129 | 123 |
| 130 // Dimensions of the video. | 124 // Dimensions of the video. |
| 131 virtual blink::WebSize naturalSize() const; | 125 virtual blink::WebSize naturalSize() const; |
| 132 | 126 |
| 133 // Getters of playback state. | 127 // Getters of playback state. |
| 134 virtual bool paused() const; | 128 virtual bool paused() const; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const std::string& session_id); | 271 const std::string& session_id); |
| 278 MediaKeyException CancelKeyRequestInternal(const std::string& key_system, | 272 MediaKeyException CancelKeyRequestInternal(const std::string& key_system, |
| 279 const std::string& session_id); | 273 const std::string& session_id); |
| 280 | 274 |
| 281 // Requests that this object notifies when a decryptor is ready through the | 275 // Requests that this object notifies when a decryptor is ready through the |
| 282 // |decryptor_ready_cb| provided. | 276 // |decryptor_ready_cb| provided. |
| 283 // If |decryptor_ready_cb| is null, the existing callback will be fired with | 277 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
| 284 // NULL immediately and reset. | 278 // NULL immediately and reset. |
| 285 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 279 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
| 286 | 280 |
| 287 bool EnsureTextureBackedSkBitmap(GrContext* gr, SkBitmap& bitmap, | |
| 288 const blink::WebSize& size, | |
| 289 GrSurfaceOrigin origin, | |
| 290 GrPixelConfig config); | |
| 291 | |
| 292 blink::WebFrame* const frame_; | 281 blink::WebFrame* const frame_; |
| 293 | 282 |
| 294 blink::WebMediaPlayerClient* const client_; | 283 blink::WebMediaPlayerClient* const client_; |
| 295 | 284 |
| 296 // |delegate_| is used to notify the browser process of the player status, so | 285 // |delegate_| is used to notify the browser process of the player status, so |
| 297 // that the browser process can control screen locks. | 286 // that the browser process can control screen locks. |
| 298 // TODO(qinmin): Currently android mediaplayer takes care of the screen | 287 // TODO(qinmin): Currently android mediaplayer takes care of the screen |
| 299 // lock. So this is only used for media source. Will apply this to regular | 288 // lock. So this is only used for media source. Will apply this to regular |
| 300 // media tag once http://crbug.com/247892 is fixed. | 289 // media tag once http://crbug.com/247892 is fixed. |
| 301 base::WeakPtr<WebMediaPlayerDelegate> delegate_; | 290 base::WeakPtr<WebMediaPlayerDelegate> delegate_; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 // Non-owned pointer to the CDM. Updated via calls to | 430 // Non-owned pointer to the CDM. Updated via calls to |
| 442 // setContentDecryptionModule(). | 431 // setContentDecryptionModule(). |
| 443 WebContentDecryptionModuleImpl* web_cdm_; | 432 WebContentDecryptionModuleImpl* web_cdm_; |
| 444 | 433 |
| 445 // This is only Used by Clear Key key system implementation, where a renderer | 434 // This is only Used by Clear Key key system implementation, where a renderer |
| 446 // side CDM will be used. This is similar to WebMediaPlayerImpl. For other key | 435 // side CDM will be used. This is similar to WebMediaPlayerImpl. For other key |
| 447 // systems, a browser side CDM will be used and we set CDM by calling | 436 // systems, a browser side CDM will be used and we set CDM by calling |
| 448 // player_manager_->SetCdm() directly. | 437 // player_manager_->SetCdm() directly. |
| 449 media::DecryptorReadyCB decryptor_ready_cb_; | 438 media::DecryptorReadyCB decryptor_ready_cb_; |
| 450 | 439 |
| 451 SkBitmap bitmap_; | 440 cc::SkCanvasVideoRenderer skcanvas_video_renderer_; |
| 452 | 441 |
| 453 // NOTE: Weak pointers must be invalidated before all other member variables. | 442 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 454 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; | 443 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; |
| 455 | 444 |
| 456 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 445 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 457 }; | 446 }; |
| 458 | 447 |
| 459 } // namespace content | 448 } // namespace content |
| 460 | 449 |
| 461 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 450 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |