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

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

Issue 1317353005: Adding PeerConnectionInterface::SetConfiguration method. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Deleting some unused code, and adding TODO for pending deletion Created 5 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
« 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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 GetObjectField(jni, j_ice_server, j_ice_server_password_id)); 1357 GetObjectField(jni, j_ice_server, j_ice_server_password_id));
1358 PeerConnectionInterface::IceServer server; 1358 PeerConnectionInterface::IceServer server;
1359 server.uri = JavaToStdString(jni, uri); 1359 server.uri = JavaToStdString(jni, uri);
1360 server.username = JavaToStdString(jni, username); 1360 server.username = JavaToStdString(jni, username);
1361 server.password = JavaToStdString(jni, password); 1361 server.password = JavaToStdString(jni, password);
1362 ice_servers->push_back(server); 1362 ice_servers->push_back(server);
1363 } 1363 }
1364 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; 1364 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
1365 } 1365 }
1366 1366
1367 JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( 1367 static void JavaRTCConfigurationToJsepRTCConfiguration(
1368 JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config, 1368 JNIEnv* jni,
1369 jobject j_constraints, jlong observer_p) { 1369 jobject j_rtc_config,
1370 rtc::scoped_refptr<PeerConnectionFactoryInterface> f( 1370 PeerConnectionInterface::RTCConfiguration* rtc_config) {
1371 reinterpret_cast<PeerConnectionFactoryInterface*>(
1372 factoryFromJava(factory)));
1373
1374 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); 1371 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
1375 1372
1376 jfieldID j_ice_transports_type_id = GetFieldID( 1373 jfieldID j_ice_transports_type_id = GetFieldID(
1377 jni, j_rtc_config_class, "iceTransportsType", 1374 jni, j_rtc_config_class, "iceTransportsType",
1378 "Lorg/webrtc/PeerConnection$IceTransportsType;"); 1375 "Lorg/webrtc/PeerConnection$IceTransportsType;");
1379 jobject j_ice_transports_type = GetObjectField( 1376 jobject j_ice_transports_type = GetObjectField(
1380 jni, j_rtc_config, j_ice_transports_type_id); 1377 jni, j_rtc_config, j_ice_transports_type_id);
1381 1378
1382 jfieldID j_bundle_policy_id = GetFieldID( 1379 jfieldID j_bundle_policy_id = GetFieldID(
1383 jni, j_rtc_config_class, "bundlePolicy", 1380 jni, j_rtc_config_class, "bundlePolicy",
(...skipping 18 matching lines...) Expand all
1402 jobject j_ice_servers = GetObjectField(jni, j_rtc_config, j_ice_servers_id); 1399 jobject j_ice_servers = GetObjectField(jni, j_rtc_config, j_ice_servers_id);
1403 1400
1404 jfieldID j_audio_jitter_buffer_max_packets_id = 1401 jfieldID j_audio_jitter_buffer_max_packets_id =
1405 GetFieldID(jni, j_rtc_config_class, "audioJitterBufferMaxPackets", "I"); 1402 GetFieldID(jni, j_rtc_config_class, "audioJitterBufferMaxPackets", "I");
1406 jfieldID j_audio_jitter_buffer_fast_accelerate_id = GetFieldID( 1403 jfieldID j_audio_jitter_buffer_fast_accelerate_id = GetFieldID(
1407 jni, j_rtc_config_class, "audioJitterBufferFastAccelerate", "Z"); 1404 jni, j_rtc_config_class, "audioJitterBufferFastAccelerate", "Z");
1408 1405
1409 jfieldID j_ice_connection_receiving_timeout_id = 1406 jfieldID j_ice_connection_receiving_timeout_id =
1410 GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I"); 1407 GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I");
1411 1408
1412 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType", 1409 rtc_config->type =
1413 "Lorg/webrtc/PeerConnection$KeyType;"); 1410 JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type);
1414 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id); 1411 rtc_config->bundle_policy =
1412 JavaBundlePolicyToNativeType(jni, j_bundle_policy);
1413 rtc_config->rtcp_mux_policy =
1414 JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy);
1415 rtc_config->tcp_candidate_policy =
1416 JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy);
1417 JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config->servers);
1418 rtc_config->audio_jitter_buffer_max_packets =
1419 GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id);
1420 rtc_config->audio_jitter_buffer_fast_accelerate = GetBooleanField(
1421 jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id);
1422 rtc_config->ice_connection_receiving_timeout =
1423 GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id);
1424 }
1425
1426 JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
1427 JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config,
1428 jobject j_constraints, jlong observer_p) {
1429 rtc::scoped_refptr<PeerConnectionFactoryInterface> f(
1430 reinterpret_cast<PeerConnectionFactoryInterface*>(
1431 factoryFromJava(factory)));
1415 1432
1416 PeerConnectionInterface::RTCConfiguration rtc_config; 1433 PeerConnectionInterface::RTCConfiguration rtc_config;
1417 rtc_config.type = 1434 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
1418 JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type); 1435
1419 rtc_config.bundle_policy = JavaBundlePolicyToNativeType(jni, j_bundle_policy); 1436 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
1420 rtc_config.rtcp_mux_policy = 1437 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType",
1421 JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy); 1438 "Lorg/webrtc/PeerConnection$KeyType;");
1422 rtc_config.tcp_candidate_policy = 1439 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
1423 JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy);
1424 JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config.servers);
1425 rtc_config.audio_jitter_buffer_max_packets =
1426 GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id);
1427 rtc_config.audio_jitter_buffer_fast_accelerate = GetBooleanField(
1428 jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id);
1429 rtc_config.ice_connection_receiving_timeout =
1430 GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id);
1431 1440
1432 // Create ECDSA certificate. 1441 // Create ECDSA certificate.
1433 if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) { 1442 if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) {
1434 scoped_ptr<rtc::SSLIdentity> ssl_identity( 1443 scoped_ptr<rtc::SSLIdentity> ssl_identity(
1435 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); 1444 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA));
1436 if (ssl_identity.get()) { 1445 if (ssl_identity.get()) {
1437 rtc_config.certificates.push_back( 1446 rtc_config.certificates.push_back(
1438 rtc::RTCCertificate::Create(ssl_identity.Pass())); 1447 rtc::RTCCertificate::Create(ssl_identity.Pass()));
1439 LOG(LS_INFO) << "ECDSA certificate created."; 1448 LOG(LS_INFO) << "ECDSA certificate created.";
1440 } else { 1449 } else {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 JOW(void, PeerConnection_setRemoteDescription)( 1562 JOW(void, PeerConnection_setRemoteDescription)(
1554 JNIEnv* jni, jobject j_pc, 1563 JNIEnv* jni, jobject j_pc,
1555 jobject j_observer, jobject j_sdp) { 1564 jobject j_observer, jobject j_sdp) {
1556 rtc::scoped_refptr<SetSdpObserverWrapper> observer( 1565 rtc::scoped_refptr<SetSdpObserverWrapper> observer(
1557 new rtc::RefCountedObject<SetSdpObserverWrapper>( 1566 new rtc::RefCountedObject<SetSdpObserverWrapper>(
1558 jni, j_observer, reinterpret_cast<ConstraintsWrapper*>(NULL))); 1567 jni, j_observer, reinterpret_cast<ConstraintsWrapper*>(NULL)));
1559 ExtractNativePC(jni, j_pc)->SetRemoteDescription( 1568 ExtractNativePC(jni, j_pc)->SetRemoteDescription(
1560 observer, JavaSdpToNativeSdp(jni, j_sdp)); 1569 observer, JavaSdpToNativeSdp(jni, j_sdp));
1561 } 1570 }
1562 1571
1563 JOW(jboolean, PeerConnection_updateIce)( 1572 JOW(jboolean, PeerConnection_setConfiguration)(
1564 JNIEnv* jni, jobject j_pc, jobject j_ice_servers, jobject j_constraints) { 1573 JNIEnv* jni, jobject j_pc, jobject j_rtc_config) {
1565 PeerConnectionInterface::IceServers ice_servers; 1574 PeerConnectionInterface::RTCConfiguration rtc_config;
1566 JavaIceServersToJsepIceServers(jni, j_ice_servers, &ice_servers); 1575 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
1567 scoped_ptr<ConstraintsWrapper> constraints( 1576 return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
1568 new ConstraintsWrapper(jni, j_constraints));
1569 return ExtractNativePC(jni, j_pc)->UpdateIce(ice_servers, constraints.get());
1570 } 1577 }
1571 1578
1572 JOW(jboolean, PeerConnection_nativeAddIceCandidate)( 1579 JOW(jboolean, PeerConnection_nativeAddIceCandidate)(
1573 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid, 1580 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid,
1574 jint j_sdp_mline_index, jstring j_candidate_sdp) { 1581 jint j_sdp_mline_index, jstring j_candidate_sdp) {
1575 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid); 1582 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid);
1576 std::string sdp = JavaToStdString(jni, j_candidate_sdp); 1583 std::string sdp = JavaToStdString(jni, j_candidate_sdp);
1577 scoped_ptr<IceCandidateInterface> candidate( 1584 scoped_ptr<IceCandidateInterface> candidate(
1578 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL)); 1585 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL));
1579 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get()); 1586 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); 1833 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
1827 stream->ReadAll(buffer.get(), log_size, &read, nullptr); 1834 stream->ReadAll(buffer.get(), log_size, &read, nullptr);
1828 1835
1829 jbyteArray result = jni->NewByteArray(read); 1836 jbyteArray result = jni->NewByteArray(read);
1830 jni->SetByteArrayRegion(result, 0, read, buffer.get()); 1837 jni->SetByteArrayRegion(result, 0, read, buffer.get());
1831 1838
1832 return result; 1839 return result;
1833 } 1840 }
1834 1841
1835 } // namespace webrtc_jni 1842 } // 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