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 #include "media/base/android/media_player_listener.h" | 5 #include "media/base/android/media_player_listener.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 DCHECK(message_loop_); | 28 DCHECK(message_loop_); |
29 DCHECK(media_player_); | 29 DCHECK(media_player_); |
30 } | 30 } |
31 | 31 |
32 MediaPlayerListener::~MediaPlayerListener() {} | 32 MediaPlayerListener::~MediaPlayerListener() {} |
33 | 33 |
34 void MediaPlayerListener::CreateMediaPlayerListener( | 34 void MediaPlayerListener::CreateMediaPlayerListener( |
35 jobject context, jobject media_player) { | 35 jobject context, jobject media_player) { |
36 JNIEnv* env = AttachCurrentThread(); | 36 JNIEnv* env = AttachCurrentThread(); |
37 CHECK(env); | 37 CHECK(env); |
38 j_media_player_listener_.Reset( | |
39 Java_MediaPlayerListener_create( | |
40 env, reinterpret_cast<intptr_t>(this), context, media_player)); | |
41 } | |
38 | 42 |
39 Java_MediaPlayerListener_create( | 43 |
40 env, reinterpret_cast<intptr_t>(this), context, media_player); | 44 void MediaPlayerListener::ReleaseMediaPlayerListenerResources() { |
45 JNIEnv* env = AttachCurrentThread(); | |
46 DCHECK(env); | |
47 if (env && !j_media_player_listener_.is_null()) { | |
Yaron
2012/11/27 05:58:00
Just change the DCHECK above to CHECK and remove t
Miguel Garcia
2012/11/27 17:24:06
Done.
| |
48 Java_MediaPlayerListener_releaseResources( | |
49 env, j_media_player_listener_.obj()); | |
50 } | |
51 j_media_player_listener_.Reset(); | |
41 } | 52 } |
42 | 53 |
43 void MediaPlayerListener::OnMediaError( | 54 void MediaPlayerListener::OnMediaError( |
44 JNIEnv* /* env */, jobject /* obj */, jint error_type) { | 55 JNIEnv* /* env */, jobject /* obj */, jint error_type) { |
45 message_loop_->PostTask(FROM_HERE, base::Bind( | 56 message_loop_->PostTask(FROM_HERE, base::Bind( |
46 &MediaPlayerBridge::OnMediaError, media_player_, error_type)); | 57 &MediaPlayerBridge::OnMediaError, media_player_, error_type)); |
47 } | 58 } |
48 | 59 |
49 void MediaPlayerListener::OnVideoSizeChanged( | 60 void MediaPlayerListener::OnVideoSizeChanged( |
50 JNIEnv* /* env */, jobject /* obj */, jint width, jint height) { | 61 JNIEnv* /* env */, jobject /* obj */, jint width, jint height) { |
(...skipping 19 matching lines...) Expand all Loading... | |
70 message_loop_->PostTask(FROM_HERE, base::Bind( | 81 message_loop_->PostTask(FROM_HERE, base::Bind( |
71 &MediaPlayerBridge::OnSeekComplete, media_player_)); | 82 &MediaPlayerBridge::OnSeekComplete, media_player_)); |
72 } | 83 } |
73 | 84 |
74 void MediaPlayerListener::OnMediaPrepared( | 85 void MediaPlayerListener::OnMediaPrepared( |
75 JNIEnv* /* env */, jobject /* obj */) { | 86 JNIEnv* /* env */, jobject /* obj */) { |
76 message_loop_->PostTask(FROM_HERE, base::Bind( | 87 message_loop_->PostTask(FROM_HERE, base::Bind( |
77 &MediaPlayerBridge::OnMediaPrepared, media_player_)); | 88 &MediaPlayerBridge::OnMediaPrepared, media_player_)); |
78 } | 89 } |
79 | 90 |
91 void MediaPlayerListener::OnMediaInterrupted( | |
92 JNIEnv* /* env */, jobject /* obj */) { | |
93 message_loop_->PostTask(FROM_HERE, base::Bind( | |
94 &MediaPlayerBridge::OnMediaInterrupted, media_player_)); | |
95 } | |
96 | |
80 bool MediaPlayerListener::RegisterMediaPlayerListener(JNIEnv* env) { | 97 bool MediaPlayerListener::RegisterMediaPlayerListener(JNIEnv* env) { |
81 bool ret = RegisterNativesImpl(env); | 98 bool ret = RegisterNativesImpl(env); |
82 DCHECK(g_MediaPlayerListener_clazz); | 99 DCHECK(g_MediaPlayerListener_clazz); |
83 return ret; | 100 return ret; |
84 } | 101 } |
85 | 102 |
86 } // namespace media | 103 } // namespace media |
OLD | NEW |