Chromium Code Reviews| Index: android_webview/native/external_video_surface_container_impl.cc |
| diff --git a/android_webview/native/external_video_surface_container_impl.cc b/android_webview/native/external_video_surface_container_impl.cc |
| index 1a10ab547ac1b062f41778945d848e5e2e2c5df4..342fc5e3cfa75518f272ade201099ce2ca55f5c2 100644 |
| --- a/android_webview/native/external_video_surface_container_impl.cc |
| +++ b/android_webview/native/external_video_surface_container_impl.cc |
| @@ -43,6 +43,22 @@ void ExternalVideoSurfaceContainerImpl::RequestExternalVideoSurface( |
| env, jobject_.obj(), static_cast<jint>(player_id)); |
| } |
| +int ExternalVideoSurfaceContainerImpl::GetCurrentPlayerId() { |
| + JNIEnv* env = AttachCurrentThread(); |
| + jclass cls = env->GetObjectClass(jobject_.obj()); |
| + jfieldID fid = env->GetStaticFieldID(cls, "INVALID_PLAYER_ID", "I"); |
| + int invalid_player = static_cast<int>(env->GetStaticIntField(cls, fid)); |
|
boliu
2014/12/09 18:15:18
We basically never write manual jni code in chromi
|
| + |
| + int current_player = static_cast<int>( |
| + Java_ExternalVideoSurfaceContainer_getCurrentPlayerId( |
| + env, jobject_.obj())); |
| + |
| + if (current_player == invalid_player) |
|
boliu
2014/12/09 18:15:18
You can just do if (current_player < 0) here.
|
| + return kInvalidPlayerId; |
| + else |
| + return current_player; |
| +} |
| + |
| void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( |
| int player_id) { |
| JNIEnv* env = AttachCurrentThread(); |