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

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

Issue 1269843005: Added DtlsCertificate, a ref counted object owning an SSLIdentity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge with master Created 5 years, 4 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 10 matching lines...) Expand all
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #ifndef TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 28 #ifndef TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
29 #define TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 29 #define TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
30 30
31 #include "talk/app/webrtc/dtlscertificate.h"
31 #include "talk/app/webrtc/dtlsidentitystore.h" 32 #include "talk/app/webrtc/dtlsidentitystore.h"
32 #include "talk/app/webrtc/peerconnectioninterface.h" 33 #include "talk/app/webrtc/peerconnectioninterface.h"
33 #include "talk/session/media/mediasession.h" 34 #include "talk/session/media/mediasession.h"
34 #include "webrtc/p2p/base/transportdescriptionfactory.h" 35 #include "webrtc/p2p/base/transportdescriptionfactory.h"
35 #include "webrtc/base/messagehandler.h" 36 #include "webrtc/base/messagehandler.h"
36 37
37 namespace cricket { 38 namespace cricket {
38 class ChannelManager; 39 class ChannelManager;
39 class TransportDescriptionFactory; 40 class TransportDescriptionFactory;
40 } // namespace cricket 41 } // namespace cricket
41 42
42 namespace webrtc { 43 namespace webrtc {
43 class CreateSessionDescriptionObserver; 44 class CreateSessionDescriptionObserver;
44 class MediaConstraintsInterface; 45 class MediaConstraintsInterface;
45 class MediaStreamSignaling; 46 class MediaStreamSignaling;
46 class SessionDescriptionInterface; 47 class SessionDescriptionInterface;
47 class WebRtcSession; 48 class WebRtcSession;
48 49
49 // DTLS identity request callback class. 50 // DTLS identity request callback class.
50 class WebRtcIdentityRequestObserver : public DtlsIdentityRequestObserver, 51 class WebRtcIdentityRequestObserver : public DtlsIdentityRequestObserver,
51 public sigslot::has_slots<> { 52 public sigslot::has_slots<> {
52 public: 53 public:
53 // DtlsIdentityRequestObserver overrides. 54 // DtlsIdentityRequestObserver overrides.
54 void OnFailure(int error) override; 55 void OnFailure(int error) override;
55 void OnSuccess(const std::string& der_cert, 56 void OnSuccess(const std::string& der_cert,
56 const std::string& der_private_key) override; 57 const std::string& der_private_key) override;
57 void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) override; 58 void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) override;
58 59
59 sigslot::signal1<int> SignalRequestFailed; 60 sigslot::signal1<int> SignalRequestFailed;
60 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; 61 sigslot::signal1<const rtc::scoped_refptr<DtlsCertificate>&>
62 SignalCertificateReady;
61 }; 63 };
62 64
63 struct CreateSessionDescriptionRequest { 65 struct CreateSessionDescriptionRequest {
64 enum Type { 66 enum Type {
65 kOffer, 67 kOffer,
66 kAnswer, 68 kAnswer,
67 }; 69 };
68 70
69 CreateSessionDescriptionRequest( 71 CreateSessionDescriptionRequest(
70 Type type, 72 Type type,
71 CreateSessionDescriptionObserver* observer, 73 CreateSessionDescriptionObserver* observer,
72 const cricket::MediaSessionOptions& options) 74 const cricket::MediaSessionOptions& options)
73 : type(type), 75 : type(type),
74 observer(observer), 76 observer(observer),
75 options(options) {} 77 options(options) {}
76 78
77 Type type; 79 Type type;
78 rtc::scoped_refptr<CreateSessionDescriptionObserver> observer; 80 rtc::scoped_refptr<CreateSessionDescriptionObserver> observer;
79 cricket::MediaSessionOptions options; 81 cricket::MediaSessionOptions options;
80 }; 82 };
81 83
82 // This class is used to create offer/answer session description with regards to 84 // This class is used to create offer/answer session description with regards to
83 // the async DTLS identity generation for WebRtcSession. 85 // the async DTLS identity generation for WebRtcSession.
84 // It queues the create offer/answer request until the DTLS identity 86 // It queues the create offer/answer request until the DTLS identity
85 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady 87 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady
86 // is called. 88 // is called.
87 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, 89 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
88 public sigslot::has_slots<> { 90 public sigslot::has_slots<> {
89 public: 91 public:
92 // Construct with DTLS disabled.
93 WebRtcSessionDescriptionFactory(
94 rtc::Thread* signaling_thread,
95 rtc::Thread* worker_thread,
96 cricket::ChannelManager* channel_manager,
97 MediaStreamSignaling* mediastream_signaling,
98 WebRtcSession* session,
99 const std::string& session_id,
100 cricket::DataChannelType dct);
101 // Construct with DTLS enabled. If a |dtls_identity_service| is provided, it
102 // is used to generate a certificate, otherwise a default service is used.
90 WebRtcSessionDescriptionFactory( 103 WebRtcSessionDescriptionFactory(
91 rtc::Thread* signaling_thread, 104 rtc::Thread* signaling_thread,
105 rtc::Thread* worker_thread,
92 cricket::ChannelManager* channel_manager, 106 cricket::ChannelManager* channel_manager,
93 MediaStreamSignaling* mediastream_signaling, 107 MediaStreamSignaling* mediastream_signaling,
94 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 108 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
95 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. 109 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed.
96 WebRtcSession* session, 110 WebRtcSession* session,
97 const std::string& session_id, 111 const std::string& session_id,
98 cricket::DataChannelType dct, 112 cricket::DataChannelType dct);
99 bool dtls_enabled); 113 // Construct with DTLS enabled using the specified (already generated)
114 // certificate.
115 WebRtcSessionDescriptionFactory(
116 rtc::Thread* signaling_thread,
117 rtc::Thread* worker_thread,
118 cricket::ChannelManager* channel_manager,
119 MediaStreamSignaling* mediastream_signaling,
120 const rtc::scoped_refptr<DtlsCertificate>& certificate,
121 WebRtcSession* session,
122 const std::string& session_id,
123 cricket::DataChannelType dct);
100 virtual ~WebRtcSessionDescriptionFactory(); 124 virtual ~WebRtcSessionDescriptionFactory();
101 125
102 static void CopyCandidatesFromSessionDescription( 126 static void CopyCandidatesFromSessionDescription(
103 const SessionDescriptionInterface* source_desc, 127 const SessionDescriptionInterface* source_desc,
104 SessionDescriptionInterface* dest_desc); 128 SessionDescriptionInterface* dest_desc);
105 129
106 void CreateOffer( 130 void CreateOffer(
107 CreateSessionDescriptionObserver* observer, 131 CreateSessionDescriptionObserver* observer,
108 const PeerConnectionInterface::RTCOfferAnswerOptions& options); 132 const PeerConnectionInterface::RTCOfferAnswerOptions& options);
109 void CreateAnswer( 133 void CreateAnswer(
110 CreateSessionDescriptionObserver* observer, 134 CreateSessionDescriptionObserver* observer,
111 const MediaConstraintsInterface* constraints); 135 const MediaConstraintsInterface* constraints);
112 136
113 void SetSdesPolicy(cricket::SecurePolicy secure_policy); 137 void SetSdesPolicy(cricket::SecurePolicy secure_policy);
114 cricket::SecurePolicy SdesPolicy() const; 138 cricket::SecurePolicy SdesPolicy() const;
115 139
116 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; 140 sigslot::signal1<const rtc::scoped_refptr<DtlsCertificate>&>
141 SignalCertificateReady;
117 142
118 // For testing. 143 // For testing.
119 bool waiting_for_identity() const { 144 bool waiting_for_certificate() const {
120 return identity_request_state_ == IDENTITY_WAITING; 145 return certificate_request_state_ == CERTIFICATE_WAITING;
121 } 146 }
122 147
123 private: 148 private:
124 enum IdentityRequestState { 149 enum CertificateRequestState {
125 IDENTITY_NOT_NEEDED, 150 CERTIFICATE_NOT_NEEDED,
126 IDENTITY_WAITING, 151 CERTIFICATE_WAITING,
127 IDENTITY_SUCCEEDED, 152 CERTIFICATE_SUCCEEDED,
128 IDENTITY_FAILED, 153 CERTIFICATE_FAILED,
129 }; 154 };
130 155
156 WebRtcSessionDescriptionFactory(
157 rtc::Thread* signaling_thread,
158 rtc::Thread* worker_thread,
159 cricket::ChannelManager* channel_manager,
160 MediaStreamSignaling* mediastream_signaling,
161 WebRtcSession* session,
162 const std::string& session_id,
163 cricket::DataChannelType dct,
164 bool dtls_enabled);
165
131 // MessageHandler implementation. 166 // MessageHandler implementation.
132 virtual void OnMessage(rtc::Message* msg); 167 virtual void OnMessage(rtc::Message* msg);
133 168
134 void InternalCreateOffer(CreateSessionDescriptionRequest request); 169 void InternalCreateOffer(CreateSessionDescriptionRequest request);
135 void InternalCreateAnswer(CreateSessionDescriptionRequest request); 170 void InternalCreateAnswer(CreateSessionDescriptionRequest request);
136 // Posts failure notifications for all pending session description requests. 171 // Posts failure notifications for all pending session description requests.
137 void FailPendingRequests(const std::string& reason); 172 void FailPendingRequests(const std::string& reason);
138 void PostCreateSessionDescriptionFailed( 173 void PostCreateSessionDescriptionFailed(
139 CreateSessionDescriptionObserver* observer, 174 CreateSessionDescriptionObserver* observer,
140 const std::string& error); 175 const std::string& error);
141 void PostCreateSessionDescriptionSucceeded( 176 void PostCreateSessionDescriptionSucceeded(
142 CreateSessionDescriptionObserver* observer, 177 CreateSessionDescriptionObserver* observer,
143 SessionDescriptionInterface* description); 178 SessionDescriptionInterface* description);
144 179
145 void OnIdentityRequestFailed(int error); 180 void OnIdentityRequestFailed(int error);
146 void SetIdentity(rtc::SSLIdentity* identity); 181 void SetCertificate(const rtc::scoped_refptr<DtlsCertificate>& certificate);
147 182
148 std::queue<CreateSessionDescriptionRequest> 183 std::queue<CreateSessionDescriptionRequest>
149 create_session_description_requests_; 184 create_session_description_requests_;
150 rtc::Thread* const signaling_thread_; 185 rtc::Thread* const signaling_thread_;
186 rtc::Thread* const worker_thread_;
151 MediaStreamSignaling* const mediastream_signaling_; 187 MediaStreamSignaling* const mediastream_signaling_;
152 cricket::TransportDescriptionFactory transport_desc_factory_; 188 cricket::TransportDescriptionFactory transport_desc_factory_;
153 cricket::MediaSessionDescriptionFactory session_desc_factory_; 189 cricket::MediaSessionDescriptionFactory session_desc_factory_;
154 uint64 session_version_; 190 uint64 session_version_;
155 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; 191 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_;
156 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_; 192 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_;
193 // TODO(jiayl): remove the dependency on session once b/10226852 is fixed.
157 WebRtcSession* const session_; 194 WebRtcSession* const session_;
158 const std::string session_id_; 195 const std::string session_id_;
159 const cricket::DataChannelType data_channel_type_; 196 const cricket::DataChannelType data_channel_type_;
160 IdentityRequestState identity_request_state_; 197 CertificateRequestState certificate_request_state_;
161 198
162 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); 199 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory);
163 }; 200 };
164 } // namespace webrtc 201 } // namespace webrtc
165 202
166 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 203 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698