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

Side by Side Diff: webrtc/sdk/android/src/jni/pc/java_native_conversion.cc

Issue 2993403002: Support a user-provided string for the TLS ALPN extension.
Patch Set: Fix previous commit Created 3 years, 3 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 * 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (enum_name == "TLS_CERT_POLICY_SECURE") 336 if (enum_name == "TLS_CERT_POLICY_SECURE")
337 return webrtc::PeerConnectionInterface::kTlsCertPolicySecure; 337 return webrtc::PeerConnectionInterface::kTlsCertPolicySecure;
338 338
339 if (enum_name == "TLS_CERT_POLICY_INSECURE_NO_CHECK") 339 if (enum_name == "TLS_CERT_POLICY_INSECURE_NO_CHECK")
340 return webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck; 340 return webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck;
341 341
342 RTC_CHECK(false) << "Unexpected TlsCertPolicy enum_name " << enum_name; 342 RTC_CHECK(false) << "Unexpected TlsCertPolicy enum_name " << enum_name;
343 return webrtc::PeerConnectionInterface::kTlsCertPolicySecure; 343 return webrtc::PeerConnectionInterface::kTlsCertPolicySecure;
344 } 344 }
345 345
346 std::vector<std::string> JavaToStdVectorStrings(JNIEnv* jni, jobject list) {
347 std::vector<std::string> converted_list;
348 if (list != nullptr) {
349 for (jobject str : Iterable(jni, list)) {
350 converted_list.push_back(
351 JavaToStdString(jni, reinterpret_cast<jstring>(str)));
352 }
353 }
354 return converted_list;
355 }
356
346 void JavaToNativeIceServers( 357 void JavaToNativeIceServers(
347 JNIEnv* jni, 358 JNIEnv* jni,
348 jobject j_ice_servers, 359 jobject j_ice_servers,
349 webrtc::PeerConnectionInterface::IceServers* ice_servers) { 360 webrtc::PeerConnectionInterface::IceServers* ice_servers) {
350 for (jobject j_ice_server : Iterable(jni, j_ice_servers)) { 361 for (jobject j_ice_server : Iterable(jni, j_ice_servers)) {
351 jclass j_ice_server_class = GetObjectClass(jni, j_ice_server); 362 jclass j_ice_server_class = GetObjectClass(jni, j_ice_server);
352 jfieldID j_ice_server_uri_id = 363 jfieldID j_ice_server_uri_id =
353 GetFieldID(jni, j_ice_server_class, "uri", "Ljava/lang/String;"); 364 GetFieldID(jni, j_ice_server_class, "uri", "Ljava/lang/String;");
354 jfieldID j_ice_server_username_id = 365 jfieldID j_ice_server_username_id =
355 GetFieldID(jni, j_ice_server_class, "username", "Ljava/lang/String;"); 366 GetFieldID(jni, j_ice_server_class, "username", "Ljava/lang/String;");
356 jfieldID j_ice_server_password_id = 367 jfieldID j_ice_server_password_id =
357 GetFieldID(jni, j_ice_server_class, "password", "Ljava/lang/String;"); 368 GetFieldID(jni, j_ice_server_class, "password", "Ljava/lang/String;");
358 jfieldID j_ice_server_tls_cert_policy_id = 369 jfieldID j_ice_server_tls_cert_policy_id =
359 GetFieldID(jni, j_ice_server_class, "tlsCertPolicy", 370 GetFieldID(jni, j_ice_server_class, "tlsCertPolicy",
360 "Lorg/webrtc/PeerConnection$TlsCertPolicy;"); 371 "Lorg/webrtc/PeerConnection$TlsCertPolicy;");
361 jobject j_ice_server_tls_cert_policy = 372 jobject j_ice_server_tls_cert_policy =
362 GetObjectField(jni, j_ice_server, j_ice_server_tls_cert_policy_id); 373 GetObjectField(jni, j_ice_server, j_ice_server_tls_cert_policy_id);
363 jfieldID j_ice_server_hostname_id = 374 jfieldID j_ice_server_hostname_id =
364 GetFieldID(jni, j_ice_server_class, "hostname", "Ljava/lang/String;"); 375 GetFieldID(jni, j_ice_server_class, "hostname", "Ljava/lang/String;");
376 jfieldID j_ice_server_tls_alpn_protocols_id = GetFieldID(
377 jni, j_ice_server_class, "tlsAlpnProtocols", "Ljava/util/List;");
365 jstring uri = reinterpret_cast<jstring>( 378 jstring uri = reinterpret_cast<jstring>(
366 GetObjectField(jni, j_ice_server, j_ice_server_uri_id)); 379 GetObjectField(jni, j_ice_server, j_ice_server_uri_id));
367 jstring username = reinterpret_cast<jstring>( 380 jstring username = reinterpret_cast<jstring>(
368 GetObjectField(jni, j_ice_server, j_ice_server_username_id)); 381 GetObjectField(jni, j_ice_server, j_ice_server_username_id));
369 jstring password = reinterpret_cast<jstring>( 382 jstring password = reinterpret_cast<jstring>(
370 GetObjectField(jni, j_ice_server, j_ice_server_password_id)); 383 GetObjectField(jni, j_ice_server, j_ice_server_password_id));
371 webrtc::PeerConnectionInterface::TlsCertPolicy tls_cert_policy = 384 webrtc::PeerConnectionInterface::TlsCertPolicy tls_cert_policy =
372 JavaToNativeTlsCertPolicy(jni, j_ice_server_tls_cert_policy); 385 JavaToNativeTlsCertPolicy(jni, j_ice_server_tls_cert_policy);
373 jstring hostname = reinterpret_cast<jstring>( 386 jstring hostname = reinterpret_cast<jstring>(
374 GetObjectField(jni, j_ice_server, j_ice_server_hostname_id)); 387 GetObjectField(jni, j_ice_server, j_ice_server_hostname_id));
388 jobject tls_alpn_protocols = GetNullableObjectField(
389 jni, j_ice_server, j_ice_server_tls_alpn_protocols_id);
375 webrtc::PeerConnectionInterface::IceServer server; 390 webrtc::PeerConnectionInterface::IceServer server;
376 server.uri = JavaToStdString(jni, uri); 391 server.uri = JavaToStdString(jni, uri);
377 server.username = JavaToStdString(jni, username); 392 server.username = JavaToStdString(jni, username);
378 server.password = JavaToStdString(jni, password); 393 server.password = JavaToStdString(jni, password);
379 server.tls_cert_policy = tls_cert_policy; 394 server.tls_cert_policy = tls_cert_policy;
380 server.hostname = JavaToStdString(jni, hostname); 395 server.hostname = JavaToStdString(jni, hostname);
396 server.tls_alpn_protocols = JavaToStdVectorStrings(jni, tls_alpn_protocols);
381 ice_servers->push_back(server); 397 ice_servers->push_back(server);
382 } 398 }
383 } 399 }
384 400
385 void JavaToNativeRTCConfiguration( 401 void JavaToNativeRTCConfiguration(
386 JNIEnv* jni, 402 JNIEnv* jni,
387 jobject j_rtc_config, 403 jobject j_rtc_config,
388 webrtc::PeerConnectionInterface::RTCConfiguration* rtc_config) { 404 webrtc::PeerConnectionInterface::RTCConfiguration* rtc_config) {
389 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); 405 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
390 406
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 707 }
692 jboolean added = jni->CallBooleanMethod(j_codecs, codecs_add, j_codec); 708 jboolean added = jni->CallBooleanMethod(j_codecs, codecs_add, j_codec);
693 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; 709 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
694 RTC_CHECK(added); 710 RTC_CHECK(added);
695 } 711 }
696 712
697 return j_parameters; 713 return j_parameters;
698 } 714 }
699 715
700 } // namespace webrtc_jni 716 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698