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" | 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 #if defined(GOOGLE_TV) | |
16 #include "media/base/demuxer_stream.h" | |
17 #endif | |
18 #include "cc/layers/video_frame_provider.h" | 15 #include "cc/layers/video_frame_provider.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
23 #include "ui/gfx/rect_f.h" | 20 #include "ui/gfx/rect_f.h" |
24 #include "webkit/media/android/stream_texture_factory_android.h" | 21 #include "webkit/media/android/stream_texture_factory_android.h" |
25 | 22 |
26 namespace media { | 23 namespace media { |
27 class MediaLog; | 24 class MediaLog; |
28 } | 25 } |
29 | 26 |
30 namespace WebKit { | 27 namespace WebKit { |
31 class WebFrame; | 28 class WebFrame; |
32 } | 29 } |
33 | 30 |
34 namespace webkit { | 31 namespace webkit { |
35 class WebLayerImpl; | 32 class WebLayerImpl; |
36 } | 33 } |
37 | 34 |
38 namespace webkit_media { | 35 namespace webkit_media { |
39 | 36 |
40 #if defined(GOOGLE_TV) | |
41 class MediaSourceDelegate; | |
42 #endif | |
43 class WebMediaPlayerManagerAndroid; | 37 class WebMediaPlayerManagerAndroid; |
44 class WebMediaPlayerProxyAndroid; | 38 class WebMediaPlayerProxyAndroid; |
45 | 39 |
46 // This class implements WebKit::WebMediaPlayer by keeping the android | 40 // This class implements WebKit::WebMediaPlayer by keeping the android |
47 // media player in the browser process. It listens to all the status changes | 41 // media player in the browser process. It listens to all the status changes |
48 // sent from the browser process and sends playback controls to the media | 42 // sent from the browser process and sends playback controls to the media |
49 // player. | 43 // player. |
50 class WebMediaPlayerAndroid | 44 class WebMediaPlayerAndroid |
51 : public WebKit::WebMediaPlayer, | 45 : public WebKit::WebMediaPlayer, |
52 public cc::VideoFrameProvider, | 46 public cc::VideoFrameProvider, |
53 public base::MessageLoop::DestructionObserver { | 47 public base::MessageLoop::DestructionObserver { |
54 public: | 48 public: |
55 // Construct a WebMediaPlayerAndroid object. This class communicates | 49 // Construct a WebMediaPlayerAndroid object. This class communicates |
56 // with the MediaPlayerBridge object in the browser process through | 50 // with the MediaPlayerBridge object in the browser process through |
57 // |proxy|. | 51 // |proxy|. |
58 // TODO(qinmin): |frame| argument is used to determine whether the current | 52 // TODO(qinmin): |frame| argument is used to determine whether the current |
59 // player can enter fullscreen. This logic should probably be moved into | 53 // player can enter fullscreen. This logic should probably be moved into |
60 // blink, so that enterFullscreen() will not be called if another video is | 54 // blink, so that enterFullscreen() will not be called if another video is |
61 // already in fullscreen. | 55 // already in fullscreen. |
62 WebMediaPlayerAndroid(WebKit::WebFrame* frame, | 56 WebMediaPlayerAndroid(WebKit::WebFrame* frame, |
63 WebKit::WebMediaPlayerClient* client, | 57 WebKit::WebMediaPlayerClient* client, |
64 WebMediaPlayerManagerAndroid* manager, | 58 WebMediaPlayerManagerAndroid* manager, |
65 WebMediaPlayerProxyAndroid* proxy, | 59 WebMediaPlayerProxyAndroid* proxy, |
66 StreamTextureFactory* factory, | 60 StreamTextureFactory* factory); |
67 media::MediaLog* media_log); | |
68 virtual ~WebMediaPlayerAndroid(); | 61 virtual ~WebMediaPlayerAndroid(); |
69 | 62 |
70 // WebKit::WebMediaPlayer implementation. | 63 // WebKit::WebMediaPlayer implementation. |
71 virtual void enterFullscreen(); | 64 virtual void enterFullscreen(); |
72 virtual void exitFullscreen(); | 65 virtual void exitFullscreen(); |
73 virtual bool canEnterFullscreen() const; | 66 virtual bool canEnterFullscreen() const; |
74 | 67 |
75 // Resource loading. | 68 // Resource loading. |
76 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); | 69 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); |
77 virtual void load(const WebKit::WebURL& url, | 70 virtual void load(const WebKit::WebURL& url, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 172 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
180 | 173 |
181 // Detach the player from its manager. | 174 // Detach the player from its manager. |
182 void Detach(); | 175 void Detach(); |
183 | 176 |
184 #if defined(GOOGLE_TV) | 177 #if defined(GOOGLE_TV) |
185 // Retrieve geometry of the media player (i.e. location and size of the video | 178 // Retrieve geometry of the media player (i.e. location and size of the video |
186 // frame) if changed. Returns true only if the geometry has been changed since | 179 // frame) if changed. Returns true only if the geometry has been changed since |
187 // the last call. | 180 // the last call. |
188 bool RetrieveGeometryChange(gfx::RectF* rect); | 181 bool RetrieveGeometryChange(gfx::RectF* rect); |
189 | |
190 virtual MediaKeyException generateKeyRequest( | |
191 const WebKit::WebString& key_system, | |
192 const unsigned char* init_data, | |
193 unsigned init_data_length) OVERRIDE; | |
194 virtual MediaKeyException addKey( | |
195 const WebKit::WebString& key_system, | |
196 const unsigned char* key, | |
197 unsigned key_length, | |
198 const unsigned char* init_data, | |
199 unsigned init_data_length, | |
200 const WebKit::WebString& session_id) OVERRIDE; | |
201 virtual MediaKeyException cancelKeyRequest( | |
202 const WebKit::WebString& key_system, | |
203 const WebKit::WebString& session_id) OVERRIDE; | |
204 | |
205 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | |
206 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); | |
207 #endif | 182 #endif |
208 | 183 |
209 protected: | 184 protected: |
210 // Helper method to update the playing state. | 185 // Helper method to update the playing state. |
211 void UpdatePlayingState(bool is_playing_); | 186 void UpdatePlayingState(bool is_playing_); |
212 | 187 |
213 // Helper methods for posting task for setting states and update WebKit. | 188 // Helper methods for posting task for setting states and update WebKit. |
214 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); | 189 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); |
215 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); | 190 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); |
216 | 191 |
217 // Helper method to reestablish the surface texture peer for android | 192 // Helper method to reestablish the surface texture peer for android |
218 // media player. | 193 // media player. |
219 void EstablishSurfaceTexturePeer(); | 194 void EstablishSurfaceTexturePeer(); |
220 | 195 |
221 // Requesting whether the surface texture peer needs to be reestablished. | 196 // Requesting whether the surface texture peer needs to be reestablished. |
222 void SetNeedsEstablishPeer(bool needs_establish_peer); | 197 void SetNeedsEstablishPeer(bool needs_establish_peer); |
223 | 198 |
224 #if defined(GOOGLE_TV) | 199 void InitializeMediaPlayer(const WebKit::WebURL& url, int flags); |
225 // Request external surface for out-of-band composition. | 200 |
226 void RequestExternalSurface(); | 201 bool NeedsExternalSurface(); |
227 #endif | 202 void SetNeedsExternalSurface(bool needs_external_surface); |
| 203 WebMediaPlayerProxyAndroid* proxy(); |
| 204 WebKit::WebFrame* frame(); |
| 205 WebKit::WebMediaPlayerClient* client(); |
| 206 int player_id(); |
228 | 207 |
229 private: | 208 private: |
230 void ReallocateVideoFrame(); | 209 void ReallocateVideoFrame(); |
231 | 210 |
232 WebKit::WebFrame* const frame_; | 211 WebKit::WebFrame* const frame_; |
233 | 212 |
234 WebKit::WebMediaPlayerClient* const client_; | 213 WebKit::WebMediaPlayerClient* const client_; |
235 | 214 |
236 // Save the list of buffered time ranges. | 215 // Save the list of buffered time ranges. |
237 WebKit::WebTimeRanges buffered_; | 216 WebKit::WebTimeRanges buffered_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // A pointer back to the compositor to inform it about state changes. This is | 277 // A pointer back to the compositor to inform it about state changes. This is |
299 // not NULL while the compositor is actively using this webmediaplayer. | 278 // not NULL while the compositor is actively using this webmediaplayer. |
300 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 279 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
301 | 280 |
302 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; | 281 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
303 | 282 |
304 #if defined(GOOGLE_TV) | 283 #if defined(GOOGLE_TV) |
305 // A rectangle represents the geometry of video frame, when computed last | 284 // A rectangle represents the geometry of video frame, when computed last |
306 // time. | 285 // time. |
307 gfx::RectF last_computed_rect_; | 286 gfx::RectF last_computed_rect_; |
308 | |
309 scoped_ptr<MediaSourceDelegate> media_source_delegate_; | |
310 #endif | 287 #endif |
311 | 288 |
312 // Proxy object that delegates method calls on Render Thread. | 289 // Proxy object that delegates method calls on Render Thread. |
313 // This object is created on the Render Thread and is only called in the | 290 // This object is created on the Render Thread and is only called in the |
314 // destructor. | 291 // destructor. |
315 WebMediaPlayerProxyAndroid* proxy_; | 292 WebMediaPlayerProxyAndroid* proxy_; |
316 | 293 |
317 // The current playing time. Because the media player is in the browser | 294 // The current playing time. Because the media player is in the browser |
318 // process, it will regularly update the |current_time_| by calling | 295 // process, it will regularly update the |current_time_| by calling |
319 // OnTimeUpdate(). | 296 // OnTimeUpdate(). |
320 float current_time_; | 297 float current_time_; |
321 | 298 |
322 media::MediaLog* media_log_; | 299 media::MediaLog* media_log_; |
323 | 300 |
324 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 301 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
325 }; | 302 }; |
326 | 303 |
327 } // namespace webkit_media | 304 } // namespace webkit_media |
328 | 305 |
329 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 306 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
OLD | NEW |