Index: talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
index 1909b0ed78dfe2c6cd5c6c82481d7560ca935ceb..3dcc0a1a3b7a78a24da249a0f7b9271c07b7e405 100644 |
--- a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
+++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
@@ -33,6 +33,7 @@ |
#include "talk/app/webrtc/mediaconstraintsinterface.h" |
#include "talk/app/webrtc/mediastreamsignaling.h" |
#include "talk/app/webrtc/webrtcsession.h" |
+#include "webrtc/base/sslidentity.h" |
using cricket::MediaSessionOptions; |
@@ -67,8 +68,7 @@ static bool ValidStreams(const MediaSessionOptions::Streams& streams) { |
enum { |
MSG_CREATE_SESSIONDESCRIPTION_SUCCESS, |
- MSG_CREATE_SESSIONDESCRIPTION_FAILED, |
- MSG_GENERATE_IDENTITY, |
+ MSG_CREATE_SESSIONDESCRIPTION_FAILED |
}; |
struct CreateSessionDescriptionMsg : public rtc::MessageData { |
@@ -102,7 +102,7 @@ void WebRtcIdentityRequestObserver::OnSuccess( |
SignalIdentityReady(identity); |
} |
-void WebRtcIdentityRequestObserver::OnSuccessWithIdentityObj( |
+void WebRtcIdentityRequestObserver::OnSuccess( |
rtc::scoped_ptr<rtc::SSLIdentity> identity) { |
SignalIdentityReady(identity.release()); |
} |
@@ -130,7 +130,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
rtc::Thread* signaling_thread, |
cricket::ChannelManager* channel_manager, |
MediaStreamSignaling* mediastream_signaling, |
- DTLSIdentityServiceInterface* dtls_identity_service, |
+ rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
WebRtcSession* session, |
const std::string& session_id, |
cricket::DataChannelType dct, |
@@ -143,7 +143,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
// to just use a random number as session id and start version from |
// |kInitSessionVersion|. |
session_version_(kInitSessionVersion), |
- identity_service_(dtls_identity_service), |
+ dtls_identity_store_(dtls_identity_store.Pass()), |
session_(session), |
session_id_(session_id), |
data_channel_type_(dct), |
@@ -153,11 +153,10 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
// SRTP-SDES is disabled if DTLS is on. |
SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED); |
- if (!dtls_enabled) { |
- return; |
- } |
+ // If |dtls_enabled| we must have a |dtls_identity_store_|. |
+ DCHECK(!dtls_enabled || dtls_identity_store_); |
- if (identity_service_.get()) { |
+ if (dtls_enabled && dtls_identity_store_) { |
identity_request_observer_ = |
new rtc::RefCountedObject<WebRtcIdentityRequestObserver>(); |
@@ -166,21 +165,10 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
identity_request_observer_->SignalIdentityReady.connect( |
this, &WebRtcSessionDescriptionFactory::SetIdentity); |
- if (identity_service_->RequestIdentity( |
- DtlsIdentityStore::kIdentityName, |
- DtlsIdentityStore::kIdentityName, |
- identity_request_observer_)) { |
- LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sent DTLS identity request."; |
- identity_request_state_ = IDENTITY_WAITING; |
- } else { |
- LOG(LS_ERROR) << "Failed to send DTLS identity request."; |
- identity_request_state_ = IDENTITY_FAILED; |
- } |
- } else { |
+ LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sending DTLS identity request."; |
identity_request_state_ = IDENTITY_WAITING; |
- // Do not generate the identity in the constructor since the caller has |
- // not got a chance to connect to SignalIdentityReady. |
- signaling_thread_->Post(this, MSG_GENERATE_IDENTITY, NULL); |
+ dtls_identity_store_->RequestIdentity(rtc::KT_DEFAULT, |
+ identity_request_observer_); |
} |
} |
@@ -324,11 +312,6 @@ void WebRtcSessionDescriptionFactory::OnMessage(rtc::Message* msg) { |
delete param; |
break; |
} |
- case MSG_GENERATE_IDENTITY: { |
- LOG(LS_INFO) << "Generating identity."; |
- SetIdentity(rtc::SSLIdentity::Generate(DtlsIdentityStore::kIdentityName)); |
- break; |
- } |
default: |
ASSERT(false); |
break; |