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

Side by Side Diff: webrtc/p2p/base/transportdescriptionfactory.cc

Issue 1336553003: Revert change which removes GICE (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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
11 #include "webrtc/p2p/base/transportdescriptionfactory.h" 11 #include "webrtc/p2p/base/transportdescriptionfactory.h"
12 12
13 #include "webrtc/p2p/base/transportdescription.h" 13 #include "webrtc/p2p/base/transportdescription.h"
14 #include "webrtc/base/helpers.h" 14 #include "webrtc/base/helpers.h"
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/base/messagedigest.h" 16 #include "webrtc/base/messagedigest.h"
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/base/sslfingerprint.h" 18 #include "webrtc/base/sslfingerprint.h"
19 19
20 namespace cricket { 20 namespace cricket {
21 21
22 static TransportProtocol kDefaultProtocol = ICEPROTO_RFC5245;
23
22 TransportDescriptionFactory::TransportDescriptionFactory() 24 TransportDescriptionFactory::TransportDescriptionFactory()
23 : secure_(SEC_DISABLED) { 25 : protocol_(kDefaultProtocol),
26 secure_(SEC_DISABLED) {
24 } 27 }
25 28
26 TransportDescription* TransportDescriptionFactory::CreateOffer( 29 TransportDescription* TransportDescriptionFactory::CreateOffer(
27 const TransportOptions& options, 30 const TransportOptions& options,
28 const TransportDescription* current_description) const { 31 const TransportDescription* current_description) const {
29 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); 32 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
30 33
34 // Set the transport type depending on the selected protocol.
35 if (protocol_ == ICEPROTO_RFC5245) {
36 desc->transport_type = NS_JINGLE_ICE_UDP;
37 } else if (protocol_ == ICEPROTO_HYBRID) {
38 desc->transport_type = NS_JINGLE_ICE_UDP;
39 desc->AddOption(ICE_OPTION_GICE);
40 } else if (protocol_ == ICEPROTO_GOOGLE) {
41 desc->transport_type = NS_GINGLE_P2P;
42 }
43
31 // Generate the ICE credentials if we don't already have them. 44 // Generate the ICE credentials if we don't already have them.
32 if (!current_description || options.ice_restart) { 45 if (!current_description || options.ice_restart) {
33 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); 46 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
34 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); 47 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH);
35 } else { 48 } else {
36 desc->ice_ufrag = current_description->ice_ufrag; 49 desc->ice_ufrag = current_description->ice_ufrag;
37 desc->ice_pwd = current_description->ice_pwd; 50 desc->ice_pwd = current_description->ice_pwd;
38 } 51 }
39 52
40 // If we are trying to establish a secure transport, add a fingerprint. 53 // If we are trying to establish a secure transport, add a fingerprint.
41 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { 54 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) {
42 // Fail if we can't create the fingerprint. 55 // Fail if we can't create the fingerprint.
43 // If we are the initiator set role to "actpass". 56 // If we are the initiator set role to "actpass".
44 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) { 57 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) {
45 return NULL; 58 return NULL;
46 } 59 }
47 } 60 }
48 61
49 return desc.release(); 62 return desc.release();
50 } 63 }
51 64
52 TransportDescription* TransportDescriptionFactory::CreateAnswer( 65 TransportDescription* TransportDescriptionFactory::CreateAnswer(
53 const TransportDescription* offer, 66 const TransportDescription* offer,
54 const TransportOptions& options, 67 const TransportOptions& options,
55 const TransportDescription* current_description) const { 68 const TransportDescription* current_description) const {
69 // A NULL offer is treated as a GICE transport description.
56 // TODO(juberti): Figure out why we get NULL offers, and fix this upstream. 70 // TODO(juberti): Figure out why we get NULL offers, and fix this upstream.
57 if (!offer) { 71 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
58 LOG(LS_WARNING) << "Failed to create TransportDescription answer " << 72
59 "because offer is NULL"; 73 // Figure out which ICE variant to negotiate; prefer RFC 5245 ICE, but fall
74 // back to G-ICE if needed. Note that we never create a hybrid answer, since
75 // we know what the other side can support already.
76 if (offer && offer->transport_type == NS_JINGLE_ICE_UDP &&
77 (protocol_ == ICEPROTO_RFC5245 || protocol_ == ICEPROTO_HYBRID)) {
78 // Offer is ICE or hybrid, we support ICE or hybrid: use ICE.
79 desc->transport_type = NS_JINGLE_ICE_UDP;
80 } else if (offer && offer->transport_type == NS_JINGLE_ICE_UDP &&
81 offer->HasOption(ICE_OPTION_GICE) &&
82 protocol_ == ICEPROTO_GOOGLE) {
83 desc->transport_type = NS_GINGLE_P2P;
84 // Offer is hybrid, we support GICE: use GICE.
85 } else if ((!offer || offer->transport_type == NS_GINGLE_P2P) &&
86 (protocol_ == ICEPROTO_HYBRID || protocol_ == ICEPROTO_GOOGLE)) {
87 // Offer is GICE, we support hybrid or GICE: use GICE.
88 desc->transport_type = NS_GINGLE_P2P;
89 } else {
90 // Mismatch.
91 LOG(LS_WARNING) << "Failed to create TransportDescription answer "
92 "because of incompatible transport types";
60 return NULL; 93 return NULL;
61 } 94 }
62 95
63 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
64 // Generate the ICE credentials if we don't already have them or ice is 96 // Generate the ICE credentials if we don't already have them or ice is
65 // being restarted. 97 // being restarted.
66 if (!current_description || options.ice_restart) { 98 if (!current_description || options.ice_restart) {
67 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); 99 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
68 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); 100 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH);
69 } else { 101 } else {
70 desc->ice_ufrag = current_description->ice_ufrag; 102 desc->ice_ufrag = current_description->ice_ufrag;
71 desc->ice_pwd = current_description->ice_pwd; 103 desc->ice_pwd = current_description->ice_pwd;
72 } 104 }
73 105
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 << digest_alg; 150 << digest_alg;
119 return false; 151 return false;
120 } 152 }
121 153
122 // Assign security role. 154 // Assign security role.
123 desc->connection_role = role; 155 desc->connection_role = role;
124 return true; 156 return true;
125 } 157 }
126 158
127 } // namespace cricket 159 } // namespace cricket
160
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportdescriptionfactory.h ('k') | webrtc/p2p/base/transportdescriptionfactory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698