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 WebVideoFrame; |
20 } | 22 } |
21 | 23 |
| 24 namespace webkit { |
| 25 class WebLayerImpl; |
| 26 } |
| 27 |
22 namespace webkit_media { | 28 namespace webkit_media { |
23 | 29 |
24 class StreamTextureFactory; | 30 class StreamTextureFactory; |
25 class StreamTextureProxy; | 31 class StreamTextureProxy; |
26 class WebMediaPlayerManagerAndroid; | 32 class WebMediaPlayerManagerAndroid; |
27 class WebVideoFrameImpl; | 33 class WebVideoFrameImpl; |
28 | 34 |
29 // An abstract class that serves as the common base class for implementing | 35 // An abstract class that serves as the common base class for implementing |
30 // WebKit::WebMediaPlayer on Android. | 36 // WebKit::WebMediaPlayer on Android. |
31 class WebMediaPlayerAndroid | 37 class WebMediaPlayerAndroid |
32 : public WebKit::WebMediaPlayer, | 38 : public WebKit::WebMediaPlayer, |
| 39 #ifdef REMOVE_WEBVIDEOFRAME |
| 40 public cc::VideoFrameProvider, |
| 41 #endif |
33 public MessageLoop::DestructionObserver { | 42 public MessageLoop::DestructionObserver { |
34 public: | 43 public: |
35 // Resource loading. | 44 // Resource loading. |
36 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); | 45 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); |
37 virtual void load(const WebKit::WebURL& url, | 46 virtual void load(const WebKit::WebURL& url, |
38 WebKit::WebMediaSource* media_source, | 47 WebKit::WebMediaSource* media_source, |
39 CORSMode cors_mode); | 48 CORSMode cors_mode); |
40 virtual void cancelLoad(); | 49 virtual void cancelLoad(); |
41 | 50 |
42 // Playback controls. | 51 // Playback controls. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; | 96 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; |
88 | 97 |
89 virtual float mediaTimeForTimeValue(float timeValue) const; | 98 virtual float mediaTimeForTimeValue(float timeValue) const; |
90 | 99 |
91 // Provide statistics. | 100 // Provide statistics. |
92 virtual unsigned decodedFrameCount() const; | 101 virtual unsigned decodedFrameCount() const; |
93 virtual unsigned droppedFrameCount() const; | 102 virtual unsigned droppedFrameCount() const; |
94 virtual unsigned audioDecodedByteCount() const; | 103 virtual unsigned audioDecodedByteCount() const; |
95 virtual unsigned videoDecodedByteCount() const; | 104 virtual unsigned videoDecodedByteCount() const; |
96 | 105 |
| 106 #ifndef REMOVE_WEBVIDEOFRAME |
97 // Methods called from VideoLayerChromium. These methods are running on the | 107 // Methods called from VideoLayerChromium. These methods are running on the |
98 // compositor thread. | 108 // compositor thread. |
99 virtual WebKit::WebVideoFrame* getCurrentFrame(); | 109 virtual WebKit::WebVideoFrame* getCurrentFrame(); |
100 virtual void putCurrentFrame(WebKit::WebVideoFrame*); | 110 virtual void putCurrentFrame(WebKit::WebVideoFrame*); |
101 | 111 |
102 // This gets called both on compositor and main thread to set the callback | 112 // This gets called both on compositor and main thread to set the callback |
103 // target when a frame is produced. | 113 // target when a frame is produced. |
104 virtual void setStreamTextureClient(WebKit::WebStreamTextureClient* client); | 114 virtual void setStreamTextureClient(WebKit::WebStreamTextureClient* client); |
| 115 #else |
| 116 // cc::VideoFrameProvider implementation. These methods are running on the |
| 117 // compositor thread. |
| 118 virtual void SetVideoFrameProviderClient( |
| 119 cc::VideoFrameProvider::Client* client) OVERRIDE; |
| 120 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE; |
| 121 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame) |
| 122 OVERRIDE; |
| 123 #endif |
105 | 124 |
106 // Media player callback handlers. | 125 // Media player callback handlers. |
107 virtual void OnMediaPrepared(base::TimeDelta duration); | 126 virtual void OnMediaPrepared(base::TimeDelta duration); |
108 virtual void OnPlaybackComplete(); | 127 virtual void OnPlaybackComplete(); |
109 virtual void OnBufferingUpdate(int percentage); | 128 virtual void OnBufferingUpdate(int percentage); |
110 virtual void OnSeekComplete(base::TimeDelta current_time); | 129 virtual void OnSeekComplete(base::TimeDelta current_time); |
111 virtual void OnMediaError(int error_type); | 130 virtual void OnMediaError(int error_type); |
112 virtual void OnVideoSizeChanged(int width, int height); | 131 virtual void OnVideoSizeChanged(int width, int height); |
113 | 132 |
114 // Called to update the current time. | 133 // Called to update the current time. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void ReallocateVideoFrame(); | 207 void ReallocateVideoFrame(); |
189 | 208 |
190 WebKit::WebMediaPlayerClient* const client_; | 209 WebKit::WebMediaPlayerClient* const client_; |
191 | 210 |
192 // Save the list of buffered time ranges. | 211 // Save the list of buffered time ranges. |
193 WebKit::WebTimeRanges buffered_; | 212 WebKit::WebTimeRanges buffered_; |
194 | 213 |
195 // Size of the video. | 214 // Size of the video. |
196 WebKit::WebSize natural_size_; | 215 WebKit::WebSize natural_size_; |
197 | 216 |
198 // The video frame object used for renderering by WebKit. | 217 // The video frame object used for rendering by the compositor. |
199 scoped_ptr<WebVideoFrameImpl> web_video_frame_; | 218 scoped_refptr<media::VideoFrame> current_frame_; |
200 | 219 |
201 // Message loop for main renderer thread. | 220 // Message loop for main renderer thread. |
202 MessageLoop* main_loop_; | 221 MessageLoop* main_loop_; |
203 | 222 |
204 // URL of the media file to be fetched. | 223 // URL of the media file to be fetched. |
205 GURL url_; | 224 GURL url_; |
206 | 225 |
207 // Media duration. | 226 // Media duration. |
208 base::TimeDelta duration_; | 227 base::TimeDelta duration_; |
209 | 228 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // Object for allocating stream textures. | 263 // Object for allocating stream textures. |
245 scoped_ptr<StreamTextureFactory> stream_texture_factory_; | 264 scoped_ptr<StreamTextureFactory> stream_texture_factory_; |
246 | 265 |
247 // Object for calling back the compositor thread to repaint the video when a | 266 // Object for calling back the compositor thread to repaint the video when a |
248 // frame available. It should be initialized on the compositor thread. | 267 // frame available. It should be initialized on the compositor thread. |
249 scoped_ptr<StreamTextureProxy> stream_texture_proxy_; | 268 scoped_ptr<StreamTextureProxy> stream_texture_proxy_; |
250 | 269 |
251 // Whether media player needs external surface. | 270 // Whether media player needs external surface. |
252 bool needs_external_surface_; | 271 bool needs_external_surface_; |
253 | 272 |
| 273 // A pointer back to the compositor to inform it about state changes. This is |
| 274 // not NULL while the compositor is actively using this webmediaplayer. |
| 275 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 276 |
| 277 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 278 |
254 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 279 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
255 }; | 280 }; |
256 | 281 |
257 } // namespace webkit_media | 282 } // namespace webkit_media |
258 | 283 |
259 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 284 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
OLD | NEW |