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

Side by Side Diff: talk/app/webrtc/webrtcsessiondescriptionfactory.cc

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merging again 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 * 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED); 158 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED);
159 } 159 }
160 160
161 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 161 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
162 rtc::Thread* signaling_thread, 162 rtc::Thread* signaling_thread,
163 cricket::ChannelManager* channel_manager, 163 cricket::ChannelManager* channel_manager,
164 MediaStreamSignaling* mediastream_signaling, 164 MediaStreamSignaling* mediastream_signaling,
165 WebRtcSession* session, 165 WebRtcSession* session,
166 const std::string& session_id, 166 const std::string& session_id,
167 cricket::DataChannelType dct) 167 cricket::DataChannelType dct)
168 : WebRtcSessionDescriptionFactory( 168 : WebRtcSessionDescriptionFactory(signaling_thread,
169 signaling_thread, channel_manager, mediastream_signaling, nullptr, 169 channel_manager,
170 nullptr, session, session_id, dct, false) { 170 mediastream_signaling,
171 nullptr,
172 nullptr,
173 session,
174 session_id,
175 dct,
176 false) {
171 LOG(LS_VERBOSE) << "DTLS-SRTP disabled."; 177 LOG(LS_VERBOSE) << "DTLS-SRTP disabled.";
172 } 178 }
173 179
174 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 180 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
175 rtc::Thread* signaling_thread, 181 rtc::Thread* signaling_thread,
176 cricket::ChannelManager* channel_manager, 182 cricket::ChannelManager* channel_manager,
177 MediaStreamSignaling* mediastream_signaling, 183 MediaStreamSignaling* mediastream_signaling,
178 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 184 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
179 WebRtcSession* session, 185 WebRtcSession* session,
180 const std::string& session_id, 186 const std::string& session_id,
181 cricket::DataChannelType dct) 187 cricket::DataChannelType dct)
182 : WebRtcSessionDescriptionFactory( 188 : WebRtcSessionDescriptionFactory(
183 signaling_thread, 189 signaling_thread,
184 channel_manager, 190 channel_manager,
185 mediastream_signaling, 191 mediastream_signaling,
186 dtls_identity_store.Pass(), 192 dtls_identity_store.Pass(),
187 new rtc::RefCountedObject<WebRtcIdentityRequestObserver>(), 193 new rtc::RefCountedObject<WebRtcIdentityRequestObserver>(),
188 session, 194 session,
189 session_id, 195 session_id,
190 dct, 196 dct,
191 true) { 197 true) {
192 DCHECK(dtls_identity_store_); 198 DCHECK(dtls_identity_store_);
193 199
194 certificate_request_state_ = CERTIFICATE_WAITING; 200 certificate_request_state_ = CERTIFICATE_WAITING;
195 201
196 identity_request_observer_->SignalRequestFailed.connect( 202 identity_request_observer_->SignalRequestFailed.connect(
197 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed); 203 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed);
198 identity_request_observer_->SignalCertificateReady.connect( 204 identity_request_observer_->SignalCertificateReady.connect(
199 this, &WebRtcSessionDescriptionFactory::SetCertificate); 205 this, &WebRtcSessionDescriptionFactory::SetCertificate);
200 206
201 rtc::KeyType key_type = rtc::KT_DEFAULT; 207 rtc::KeyType key_type = rtc::KT_DEFAULT;
202 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sending DTLS identity request (key " 208 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sending DTLS identity request (key "
203 << "type: " << key_type << ")."; 209 << "type: " << key_type << ").";
204 210
205 // Request identity. This happens asynchronously, so the caller will have a 211 // Request identity. This happens asynchronously, so the caller will have a
206 // chance to connect to SignalIdentityReady. 212 // chance to connect to SignalIdentityReady.
207 dtls_identity_store_->RequestIdentity(key_type, identity_request_observer_); 213 dtls_identity_store_->RequestIdentity(key_type, identity_request_observer_);
208 } 214 }
209 215
210 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 216 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
211 rtc::Thread* signaling_thread, 217 rtc::Thread* signaling_thread,
212 cricket::ChannelManager* channel_manager, 218 cricket::ChannelManager* channel_manager,
213 MediaStreamSignaling* mediastream_signaling, 219 MediaStreamSignaling* mediastream_signaling,
214 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate, 220 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate,
215 WebRtcSession* session, 221 WebRtcSession* session,
216 const std::string& session_id, 222 const std::string& session_id,
217 cricket::DataChannelType dct) 223 cricket::DataChannelType dct)
218 : WebRtcSessionDescriptionFactory( 224 : WebRtcSessionDescriptionFactory(signaling_thread,
219 signaling_thread, channel_manager, mediastream_signaling, nullptr, 225 channel_manager,
220 nullptr, session, session_id, dct, true) { 226 mediastream_signaling,
227 nullptr,
228 nullptr,
229 session,
230 session_id,
231 dct,
232 true) {
221 DCHECK(certificate); 233 DCHECK(certificate);
222 234
223 certificate_request_state_ = CERTIFICATE_WAITING; 235 certificate_request_state_ = CERTIFICATE_WAITING;
224 236
225 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter."; 237 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter.";
226 // We already have a certificate but we wait to do SetIdentity; if we do 238 // We already have a certificate but we wait to do SetIdentity; if we do
227 // it in the constructor then the caller has not had a chance to connect to 239 // it in the constructor then the caller has not had a chance to connect to
228 // SignalIdentityReady. 240 // SignalIdentityReady.
229 signaling_thread_->Post(this, MSG_USE_CONSTRUCTOR_CERTIFICATE, 241 signaling_thread_->Post(
230 new rtc::ScopedRefMessageData<rtc::RTCCertificate>( 242 this, MSG_USE_CONSTRUCTOR_CERTIFICATE,
231 certificate)); 243 new rtc::ScopedRefMessageData<rtc::RTCCertificate>(certificate));
232 } 244 }
233 245
234 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() { 246 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
235 ASSERT(signaling_thread_->IsCurrent()); 247 ASSERT(signaling_thread_->IsCurrent());
236 248
237 // Fail any requests that were asked for before identity generation completed. 249 // Fail any requests that were asked for before identity generation completed.
238 FailPendingRequests(kFailedDueToSessionShutdown); 250 FailPendingRequests(kFailedDueToSessionShutdown);
239 251
240 // Process all pending notifications in the message queue. If we don't do 252 // Process all pending notifications in the message queue. If we don't do
241 // this, requests will linger and not know they succeeded or failed. 253 // this, requests will linger and not know they succeeded or failed.
242 rtc::MessageList list; 254 rtc::MessageList list;
243 signaling_thread_->Clear(this, rtc::MQID_ANY, &list); 255 signaling_thread_->Clear(this, rtc::MQID_ANY, &list);
244 for (auto& msg : list) { 256 for (auto& msg : list) {
245 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) { 257 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) {
246 OnMessage(&msg); 258 OnMessage(&msg);
247 } else { 259 } else {
248 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger 260 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger
249 // SetIdentity-related callbacks in the destructor. This can be a problem 261 // SetIdentity-related callbacks in the destructor. This can be a problem
250 // when WebRtcSession listens to the callback but it was the WebRtcSession 262 // when WebRtcSession listens to the callback but it was the WebRtcSession
251 // destructor that caused WebRtcSessionDescriptionFactory's destruction. 263 // destructor that caused WebRtcSessionDescriptionFactory's destruction.
252 // The callback is then ignored, leaking memory allocated by OnMessage for 264 // The callback is then ignored, leaking memory allocated by OnMessage for
253 // MSG_USE_CONSTRUCTOR_CERTIFICATE. 265 // MSG_USE_CONSTRUCTOR_CERTIFICATE.
254 delete msg.pdata; 266 delete msg.pdata;
255 } 267 }
256 } 268 }
257
258 transport_desc_factory_.set_certificate(nullptr);
259 } 269 }
260 270
261 void WebRtcSessionDescriptionFactory::CreateOffer( 271 void WebRtcSessionDescriptionFactory::CreateOffer(
262 CreateSessionDescriptionObserver* observer, 272 CreateSessionDescriptionObserver* observer,
263 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { 273 const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
264 cricket::MediaSessionOptions session_options; 274 cricket::MediaSessionOptions session_options;
265 275
266 std::string error = "CreateOffer"; 276 std::string error = "CreateOffer";
267 if (certificate_request_state_ == CERTIFICATE_FAILED) { 277 if (certificate_request_state_ == CERTIFICATE_FAILED) {
268 error += kFailedDueToIdentityFailed; 278 error += kFailedDueToIdentityFailed;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (create_session_description_requests_.front().type == 539 if (create_session_description_requests_.front().type ==
530 CreateSessionDescriptionRequest::kOffer) { 540 CreateSessionDescriptionRequest::kOffer) {
531 InternalCreateOffer(create_session_description_requests_.front()); 541 InternalCreateOffer(create_session_description_requests_.front());
532 } else { 542 } else {
533 InternalCreateAnswer(create_session_description_requests_.front()); 543 InternalCreateAnswer(create_session_description_requests_.front());
534 } 544 }
535 create_session_description_requests_.pop(); 545 create_session_description_requests_.pop();
536 } 546 }
537 } 547 }
538 } // namespace webrtc 548 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698