| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 25 matching lines...) Expand all Loading... |
| 36 // impossible to tell which JNI call broke). | 36 // impossible to tell which JNI call broke). |
| 37 | 37 |
| 38 #include <jni.h> | 38 #include <jni.h> |
| 39 #undef JNIEXPORT | 39 #undef JNIEXPORT |
| 40 #define JNIEXPORT __attribute__((visibility("default"))) | 40 #define JNIEXPORT __attribute__((visibility("default"))) |
| 41 | 41 |
| 42 #include <limits> | 42 #include <limits> |
| 43 #include <memory> | 43 #include <memory> |
| 44 #include <utility> | 44 #include <utility> |
| 45 | 45 |
| 46 #include "webrtc/api/androidvideocapturer.h" | |
| 47 #include "webrtc/api/androidvideotracksource.h" | 46 #include "webrtc/api/androidvideotracksource.h" |
| 48 #include "webrtc/api/android/jni/androidmediadecoder_jni.h" | 47 #include "webrtc/api/android/jni/androidmediadecoder_jni.h" |
| 49 #include "webrtc/api/android/jni/androidmediaencoder_jni.h" | 48 #include "webrtc/api/android/jni/androidmediaencoder_jni.h" |
| 50 #include "webrtc/api/android/jni/androidnetworkmonitor_jni.h" | 49 #include "webrtc/api/android/jni/androidnetworkmonitor_jni.h" |
| 51 #include "webrtc/api/android/jni/androidvideocapturer_jni.h" | |
| 52 #include "webrtc/api/android/jni/classreferenceholder.h" | 50 #include "webrtc/api/android/jni/classreferenceholder.h" |
| 53 #include "webrtc/api/android/jni/jni_helpers.h" | 51 #include "webrtc/api/android/jni/jni_helpers.h" |
| 54 #include "webrtc/api/android/jni/native_handle_impl.h" | 52 #include "webrtc/api/android/jni/native_handle_impl.h" |
| 55 #include "webrtc/api/mediaconstraintsinterface.h" | 53 #include "webrtc/api/mediaconstraintsinterface.h" |
| 56 #include "webrtc/api/peerconnectioninterface.h" | 54 #include "webrtc/api/peerconnectioninterface.h" |
| 57 #include "webrtc/api/rtpreceiverinterface.h" | 55 #include "webrtc/api/rtpreceiverinterface.h" |
| 58 #include "webrtc/api/rtpsenderinterface.h" | 56 #include "webrtc/api/rtpsenderinterface.h" |
| 59 #include "webrtc/api/videosourceproxy.h" | 57 #include "webrtc/api/videosourceproxy.h" |
| 60 #include "webrtc/api/webrtcsdp.h" | 58 #include "webrtc/api/webrtcsdp.h" |
| 61 #include "webrtc/base/bind.h" | 59 #include "webrtc/base/bind.h" |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 jboolean initialize_audio, | 993 jboolean initialize_audio, |
| 996 jboolean initialize_video, | 994 jboolean initialize_video, |
| 997 jboolean video_hw_acceleration) { | 995 jboolean video_hw_acceleration) { |
| 998 bool failure = false; | 996 bool failure = false; |
| 999 video_hw_acceleration_enabled = video_hw_acceleration; | 997 video_hw_acceleration_enabled = video_hw_acceleration; |
| 1000 AndroidNetworkMonitor::SetAndroidContext(jni, context); | 998 AndroidNetworkMonitor::SetAndroidContext(jni, context); |
| 1001 if (!factory_static_initialized) { | 999 if (!factory_static_initialized) { |
| 1002 RTC_DCHECK(j_application_context == nullptr); | 1000 RTC_DCHECK(j_application_context == nullptr); |
| 1003 j_application_context = NewGlobalRef(jni, context); | 1001 j_application_context = NewGlobalRef(jni, context); |
| 1004 | 1002 |
| 1005 if (initialize_video) { | |
| 1006 failure |= AndroidVideoCapturerJni::SetAndroidObjects(jni, context); | |
| 1007 } | |
| 1008 if (initialize_audio) | 1003 if (initialize_audio) |
| 1009 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context); | 1004 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context); |
| 1010 factory_static_initialized = true; | 1005 factory_static_initialized = true; |
| 1011 } | 1006 } |
| 1012 return !failure; | 1007 return !failure; |
| 1013 } | 1008 } |
| 1014 | 1009 |
| 1015 JOW(void, PeerConnectionFactory_initializeFieldTrials)( | 1010 JOW(void, PeerConnectionFactory_initializeFieldTrials)( |
| 1016 JNIEnv* jni, jclass, jstring j_trials_init_string) { | 1011 JNIEnv* jni, jclass, jstring j_trials_init_string) { |
| 1017 field_trials_init_string = NULL; | 1012 field_trials_init_string = NULL; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 | 1249 |
| 1255 JOW(jlong, PeerConnectionFactory_nativeCreateLocalMediaStream)( | 1250 JOW(jlong, PeerConnectionFactory_nativeCreateLocalMediaStream)( |
| 1256 JNIEnv* jni, jclass, jlong native_factory, jstring label) { | 1251 JNIEnv* jni, jclass, jlong native_factory, jstring label) { |
| 1257 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1252 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
| 1258 factoryFromJava(native_factory)); | 1253 factoryFromJava(native_factory)); |
| 1259 rtc::scoped_refptr<MediaStreamInterface> stream( | 1254 rtc::scoped_refptr<MediaStreamInterface> stream( |
| 1260 factory->CreateLocalMediaStream(JavaToStdString(jni, label))); | 1255 factory->CreateLocalMediaStream(JavaToStdString(jni, label))); |
| 1261 return (jlong)stream.release(); | 1256 return (jlong)stream.release(); |
| 1262 } | 1257 } |
| 1263 | 1258 |
| 1264 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource)( | 1259 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) |
| 1265 JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, | |
| 1266 jobject j_video_capturer, jobject j_constraints) { | |
| 1267 // Create a cricket::VideoCapturer from |j_video_capturer|. | |
| 1268 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = | |
| 1269 new rtc::RefCountedObject<AndroidVideoCapturerJni>( | |
| 1270 jni, j_video_capturer, j_egl_context); | |
| 1271 std::unique_ptr<cricket::VideoCapturer> capturer( | |
| 1272 new webrtc::AndroidVideoCapturer(delegate)); | |
| 1273 // Create a webrtc::VideoTrackSourceInterface from the cricket::VideoCapturer, | |
| 1274 // native factory and constraints. | |
| 1275 std::unique_ptr<ConstraintsWrapper> constraints( | |
| 1276 new ConstraintsWrapper(jni, j_constraints)); | |
| 1277 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | |
| 1278 factoryFromJava(native_factory)); | |
| 1279 rtc::scoped_refptr<VideoTrackSourceInterface> source( | |
| 1280 factory->CreateVideoSource(capturer.release(), constraints.get())); | |
| 1281 return (jlong)source.release(); | |
| 1282 } | |
| 1283 | |
| 1284 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource2) | |
| 1285 (JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context) { | 1260 (JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context) { |
| 1286 OwnedFactoryAndThreads* factory = | 1261 OwnedFactoryAndThreads* factory = |
| 1287 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); | 1262 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
| 1288 | 1263 |
| 1289 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( | 1264 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( |
| 1290 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( | 1265 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( |
| 1291 factory->signaling_thread(), jni, j_egl_context)); | 1266 factory->signaling_thread(), jni, j_egl_context)); |
| 1292 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = | 1267 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = |
| 1293 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), | 1268 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), |
| 1294 factory->worker_thread(), source); | 1269 factory->worker_thread(), source); |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 return JavaStringFromStdString( | 2323 return JavaStringFromStdString( |
| 2349 jni, | 2324 jni, |
| 2350 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2325 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
| 2351 } | 2326 } |
| 2352 | 2327 |
| 2353 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2328 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
| 2354 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2329 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
| 2355 } | 2330 } |
| 2356 | 2331 |
| 2357 } // namespace webrtc_jni | 2332 } // namespace webrtc_jni |
| OLD | NEW |