| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <jni.h> | 9 #include <jni.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| 19 | 19 |
| 20 namespace WebKit { | 20 namespace WebKit { |
| 21 class WebCookieJar; | 21 class WebCookieJar; |
| 22 class WebFrame; | 22 class WebFrame; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace media { | 25 namespace media { |
| 26 class MediaPlayerBridge; | 26 class MediaPlayerBridge; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace webkit_media { | 29 namespace webkit_media { |
| 30 | 30 |
| 31 class StreamTextureFactory; | 31 class StreamTextureFactory; |
| 32 class StreamTextureProxy; | 32 class StreamTextureProxy; |
| 33 class WebMediaPlayerManagerAndroid; | 33 class WebMediaPlayerManagerAndroid; |
| 34 class WebMediaPlayerProxyAndroid; | 34 class WebMediaPlayerProxyAndroid; |
| 35 | 35 |
| 36 // This class serves as the android implementation of WebKit::WebMediaPlayer. | 36 // This class serves as the android implementation of WebKit::WebMediaPlayer. |
| 37 // It implements all the playback functions by forwarding calls to android | 37 // It implements all the playback functions by forwarding calls to android |
| 38 // media player, and reports player state changes to the webkit. | 38 // media player, and reports player state changes to the webkit. |
| 39 class WebMediaPlayerAndroid : | 39 class WebMediaPlayerAndroid : |
| 40 public WebKit::WebMediaPlayer, | 40 public WebKit::WebMediaPlayer, |
| 41 public MessageLoop::DestructionObserver, |
| 41 public base::SupportsWeakPtr<WebMediaPlayerAndroid> { | 42 public base::SupportsWeakPtr<WebMediaPlayerAndroid> { |
| 42 public: | 43 public: |
| 43 WebMediaPlayerAndroid(WebKit::WebFrame* frame, | 44 WebMediaPlayerAndroid(WebKit::WebFrame* frame, |
| 44 WebKit::WebMediaPlayerClient* client, | 45 WebKit::WebMediaPlayerClient* client, |
| 45 WebKit::WebCookieJar* cookie_jar, | 46 WebKit::WebCookieJar* cookie_jar, |
| 46 webkit_media::WebMediaPlayerManagerAndroid* manager, | 47 webkit_media::WebMediaPlayerManagerAndroid* manager, |
| 47 webkit_media::StreamTextureFactory* factory); | 48 webkit_media::StreamTextureFactory* factory); |
| 48 virtual ~WebMediaPlayerAndroid(); | 49 virtual ~WebMediaPlayerAndroid(); |
| 49 | 50 |
| 50 // Set |incognito_mode_| to true if in incognito mode. | 51 // Set |incognito_mode_| to true if in incognito mode. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void OnSeekComplete(); | 124 void OnSeekComplete(); |
| 124 void OnMediaError(int error_type); | 125 void OnMediaError(int error_type); |
| 125 void OnMediaInfo(int info_type); | 126 void OnMediaInfo(int info_type); |
| 126 void OnVideoSizeChanged(int width, int height); | 127 void OnVideoSizeChanged(int width, int height); |
| 127 | 128 |
| 128 // This function is called by WebMediaPlayerManagerAndroid to pause the video | 129 // This function is called by WebMediaPlayerManagerAndroid to pause the video |
| 129 // and release |media_player_| and its surface texture when we switch tabs. | 130 // and release |media_player_| and its surface texture when we switch tabs. |
| 130 // However, the actual GlTexture is not released to keep the video screenshot. | 131 // However, the actual GlTexture is not released to keep the video screenshot. |
| 131 void ReleaseMediaResources(); | 132 void ReleaseMediaResources(); |
| 132 | 133 |
| 134 // Whether |media_player_| has been initialized. |
| 135 bool IsInitialized() const; |
| 136 |
| 137 // Method inherited from DestructionObserver. |
| 138 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 139 |
| 133 private: | 140 private: |
| 134 // Create a media player to load the |url_| and prepare for playback. | 141 // Create a media player to load the |url_| and prepare for playback. |
| 135 // Because of limited decoding resources on mobile devices, idle media players | 142 // Because of limited decoding resources on mobile devices, idle media players |
| 136 // could get released. In that case, we call this function to get a new media | 143 // could get released. In that case, we call this function to get a new media |
| 137 // player when needed. | 144 // player when needed. |
| 138 void InitializeMediaPlayer(); | 145 void InitializeMediaPlayer(); |
| 139 | 146 |
| 140 // Functions that implements media player control. | 147 // Functions that implements media player control. |
| 141 void PlayInternal(); | 148 void PlayInternal(); |
| 142 void PauseInternal(); | 149 void PauseInternal(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 165 | 172 |
| 166 // Size of the media element. | 173 // Size of the media element. |
| 167 WebKit::WebSize texture_size_; | 174 WebKit::WebSize texture_size_; |
| 168 | 175 |
| 169 // Size of the video. | 176 // Size of the video. |
| 170 WebKit::WebSize natural_size_; | 177 WebKit::WebSize natural_size_; |
| 171 | 178 |
| 172 // The video frame object used for renderering by WebKit. | 179 // The video frame object used for renderering by WebKit. |
| 173 scoped_ptr<WebKit::WebVideoFrame> video_frame_; | 180 scoped_ptr<WebKit::WebVideoFrame> video_frame_; |
| 174 | 181 |
| 182 // Message loops for main renderer thread. |
| 183 MessageLoop* main_loop_; |
| 184 |
| 175 // Proxy object that delegates method calls on Render Thread. | 185 // Proxy object that delegates method calls on Render Thread. |
| 176 // This object is created on the Render Thread and is only called in the | 186 // This object is created on the Render Thread and is only called in the |
| 177 // destructor. | 187 // destructor. |
| 178 scoped_refptr<WebMediaPlayerProxyAndroid> proxy_; | 188 scoped_refptr<WebMediaPlayerProxyAndroid> proxy_; |
| 179 | 189 |
| 180 // If this is set to true, prepare of the media player is done. | 190 // If this is set to true, prepare of the media player is done. |
| 181 bool prepared_; | 191 bool prepared_; |
| 182 | 192 |
| 183 // URL of the media file to be fetched. | 193 // URL of the media file to be fetched. |
| 184 GURL url_; | 194 GURL url_; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Object for calling back the compositor thread to repaint the video when a | 245 // Object for calling back the compositor thread to repaint the video when a |
| 236 // frame available. It should be initialized on the compositor thread. | 246 // frame available. It should be initialized on the compositor thread. |
| 237 scoped_ptr<webkit_media::StreamTextureProxy> stream_texture_proxy_; | 247 scoped_ptr<webkit_media::StreamTextureProxy> stream_texture_proxy_; |
| 238 | 248 |
| 239 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); | 249 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); |
| 240 }; | 250 }; |
| 241 | 251 |
| 242 } // namespace webkit_media | 252 } // namespace webkit_media |
| 243 | 253 |
| 244 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ | 254 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ |
| OLD | NEW |