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

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: rebased 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"
62 #include "talk/app/webrtc/dtlsidentitystore.h" 63 #include "talk/app/webrtc/dtlsidentitystore.h"
64 #include "talk/app/webrtc/java/jni/androidmediadecoder_jni.h"
65 #include "talk/app/webrtc/java/jni/androidmediaencoder_jni.h"
66 #include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h"
67 #include "talk/app/webrtc/java/jni/androidnetworkmonitor_jni.h"
63 #include "talk/app/webrtc/java/jni/classreferenceholder.h" 68 #include "talk/app/webrtc/java/jni/classreferenceholder.h"
64 #include "talk/app/webrtc/java/jni/jni_helpers.h" 69 #include "talk/app/webrtc/java/jni/jni_helpers.h"
65 #include "talk/app/webrtc/java/jni/native_handle_impl.h" 70 #include "talk/app/webrtc/java/jni/native_handle_impl.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 "webrtc/base/bind.h" 76 #include "webrtc/base/bind.h"
72 #include "webrtc/base/checks.h" 77 #include "webrtc/base/checks.h"
73 #include "webrtc/base/event_tracer.h" 78 #include "webrtc/base/event_tracer.h"
74 #include "webrtc/base/logging.h" 79 #include "webrtc/base/logging.h"
75 #include "webrtc/base/logsinks.h" 80 #include "webrtc/base/logsinks.h"
76 #include "webrtc/base/messagequeue.h" 81 #include "webrtc/base/messagequeue.h"
77 #include "webrtc/base/networkmonitor.h" 82 #include "webrtc/base/networkmonitor.h"
78 #include "webrtc/base/ssladapter.h" 83 #include "webrtc/base/ssladapter.h"
79 #include "webrtc/base/stringutils.h" 84 #include "webrtc/base/stringutils.h"
80 #include "webrtc/media/base/videocapturer.h" 85 #include "webrtc/media/base/videocapturer.h"
81 #include "webrtc/media/base/videorenderer.h" 86 #include "webrtc/media/base/videorenderer.h"
82 #include "webrtc/media/devices/videorendererfactory.h" 87 #include "webrtc/media/devices/videorendererfactory.h"
83 #include "webrtc/media/webrtc/webrtcvideodecoderfactory.h" 88 #include "webrtc/media/webrtc/webrtcvideodecoderfactory.h"
84 #include "webrtc/media/webrtc/webrtcvideoencoderfactory.h" 89 #include "webrtc/media/webrtc/webrtcvideoencoderfactory.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/androidnetworkmonitor_jni.h"
94 #include "talk/app/webrtc/java/jni/androidvideocapturer_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) {
944 delete reinterpret_cast<VideoRendererWrapper*>(j_p);
945 }
946
947 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) { 933 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
948 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p); 934 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p);
949 } 935 }
950 936
951 JOW(void, VideoRenderer_releaseNativeFrame)( 937 JOW(void, VideoRenderer_releaseNativeFrame)(
952 JNIEnv* jni, jclass, jlong j_frame_ptr) { 938 JNIEnv* jni, jclass, jlong j_frame_ptr) {
953 delete reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr); 939 delete reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr);
954 } 940 }
955 941
956 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) { 942 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 974
989 JOW(void, MediaStream_free)(JNIEnv*, jclass, jlong j_p) { 975 JOW(void, MediaStream_free)(JNIEnv*, jclass, jlong j_p) {
990 CHECK_RELEASE(reinterpret_cast<MediaStreamInterface*>(j_p)); 976 CHECK_RELEASE(reinterpret_cast<MediaStreamInterface*>(j_p));
991 } 977 }
992 978
993 JOW(jlong, PeerConnectionFactory_nativeCreateObserver)( 979 JOW(jlong, PeerConnectionFactory_nativeCreateObserver)(
994 JNIEnv * jni, jclass, jobject j_observer) { 980 JNIEnv * jni, jclass, jobject j_observer) {
995 return (jlong)new PCOJava(jni, j_observer); 981 return (jlong)new PCOJava(jni, j_observer);
996 } 982 }
997 983
998 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
999 JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals)( 984 JOW(jboolean, PeerConnectionFactory_initializeAndroidGlobals)(
1000 JNIEnv* jni, jclass, jobject context, 985 JNIEnv* jni, jclass, jobject context,
1001 jboolean initialize_audio, jboolean initialize_video, 986 jboolean initialize_audio, jboolean initialize_video,
1002 jboolean video_hw_acceleration) { 987 jboolean video_hw_acceleration) {
1003 bool failure = false; 988 bool failure = false;
1004 video_hw_acceleration_enabled = video_hw_acceleration; 989 video_hw_acceleration_enabled = video_hw_acceleration;
1005 AndroidNetworkMonitor::SetAndroidContext(jni, context); 990 AndroidNetworkMonitor::SetAndroidContext(jni, context);
1006 if (!factory_static_initialized) { 991 if (!factory_static_initialized) {
1007 if (initialize_video) { 992 if (initialize_video) {
1008 failure |= webrtc::SetRenderAndroidVM(GetJVM());
1009 failure |= AndroidVideoCapturerJni::SetAndroidObjects(jni, context); 993 failure |= AndroidVideoCapturerJni::SetAndroidObjects(jni, context);
1010 } 994 }
1011 if (initialize_audio) 995 if (initialize_audio)
1012 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context); 996 failure |= webrtc::VoiceEngine::SetAndroidObjects(GetJVM(), context);
1013 factory_static_initialized = true; 997 factory_static_initialized = true;
1014 } 998 }
1015 return !failure; 999 return !failure;
1016 } 1000 }
1017 #endif // defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
1018 1001
1019 JOW(void, PeerConnectionFactory_initializeFieldTrials)( 1002 JOW(void, PeerConnectionFactory_initializeFieldTrials)(
1020 JNIEnv* jni, jclass, jstring j_trials_init_string) { 1003 JNIEnv* jni, jclass, jstring j_trials_init_string) {
1021 field_trials_init_string = NULL; 1004 field_trials_init_string = NULL;
1022 if (j_trials_init_string != NULL) { 1005 if (j_trials_init_string != NULL) {
1023 const char* init_string = 1006 const char* init_string =
1024 jni->GetStringUTFChars(j_trials_init_string, NULL); 1007 jni->GetStringUTFChars(j_trials_init_string, NULL);
1025 int init_string_length = jni->GetStringUTFLength(j_trials_init_string); 1008 int init_string_length = jni->GetStringUTFLength(j_trials_init_string);
1026 field_trials_init_string = new char[init_string_length + 1]; 1009 field_trials_init_string = new char[init_string_length + 1];
1027 rtc::strcpyn(field_trials_init_string, init_string_length + 1, init_string); 1010 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"; 1161 << "Failed to start threads";
1179 WebRtcVideoEncoderFactory* encoder_factory = nullptr; 1162 WebRtcVideoEncoderFactory* encoder_factory = nullptr;
1180 WebRtcVideoDecoderFactory* decoder_factory = nullptr; 1163 WebRtcVideoDecoderFactory* decoder_factory = nullptr;
1181 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr; 1164 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr;
1182 1165
1183 PeerConnectionFactoryInterface::Options options; 1166 PeerConnectionFactoryInterface::Options options;
1184 bool has_options = joptions != NULL; 1167 bool has_options = joptions != NULL;
1185 if (has_options) { 1168 if (has_options) {
1186 options = ParseOptionsFromJava(jni, joptions); 1169 options = ParseOptionsFromJava(jni, joptions);
1187 } 1170 }
1188 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) 1171
1189 if (video_hw_acceleration_enabled) { 1172 if (video_hw_acceleration_enabled) {
1190 encoder_factory = new MediaCodecVideoEncoderFactory(); 1173 encoder_factory = new MediaCodecVideoEncoderFactory();
1191 decoder_factory = new MediaCodecVideoDecoderFactory(); 1174 decoder_factory = new MediaCodecVideoDecoderFactory();
1192 } 1175 }
1193 // Do not create network_monitor_factory only if the options are 1176 // Do not create network_monitor_factory only if the options are
1194 // provided and disable_network_monitor therein is set to true. 1177 // provided and disable_network_monitor therein is set to true.
1195 if (!(has_options && options.disable_network_monitor)) { 1178 if (!(has_options && options.disable_network_monitor)) {
1196 network_monitor_factory = new AndroidNetworkMonitorFactory(); 1179 network_monitor_factory = new AndroidNetworkMonitorFactory();
1197 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory); 1180 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory);
1198 } 1181 }
1199 #endif 1182
1200 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1183 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1201 webrtc::CreatePeerConnectionFactory(worker_thread, 1184 webrtc::CreatePeerConnectionFactory(worker_thread,
1202 signaling_thread, 1185 signaling_thread,
1203 NULL, 1186 NULL,
1204 encoder_factory, 1187 encoder_factory,
1205 decoder_factory)); 1188 decoder_factory));
1206 RTC_CHECK(factory) << "Failed to create the peer connection factory; " 1189 RTC_CHECK(factory) << "Failed to create the peer connection factory; "
1207 << "WebRTC/libjingle init likely failed on this device"; 1190 << "WebRTC/libjingle init likely failed on this device";
1208 // TODO(honghaiz): Maybe put the options as the argument of 1191 // TODO(honghaiz): Maybe put the options as the argument of
1209 // CreatePeerConnectionFactory. 1192 // CreatePeerConnectionFactory.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 factoryFromJava(native_factory)); 1275 factoryFromJava(native_factory));
1293 rtc::scoped_refptr<AudioTrackInterface> track(factory->CreateAudioTrack( 1276 rtc::scoped_refptr<AudioTrackInterface> track(factory->CreateAudioTrack(
1294 JavaToStdString(jni, id), 1277 JavaToStdString(jni, id),
1295 reinterpret_cast<AudioSourceInterface*>(native_source))); 1278 reinterpret_cast<AudioSourceInterface*>(native_source)));
1296 return (jlong)track.release(); 1279 return (jlong)track.release();
1297 } 1280 }
1298 1281
1299 JOW(jboolean, PeerConnectionFactory_nativeStartAecDump)( 1282 JOW(jboolean, PeerConnectionFactory_nativeStartAecDump)(
1300 JNIEnv* jni, jclass, jlong native_factory, jint file, 1283 JNIEnv* jni, jclass, jlong native_factory, jint file,
1301 jint filesize_limit_bytes) { 1284 jint filesize_limit_bytes) {
1302 #if defined(ANDROID)
1303 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1285 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1304 factoryFromJava(native_factory)); 1286 factoryFromJava(native_factory));
1305 return factory->StartAecDump(file, filesize_limit_bytes); 1287 return factory->StartAecDump(file, filesize_limit_bytes);
1306 #else
1307 return false;
1308 #endif
1309 } 1288 }
1310 1289
1311 JOW(void, PeerConnectionFactory_nativeStopAecDump)( 1290 JOW(void, PeerConnectionFactory_nativeStopAecDump)(
1312 JNIEnv* jni, jclass, jlong native_factory) { 1291 JNIEnv* jni, jclass, jlong native_factory) {
1313 #if defined(ANDROID)
1314 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1292 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1315 factoryFromJava(native_factory)); 1293 factoryFromJava(native_factory));
1316 factory->StopAecDump(); 1294 factory->StopAecDump();
1317 #endif
1318 } 1295 }
1319 1296
1320 JOW(jboolean, PeerConnectionFactory_nativeStartRtcEventLog)( 1297 JOW(jboolean, PeerConnectionFactory_nativeStartRtcEventLog)(
1321 JNIEnv* jni, jclass, jlong native_factory, jint file) { 1298 JNIEnv* jni, jclass, jlong native_factory, jint file) {
1322 #if defined(ANDROID)
1323 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1299 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1324 factoryFromJava(native_factory)); 1300 factoryFromJava(native_factory));
1325 return factory->StartRtcEventLog(file); 1301 return factory->StartRtcEventLog(file);
1326 #else
1327 return false;
1328 #endif
1329 } 1302 }
1330 1303
1331 JOW(void, PeerConnectionFactory_nativeStopRtcEventLog)( 1304 JOW(void, PeerConnectionFactory_nativeStopRtcEventLog)(
1332 JNIEnv* jni, jclass, jlong native_factory) { 1305 JNIEnv* jni, jclass, jlong native_factory) {
1333 #if defined(ANDROID)
1334 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1306 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1335 factoryFromJava(native_factory)); 1307 factoryFromJava(native_factory));
1336 factory->StopRtcEventLog(); 1308 factory->StopRtcEventLog();
1337 #endif
1338 } 1309 }
1339 1310
1340 JOW(void, PeerConnectionFactory_nativeSetOptions)( 1311 JOW(void, PeerConnectionFactory_nativeSetOptions)(
1341 JNIEnv* jni, jclass, jlong native_factory, jobject options) { 1312 JNIEnv* jni, jclass, jlong native_factory, jobject options) {
1342 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( 1313 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
1343 factoryFromJava(native_factory)); 1314 factoryFromJava(native_factory));
1344 PeerConnectionFactoryInterface::Options options_to_set = 1315 PeerConnectionFactoryInterface::Options options_to_set =
1345 ParseOptionsFromJava(jni, options); 1316 ParseOptionsFromJava(jni, options);
1346 factory->SetOptions(options_to_set); 1317 factory->SetOptions(options_to_set);
1347 1318
1348 if (options_to_set.disable_network_monitor) { 1319 if (options_to_set.disable_network_monitor) {
1349 OwnedFactoryAndThreads* owner = 1320 OwnedFactoryAndThreads* owner =
1350 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); 1321 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
1351 if (owner->network_monitor_factory()) { 1322 if (owner->network_monitor_factory()) {
1352 rtc::NetworkMonitorFactory::ReleaseFactory( 1323 rtc::NetworkMonitorFactory::ReleaseFactory(
1353 owner->network_monitor_factory()); 1324 owner->network_monitor_factory());
1354 owner->clear_network_monitor_factory(); 1325 owner->clear_network_monitor_factory();
1355 } 1326 }
1356 } 1327 }
1357 } 1328 }
1358 1329
1359 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( 1330 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)(
1360 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context, 1331 JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context,
1361 jobject remote_egl_context) { 1332 jobject remote_egl_context) {
1362 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
1363 OwnedFactoryAndThreads* owned_factory = 1333 OwnedFactoryAndThreads* owned_factory =
1364 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); 1334 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
1365 1335
1366 jclass j_eglbase14_context_class = 1336 jclass j_eglbase14_context_class =
1367 FindClass(jni, "org/webrtc/EglBase14$Context"); 1337 FindClass(jni, "org/webrtc/EglBase14$Context");
1368 1338
1369 MediaCodecVideoEncoderFactory* encoder_factory = 1339 MediaCodecVideoEncoderFactory* encoder_factory =
1370 static_cast<MediaCodecVideoEncoderFactory*> 1340 static_cast<MediaCodecVideoEncoderFactory*>
1371 (owned_factory->encoder_factory()); 1341 (owned_factory->encoder_factory());
1372 if (encoder_factory && 1342 if (encoder_factory &&
1373 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { 1343 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) {
1374 LOG(LS_INFO) << "Set EGL context for HW encoding."; 1344 LOG(LS_INFO) << "Set EGL context for HW encoding.";
1375 encoder_factory->SetEGLContext(jni, local_egl_context); 1345 encoder_factory->SetEGLContext(jni, local_egl_context);
1376 } 1346 }
1377 1347
1378 MediaCodecVideoDecoderFactory* decoder_factory = 1348 MediaCodecVideoDecoderFactory* decoder_factory =
1379 static_cast<MediaCodecVideoDecoderFactory*> 1349 static_cast<MediaCodecVideoDecoderFactory*>
1380 (owned_factory->decoder_factory()); 1350 (owned_factory->decoder_factory());
1381 if (decoder_factory && 1351 if (decoder_factory &&
1382 jni->IsInstanceOf(remote_egl_context, j_eglbase14_context_class)) { 1352 jni->IsInstanceOf(remote_egl_context, j_eglbase14_context_class)) {
1383 LOG(LS_INFO) << "Set EGL context for HW decoding."; 1353 LOG(LS_INFO) << "Set EGL context for HW decoding.";
1384 decoder_factory->SetEGLContext(jni, remote_egl_context); 1354 decoder_factory->SetEGLContext(jni, remote_egl_context);
1385 } 1355 }
1386 #endif
1387 } 1356 }
1388 1357
1389 static PeerConnectionInterface::IceTransportsType 1358 static PeerConnectionInterface::IceTransportsType
1390 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) { 1359 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) {
1391 std::string enum_name = GetJavaEnumName( 1360 std::string enum_name = GetJavaEnumName(
1392 jni, "org/webrtc/PeerConnection$IceTransportsType", 1361 jni, "org/webrtc/PeerConnection$IceTransportsType",
1393 j_ice_transports_type); 1362 j_ice_transports_type);
1394 1363
1395 if (enum_name == "ALL") 1364 if (enum_name == "ALL")
1396 return PeerConnectionInterface::kAll; 1365 return PeerConnectionInterface::kAll;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 ExtractNativePC(jni, j_pc)->Close(); 1855 ExtractNativePC(jni, j_pc)->Close();
1887 return; 1856 return;
1888 } 1857 }
1889 1858
1890 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { 1859 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) {
1891 rtc::scoped_refptr<MediaSourceInterface> p( 1860 rtc::scoped_refptr<MediaSourceInterface> p(
1892 reinterpret_cast<MediaSourceInterface*>(j_p)); 1861 reinterpret_cast<MediaSourceInterface*>(j_p));
1893 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); 1862 return JavaEnumFromIndex(jni, "MediaSource$State", p->state());
1894 } 1863 }
1895 1864
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.
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)(
1959 JNIEnv* jni, jclass, int x, int y) {
1960 scoped_ptr<VideoRendererWrapper> renderer(VideoRendererWrapper::Create(
1961 cricket::VideoRendererFactory::CreateGuiVideoRenderer(x, y)));
1962 return (jlong)renderer.release();
1963 }
1964
1965 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)( 1865 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)(
1966 JNIEnv* jni, jclass, jobject j_callbacks) { 1866 JNIEnv* jni, jclass, jobject j_callbacks) {
1967 scoped_ptr<JavaVideoRendererWrapper> renderer( 1867 scoped_ptr<JavaVideoRendererWrapper> renderer(
1968 new JavaVideoRendererWrapper(jni, j_callbacks)); 1868 new JavaVideoRendererWrapper(jni, j_callbacks));
1969 return (jlong)renderer.release(); 1869 return (jlong)renderer.release();
1970 } 1870 }
1971 1871
1972 JOW(void, VideoRenderer_nativeCopyPlane)( 1872 JOW(void, VideoRenderer_nativeCopyPlane)(
1973 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, 1873 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height,
1974 jint src_stride, jobject j_dst_buffer, jint dst_stride) { 1874 jint src_stride, jobject j_dst_buffer, jint dst_stride) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 return JavaStringFromStdString( 2048 return JavaStringFromStdString(
2149 jni, 2049 jni,
2150 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2050 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2151 } 2051 }
2152 2052
2153 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2053 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2154 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2054 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2155 } 2055 }
2156 2056
2157 } // namespace webrtc_jni 2057 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/classreferenceholder.cc ('k') | talk/app/webrtc/java/src/org/webrtc/VideoCapturer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698