OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 } | 1331 } |
1332 } | 1332 } |
1333 | 1333 |
1334 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( | 1334 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( |
1335 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context, | 1335 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context, |
1336 jobject remote_egl_context) { | 1336 jobject remote_egl_context) { |
1337 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) | 1337 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) |
1338 OwnedFactoryAndThreads* owned_factory = | 1338 OwnedFactoryAndThreads* owned_factory = |
1339 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); | 1339 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
1340 | 1340 |
| 1341 // TODO(perkj): In order to not break existing applications we need to |
| 1342 // check if |local_egl_context| or |remote_egl_context| is an |
| 1343 // EGL10 context. If so, create an EGLBase10.EGL10Context instead. |
| 1344 // Remove this once existing applications has been updated. |
| 1345 jobject local_eglbase_context = local_egl_context; |
| 1346 jobject remote_eglbase_context = remote_egl_context; |
| 1347 |
| 1348 jclass j_egl10_context_class = |
| 1349 FindClass(jni, "javax/microedition/khronos/egl/EGLContext"); |
| 1350 jclass j_eglbase_context_class = |
| 1351 FindClass(jni, "org/webrtc/EglBase$Context"); |
| 1352 |
| 1353 jmethodID j_eglbase_context_ctor = GetMethodID( |
| 1354 jni, j_eglbase_context_class, |
| 1355 "<init>", "(Ljavax/microedition/khronos/egl/EGLContext;)V"); |
| 1356 if (local_egl_context != nullptr && |
| 1357 jni->IsInstanceOf(local_egl_context, j_egl10_context_class)) { |
| 1358 local_eglbase_context = jni->NewObject( |
| 1359 j_eglbase_context_class, j_eglbase_context_ctor, |
| 1360 local_egl_context); |
| 1361 } |
| 1362 if (remote_egl_context != nullptr && |
| 1363 jni->IsInstanceOf(remote_egl_context, j_egl10_context_class)) { |
| 1364 remote_eglbase_context = jni->NewObject( |
| 1365 j_eglbase_context_class, j_eglbase_context_ctor, |
| 1366 remote_egl_context); |
| 1367 } |
| 1368 |
1341 MediaCodecVideoEncoderFactory* encoder_factory = | 1369 MediaCodecVideoEncoderFactory* encoder_factory = |
1342 static_cast<MediaCodecVideoEncoderFactory*> | 1370 static_cast<MediaCodecVideoEncoderFactory*> |
1343 (owned_factory->encoder_factory()); | 1371 (owned_factory->encoder_factory()); |
1344 if (encoder_factory) { | 1372 if (encoder_factory) { |
1345 LOG(LS_INFO) << "Set EGL context for HW encoding."; | 1373 LOG(LS_INFO) << "Set EGL context for HW encoding."; |
1346 encoder_factory->SetEGLContext(jni, local_egl_context); | 1374 encoder_factory->SetEGLContext(jni, local_eglbase_context); |
1347 } | 1375 } |
1348 | 1376 |
1349 MediaCodecVideoDecoderFactory* decoder_factory = | 1377 MediaCodecVideoDecoderFactory* decoder_factory = |
1350 static_cast<MediaCodecVideoDecoderFactory*> | 1378 static_cast<MediaCodecVideoDecoderFactory*> |
1351 (owned_factory->decoder_factory()); | 1379 (owned_factory->decoder_factory()); |
1352 if (decoder_factory) { | 1380 if (decoder_factory) { |
1353 LOG(LS_INFO) << "Set EGL context for HW decoding."; | 1381 LOG(LS_INFO) << "Set EGL context for HW decoding."; |
1354 decoder_factory->SetEGLContext(jni, remote_egl_context); | 1382 decoder_factory->SetEGLContext(jni, remote_eglbase_context); |
1355 } | 1383 } |
1356 #endif | 1384 #endif |
1357 } | 1385 } |
1358 | 1386 |
1359 static std::string | 1387 static std::string |
1360 GetJavaEnumName(JNIEnv* jni, const std::string& className, jobject j_enum) { | 1388 GetJavaEnumName(JNIEnv* jni, const std::string& className, jobject j_enum) { |
1361 jclass enumClass = FindClass(jni, className.c_str()); | 1389 jclass enumClass = FindClass(jni, className.c_str()); |
1362 jmethodID nameMethod = | 1390 jmethodID nameMethod = |
1363 GetMethodID(jni, enumClass, "name", "()Ljava/lang/String;"); | 1391 GetMethodID(jni, enumClass, "name", "()Ljava/lang/String;"); |
1364 jstring name = | 1392 jstring name = |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 return JavaStringFromStdString( | 2123 return JavaStringFromStdString( |
2096 jni, | 2124 jni, |
2097 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2125 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2098 } | 2126 } |
2099 | 2127 |
2100 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2128 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2101 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2129 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2102 } | 2130 } |
2103 | 2131 |
2104 } // namespace webrtc_jni | 2132 } // namespace webrtc_jni |
OLD | NEW |