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

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

Issue 1353713002: Remove GICE (again). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Undo .gclient 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
24 TransportDescriptionFactory::TransportDescriptionFactory() 22 TransportDescriptionFactory::TransportDescriptionFactory()
25 : protocol_(kDefaultProtocol), 23 : secure_(SEC_DISABLED) {
26 secure_(SEC_DISABLED) {
27 } 24 }
28 25
29 TransportDescription* TransportDescriptionFactory::CreateOffer( 26 TransportDescription* TransportDescriptionFactory::CreateOffer(
30 const TransportOptions& options, 27 const TransportOptions& options,
31 const TransportDescription* current_description) const { 28 const TransportDescription* current_description) const {
32 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); 29 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
33 30
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
44 // Generate the ICE credentials if we don't already have them. 31 // Generate the ICE credentials if we don't already have them.
45 if (!current_description || options.ice_restart) { 32 if (!current_description || options.ice_restart) {
46 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); 33 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
47 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); 34 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH);
48 } else { 35 } else {
49 desc->ice_ufrag = current_description->ice_ufrag; 36 desc->ice_ufrag = current_description->ice_ufrag;
50 desc->ice_pwd = current_description->ice_pwd; 37 desc->ice_pwd = current_description->ice_pwd;
51 } 38 }
52 39
53 // If we are trying to establish a secure transport, add a fingerprint. 40 // If we are trying to establish a secure transport, add a fingerprint.
54 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { 41 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) {
55 // Fail if we can't create the fingerprint. 42 // Fail if we can't create the fingerprint.
56 // If we are the initiator set role to "actpass". 43 // If we are the initiator set role to "actpass".
57 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) { 44 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) {
58 return NULL; 45 return NULL;
59 } 46 }
60 } 47 }
61 48
62 return desc.release(); 49 return desc.release();
63 } 50 }
64 51
65 TransportDescription* TransportDescriptionFactory::CreateAnswer( 52 TransportDescription* TransportDescriptionFactory::CreateAnswer(
66 const TransportDescription* offer, 53 const TransportDescription* offer,
67 const TransportOptions& options, 54 const TransportOptions& options,
68 const TransportDescription* current_description) const { 55 const TransportDescription* current_description) const {
69 // A NULL offer is treated as a GICE transport description.
70 // TODO(juberti): Figure out why we get NULL offers, and fix this upstream. 56 // TODO(juberti): Figure out why we get NULL offers, and fix this upstream.
71 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); 57 if (!offer) {
72 58 LOG(LS_WARNING) << "Failed to create TransportDescription answer " <<
73 // Figure out which ICE variant to negotiate; prefer RFC 5245 ICE, but fall 59 "because offer is NULL";
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";
93 return NULL; 60 return NULL;
94 } 61 }
95 62
63 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
96 // Generate the ICE credentials if we don't already have them or ice is 64 // Generate the ICE credentials if we don't already have them or ice is
97 // being restarted. 65 // being restarted.
98 if (!current_description || options.ice_restart) { 66 if (!current_description || options.ice_restart) {
99 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); 67 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
100 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); 68 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH);
101 } else { 69 } else {
102 desc->ice_ufrag = current_description->ice_ufrag; 70 desc->ice_ufrag = current_description->ice_ufrag;
103 desc->ice_pwd = current_description->ice_pwd; 71 desc->ice_pwd = current_description->ice_pwd;
104 } 72 }
105 73
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 << digest_alg; 118 << digest_alg;
151 return false; 119 return false;
152 } 120 }
153 121
154 // Assign security role. 122 // Assign security role.
155 desc->connection_role = role; 123 desc->connection_role = role;
156 return true; 124 return true;
157 } 125 }
158 126
159 } // namespace cricket 127 } // 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