OLD | NEW |
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 Loading... |
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(signaling_thread, | 168 : WebRtcSessionDescriptionFactory( |
169 channel_manager, | 169 signaling_thread, channel_manager, mediastream_signaling, nullptr, |
170 mediastream_signaling, | 170 nullptr, session, session_id, dct, false) { |
171 nullptr, | |
172 nullptr, | |
173 session, | |
174 session_id, | |
175 dct, | |
176 false) { | |
177 LOG(LS_VERBOSE) << "DTLS-SRTP disabled."; | 171 LOG(LS_VERBOSE) << "DTLS-SRTP disabled."; |
178 } | 172 } |
179 | 173 |
180 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( | 174 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
181 rtc::Thread* signaling_thread, | 175 rtc::Thread* signaling_thread, |
182 cricket::ChannelManager* channel_manager, | 176 cricket::ChannelManager* channel_manager, |
183 MediaStreamSignaling* mediastream_signaling, | 177 MediaStreamSignaling* mediastream_signaling, |
184 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 178 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
185 WebRtcSession* session, | 179 WebRtcSession* session, |
186 const std::string& session_id, | 180 const std::string& session_id, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 signaling_thread, channel_manager, mediastream_signaling, nullptr, | 219 signaling_thread, channel_manager, mediastream_signaling, nullptr, |
226 nullptr, session, session_id, dct, true) { | 220 nullptr, session, session_id, dct, true) { |
227 RTC_DCHECK(certificate); | 221 RTC_DCHECK(certificate); |
228 | 222 |
229 certificate_request_state_ = CERTIFICATE_WAITING; | 223 certificate_request_state_ = CERTIFICATE_WAITING; |
230 | 224 |
231 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter."; | 225 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter."; |
232 // We already have a certificate but we wait to do SetIdentity; if we do | 226 // We already have a certificate but we wait to do SetIdentity; if we do |
233 // it in the constructor then the caller has not had a chance to connect to | 227 // it in the constructor then the caller has not had a chance to connect to |
234 // SignalIdentityReady. | 228 // SignalIdentityReady. |
235 signaling_thread_->Post( | 229 signaling_thread_->Post(this, MSG_USE_CONSTRUCTOR_CERTIFICATE, |
236 this, MSG_USE_CONSTRUCTOR_CERTIFICATE, | 230 new rtc::ScopedRefMessageData<rtc::RTCCertificate>( |
237 new rtc::ScopedRefMessageData<rtc::RTCCertificate>(certificate)); | 231 certificate)); |
238 } | 232 } |
239 | 233 |
240 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() { | 234 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() { |
241 ASSERT(signaling_thread_->IsCurrent()); | 235 ASSERT(signaling_thread_->IsCurrent()); |
242 | 236 |
243 // Fail any requests that were asked for before identity generation completed. | 237 // Fail any requests that were asked for before identity generation completed. |
244 FailPendingRequests(kFailedDueToSessionShutdown); | 238 FailPendingRequests(kFailedDueToSessionShutdown); |
245 | 239 |
246 // Process all pending notifications in the message queue. If we don't do | 240 // Process all pending notifications in the message queue. If we don't do |
247 // this, requests will linger and not know they succeeded or failed. | 241 // this, requests will linger and not know they succeeded or failed. |
248 rtc::MessageList list; | 242 rtc::MessageList list; |
249 signaling_thread_->Clear(this, rtc::MQID_ANY, &list); | 243 signaling_thread_->Clear(this, rtc::MQID_ANY, &list); |
250 for (auto& msg : list) { | 244 for (auto& msg : list) { |
251 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) { | 245 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) { |
252 OnMessage(&msg); | 246 OnMessage(&msg); |
253 } else { | 247 } else { |
254 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger | 248 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger |
255 // SetIdentity-related callbacks in the destructor. This can be a problem | 249 // SetIdentity-related callbacks in the destructor. This can be a problem |
256 // when WebRtcSession listens to the callback but it was the WebRtcSession | 250 // when WebRtcSession listens to the callback but it was the WebRtcSession |
257 // destructor that caused WebRtcSessionDescriptionFactory's destruction. | 251 // destructor that caused WebRtcSessionDescriptionFactory's destruction. |
258 // The callback is then ignored, leaking memory allocated by OnMessage for | 252 // The callback is then ignored, leaking memory allocated by OnMessage for |
259 // MSG_USE_CONSTRUCTOR_CERTIFICATE. | 253 // MSG_USE_CONSTRUCTOR_CERTIFICATE. |
260 delete msg.pdata; | 254 delete msg.pdata; |
261 } | 255 } |
262 } | 256 } |
| 257 |
| 258 transport_desc_factory_.set_certificate(nullptr); |
263 } | 259 } |
264 | 260 |
265 void WebRtcSessionDescriptionFactory::CreateOffer( | 261 void WebRtcSessionDescriptionFactory::CreateOffer( |
266 CreateSessionDescriptionObserver* observer, | 262 CreateSessionDescriptionObserver* observer, |
267 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { | 263 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { |
268 cricket::MediaSessionOptions session_options; | 264 cricket::MediaSessionOptions session_options; |
269 | 265 |
270 std::string error = "CreateOffer"; | 266 std::string error = "CreateOffer"; |
271 if (certificate_request_state_ == CERTIFICATE_FAILED) { | 267 if (certificate_request_state_ == CERTIFICATE_FAILED) { |
272 error += kFailedDueToIdentityFailed; | 268 error += kFailedDueToIdentityFailed; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (create_session_description_requests_.front().type == | 529 if (create_session_description_requests_.front().type == |
534 CreateSessionDescriptionRequest::kOffer) { | 530 CreateSessionDescriptionRequest::kOffer) { |
535 InternalCreateOffer(create_session_description_requests_.front()); | 531 InternalCreateOffer(create_session_description_requests_.front()); |
536 } else { | 532 } else { |
537 InternalCreateAnswer(create_session_description_requests_.front()); | 533 InternalCreateAnswer(create_session_description_requests_.front()); |
538 } | 534 } |
539 create_session_description_requests_.pop(); | 535 create_session_description_requests_.pop(); |
540 } | 536 } |
541 } | 537 } |
542 } // namespace webrtc | 538 } // namespace webrtc |
OLD | NEW |