Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_IN_PROCESS_ANDROID_H_ | |
| 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_IN_PROCESS_ANDROID_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include <jni.h> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "media/base/android/media_resource_getter.h" | |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | |
| 18 #include "webkit/media/android/webmediaplayer_android.h" | |
| 19 | |
| 20 namespace WebKit { | |
| 21 class WebCookieJar; | |
| 22 class WebFrame; | |
| 23 } | |
| 24 | |
| 25 namespace media { | |
| 26 class MediaPlayerBridge; | |
| 27 class MediaPlayerBridgeManager; | |
| 28 } | |
| 29 | |
| 30 namespace webkit_media { | |
| 31 | |
| 32 class StreamTextureFactory; | |
| 33 class WebMediaPlayerManagerAndroid; | |
| 34 | |
| 35 // Class for retrieving the media resources. | |
| 36 class InProcessMediaResourceGetter | |
| 37 : public media::MediaResourceGetter { | |
| 38 public: | |
| 39 // Construct an InProcessCookieGetter object from a WebCookieJar. | |
| 40 explicit InProcessMediaResourceGetter(WebKit::WebCookieJar* cookie_jar); | |
| 41 virtual ~InProcessMediaResourceGetter(); | |
| 42 | |
| 43 // media::CookieGetter implementation. | |
| 44 virtual void GetCookies(const GURL& url, | |
| 45 const GURL& first_party_for_cookies, | |
| 46 const GetCookieCB& callback) OVERRIDE; | |
| 47 virtual void GetPlatformPathFromFileSystemURL( | |
| 48 const GURL& url, | |
| 49 const GetPlatformPathCB& callback) OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 WebKit::WebCookieJar* cookie_jar_; | |
| 53 DISALLOW_COPY_AND_ASSIGN(InProcessMediaResourceGetter); | |
| 54 }; | |
| 55 | |
| 56 // This class implements WebKit::WebMediaPlayer by keeping the android | |
| 57 // mediaplayer in the render process. This mode is being deprecated | |
| 58 // as mediaplayer is going to be moved to the browser process. | |
| 59 class WebMediaPlayerInProcessAndroid : public WebMediaPlayerAndroid { | |
|
scherkus (not reviewing)
2013/03/21 20:07:18
can we merge the WebMediaPlayerAndroid base class
qinmin
2013/03/21 20:08:09
Yes, I am planning to do that in a seperate CL
On
scherkus (not reviewing)
2013/03/21 20:48:27
Great!
| |
| 60 public: | |
| 61 // Construct a WebMediaPlayerInProcessAndroid object. | |
| 62 WebMediaPlayerInProcessAndroid( | |
| 63 WebKit::WebFrame* frame, | |
| 64 WebKit::WebMediaPlayerClient* client, | |
| 65 WebKit::WebCookieJar* cookie_jar, | |
| 66 WebMediaPlayerManagerAndroid* manager, | |
| 67 media::MediaPlayerBridgeManager* resource_manager, | |
| 68 StreamTextureFactory* factory, | |
| 69 bool disable_media_history_logging); | |
| 70 virtual ~WebMediaPlayerInProcessAndroid(); | |
| 71 | |
| 72 // Getters of playback state. | |
| 73 virtual bool paused() const; | |
| 74 | |
| 75 // Callbacks from media::MediaPlayerBridge to WebMediaPlayerInProcessAndroid. | |
| 76 void MediaErrorCallback(int player_id, int error_type); | |
| 77 void VideoSizeChangedCallback(int player_id, int width, int height); | |
| 78 void BufferingUpdateCallback(int player_id, int percent); | |
| 79 void PlaybackCompleteCallback(int player_id); | |
| 80 void SeekCompleteCallback(int player_id, base::TimeDelta current_time); | |
| 81 void MediaPreparedCallback(int player_id, base::TimeDelta duration); | |
| 82 void TimeUpdateCallback(int player_id, base::TimeDelta current_time) {} | |
| 83 void MediaInterruptedCallback(int player_id); | |
| 84 | |
| 85 // WebMediaPlayerAndroid implementation. | |
| 86 virtual void SetVideoSurface(jobject j_surface) OVERRIDE; | |
| 87 virtual void OnTimeUpdate(base::TimeDelta current_time) OVERRIDE; | |
| 88 | |
| 89 private: | |
| 90 // Methods inherited from WebMediaPlayerAndroid. | |
| 91 virtual void InitializeMediaPlayer(GURL url) OVERRIDE; | |
| 92 virtual void PlayInternal() OVERRIDE; | |
| 93 virtual void PauseInternal() OVERRIDE; | |
| 94 virtual void SeekInternal(base::TimeDelta time) OVERRIDE; | |
| 95 virtual float GetCurrentTimeInternal() const OVERRIDE; | |
| 96 virtual void ReleaseResourcesInternal() OVERRIDE; | |
| 97 virtual void Destroy() OVERRIDE; | |
| 98 virtual void RequestExternalSurface() OVERRIDE; | |
| 99 | |
| 100 WebKit::WebFrame* const frame_; | |
| 101 | |
| 102 // Bridge to the android media player. | |
| 103 scoped_ptr<media::MediaPlayerBridge> media_player_; | |
| 104 | |
| 105 // Whether playback has completed. | |
| 106 float playback_completed_; | |
| 107 | |
| 108 // Pointer to the cookie jar to get the cookie for the media url. | |
| 109 WebKit::WebCookieJar* cookie_jar_; | |
| 110 | |
| 111 // Manager for managing all the hardware player resources. | |
| 112 media::MediaPlayerBridgeManager* resource_manager_; | |
| 113 | |
| 114 // Whether we should disable history logging. | |
| 115 bool disable_history_logging_; | |
| 116 | |
| 117 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerInProcessAndroid); | |
| 118 }; | |
| 119 | |
| 120 } // namespace webkit_media | |
| 121 | |
| 122 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_IN_PROCESS_ANDROID_H_ | |
| OLD | NEW |