Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: media/base/android/media_player_listener.h

Issue 10919075: Move android mediaplayer from render process to browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments and resolving merge conflicts Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/android/media_player_bridge_manager.cc ('k') | media/base/android/media_player_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_player_listener.h
diff --git a/media/base/android/media_player_listener.h b/media/base/android/media_player_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..46185e969171e4aea1c323fa57b4ceabd47ea14f
--- /dev/null
+++ b/media/base/android/media_player_listener.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_LISTENER_H_
+#define MEDIA_BASE_ANDROID_MEDIA_PLAYER_LISTENER_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace media {
+
+class MediaPlayerBridge;
+
+// Acts as a thread proxy between java MediaPlayerListener object and
+// MediaPlayerBridge so that callbacks are posted onto the UI thread.
+class MediaPlayerListener {
+ public:
+ // Construct a native MediaPlayerListener object. Callbacks from the java
+ // side object will be forwarded to |media_player| by posting a task on the
+ // |message_loop|.
+ MediaPlayerListener(
+ const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ base::WeakPtr<MediaPlayerBridge> media_player);
+ virtual ~MediaPlayerListener();
+
+ // Called by the Java MediaPlayerListener and mirrored to corresponding
+ // callbacks.
+ void OnMediaError(JNIEnv* /* env */, jobject /* obj */, jint error_type);
+ void OnVideoSizeChanged(JNIEnv* /* env */, jobject /* obj */,
+ jint width, jint height);
+ void OnBufferingUpdate(JNIEnv* /* env */, jobject /* obj */, jint percent);
+ void OnPlaybackComplete(JNIEnv* /* env */, jobject /* obj */);
+ void OnSeekComplete(JNIEnv* /* env */, jobject /* obj */);
+ void OnMediaPrepared(JNIEnv* /* env */, jobject /* obj */);
+
+ // Create a Java MediaPlayerListener object.
+ base::android::ScopedJavaLocalRef<jobject> CreateMediaPlayerListener();
+
+ // Register MediaPlayerListener in the system library loader.
+ static bool RegisterMediaPlayerListener(JNIEnv* env);
+
+ private:
+ // The message loop where |media_player_| lives.
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
+
+ // The MediaPlayerBridge object all the callbacks should be send to.
+ base::WeakPtr<MediaPlayerBridge> media_player_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaPlayerListener);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_LISTENER_H_
« no previous file with comments | « media/base/android/media_player_bridge_manager.cc ('k') | media/base/android/media_player_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698