OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 15 matching lines...) Expand all Loading... | |
26 */ | 26 */ |
27 | 27 |
28 #import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h" | 28 #import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h" |
29 | 29 |
30 #import "talk/app/webrtc/objc/RTCEnumConverter.h" | 30 #import "talk/app/webrtc/objc/RTCEnumConverter.h" |
31 #import "talk/app/webrtc/objc/RTCICEServer+Internal.h" | 31 #import "talk/app/webrtc/objc/RTCICEServer+Internal.h" |
32 #import "talk/app/webrtc/objc/public/RTCLogging.h" | 32 #import "talk/app/webrtc/objc/public/RTCLogging.h" |
33 | 33 |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 #include "webrtc/base/rtccertificategenerator.h" | |
37 | |
36 @implementation RTCConfiguration | 38 @implementation RTCConfiguration |
37 | 39 |
38 @synthesize iceTransportsType = _iceTransportsType; | 40 @synthesize iceTransportsType = _iceTransportsType; |
39 @synthesize iceServers = _iceServers; | 41 @synthesize iceServers = _iceServers; |
40 @synthesize bundlePolicy = _bundlePolicy; | 42 @synthesize bundlePolicy = _bundlePolicy; |
41 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; | 43 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
42 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; | 44 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
43 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; | 45 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
44 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; | 46 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
45 @synthesize iceBackupCandidatePairPingInterval = _iceBackupCandidatePairPingInte rval; | 47 @synthesize iceBackupCandidatePairPingInterval = _iceBackupCandidatePairPingInte rval; |
(...skipping 30 matching lines...) Expand all Loading... | |
76 _tcpCandidatePolicy = tcpCandidatePolicy; | 78 _tcpCandidatePolicy = tcpCandidatePolicy; |
77 _audioJitterBufferMaxPackets = audioJitterBufferMaxPackets; | 79 _audioJitterBufferMaxPackets = audioJitterBufferMaxPackets; |
78 _iceConnectionReceivingTimeout = iceConnectionReceivingTimeout; | 80 _iceConnectionReceivingTimeout = iceConnectionReceivingTimeout; |
79 _iceBackupCandidatePairPingInterval = iceBackupCandidatePairPingInterval; | 81 _iceBackupCandidatePairPingInterval = iceBackupCandidatePairPingInterval; |
80 } | 82 } |
81 return self; | 83 return self; |
82 } | 84 } |
83 | 85 |
84 #pragma mark - Private | 86 #pragma mark - Private |
85 | 87 |
86 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { | 88 - (webrtc::PeerConnectionInterface::RTCConfiguration *) |
87 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; | 89 createNativeConfiguration { |
88 nativeConfig.type = [RTCEnumConverter nativeEnumForIceTransportsType:_iceTrans portsType]; | 90 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
91 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration()); | |
92 nativeConfig->type = [RTCEnumConverter nativeEnumForIceTransportsType:_iceTran sportsType]; | |
89 for (RTCICEServer *iceServer : _iceServers) { | 93 for (RTCICEServer *iceServer : _iceServers) { |
90 nativeConfig.servers.push_back(iceServer.iceServer); | 94 nativeConfig->servers.push_back(iceServer.iceServer); |
91 } | 95 } |
92 nativeConfig.bundle_policy = [RTCEnumConverter nativeEnumForBundlePolicy:_bund lePolicy]; | 96 nativeConfig->bundle_policy = [RTCEnumConverter nativeEnumForBundlePolicy:_bun dlePolicy]; |
93 nativeConfig.rtcp_mux_policy = [RTCEnumConverter nativeEnumForRtcpMuxPolicy:_r tcpMuxPolicy]; | 97 nativeConfig->rtcp_mux_policy = [RTCEnumConverter nativeEnumForRtcpMuxPolicy:_ rtcpMuxPolicy]; |
94 nativeConfig.tcp_candidate_policy = | 98 nativeConfig->tcp_candidate_policy = |
95 [RTCEnumConverter nativeEnumForTcpCandidatePolicy:_tcpCandidatePolicy]; | 99 [RTCEnumConverter nativeEnumForTcpCandidatePolicy:_tcpCandidatePolicy]; |
96 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; | 100 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
97 nativeConfig.ice_connection_receiving_timeout = _iceConnectionReceivingTimeout ; | 101 nativeConfig->ice_connection_receiving_timeout = _iceConnectionReceivingTimeou t; |
98 nativeConfig.ice_backup_candidate_pair_ping_interval = _iceBackupCandidatePair PingInterval; | 102 nativeConfig->ice_backup_candidate_pair_ping_interval = _iceBackupCandidatePai rPingInterval; |
99 if (_keyType == kRTCEncryptionKeyTypeECDSA) { | 103 rtc::KeyType keyType = |
100 std::unique_ptr<rtc::SSLIdentity> identity( | 104 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; |
101 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); | 105 if (keyType != rtc::KT_DEFAULT) { |
102 if (identity) { | 106 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
103 nativeConfig.certificates.push_back( | 107 rtc::RTCCertificateGenerator::GenerateCertificate( |
104 rtc::RTCCertificate::Create(std::move(identity))); | 108 rtc::KeyParams(keyType), rtc::Optional<uint64_t>()); |
105 } else { | 109 if (!certificate) { |
106 RTCLogWarning(@"Failed to generate ECDSA identity. RSA will be used."); | 110 RTCLogError(@"Failed to generate certificate."); |
111 return nil; | |
tkchin_webrtc
2016/06/03 23:36:40
nil isn't appropriate since the type is a C++ obje
hbos
2016/06/05 11:08:53
Done.
| |
107 } | 112 } |
113 nativeConfig->certificates.push_back(certificate); | |
108 } | 114 } |
109 return nativeConfig; | 115 return nativeConfig.release(); |
116 } | |
117 | |
118 + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: | |
119 (RTCEncryptionKeyType)keyType { | |
120 switch (keyType) { | |
121 case kRTCEncryptionKeyTypeRSA: | |
122 return rtc::KT_RSA; | |
123 case kRTCEncryptionKeyTypeECDSA: | |
124 return rtc::KT_ECDSA; | |
125 } | |
110 } | 126 } |
111 | 127 |
112 @end | 128 @end |
OLD | NEW |