| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 jobject GetJavaSurfaceTextureHelper( | 53 jobject GetJavaSurfaceTextureHelper( |
| 54 const rtc::scoped_refptr<SurfaceTextureHelper>& surface_texture_helper) { | 54 const rtc::scoped_refptr<SurfaceTextureHelper>& surface_texture_helper) { |
| 55 return surface_texture_helper | 55 return surface_texture_helper |
| 56 ? surface_texture_helper->GetJavaSurfaceTextureHelper() | 56 ? surface_texture_helper->GetJavaSurfaceTextureHelper() |
| 57 : nullptr; | 57 : nullptr; |
| 58 } | 58 } |
| 59 | 59 |
| 60 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) | 60 JNI_FUNCTION_DECLARATION(jlong, |
| 61 (JNIEnv* jni, | 61 PeerConnectionFactory_nativeCreateVideoSource, |
| 62 jclass, | 62 JNIEnv* jni, |
| 63 jlong native_factory, | 63 jclass, |
| 64 jobject j_surface_texture_helper, | 64 jlong native_factory, |
| 65 jboolean is_screencast) { | 65 jobject j_surface_texture_helper, |
| 66 jboolean is_screencast) { |
| 66 OwnedFactoryAndThreads* factory = | 67 OwnedFactoryAndThreads* factory = |
| 67 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); | 68 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
| 68 | 69 |
| 69 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( | 70 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( |
| 70 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( | 71 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( |
| 71 factory->signaling_thread(), jni, j_surface_texture_helper, | 72 factory->signaling_thread(), jni, j_surface_texture_helper, |
| 72 is_screencast)); | 73 is_screencast)); |
| 73 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = | 74 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = |
| 74 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), | 75 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), |
| 75 factory->worker_thread(), source); | 76 factory->worker_thread(), source); |
| 76 | 77 |
| 77 return (jlong)proxy_source.release(); | 78 return (jlong)proxy_source.release(); |
| 78 } | 79 } |
| 79 | 80 |
| 80 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack) | 81 JNI_FUNCTION_DECLARATION(jlong, |
| 81 (JNIEnv* jni, jclass, jlong native_factory, jstring id, jlong native_source) { | 82 PeerConnectionFactory_nativeCreateVideoTrack, |
| 83 JNIEnv* jni, |
| 84 jclass, |
| 85 jlong native_factory, |
| 86 jstring id, |
| 87 jlong native_source) { |
| 82 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 88 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
| 83 factoryFromJava(native_factory)); | 89 factoryFromJava(native_factory)); |
| 84 rtc::scoped_refptr<webrtc::VideoTrackInterface> track( | 90 rtc::scoped_refptr<webrtc::VideoTrackInterface> track( |
| 85 factory->CreateVideoTrack( | 91 factory->CreateVideoTrack( |
| 86 JavaToStdString(jni, id), | 92 JavaToStdString(jni, id), |
| 87 reinterpret_cast<webrtc::VideoTrackSourceInterface*>(native_source))); | 93 reinterpret_cast<webrtc::VideoTrackSourceInterface*>(native_source))); |
| 88 return (jlong)track.release(); | 94 return (jlong)track.release(); |
| 89 } | 95 } |
| 90 | 96 |
| 91 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions) | 97 JNI_FUNCTION_DECLARATION( |
| 92 (JNIEnv* jni, | 98 void, |
| 93 jclass, | 99 PeerConnectionFactory_nativeSetVideoHwAccelerationOptions, |
| 94 jlong native_factory, | 100 JNIEnv* jni, |
| 95 jobject local_egl_context, | 101 jclass, |
| 96 jobject remote_egl_context) { | 102 jlong native_factory, |
| 103 jobject local_egl_context, |
| 104 jobject remote_egl_context) { |
| 97 OwnedFactoryAndThreads* owned_factory = | 105 OwnedFactoryAndThreads* owned_factory = |
| 98 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); | 106 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
| 99 | 107 |
| 100 jclass j_eglbase14_context_class = | 108 jclass j_eglbase14_context_class = |
| 101 FindClass(jni, "org/webrtc/EglBase14$Context"); | 109 FindClass(jni, "org/webrtc/EglBase14$Context"); |
| 102 | 110 |
| 103 MediaCodecVideoEncoderFactory* encoder_factory = | 111 MediaCodecVideoEncoderFactory* encoder_factory = |
| 104 static_cast<MediaCodecVideoEncoderFactory*>( | 112 static_cast<MediaCodecVideoEncoderFactory*>( |
| 105 owned_factory->encoder_factory()); | 113 owned_factory->encoder_factory()); |
| 106 if (encoder_factory && | 114 if (encoder_factory && |
| 107 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { | 115 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { |
| 108 LOG(LS_INFO) << "Set EGL context for HW encoding."; | 116 LOG(LS_INFO) << "Set EGL context for HW encoding."; |
| 109 encoder_factory->SetEGLContext(jni, local_egl_context); | 117 encoder_factory->SetEGLContext(jni, local_egl_context); |
| 110 } | 118 } |
| 111 | 119 |
| 112 MediaCodecVideoDecoderFactory* decoder_factory = | 120 MediaCodecVideoDecoderFactory* decoder_factory = |
| 113 static_cast<MediaCodecVideoDecoderFactory*>( | 121 static_cast<MediaCodecVideoDecoderFactory*>( |
| 114 owned_factory->decoder_factory()); | 122 owned_factory->decoder_factory()); |
| 115 if (use_media_codec_decoder_factory && decoder_factory) { | 123 if (use_media_codec_decoder_factory && decoder_factory) { |
| 116 LOG(LS_INFO) << "Set EGL context for HW decoding."; | 124 LOG(LS_INFO) << "Set EGL context for HW decoding."; |
| 117 decoder_factory->SetEGLContext(jni, remote_egl_context); | 125 decoder_factory->SetEGLContext(jni, remote_egl_context); |
| 118 } | 126 } |
| 119 } | 127 } |
| 120 | 128 |
| 121 } // namespace webrtc_jni | 129 } // namespace webrtc_jni |
| OLD | NEW |