| 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 MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // the |manager| when needed. | 43 // the |manager| when needed. |
| 44 MediaPlayerBridge(int player_id, | 44 MediaPlayerBridge(int player_id, |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 const GURL& first_party_for_cookies, | 46 const GURL& first_party_for_cookies, |
| 47 const std::string& user_agent, | 47 const std::string& user_agent, |
| 48 bool hide_url_log, | 48 bool hide_url_log, |
| 49 MediaPlayerManager* manager, | 49 MediaPlayerManager* manager, |
| 50 const RequestMediaResourcesCB& request_media_resources_cb, | 50 const RequestMediaResourcesCB& request_media_resources_cb, |
| 51 const GURL& frame_url, | 51 const GURL& frame_url, |
| 52 bool allow_credentials); | 52 bool allow_credentials); |
| 53 virtual ~MediaPlayerBridge(); | 53 ~MediaPlayerBridge() override; |
| 54 | 54 |
| 55 // Initialize this object and extract the metadata from the media. | 55 // Initialize this object and extract the metadata from the media. |
| 56 virtual void Initialize(); | 56 virtual void Initialize(); |
| 57 | 57 |
| 58 // MediaPlayerAndroid implementation. | 58 // MediaPlayerAndroid implementation. |
| 59 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) override; | 59 void SetVideoSurface(gfx::ScopedJavaSurface surface) override; |
| 60 virtual void Start() override; | 60 void Start() override; |
| 61 virtual void Pause(bool is_media_related_action) override; | 61 void Pause(bool is_media_related_action) override; |
| 62 virtual void SeekTo(base::TimeDelta timestamp) override; | 62 void SeekTo(base::TimeDelta timestamp) override; |
| 63 virtual void Release() override; | 63 void Release() override; |
| 64 virtual void SetVolume(double volume) override; | 64 void SetVolume(double volume) override; |
| 65 virtual int GetVideoWidth() override; | 65 int GetVideoWidth() override; |
| 66 virtual int GetVideoHeight() override; | 66 int GetVideoHeight() override; |
| 67 virtual base::TimeDelta GetCurrentTime() override; | 67 base::TimeDelta GetCurrentTime() override; |
| 68 virtual base::TimeDelta GetDuration() override; | 68 base::TimeDelta GetDuration() override; |
| 69 virtual bool IsPlaying() override; | 69 bool IsPlaying() override; |
| 70 virtual bool CanPause() override; | 70 bool CanPause() override; |
| 71 virtual bool CanSeekForward() override; | 71 bool CanSeekForward() override; |
| 72 virtual bool CanSeekBackward() override; | 72 bool CanSeekBackward() override; |
| 73 virtual bool IsPlayerReady() override; | 73 bool IsPlayerReady() override; |
| 74 virtual GURL GetUrl() override; | 74 GURL GetUrl() override; |
| 75 virtual GURL GetFirstPartyForCookies() override; | 75 GURL GetFirstPartyForCookies() override; |
| 76 | 76 |
| 77 void OnDidSetDataUriDataSource(JNIEnv* env, jobject obj, jboolean success); | 77 void OnDidSetDataUriDataSource(JNIEnv* env, jobject obj, jboolean success); |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 void SetDuration(base::TimeDelta time); | 80 void SetDuration(base::TimeDelta time); |
| 81 | 81 |
| 82 virtual void PendingSeekInternal(const base::TimeDelta& time); | 82 virtual void PendingSeekInternal(const base::TimeDelta& time); |
| 83 | 83 |
| 84 // Prepare the player for playback, asynchronously. When succeeds, | 84 // Prepare the player for playback, asynchronously. When succeeds, |
| 85 // OnMediaPrepared() will be called. Otherwise, OnMediaError() will | 85 // OnMediaPrepared() will be called. Otherwise, OnMediaError() will |
| 86 // be called with an error type. | 86 // be called with an error type. |
| 87 virtual void Prepare(); | 87 virtual void Prepare(); |
| 88 | 88 |
| 89 // MediaPlayerAndroid implementation. | 89 // MediaPlayerAndroid implementation. |
| 90 virtual void OnVideoSizeChanged(int width, int height) override; | 90 void OnVideoSizeChanged(int width, int height) override; |
| 91 virtual void OnPlaybackComplete() override; | 91 void OnPlaybackComplete() override; |
| 92 virtual void OnMediaInterrupted() override; | 92 void OnMediaInterrupted() override; |
| 93 virtual void OnMediaPrepared() override; | 93 void OnMediaPrepared() override; |
| 94 | 94 |
| 95 // Create the corresponding Java class instance. | 95 // Create the corresponding Java class instance. |
| 96 virtual void CreateJavaMediaPlayerBridge(); | 96 virtual void CreateJavaMediaPlayerBridge(); |
| 97 | 97 |
| 98 // Get allowed operations from the player. | 98 // Get allowed operations from the player. |
| 99 virtual base::android::ScopedJavaLocalRef<jobject> GetAllowedOperations(); | 99 virtual base::android::ScopedJavaLocalRef<jobject> GetAllowedOperations(); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 // Set the data source for the media player. | 102 // Set the data source for the media player. |
| 103 void SetDataSource(const std::string& url); | 103 void SetDataSource(const std::string& url); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 // NOTE: Weak pointers must be invalidated before all other member variables. | 184 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 185 base::WeakPtrFactory<MediaPlayerBridge> weak_factory_; | 185 base::WeakPtrFactory<MediaPlayerBridge> weak_factory_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge); | 187 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 } // namespace media | 190 } // namespace media |
| 191 | 191 |
| 192 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ | 192 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ |
| OLD | NEW |