| 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" |
| 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "cc/layers/video_frame_provider.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
| 17 | 19 |
| 18 namespace WebKit { | 20 namespace webkit { |
| 19 class WebVideoFrame; | 21 class WebLayerImpl; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace webkit_media { | 24 namespace webkit_media { |
| 23 | 25 |
| 24 class StreamTextureFactory; | 26 class StreamTextureFactory; |
| 25 class StreamTextureProxy; | 27 class StreamTextureProxy; |
| 26 class WebMediaPlayerManagerAndroid; | 28 class WebMediaPlayerManagerAndroid; |
| 27 class WebVideoFrameImpl; | |
| 28 | 29 |
| 29 // An abstract class that serves as the common base class for implementing | 30 // An abstract class that serves as the common base class for implementing |
| 30 // WebKit::WebMediaPlayer on Android. | 31 // WebKit::WebMediaPlayer on Android. |
| 31 class WebMediaPlayerAndroid | 32 class WebMediaPlayerAndroid |
| 32 : public WebKit::WebMediaPlayer, | 33 : public WebKit::WebMediaPlayer, |
| 34 public cc::VideoFrameProvider, |
| 33 public MessageLoop::DestructionObserver { | 35 public MessageLoop::DestructionObserver { |
| 34 public: | 36 public: |
| 35 // Resource loading. | 37 // Resource loading. |
| 36 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); | 38 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); |
| 37 virtual void load(const WebKit::WebURL& url, | 39 virtual void load(const WebKit::WebURL& url, |
| 38 WebKit::WebMediaSource* media_source, | 40 WebKit::WebMediaSource* media_source, |
| 39 CORSMode cors_mode); | 41 CORSMode cors_mode); |
| 40 virtual void cancelLoad(); | 42 virtual void cancelLoad(); |
| 41 | 43 |
| 42 // Playback controls. | 44 // Playback controls. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; | 89 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; |
| 88 | 90 |
| 89 virtual float mediaTimeForTimeValue(float timeValue) const; | 91 virtual float mediaTimeForTimeValue(float timeValue) const; |
| 90 | 92 |
| 91 // Provide statistics. | 93 // Provide statistics. |
| 92 virtual unsigned decodedFrameCount() const; | 94 virtual unsigned decodedFrameCount() const; |
| 93 virtual unsigned droppedFrameCount() const; | 95 virtual unsigned droppedFrameCount() const; |
| 94 virtual unsigned audioDecodedByteCount() const; | 96 virtual unsigned audioDecodedByteCount() const; |
| 95 virtual unsigned videoDecodedByteCount() const; | 97 virtual unsigned videoDecodedByteCount() const; |
| 96 | 98 |
| 97 // Methods called from VideoLayerChromium. These methods are running on the | 99 // cc::VideoFrameProvider implementation. |
| 98 // compositor thread. | 100 virtual void SetVideoFrameProviderClient( |
| 99 virtual WebKit::WebVideoFrame* getCurrentFrame(); | 101 cc::VideoFrameProvider::Client* client) OVERRIDE; |
| 100 virtual void putCurrentFrame(WebKit::WebVideoFrame*); | 102 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE; |
| 101 | 103 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame) |
| 102 // This gets called both on compositor and main thread to set the callback | 104 OVERRIDE; |
| 103 // target when a frame is produced. | |
| 104 virtual void setStreamTextureClient(WebKit::WebStreamTextureClient* client); | |
| 105 | 105 |
| 106 // Media player callback handlers. | 106 // Media player callback handlers. |
| 107 virtual void OnMediaPrepared(base::TimeDelta duration); | 107 virtual void OnMediaPrepared(base::TimeDelta duration); |
| 108 virtual void OnPlaybackComplete(); | 108 virtual void OnPlaybackComplete(); |
| 109 virtual void OnBufferingUpdate(int percentage); | 109 virtual void OnBufferingUpdate(int percentage); |
| 110 virtual void OnSeekComplete(base::TimeDelta current_time); | 110 virtual void OnSeekComplete(base::TimeDelta current_time); |
| 111 virtual void OnMediaError(int error_type); | 111 virtual void OnMediaError(int error_type); |
| 112 virtual void OnVideoSizeChanged(int width, int height); | 112 virtual void OnVideoSizeChanged(int width, int height); |
| 113 | 113 |
| 114 // Called to update the current time. | 114 // Called to update the current time. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void ReallocateVideoFrame(); | 188 void ReallocateVideoFrame(); |
| 189 | 189 |
| 190 WebKit::WebMediaPlayerClient* const client_; | 190 WebKit::WebMediaPlayerClient* const client_; |
| 191 | 191 |
| 192 // Save the list of buffered time ranges. | 192 // Save the list of buffered time ranges. |
| 193 WebKit::WebTimeRanges buffered_; | 193 WebKit::WebTimeRanges buffered_; |
| 194 | 194 |
| 195 // Size of the video. | 195 // Size of the video. |
| 196 WebKit::WebSize natural_size_; | 196 WebKit::WebSize natural_size_; |
| 197 | 197 |
| 198 // The video frame object used for renderering by WebKit. | 198 // The video frame object used for rendering by the compositor. |
| 199 scoped_ptr<WebVideoFrameImpl> web_video_frame_; | 199 scoped_refptr<media::VideoFrame> current_frame_; |
| 200 | 200 |
| 201 // Message loop for main renderer thread. | 201 // Message loop for main renderer thread. |
| 202 MessageLoop* main_loop_; | 202 MessageLoop* main_loop_; |
| 203 | 203 |
| 204 // URL of the media file to be fetched. | 204 // URL of the media file to be fetched. |
| 205 GURL url_; | 205 GURL url_; |
| 206 | 206 |
| 207 // Media duration. | 207 // Media duration. |
| 208 base::TimeDelta duration_; | 208 base::TimeDelta duration_; |
| 209 | 209 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // Object for allocating stream textures. | 244 // Object for allocating stream textures. |
| 245 scoped_ptr<StreamTextureFactory> stream_texture_factory_; | 245 scoped_ptr<StreamTextureFactory> stream_texture_factory_; |
| 246 | 246 |
| 247 // Object for calling back the compositor thread to repaint the video when a | 247 // Object for calling back the compositor thread to repaint the video when a |
| 248 // frame available. It should be initialized on the compositor thread. | 248 // frame available. It should be initialized on the compositor thread. |
| 249 scoped_ptr<StreamTextureProxy> stream_texture_proxy_; | 249 scoped_ptr<StreamTextureProxy> stream_texture_proxy_; |
| 250 | 250 |
| 251 // Whether media player needs external surface. | 251 // Whether media player needs external surface. |
| 252 bool needs_external_surface_; | 252 bool needs_external_surface_; |
| 253 | 253 |
| 254 // A pointer back to the compositor to inform it about state changes. This is |
| 255 // not NULL while the compositor is actively using this webmediaplayer. |
| 256 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 257 |
| 258 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 259 |
| 254 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 260 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 255 }; | 261 }; |
| 256 | 262 |
| 257 } // namespace webkit_media | 263 } // namespace webkit_media |
| 258 | 264 |
| 259 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 265 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |