Chromium Code Reviews| 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 CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class BrowserMediaPlayerManager; | 20 class BrowserMediaPlayerManager; |
| 21 | 21 |
| 22 // Native mirror of ContentVideoView.java. This class is responsible for | 22 // Native mirror of ContentVideoView.java. This class is responsible for |
| 23 // creating the Java video view and pass all the player status change to | 23 // creating the Java video view and pass all the player status change to |
| 24 // it. It accepts media control from Java class, and forwards it to | 24 // it. It accepts media control from Java class, and forwards it to |
| 25 // MediaPlayerManagerImpl. | 25 // MediaPlayerManagerImpl. |
| 26 class ContentVideoView { | 26 class ContentVideoView { |
| 27 public: | 27 public: |
| 28 // Construct a ContentVideoView object. The |manager| will handle all the | 28 // Construct a ContentVideoView object. The |manager| will handle all the |
| 29 // playback controls from the Java class. | 29 // playback controls from the Java class. |
| 30 ContentVideoView( | |
| 31 const base::android::ScopedJavaLocalRef<jobject>& context, | |
| 32 const base::android::ScopedJavaLocalRef<jobject>& client, | |
| 33 BrowserMediaPlayerManager* manager); | |
|
bulach
2014/02/13 12:02:44
hmm... in the patches referenced in the descriptio
| |
| 34 | |
| 35 explicit ContentVideoView(BrowserMediaPlayerManager* manager); | 30 explicit ContentVideoView(BrowserMediaPlayerManager* manager); |
| 36 | 31 |
| 37 ~ContentVideoView(); | 32 ~ContentVideoView(); |
| 38 | 33 |
| 39 // To open another video on existing ContentVideoView. | 34 // To open another video on existing ContentVideoView. |
| 40 void OpenVideo(); | 35 void OpenVideo(); |
| 41 | 36 |
| 42 static bool RegisterContentVideoView(JNIEnv* env); | 37 static bool RegisterContentVideoView(JNIEnv* env); |
| 43 static void KeepScreenOn(bool screen_on); | 38 static void KeepScreenOn(bool screen_on); |
| 44 | 39 |
| 45 // Return the singleton object or NULL. | 40 // Return the singleton object or NULL. |
| 46 static ContentVideoView* GetInstance(); | 41 static ContentVideoView* GetInstance(); |
| 47 | 42 |
| 48 // Getter method called by the Java class to get the media information. | 43 // Getter method called by the Java class to get the media information. |
| 49 int GetVideoWidth(JNIEnv*, jobject obj) const; | 44 int GetVideoWidth(JNIEnv*, jobject obj) const; |
| 50 int GetVideoHeight(JNIEnv*, jobject obj) const; | 45 int GetVideoHeight(JNIEnv*, jobject obj) const; |
| 51 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; | 46 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; |
| 52 int GetCurrentPosition(JNIEnv*, jobject obj) const; | 47 int GetCurrentPosition(JNIEnv*, jobject obj) const; |
| 53 bool IsPlaying(JNIEnv*, jobject obj); | 48 bool IsPlaying(JNIEnv*, jobject obj); |
| 54 void RequestMediaMetadata(JNIEnv*, jobject obj); | 49 void RequestMediaMetadata(JNIEnv*, jobject obj); |
| 55 | 50 |
| 56 // Called when the Java fullscreen view is destroyed. If | 51 // Called when the Java fullscreen view is destroyed. If |
| 57 // |release_media_player| is true, |manager_| needs to release the player | 52 // |release_media_player| is true, |manager_| needs to release the player |
| 58 // as we are quitting the app. | 53 // as we are quitting the app. |
| 59 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); | 54 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); |
| 60 | 55 |
| 61 // Supposed to be called when the application paused or stopped. | |
| 62 // Destroys the fullscreen view in a way that it can be recreated | |
| 63 // via ResumeFullscreenIfSuspended. | |
| 64 void SuspendFullscreen(); | |
| 65 | |
| 66 // Supposed to be called when the application switches back to foreground. | |
| 67 // Recreates the fullscreen view if it was suspended via SuspendFullscreen. | |
| 68 void ResumeFullscreenIfSuspended(); | |
| 69 | |
| 70 // Media control method called by the Java class. | 56 // Media control method called by the Java class. |
| 71 void SeekTo(JNIEnv*, jobject obj, jint msec); | 57 void SeekTo(JNIEnv*, jobject obj, jint msec); |
| 72 void Play(JNIEnv*, jobject obj); | 58 void Play(JNIEnv*, jobject obj); |
| 73 void Pause(JNIEnv*, jobject obj); | 59 void Pause(JNIEnv*, jobject obj); |
| 74 | 60 |
| 75 // Called by the Java class to pass the surface object to the player. | 61 // Called by the Java class to pass the surface object to the player. |
| 76 void SetSurface(JNIEnv*, jobject obj, jobject surface); | 62 void SetSurface(JNIEnv*, jobject obj, jobject surface); |
| 77 | 63 |
| 78 // Method called by |manager_| to inform the Java class about player status | 64 // Method called by |manager_| to inform the Java class about player status |
| 79 // change. | 65 // change. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 95 // Creates the corresponding ContentVideoView Java object. | 81 // Creates the corresponding ContentVideoView Java object. |
| 96 JavaObjectWeakGlobalRef CreateJavaObject(); | 82 JavaObjectWeakGlobalRef CreateJavaObject(); |
| 97 | 83 |
| 98 // Object that manages the fullscreen media player. It is responsible for | 84 // Object that manages the fullscreen media player. It is responsible for |
| 99 // handling all the playback controls. | 85 // handling all the playback controls. |
| 100 BrowserMediaPlayerManager* manager_; | 86 BrowserMediaPlayerManager* manager_; |
| 101 | 87 |
| 102 // Weak reference of corresponding Java object. | 88 // Weak reference of corresponding Java object. |
| 103 JavaObjectWeakGlobalRef j_content_video_view_; | 89 JavaObjectWeakGlobalRef j_content_video_view_; |
| 104 | 90 |
| 105 enum FullscreenState { | |
| 106 ENTERED, | |
| 107 SUSPENDED, | |
| 108 RESUME | |
| 109 } fullscreen_state_; | |
| 110 | |
| 111 // Weak pointer for posting tasks. | 91 // Weak pointer for posting tasks. |
| 112 base::WeakPtrFactory<ContentVideoView> weak_factory_; | 92 base::WeakPtrFactory<ContentVideoView> weak_factory_; |
| 113 | 93 |
| 114 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); | 94 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); |
| 115 }; | 95 }; |
| 116 | 96 |
| 117 } // namespace content | 97 } // namespace content |
| 118 | 98 |
| 119 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 99 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| OLD | NEW |