OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_codec_bridge.h" | 5 #include "media/base/android/media_codec_bridge.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 // static | 126 // static |
127 bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) { | 127 bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) { |
128 JNIEnv* env = AttachCurrentThread(); | 128 JNIEnv* env = AttachCurrentThread(); |
129 std::string mime = CodecTypeToAndroidMimeType(codec); | 129 std::string mime = CodecTypeToAndroidMimeType(codec); |
130 if (mime.empty()) | 130 if (mime.empty()) |
131 return false; | 131 return false; |
132 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); | 132 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
133 return !Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure).is_null(); | 133 ScopedJavaLocalRef<jobject> j_media_codec_bridge = |
| 134 Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure); |
| 135 if (!j_media_codec_bridge.is_null()) { |
| 136 Java_MediaCodecBridge_release(env, j_media_codec_bridge.obj()); |
| 137 return true; |
| 138 } |
| 139 return false; |
134 } | 140 } |
135 | 141 |
136 MediaCodecBridge::MediaCodecBridge(const std::string& mime, bool is_secure) { | 142 MediaCodecBridge::MediaCodecBridge(const std::string& mime, bool is_secure) { |
137 JNIEnv* env = AttachCurrentThread(); | 143 JNIEnv* env = AttachCurrentThread(); |
138 CHECK(env); | 144 CHECK(env); |
139 DCHECK(!mime.empty()); | 145 DCHECK(!mime.empty()); |
140 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); | 146 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
141 j_media_codec_.Reset( | 147 j_media_codec_.Reset( |
142 Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure)); | 148 Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure)); |
143 } | 149 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 bool is_secure) { | 491 bool is_secure) { |
486 const std::string mime = VideoCodecToAndroidMimeType(codec); | 492 const std::string mime = VideoCodecToAndroidMimeType(codec); |
487 return mime.empty() ? NULL : new VideoCodecBridge(mime, is_secure); | 493 return mime.empty() ? NULL : new VideoCodecBridge(mime, is_secure); |
488 } | 494 } |
489 | 495 |
490 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 496 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
491 return RegisterNativesImpl(env); | 497 return RegisterNativesImpl(env); |
492 } | 498 } |
493 | 499 |
494 } // namespace media | 500 } // namespace media |
OLD | NEW |