Index: talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
index aab24cf0654b01054355842d54c22ea470c2c3d7..269870e2c3291b037c64e9e0f33ada85088b1018 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; |
@@ -65,8 +66,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 { |
@@ -128,7 +128,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
rtc::Thread* signaling_thread, |
cricket::ChannelManager* channel_manager, |
MediaStreamSignaling* mediastream_signaling, |
- DTLSIdentityServiceInterface* dtls_identity_service, |
+ DtlsIdentityStoreInterface* dtls_identity_store, |
WebRtcSession* session, |
const std::string& session_id, |
cricket::DataChannelType dct, |
@@ -141,7 +141,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), |
session_(session), |
session_id_(session_id), |
data_channel_type_(dct), |
@@ -151,11 +151,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>(); |
@@ -164,21 +163,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_.get()); |
} |
} |
@@ -310,11 +298,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; |