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

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

Issue 1361273002: Reland of Adding PeerConnectionInterface::SetConfiguration method. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing patch conflict. Created 5 years, 2 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
« no previous file with comments | « no previous file | talk/app/webrtc/java/src/org/webrtc/PeerConnection.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 GetObjectField(jni, j_ice_server, j_ice_server_password_id)); 1376 GetObjectField(jni, j_ice_server, j_ice_server_password_id));
1377 PeerConnectionInterface::IceServer server; 1377 PeerConnectionInterface::IceServer server;
1378 server.uri = JavaToStdString(jni, uri); 1378 server.uri = JavaToStdString(jni, uri);
1379 server.username = JavaToStdString(jni, username); 1379 server.username = JavaToStdString(jni, username);
1380 server.password = JavaToStdString(jni, password); 1380 server.password = JavaToStdString(jni, password);
1381 ice_servers->push_back(server); 1381 ice_servers->push_back(server);
1382 } 1382 }
1383 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; 1383 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
1384 } 1384 }
1385 1385
1386 JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( 1386 static void JavaRTCConfigurationToJsepRTCConfiguration(
1387 JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config, 1387 JNIEnv* jni,
1388 jobject j_constraints, jlong observer_p) { 1388 jobject j_rtc_config,
1389 rtc::scoped_refptr<PeerConnectionFactoryInterface> f( 1389 PeerConnectionInterface::RTCConfiguration* rtc_config) {
1390 reinterpret_cast<PeerConnectionFactoryInterface*>(
1391 factoryFromJava(factory)));
1392
1393 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); 1390 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
1394 1391
1395 jfieldID j_ice_transports_type_id = GetFieldID( 1392 jfieldID j_ice_transports_type_id = GetFieldID(
1396 jni, j_rtc_config_class, "iceTransportsType", 1393 jni, j_rtc_config_class, "iceTransportsType",
1397 "Lorg/webrtc/PeerConnection$IceTransportsType;"); 1394 "Lorg/webrtc/PeerConnection$IceTransportsType;");
1398 jobject j_ice_transports_type = GetObjectField( 1395 jobject j_ice_transports_type = GetObjectField(
1399 jni, j_rtc_config, j_ice_transports_type_id); 1396 jni, j_rtc_config, j_ice_transports_type_id);
1400 1397
1401 jfieldID j_bundle_policy_id = GetFieldID( 1398 jfieldID j_bundle_policy_id = GetFieldID(
1402 jni, j_rtc_config_class, "bundlePolicy", 1399 jni, j_rtc_config_class, "bundlePolicy",
(...skipping 18 matching lines...) Expand all
1421 jobject j_ice_servers = GetObjectField(jni, j_rtc_config, j_ice_servers_id); 1418 jobject j_ice_servers = GetObjectField(jni, j_rtc_config, j_ice_servers_id);
1422 1419
1423 jfieldID j_audio_jitter_buffer_max_packets_id = 1420 jfieldID j_audio_jitter_buffer_max_packets_id =
1424 GetFieldID(jni, j_rtc_config_class, "audioJitterBufferMaxPackets", "I"); 1421 GetFieldID(jni, j_rtc_config_class, "audioJitterBufferMaxPackets", "I");
1425 jfieldID j_audio_jitter_buffer_fast_accelerate_id = GetFieldID( 1422 jfieldID j_audio_jitter_buffer_fast_accelerate_id = GetFieldID(
1426 jni, j_rtc_config_class, "audioJitterBufferFastAccelerate", "Z"); 1423 jni, j_rtc_config_class, "audioJitterBufferFastAccelerate", "Z");
1427 1424
1428 jfieldID j_ice_connection_receiving_timeout_id = 1425 jfieldID j_ice_connection_receiving_timeout_id =
1429 GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I"); 1426 GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I");
1430 1427
1431 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType",
1432 "Lorg/webrtc/PeerConnection$KeyType;");
1433 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
1434
1435 jfieldID j_continual_gathering_policy_id = 1428 jfieldID j_continual_gathering_policy_id =
1436 GetFieldID(jni, j_rtc_config_class, "continualGatheringPolicy", 1429 GetFieldID(jni, j_rtc_config_class, "continualGatheringPolicy",
1437 "Lorg/webrtc/PeerConnection$ContinualGatheringPolicy;"); 1430 "Lorg/webrtc/PeerConnection$ContinualGatheringPolicy;");
1438 jobject j_continual_gathering_policy = 1431 jobject j_continual_gathering_policy =
1439 GetObjectField(jni, j_rtc_config, j_continual_gathering_policy_id); 1432 GetObjectField(jni, j_rtc_config, j_continual_gathering_policy_id);
1440 1433
1441 PeerConnectionInterface::RTCConfiguration rtc_config; 1434 rtc_config->type =
1442 rtc_config.type =
1443 JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type); 1435 JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type);
1444 rtc_config.bundle_policy = JavaBundlePolicyToNativeType(jni, j_bundle_policy); 1436 rtc_config->bundle_policy =
1445 rtc_config.rtcp_mux_policy = 1437 JavaBundlePolicyToNativeType(jni, j_bundle_policy);
1438 rtc_config->rtcp_mux_policy =
1446 JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy); 1439 JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy);
1447 rtc_config.tcp_candidate_policy = 1440 rtc_config->tcp_candidate_policy =
1448 JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy); 1441 JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy);
1449 JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config.servers); 1442 JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config->servers);
1450 rtc_config.audio_jitter_buffer_max_packets = 1443 rtc_config->audio_jitter_buffer_max_packets =
1451 GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id); 1444 GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id);
1452 rtc_config.audio_jitter_buffer_fast_accelerate = GetBooleanField( 1445 rtc_config->audio_jitter_buffer_fast_accelerate = GetBooleanField(
1453 jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id); 1446 jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id);
1454 rtc_config.ice_connection_receiving_timeout = 1447 rtc_config->ice_connection_receiving_timeout =
1455 GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id); 1448 GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id);
1456 rtc_config.continual_gathering_policy = 1449 rtc_config->continual_gathering_policy =
1457 JavaContinualGatheringPolicyToNativeType( 1450 JavaContinualGatheringPolicyToNativeType(
1458 jni, j_continual_gathering_policy); 1451 jni, j_continual_gathering_policy);
1452 }
1453
1454 JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
1455 JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config,
1456 jobject j_constraints, jlong observer_p) {
1457 rtc::scoped_refptr<PeerConnectionFactoryInterface> f(
1458 reinterpret_cast<PeerConnectionFactoryInterface*>(
1459 factoryFromJava(factory)));
1460
1461 PeerConnectionInterface::RTCConfiguration rtc_config;
1462 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
1463
1464 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
1465 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType",
1466 "Lorg/webrtc/PeerConnection$KeyType;");
1467 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
1459 1468
1460 // Create ECDSA certificate. 1469 // Create ECDSA certificate.
1461 if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) { 1470 if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) {
1462 scoped_ptr<rtc::SSLIdentity> ssl_identity( 1471 scoped_ptr<rtc::SSLIdentity> ssl_identity(
1463 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); 1472 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA));
1464 if (ssl_identity.get()) { 1473 if (ssl_identity.get()) {
1465 rtc_config.certificates.push_back( 1474 rtc_config.certificates.push_back(
1466 rtc::RTCCertificate::Create(ssl_identity.Pass())); 1475 rtc::RTCCertificate::Create(ssl_identity.Pass()));
1467 LOG(LS_INFO) << "ECDSA certificate created."; 1476 LOG(LS_INFO) << "ECDSA certificate created.";
1468 } else { 1477 } else {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 JOW(void, PeerConnection_setRemoteDescription)( 1590 JOW(void, PeerConnection_setRemoteDescription)(
1582 JNIEnv* jni, jobject j_pc, 1591 JNIEnv* jni, jobject j_pc,
1583 jobject j_observer, jobject j_sdp) { 1592 jobject j_observer, jobject j_sdp) {
1584 rtc::scoped_refptr<SetSdpObserverWrapper> observer( 1593 rtc::scoped_refptr<SetSdpObserverWrapper> observer(
1585 new rtc::RefCountedObject<SetSdpObserverWrapper>( 1594 new rtc::RefCountedObject<SetSdpObserverWrapper>(
1586 jni, j_observer, reinterpret_cast<ConstraintsWrapper*>(NULL))); 1595 jni, j_observer, reinterpret_cast<ConstraintsWrapper*>(NULL)));
1587 ExtractNativePC(jni, j_pc)->SetRemoteDescription( 1596 ExtractNativePC(jni, j_pc)->SetRemoteDescription(
1588 observer, JavaSdpToNativeSdp(jni, j_sdp)); 1597 observer, JavaSdpToNativeSdp(jni, j_sdp));
1589 } 1598 }
1590 1599
1591 JOW(jboolean, PeerConnection_updateIce)( 1600 JOW(jboolean, PeerConnection_setConfiguration)(
1592 JNIEnv* jni, jobject j_pc, jobject j_ice_servers, jobject j_constraints) { 1601 JNIEnv* jni, jobject j_pc, jobject j_rtc_config) {
1593 PeerConnectionInterface::IceServers ice_servers; 1602 PeerConnectionInterface::RTCConfiguration rtc_config;
1594 JavaIceServersToJsepIceServers(jni, j_ice_servers, &ice_servers); 1603 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
1595 scoped_ptr<ConstraintsWrapper> constraints( 1604 return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
1596 new ConstraintsWrapper(jni, j_constraints));
1597 return ExtractNativePC(jni, j_pc)->UpdateIce(ice_servers, constraints.get());
1598 } 1605 }
1599 1606
1600 JOW(jboolean, PeerConnection_nativeAddIceCandidate)( 1607 JOW(jboolean, PeerConnection_nativeAddIceCandidate)(
1601 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid, 1608 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid,
1602 jint j_sdp_mline_index, jstring j_candidate_sdp) { 1609 jint j_sdp_mline_index, jstring j_candidate_sdp) {
1603 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid); 1610 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid);
1604 std::string sdp = JavaToStdString(jni, j_candidate_sdp); 1611 std::string sdp = JavaToStdString(jni, j_candidate_sdp);
1605 scoped_ptr<IceCandidateInterface> candidate( 1612 scoped_ptr<IceCandidateInterface> candidate(
1606 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL)); 1613 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL));
1607 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get()); 1614 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); 1861 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
1855 stream->ReadAll(buffer.get(), log_size, &read, nullptr); 1862 stream->ReadAll(buffer.get(), log_size, &read, nullptr);
1856 1863
1857 jbyteArray result = jni->NewByteArray(read); 1864 jbyteArray result = jni->NewByteArray(read);
1858 jni->SetByteArrayRegion(result, 0, read, buffer.get()); 1865 jni->SetByteArrayRegion(result, 0, read, buffer.get());
1859 1866
1860 return result; 1867 return result;
1861 } 1868 }
1862 1869
1863 } // namespace webrtc_jni 1870 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/java/src/org/webrtc/PeerConnection.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698