Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: talk/app/webrtc/java/jni/peerconnection_jni.cc

Issue 1652123002: Remove Java PC support. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // return to the Java frame that called code in this file, at which point it's 52 // return to the Java frame that called code in this file, at which point it's
53 // impossible to tell which JNI call broke). 53 // impossible to tell which JNI call broke).
54 54
55 #include <jni.h> 55 #include <jni.h>
56 #undef JNIEXPORT 56 #undef JNIEXPORT
57 #define JNIEXPORT __attribute__((visibility("default"))) 57 #define JNIEXPORT __attribute__((visibility("default")))
58 58
59 #include <limits> 59 #include <limits>
60 #include <utility> 60 #include <utility>
61 61
62 #include "talk/app/webrtc/androidvideocapturer.h"
63 #include "talk/app/webrtc/java/jni/androidmediadecoder_jni.h"
64 #include "talk/app/webrtc/java/jni/androidmediaencoder_jni.h"
65 #include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h"
66 #include "talk/app/webrtc/java/jni/androidnetworkmonitor_jni.h"
62 #include "talk/app/webrtc/java/jni/classreferenceholder.h" 67 #include "talk/app/webrtc/java/jni/classreferenceholder.h"
63 #include "talk/app/webrtc/java/jni/jni_helpers.h" 68 #include "talk/app/webrtc/java/jni/jni_helpers.h"
64 #include "talk/app/webrtc/java/jni/native_handle_impl.h" 69 #include "talk/app/webrtc/java/jni/native_handle_impl.h"
65 #include "talk/app/webrtc/dtlsidentitystore.h" 70 #include "talk/app/webrtc/dtlsidentitystore.h"
66 #include "talk/app/webrtc/mediaconstraintsinterface.h" 71 #include "talk/app/webrtc/mediaconstraintsinterface.h"
67 #include "talk/app/webrtc/peerconnectioninterface.h" 72 #include "talk/app/webrtc/peerconnectioninterface.h"
68 #include "talk/app/webrtc/rtpreceiverinterface.h" 73 #include "talk/app/webrtc/rtpreceiverinterface.h"
69 #include "talk/app/webrtc/rtpsenderinterface.h" 74 #include "talk/app/webrtc/rtpsenderinterface.h"
70 #include "talk/app/webrtc/videosourceinterface.h" 75 #include "talk/app/webrtc/videosourceinterface.h"
71 #include "talk/media/base/videocapturer.h" 76 #include "talk/media/base/videocapturer.h"
72 #include "talk/media/base/videorenderer.h" 77 #include "talk/media/base/videorenderer.h"
73 #include "talk/media/devices/videorendererfactory.h" 78 #include "talk/media/devices/videorendererfactory.h"
74 #include "talk/media/webrtc/webrtcvideodecoderfactory.h" 79 #include "talk/media/webrtc/webrtcvideodecoderfactory.h"
75 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" 80 #include "talk/media/webrtc/webrtcvideoencoderfactory.h"
76 #include "webrtc/base/bind.h" 81 #include "webrtc/base/bind.h"
77 #include "webrtc/base/checks.h" 82 #include "webrtc/base/checks.h"
78 #include "webrtc/base/event_tracer.h" 83 #include "webrtc/base/event_tracer.h"
79 #include "webrtc/base/logging.h" 84 #include "webrtc/base/logging.h"
80 #include "webrtc/base/logsinks.h" 85 #include "webrtc/base/logsinks.h"
81 #include "webrtc/base/messagequeue.h" 86 #include "webrtc/base/messagequeue.h"
82 #include "webrtc/base/networkmonitor.h" 87 #include "webrtc/base/networkmonitor.h"
83 #include "webrtc/base/ssladapter.h" 88 #include "webrtc/base/ssladapter.h"
84 #include "webrtc/base/stringutils.h" 89 #include "webrtc/base/stringutils.h"
85 #include "webrtc/system_wrappers/include/field_trial_default.h" 90 #include "webrtc/system_wrappers/include/field_trial_default.h"
91 #include "webrtc/system_wrappers/include/logcat_trace_context.h"
86 #include "webrtc/system_wrappers/include/trace.h" 92 #include "webrtc/system_wrappers/include/trace.h"
87 #include "webrtc/voice_engine/include/voe_base.h" 93 #include "webrtc/voice_engine/include/voe_base.h"
88 94
89 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
90 #include "talk/app/webrtc/androidvideocapturer.h"
91 #include "talk/app/webrtc/java/jni/androidmediadecoder_jni.h"
92 #include "talk/app/webrtc/java/jni/androidmediaencoder_jni.h"
93 #include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h"
94 #include "talk/app/webrtc/java/jni/androidnetworkmonitor_jni.h"
95 #include "webrtc/modules/video_render/video_render_internal.h"
96 #include "webrtc/system_wrappers/include/logcat_trace_context.h"
97 using webrtc::LogcatTraceContext;
98 #endif
99
100 using cricket::WebRtcVideoDecoderFactory; 95 using cricket::WebRtcVideoDecoderFactory;
101 using cricket::WebRtcVideoEncoderFactory; 96 using cricket::WebRtcVideoEncoderFactory;
102 using rtc::Bind; 97 using rtc::Bind;
103 using rtc::Thread; 98 using rtc::Thread;
104 using rtc::ThreadManager; 99 using rtc::ThreadManager;
105 using rtc::scoped_ptr; 100 using rtc::scoped_ptr;
106 using webrtc::AudioSourceInterface; 101 using webrtc::AudioSourceInterface;
107 using webrtc::AudioTrackInterface; 102 using webrtc::AudioTrackInterface;
108 using webrtc::AudioTrackVector; 103 using webrtc::AudioTrackVector;
109 using webrtc::CreateSessionDescriptionObserver; 104 using webrtc::CreateSessionDescriptionObserver;
110 using webrtc::DataBuffer; 105 using webrtc::DataBuffer;
111 using webrtc::DataChannelInit; 106 using webrtc::DataChannelInit;
112 using webrtc::DataChannelInterface; 107 using webrtc::DataChannelInterface;
113 using webrtc::DataChannelObserver; 108 using webrtc::DataChannelObserver;
114 using webrtc::IceCandidateInterface; 109 using webrtc::IceCandidateInterface;
110 using webrtc::LogcatTraceContext;
115 using webrtc::MediaConstraintsInterface; 111 using webrtc::MediaConstraintsInterface;
116 using webrtc::MediaSourceInterface; 112 using webrtc::MediaSourceInterface;
117 using webrtc::MediaStreamInterface; 113 using webrtc::MediaStreamInterface;
118 using webrtc::MediaStreamTrackInterface; 114 using webrtc::MediaStreamTrackInterface;
119 using webrtc::PeerConnectionFactoryInterface; 115 using webrtc::PeerConnectionFactoryInterface;
120 using webrtc::PeerConnectionInterface; 116 using webrtc::PeerConnectionInterface;
121 using webrtc::PeerConnectionObserver; 117 using webrtc::PeerConnectionObserver;
122 using webrtc::RtpReceiverInterface; 118 using webrtc::RtpReceiverInterface;
123 using webrtc::RtpSenderInterface; 119 using webrtc::RtpSenderInterface;
124 using webrtc::SessionDescriptionInterface; 120 using webrtc::SessionDescriptionInterface;
125 using webrtc::SetSessionDescriptionObserver; 121 using webrtc::SetSessionDescriptionObserver;
126 using webrtc::StatsObserver; 122 using webrtc::StatsObserver;
127 using webrtc::StatsReport; 123 using webrtc::StatsReport;
128 using webrtc::StatsReports; 124 using webrtc::StatsReports;
129 using webrtc::VideoRendererInterface; 125 using webrtc::VideoRendererInterface;
130 using webrtc::VideoSourceInterface; 126 using webrtc::VideoSourceInterface;
131 using webrtc::VideoTrackInterface; 127 using webrtc::VideoTrackInterface;
132 using webrtc::VideoTrackVector; 128 using webrtc::VideoTrackVector;
133 using webrtc::kVideoCodecVP8; 129 using webrtc::kVideoCodecVP8;
134 130
135 namespace webrtc_jni { 131 namespace webrtc_jni {
136 132
137 // Field trials initialization string 133 // Field trials initialization string
138 static char *field_trials_init_string = NULL; 134 static char *field_trials_init_string = NULL;
139 135
140 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
141 // Set in PeerConnectionFactory_initializeAndroidGlobals(). 136 // Set in PeerConnectionFactory_initializeAndroidGlobals().
142 static bool factory_static_initialized = false; 137 static bool factory_static_initialized = false;
143 static bool video_hw_acceleration_enabled = true; 138 static bool video_hw_acceleration_enabled = true;
144 #endif
145 139
146 // Return the (singleton) Java Enum object corresponding to |index|; 140 // Return the (singleton) Java Enum object corresponding to |index|;
147 // |state_class_fragment| is something like "MediaSource$State". 141 // |state_class_fragment| is something like "MediaSource$State".
148 static jobject JavaEnumFromIndex( 142 static jobject JavaEnumFromIndex(
149 JNIEnv* jni, const std::string& state_class_fragment, int index) { 143 JNIEnv* jni, const std::string& state_class_fragment, int index) {
150 const std::string state_class = "org/webrtc/" + state_class_fragment; 144 const std::string state_class = "org/webrtc/" + state_class_fragment;
151 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()), 145 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()),
152 state_class, index); 146 state_class, index);
153 } 147 }
154 148
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 JOW(void, DataChannel_dispose)(JNIEnv* jni, jobject j_dc) { 876 JOW(void, DataChannel_dispose)(JNIEnv* jni, jobject j_dc) {
883 CHECK_RELEASE(ExtractNativeDC(jni, j_dc)); 877 CHECK_RELEASE(ExtractNativeDC(jni, j_dc));
884 } 878 }
885 879
886 JOW(void, Logging_nativeEnableTracing)( 880 JOW(void, Logging_nativeEnableTracing)(
887 JNIEnv* jni, jclass, jstring j_path, jint nativeLevels, 881 JNIEnv* jni, jclass, jstring j_path, jint nativeLevels,
888 jint nativeSeverity) { 882 jint nativeSeverity) {
889 std::string path = JavaToStdString(jni, j_path); 883 std::string path = JavaToStdString(jni, j_path);
890 if (nativeLevels != webrtc::kTraceNone) { 884 if (nativeLevels != webrtc::kTraceNone) {
891 webrtc::Trace::set_level_filter(nativeLevels); 885 webrtc::Trace::set_level_filter(nativeLevels);
892 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
893 if (path != "logcat:") { 886 if (path != "logcat:") {
894 #endif
895 RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false)) 887 RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
896 << "SetTraceFile failed"; 888 << "SetTraceFile failed";
897 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
898 } else { 889 } else {
899 // Intentionally leak this to avoid needing to reason about its lifecycle. 890 // Intentionally leak this to avoid needing to reason about its lifecycle.
900 // It keeps no state and functions only as a dispatch point. 891 // It keeps no state and functions only as a dispatch point.
901 static LogcatTraceContext* g_trace_callback = new LogcatTraceContext(); 892 static LogcatTraceContext* g_trace_callback = new LogcatTraceContext();
902 } 893 }
903 #endif
904 } 894 }
905 if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_ERROR) { 895 if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_ERROR) {
906 rtc::LogMessage::LogToDebug( 896 rtc::LogMessage::LogToDebug(
907 static_cast<rtc::LoggingSeverity>(nativeSeverity)); 897 static_cast<rtc::LoggingSeverity>(nativeSeverity));
908 } 898 }
909 } 899 }
910 900
911 JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) { 901 JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) {
912 rtc::LogMessage::LogThreads(true); 902 rtc::LogMessage::LogThreads(true);
913 } 903 }
(...skipping 19 matching lines...) Expand all
933 } 923 }
934 924
935 JOW(void, MediaSource_free)(JNIEnv*, jclass, jlong j_p) { 925 JOW(void, MediaSource_free)(JNIEnv*, jclass, jlong j_p) {
936 CHECK_RELEASE(reinterpret_cast<MediaSourceInterface*>(j_p)); 926 CHECK_RELEASE(reinterpret_cast<MediaSourceInterface*>(j_p));
937 } 927 }
938 928
939 JOW(void, VideoCapturer_free)(JNIEnv*, jclass, jlong j_p) { 929 JOW(void, VideoCapturer_free)(JNIEnv*, jclass, jlong j_p) {
940 delete reinterpret_cast<cricket::VideoCapturer*>(j_p); 930 delete reinterpret_cast<cricket::VideoCapturer*>(j_p);
941 } 931 }
942 932
943 JOW(void, VideoRenderer_freeGuiVideoRenderer)(JNIEnv*, jclass, jlong j_p) { 933 JOW(void, VideoRenderer_freeGuiVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
AlexG 2016/02/01 21:05:33 Not needed?
magjed_webrtc 2016/02/02 09:00:01 Yes, I think VideoRenderer can be cleaned up as we
perkj_webrtc 2016/02/03 17:00:03 Used by VideoRenderer.createGui which is used by P
AlexG 2016/02/04 00:01:22 Add TODO item since I think nativeCreateGuiVideoRe
perkj_webrtc 2016/02/05 13:43:44 you are actually right. The test did call this met
944 delete reinterpret_cast<VideoRendererWrapper*>(j_p); 934 delete reinterpret_cast<VideoRendererWrapper*>(j_p);
945 } 935 }
946 936
947 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) { 937 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
948 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p); 938 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p);
949 } 939 }
950 940
951 JOW(void, VideoRenderer_releaseNativeFrame)( 941 JOW(void, VideoRenderer_releaseNativeFrame)(
952 JNIEnv* jni, jclass, jlong j_frame_ptr) { 942 JNIEnv* jni, jclass, jlong j_frame_ptr) {
953 delete reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr); 943 delete reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 978
989 JOW(void, MediaStream_free)(JNIEnv*, jclass, jlong j_p) { 979 JOW(void, MediaStream_free)(JNIEnv*, jclass, jlong j_p) {
990 CHECK_RELEASE(reinterpret_cast<MediaStreamInterface*>(j_p)); 980 CHECK_RELEASE(reinterpret_cast<MediaStreamInterface*>(j_p));
991 } 981 }
992 982
993 JOW(jlong, PeerConnectionFactory_nativeCreateObserver)( 983 JOW(jlong, PeerConnectionFactory_nativeCreateObserver)(
994 JNIEnv * jni, jclass, jobject j_observer) { 984 JNIEnv * jni, jclass, jobject j_observer) {
995 return (jlong)new PCOJava(jni, j_observer); 985 return (jlong)new PCOJava(jni, j_observer);
996 } 986 }
997 987
998 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
999 JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals)( 988 JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals)(
1000 JNIEnv* jni, jclass, jobject context, 989 JNIEnv* jni, jclass, jobject context,
1001 jboolean initialize_audio, jboolean initialize_video, 990 jboolean initialize_audio, jboolean initialize_video,
1002 jboolean video_hw_acceleration) { 991 jboolean video_hw_acceleration) {
1003 bool failure = false; 992 bool failure = false;
1004 video_hw_acceleration_enabled = video_hw_acceleration; 993 video_hw_acceleration_enabled = video_hw_acceleration;
1005 AndroidNetworkMonitor::SetAndroidContext(jni, context); 994 AndroidNetworkMonitor::SetAndroidContext(jni, context);
1006 if (!factory_static_initialized) { 995 if (!factory_static_initialized) {
1007 if (initialize_video) { 996 if (initialize_video) {
1008 failure |= webrtc::SetRenderAndroidVM(GetJVM());
1009 failure |= AndroidVideoCapturerJni::SetAndroidObjects(jni, context); 997 failure |= AndroidVideoCapturerJni::SetAndroidObjects(jni, context);
1010 } 998 }
1011 if (initialize_audio) 999 if (initialize_audio)
1012 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context); 1000 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context);
1013 factory_static_initialized = true; 1001 factory_static_initialized = true;
1014 } 1002 }
1015 return !failure; 1003 return !failure;
1016 } 1004 }
1017 #endif // defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
1018 1005
1019 JOW(void, PeerConnectionFactory_initializeFieldTrials)( 1006 JOW(void, PeerConnectionFactory_initializeFieldTrials)(
1020 JNIEnv* jni, jclass, jstring j_trials_init_string) { 1007 JNIEnv* jni, jclass, jstring j_trials_init_string) {
1021 field_trials_init_string = NULL; 1008 field_trials_init_string = NULL;
1022 if (j_trials_init_string != NULL) { 1009 if (j_trials_init_string != NULL) {
1023 const char* init_string = 1010 const char* init_string =
1024 jni->GetStringUTFChars(j_trials_init_string, NULL); 1011 jni->GetStringUTFChars(j_trials_init_string, NULL);
1025 int init_string_length = jni->GetStringUTFLength(j_trials_init_string); 1012 int init_string_length = jni->GetStringUTFLength(j_trials_init_string);
1026 field_trials_init_string = new char[init_string_length + 1]; 1013 field_trials_init_string = new char[init_string_length + 1];
1027 rtc::strcpyn(field_trials_init_string, init_string_length + 1, init_string); 1014 rtc::strcpyn(field_trials_init_string, init_string_length + 1, init_string);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 << "Failed to start threads"; 1165 << "Failed to start threads";
1179 WebRtcVideoEncoderFactory* encoder_factory = nullptr; 1166 WebRtcVideoEncoderFactory* encoder_factory = nullptr;
1180 WebRtcVideoDecoderFactory* decoder_factory = nullptr; 1167 WebRtcVideoDecoderFactory* decoder_factory = nullptr;
1181 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr; 1168 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr;
1182 1169
1183 PeerConnectionFactoryInterface::Options options; 1170 PeerConnectionFactoryInterface::Options options;
1184 bool has_options = joptions != NULL; 1171 bool has_options = joptions != NULL;
1185 if (has_options) { 1172 if (has_options) {
1186 options = ParseOptionsFromJava(jni, joptions); 1173 options = ParseOptionsFromJava(jni, joptions);
1187 } 1174 }
1188 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) 1175
1189 if (video_hw_acceleration_enabled) { 1176 if (video_hw_acceleration_enabled) {
1190 encoder_factory = new MediaCodecVideoEncoderFactory(); 1177 encoder_factory = new MediaCodecVideoEncoderFactory();
1191 decoder_factory = new MediaCodecVideoDecoderFactory(); 1178 decoder_factory = new MediaCodecVideoDecoderFactory();
1192 } 1179 }
1193 // Do not create network_monitor_factory only if the options are 1180 // Do not create network_monitor_factory only if the options are
1194 // provided and disable_network_monitor therein is set to true. 1181 // provided and disable_network_monitor therein is set to true.
1195 if (!(has_options && options.disable_network_monitor)) { 1182 if (!(has_options && options.disable_network_monitor)) {
1196 network_monitor_factory = new AndroidNetworkMonitorFactory(); 1183 network_monitor_factory = new AndroidNetworkMonitorFactory();
1197 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory); 1184 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory);
1198 } 1185 }
1199 #endif 1186
1200 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1187 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1201 webrtc::CreatePeerConnectionFactory(worker_thread, 1188 webrtc::CreatePeerConnectionFactory(worker_thread,
1202 signaling_thread, 1189 signaling_thread,
1203 NULL, 1190 NULL,
1204 encoder_factory, 1191 encoder_factory,
1205 decoder_factory)); 1192 decoder_factory));
1206 RTC_CHECK(factory) << "Failed to create the peer connection factory; " 1193 RTC_CHECK(factory) << "Failed to create the peer connection factory; "
1207 << "WebRTC/libjingle init likely failed on this device"; 1194 << "WebRTC/libjingle init likely failed on this device";
1208 // TODO(honghaiz): Maybe put the options as the argument of 1195 // TODO(honghaiz): Maybe put the options as the argument of
1209 // CreatePeerConnectionFactory. 1196 // CreatePeerConnectionFactory.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 factoryFromJava(native_factory)); 1279 factoryFromJava(native_factory));
1293 rtc::scoped_refptr<AudioTrackInterface> track(factory->CreateAudioTrack( 1280 rtc::scoped_refptr<AudioTrackInterface> track(factory->CreateAudioTrack(
1294 JavaToStdString(jni, id), 1281 JavaToStdString(jni, id),
1295 reinterpret_cast<AudioSourceInterface*>(native_source))); 1282 reinterpret_cast<AudioSourceInterface*>(native_source)));
1296 return (jlong)track.release(); 1283 return (jlong)track.release();
1297 } 1284 }
1298 1285
1299 JOW(jboolean, PeerConnectionFactory_nativeStartAecDump)( 1286 JOW(jboolean, PeerConnectionFactory_nativeStartAecDump)(
1300 JNIEnv* jni, jclass, jlong native_factory, jint file, 1287 JNIEnv* jni, jclass, jlong native_factory, jint file,
1301 jint filesize_limit_bytes) { 1288 jint filesize_limit_bytes) {
1302 #if defined(ANDROID)
1303 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1289 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1304 factoryFromJava(native_factory)); 1290 factoryFromJava(native_factory));
1305 return factory->StartAecDump(file, filesize_limit_bytes); 1291 return factory->StartAecDump(file, filesize_limit_bytes);
1306 #else
1307 return false;
1308 #endif
1309 } 1292 }
1310 1293
1311 JOW(void, PeerConnectionFactory_nativeStopAecDump)( 1294 JOW(void, PeerConnectionFactory_nativeStopAecDump)(
1312 JNIEnv* jni, jclass, jlong native_factory) { 1295 JNIEnv* jni, jclass, jlong native_factory) {
1313 #if defined(ANDROID)
1314 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1296 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1315 factoryFromJava(native_factory)); 1297 factoryFromJava(native_factory));
1316 factory->StopAecDump(); 1298 factory->StopAecDump();
1317 #endif
1318 } 1299 }
1319 1300
1320 JOW(jboolean, PeerConnectionFactory_nativeStartRtcEventLog)( 1301 JOW(jboolean, PeerConnectionFactory_nativeStartRtcEventLog)(
1321 JNIEnv* jni, jclass, jlong native_factory, jint file) { 1302 JNIEnv* jni, jclass, jlong native_factory, jint file) {
1322 #if defined(ANDROID)
1323 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1303 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1324 factoryFromJava(native_factory)); 1304 factoryFromJava(native_factory));
1325 return factory->StartRtcEventLog(file); 1305 return factory->StartRtcEventLog(file);
1326 #else
1327 return false;
1328 #endif
1329 } 1306 }
1330 1307
1331 JOW(void, PeerConnectionFactory_nativeStopRtcEventLog)( 1308 JOW(void, PeerConnectionFactory_nativeStopRtcEventLog)(
1332 JNIEnv* jni, jclass, jlong native_factory) { 1309 JNIEnv* jni, jclass, jlong native_factory) {
1333 #if defined(ANDROID)
1334 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1310 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1335 factoryFromJava(native_factory)); 1311 factoryFromJava(native_factory));
1336 factory->StopRtcEventLog(); 1312 factory->StopRtcEventLog();
1337 #endif
1338 } 1313 }
1339 1314
1340 JOW(void, PeerConnectionFactory_nativeSetOptions)( 1315 JOW(void, PeerConnectionFactory_nativeSetOptions)(
1341 JNIEnv* jni, jclass, jlong native_factory, jobject options) { 1316 JNIEnv* jni, jclass, jlong native_factory, jobject options) {
1342 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1317 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1343 factoryFromJava(native_factory)); 1318 factoryFromJava(native_factory));
1344 PeerConnectionFactoryInterface::Options options_to_set = 1319 PeerConnectionFactoryInterface::Options options_to_set =
1345 ParseOptionsFromJava(jni, options); 1320 ParseOptionsFromJava(jni, options);
1346 factory->SetOptions(options_to_set); 1321 factory->SetOptions(options_to_set);
1347 1322
1348 if (options_to_set.disable_network_monitor) { 1323 if (options_to_set.disable_network_monitor) {
1349 OwnedFactoryAndThreads* owner = 1324 OwnedFactoryAndThreads* owner =
1350 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); 1325 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
1351 if (owner->network_monitor_factory()) { 1326 if (owner->network_monitor_factory()) {
1352 rtc::NetworkMonitorFactory::ReleaseFactory( 1327 rtc::NetworkMonitorFactory::ReleaseFactory(
1353 owner->network_monitor_factory()); 1328 owner->network_monitor_factory());
1354 owner->clear_network_monitor_factory(); 1329 owner->clear_network_monitor_factory();
1355 } 1330 }
1356 } 1331 }
1357 } 1332 }
1358 1333
1359 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( 1334 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)(
1360 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context, 1335 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context,
1361 jobject remote_egl_context) { 1336 jobject remote_egl_context) {
1362 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
1363 OwnedFactoryAndThreads* owned_factory = 1337 OwnedFactoryAndThreads* owned_factory =
1364 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); 1338 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
1365 1339
1366 jclass j_eglbase14_context_class = 1340 jclass j_eglbase14_context_class =
1367 FindClass(jni, "org/webrtc/EglBase14$Context"); 1341 FindClass(jni, "org/webrtc/EglBase14$Context");
1368 1342
1369 MediaCodecVideoEncoderFactory* encoder_factory = 1343 MediaCodecVideoEncoderFactory* encoder_factory =
1370 static_cast<MediaCodecVideoEncoderFactory*> 1344 static_cast<MediaCodecVideoEncoderFactory*>
1371 (owned_factory->encoder_factory()); 1345 (owned_factory->encoder_factory());
1372 if (encoder_factory && 1346 if (encoder_factory &&
1373 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { 1347 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) {
1374 LOG(LS_INFO) << "Set EGL context for HW encoding."; 1348 LOG(LS_INFO) << "Set EGL context for HW encoding.";
1375 encoder_factory->SetEGLContext(jni, local_egl_context); 1349 encoder_factory->SetEGLContext(jni, local_egl_context);
1376 } 1350 }
1377 1351
1378 MediaCodecVideoDecoderFactory* decoder_factory = 1352 MediaCodecVideoDecoderFactory* decoder_factory =
1379 static_cast<MediaCodecVideoDecoderFactory*> 1353 static_cast<MediaCodecVideoDecoderFactory*>
1380 (owned_factory->decoder_factory()); 1354 (owned_factory->decoder_factory());
1381 if (decoder_factory && 1355 if (decoder_factory &&
1382 jni->IsInstanceOf(remote_egl_context, j_eglbase14_context_class)) { 1356 jni->IsInstanceOf(remote_egl_context, j_eglbase14_context_class)) {
1383 LOG(LS_INFO) << "Set EGL context for HW decoding."; 1357 LOG(LS_INFO) << "Set EGL context for HW decoding.";
1384 decoder_factory->SetEGLContext(jni, remote_egl_context); 1358 decoder_factory->SetEGLContext(jni, remote_egl_context);
1385 } 1359 }
1386 #endif
1387 } 1360 }
1388 1361
1389 static PeerConnectionInterface::IceTransportsType 1362 static PeerConnectionInterface::IceTransportsType
1390 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) { 1363 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) {
1391 std::string enum_name = GetJavaEnumName( 1364 std::string enum_name = GetJavaEnumName(
1392 jni, "org/webrtc/PeerConnection$IceTransportsType", 1365 jni, "org/webrtc/PeerConnection$IceTransportsType",
1393 j_ice_transports_type); 1366 j_ice_transports_type);
1394 1367
1395 if (enum_name == "ALL") 1368 if (enum_name == "ALL")
1396 return PeerConnectionInterface::kAll; 1369 return PeerConnectionInterface::kAll;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 ExtractNativePC(jni, j_pc)->Close(); 1859 ExtractNativePC(jni, j_pc)->Close();
1887 return; 1860 return;
1888 } 1861 }
1889 1862
1890 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { 1863 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) {
1891 rtc::scoped_refptr<MediaSourceInterface> p( 1864 rtc::scoped_refptr<MediaSourceInterface> p(
1892 reinterpret_cast<MediaSourceInterface*>(j_p)); 1865 reinterpret_cast<MediaSourceInterface*>(j_p));
1893 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); 1866 return JavaEnumFromIndex(jni, "MediaSource$State", p->state());
1894 } 1867 }
1895 1868
1896 JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)(
1897 JNIEnv* jni, jclass, jstring j_device_name) {
1898 // Since we can't create platform specific java implementations in Java, we
1899 // defer the creation to C land.
1900 #if defined(ANDROID)
1901 // TODO(nisse): This case is intended to be deleted.
phoglund 2016/02/02 08:04:43 But this deletes the android implementation as wel
perkj_webrtc 2016/02/03 17:00:03 Yes. it it no longer used.
1902 jclass j_video_capturer_class(
1903 FindClass(jni, "org/webrtc/VideoCapturerAndroid"));
1904 const int camera_id = jni->CallStaticIntMethod(
1905 j_video_capturer_class,
1906 GetStaticMethodID(jni, j_video_capturer_class, "lookupDeviceName",
1907 "(Ljava/lang/String;)I"),
1908 j_device_name);
1909 CHECK_EXCEPTION(jni) << "error during VideoCapturerAndroid.lookupDeviceName";
1910 if (camera_id == -1)
1911 return nullptr;
1912 jobject j_video_capturer = jni->NewObject(
1913 j_video_capturer_class,
1914 GetMethodID(jni, j_video_capturer_class, "<init>", "(I)V"), camera_id);
1915 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturerAndroid";
1916 jfieldID helper_fid = GetFieldID(jni, j_video_capturer_class, "surfaceHelper",
1917 "Lorg/webrtc/SurfaceTextureHelper;");
1918
1919 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate =
1920 new rtc::RefCountedObject<AndroidVideoCapturerJni>(
1921 jni, j_video_capturer,
1922 GetObjectField(jni, j_video_capturer, helper_fid));
1923 rtc::scoped_ptr<cricket::VideoCapturer> capturer(
1924 new webrtc::AndroidVideoCapturer(delegate));
1925
1926 #else
1927 std::string device_name = JavaToStdString(jni, j_device_name);
1928 scoped_ptr<cricket::DeviceManagerInterface> device_manager(
1929 cricket::DeviceManagerFactory::Create());
1930 RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed";
1931 cricket::Device device;
1932 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) {
1933 LOG(LS_ERROR) << "GetVideoCaptureDevice failed for " << device_name;
1934 return 0;
1935 }
1936 scoped_ptr<cricket::VideoCapturer> capturer(
1937 device_manager->CreateVideoCapturer(device));
1938
1939 jclass j_video_capturer_class(
1940 FindClass(jni, "org/webrtc/VideoCapturer"));
1941 const jmethodID j_videocapturer_ctor(GetMethodID(
1942 jni, j_video_capturer_class, "<init>", "()V"));
1943 jobject j_video_capturer =
1944 jni->NewObject(j_video_capturer_class,
1945 j_videocapturer_ctor);
1946 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturer";
1947
1948 #endif
1949 const jmethodID j_videocapturer_set_native_capturer(GetMethodID(
1950 jni, j_video_capturer_class, "setNativeCapturer", "(J)V"));
1951 jni->CallVoidMethod(j_video_capturer,
1952 j_videocapturer_set_native_capturer,
1953 jlongFromPointer(capturer.release()));
1954 CHECK_EXCEPTION(jni) << "error during setNativeCapturer";
1955 return j_video_capturer;
1956 }
1957
1958 JOW(jlong, VideoRenderer_nativeCreateGuiVideoRenderer)( 1869 JOW(jlong, VideoRenderer_nativeCreateGuiVideoRenderer)(
AlexG 2016/02/01 21:05:33 Not needed as well? I may be wrong, but I think th
perkj_webrtc 2016/02/03 17:00:03 dito- It is still used by PeerConnectionTest.
1959 JNIEnv* jni, jclass, int x, int y) { 1870 JNIEnv* jni, jclass, int x, int y) {
1960 scoped_ptr<VideoRendererWrapper> renderer(VideoRendererWrapper::Create( 1871 scoped_ptr<VideoRendererWrapper> renderer(VideoRendererWrapper::Create(
1961 cricket::VideoRendererFactory::CreateGuiVideoRenderer(x, y))); 1872 cricket::VideoRendererFactory::CreateGuiVideoRenderer(x, y)));
1962 return (jlong)renderer.release(); 1873 return (jlong)renderer.release();
1963 } 1874 }
1964 1875
1965 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)( 1876 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)(
1966 JNIEnv* jni, jclass, jobject j_callbacks) { 1877 JNIEnv* jni, jclass, jobject j_callbacks) {
1967 scoped_ptr<JavaVideoRendererWrapper> renderer( 1878 scoped_ptr<JavaVideoRendererWrapper> renderer(
1968 new JavaVideoRendererWrapper(jni, j_callbacks)); 1879 new JavaVideoRendererWrapper(jni, j_callbacks));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 return JavaStringFromStdString( 2059 return JavaStringFromStdString(
2149 jni, 2060 jni,
2150 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2061 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2151 } 2062 }
2152 2063
2153 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2064 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2154 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2065 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2155 } 2066 }
2156 2067
2157 } // namespace webrtc_jni 2068 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698