Chromium Code Reviews| 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..09219df7a79a9c64e7285bcb09f03e4ea9e0e46e |
| --- /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 base::RefCountedThreadSafe<MediaPlayerListener> { |
|
scherkus (not reviewing)
2012/09/10 12:19:08
does this need to be refcounted?
who holds refere
qinmin
2012/09/11 04:50:24
On 2nd thought, I don't think this class needs to
|
| + public: |
| + MediaPlayerListener( |
| + const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| + base::WeakPtr<MediaPlayerBridge> mediaplayer); |
| + |
| + // 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: |
| + friend class base::RefCountedThreadSafe<MediaPlayerListener>; |
| + virtual ~MediaPlayerListener(); |
| + |
| + // The message loop where |mediaplayer_| lives. |
| + scoped_refptr<base::MessageLoopProxy> message_loop_; |
| + |
| + // The MediaPlayerBridge object all the callbacks should be send to. |
| + base::WeakPtr<MediaPlayerBridge> mediaplayer_; |
|
scherkus (not reviewing)
2012/09/10 12:19:08
s/mediaplayer_/media_player_/
qinmin
2012/09/11 04:50:24
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaPlayerListener); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_LISTENER_H_ |