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

Side by Side Diff: webrtc/api/webrtcsessiondescriptionfactory.h

Issue 2000163002: Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase with master after CL 2001103002 landed Created 4 years, 6 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
« no previous file with comments | « webrtc/api/webrtcsession_unittest.cc ('k') | webrtc/api/webrtcsessiondescriptionfactory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 11 #ifndef WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
12 #define WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 12 #define WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
13 13
14 #include <memory> 14 #include <memory>
15 15
16 #include "webrtc/api/dtlsidentitystore.h" 16 #include "webrtc/api/dtlsidentitystore.h"
17 #include "webrtc/api/peerconnectioninterface.h" 17 #include "webrtc/api/peerconnectioninterface.h"
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/messagehandler.h" 19 #include "webrtc/base/messagehandler.h"
20 #include "webrtc/base/rtccertificate.h" 20 #include "webrtc/base/rtccertificate.h"
21 #include "webrtc/base/rtccertificategenerator.h"
21 #include "webrtc/p2p/base/transportdescriptionfactory.h" 22 #include "webrtc/p2p/base/transportdescriptionfactory.h"
22 #include "webrtc/pc/mediasession.h" 23 #include "webrtc/pc/mediasession.h"
23 24
24 namespace cricket { 25 namespace cricket {
25 class ChannelManager; 26 class ChannelManager;
26 class TransportDescriptionFactory; 27 class TransportDescriptionFactory;
27 } // namespace cricket 28 } // namespace cricket
28 29
29 namespace webrtc { 30 namespace webrtc {
30 class CreateSessionDescriptionObserver; 31 class CreateSessionDescriptionObserver;
31 class MediaConstraintsInterface; 32 class MediaConstraintsInterface;
32 class SessionDescriptionInterface; 33 class SessionDescriptionInterface;
33 class WebRtcSession; 34 class WebRtcSession;
34 35
35 // DTLS identity request callback class. 36 // DTLS certificate request callback class.
36 class WebRtcIdentityRequestObserver : public DtlsIdentityRequestObserver, 37 class WebRtcCertificateGeneratorCallback
37 public sigslot::has_slots<> { 38 : public rtc::RTCCertificateGeneratorCallback,
39 public sigslot::has_slots<> {
38 public: 40 public:
39 // DtlsIdentityRequestObserver overrides. 41 // |rtc::RTCCertificateGeneratorCallback| overrides.
40 void OnFailure(int error) override; 42 void OnSuccess(
41 void OnSuccess(const std::string& der_cert, 43 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override;
42 const std::string& der_private_key) override; 44 void OnFailure() override;
43 void OnSuccess(std::unique_ptr<rtc::SSLIdentity> identity) override;
44 45
45 sigslot::signal1<int> SignalRequestFailed; 46 sigslot::signal0<> SignalRequestFailed;
46 sigslot::signal1<const rtc::scoped_refptr<rtc::RTCCertificate>&> 47 sigslot::signal1<const rtc::scoped_refptr<rtc::RTCCertificate>&>
47 SignalCertificateReady; 48 SignalCertificateReady;
48 }; 49 };
49 50
50 struct CreateSessionDescriptionRequest { 51 struct CreateSessionDescriptionRequest {
51 enum Type { 52 enum Type {
52 kOffer, 53 kOffer,
53 kAnswer, 54 kAnswer,
54 }; 55 };
55 56
56 CreateSessionDescriptionRequest( 57 CreateSessionDescriptionRequest(
57 Type type, 58 Type type,
58 CreateSessionDescriptionObserver* observer, 59 CreateSessionDescriptionObserver* observer,
59 const cricket::MediaSessionOptions& options) 60 const cricket::MediaSessionOptions& options)
60 : type(type), 61 : type(type),
61 observer(observer), 62 observer(observer),
62 options(options) {} 63 options(options) {}
63 64
64 Type type; 65 Type type;
65 rtc::scoped_refptr<CreateSessionDescriptionObserver> observer; 66 rtc::scoped_refptr<CreateSessionDescriptionObserver> observer;
66 cricket::MediaSessionOptions options; 67 cricket::MediaSessionOptions options;
67 }; 68 };
68 69
69 // This class is used to create offer/answer session description with regards to 70 // This class is used to create offer/answer session description. Certificates
70 // the async DTLS identity generation for WebRtcSession. 71 // for WebRtcSession/DTLS are either supplied at construction or generated
71 // It queues the create offer/answer request until the DTLS identity 72 // asynchronously. It queues the create offer/answer request until the
72 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady 73 // certificate generation has completed, i.e. when OnCertificateRequestFailed or
73 // is called. 74 // OnCertificateReady is called.
74 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, 75 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
75 public sigslot::has_slots<> { 76 public sigslot::has_slots<> {
76 public: 77 public:
77 // Construct with DTLS disabled. 78 // If |certificate_generator| is not null, DTLS is enabled and a default
78 WebRtcSessionDescriptionFactory(rtc::Thread* signaling_thread, 79 // certificate is generated asynchronously; otherwise DTLS is disabled.
79 cricket::ChannelManager* channel_manager,
80 WebRtcSession* session,
81 const std::string& session_id);
82
83 // Construct with DTLS enabled using the specified |dtls_identity_store| to
84 // generate a certificate.
85 WebRtcSessionDescriptionFactory( 80 WebRtcSessionDescriptionFactory(
86 rtc::Thread* signaling_thread, 81 rtc::Thread* signaling_thread,
87 cricket::ChannelManager* channel_manager, 82 cricket::ChannelManager* channel_manager,
88 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
89 WebRtcSession* session, 83 WebRtcSession* session,
90 const std::string& session_id); 84 const std::string& session_id,
91 85 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator);
92 // Construct with DTLS enabled using the specified (already generated) 86 // Construct with DTLS enabled using the specified |certificate|.
93 // |certificate|.
94 WebRtcSessionDescriptionFactory( 87 WebRtcSessionDescriptionFactory(
95 rtc::Thread* signaling_thread, 88 rtc::Thread* signaling_thread,
96 cricket::ChannelManager* channel_manager, 89 cricket::ChannelManager* channel_manager,
97 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate,
98 WebRtcSession* session, 90 WebRtcSession* session,
99 const std::string& session_id); 91 const std::string& session_id,
92 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
100 virtual ~WebRtcSessionDescriptionFactory(); 93 virtual ~WebRtcSessionDescriptionFactory();
101 94
102 static void CopyCandidatesFromSessionDescription( 95 static void CopyCandidatesFromSessionDescription(
103 const SessionDescriptionInterface* source_desc, 96 const SessionDescriptionInterface* source_desc,
104 const std::string& content_name, 97 const std::string& content_name,
105 SessionDescriptionInterface* dest_desc); 98 SessionDescriptionInterface* dest_desc);
106 99
107 void CreateOffer( 100 void CreateOffer(
108 CreateSessionDescriptionObserver* observer, 101 CreateSessionDescriptionObserver* observer,
109 const PeerConnectionInterface::RTCOfferAnswerOptions& options, 102 const PeerConnectionInterface::RTCOfferAnswerOptions& options,
(...skipping 13 matching lines...) Expand all
123 } 116 }
124 117
125 private: 118 private:
126 enum CertificateRequestState { 119 enum CertificateRequestState {
127 CERTIFICATE_NOT_NEEDED, 120 CERTIFICATE_NOT_NEEDED,
128 CERTIFICATE_WAITING, 121 CERTIFICATE_WAITING,
129 CERTIFICATE_SUCCEEDED, 122 CERTIFICATE_SUCCEEDED,
130 CERTIFICATE_FAILED, 123 CERTIFICATE_FAILED,
131 }; 124 };
132 125
126 // If |certificate_generator| or |certificate| is not null DTLS is enabled,
127 // otherwise DTLS is disabled.
133 WebRtcSessionDescriptionFactory( 128 WebRtcSessionDescriptionFactory(
134 rtc::Thread* signaling_thread, 129 rtc::Thread* signaling_thread,
135 cricket::ChannelManager* channel_manager, 130 cricket::ChannelManager* channel_manager,
136 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
137 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>&
138 identity_request_observer,
139 WebRtcSession* session, 131 WebRtcSession* session,
140 const std::string& session_id, 132 const std::string& session_id,
141 bool dtls_enabled); 133 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
134 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
142 135
143 // MessageHandler implementation. 136 // MessageHandler implementation.
144 virtual void OnMessage(rtc::Message* msg); 137 virtual void OnMessage(rtc::Message* msg);
145 138
146 void InternalCreateOffer(CreateSessionDescriptionRequest request); 139 void InternalCreateOffer(CreateSessionDescriptionRequest request);
147 void InternalCreateAnswer(CreateSessionDescriptionRequest request); 140 void InternalCreateAnswer(CreateSessionDescriptionRequest request);
148 // Posts failure notifications for all pending session description requests. 141 // Posts failure notifications for all pending session description requests.
149 void FailPendingRequests(const std::string& reason); 142 void FailPendingRequests(const std::string& reason);
150 void PostCreateSessionDescriptionFailed( 143 void PostCreateSessionDescriptionFailed(
151 CreateSessionDescriptionObserver* observer, 144 CreateSessionDescriptionObserver* observer,
152 const std::string& error); 145 const std::string& error);
153 void PostCreateSessionDescriptionSucceeded( 146 void PostCreateSessionDescriptionSucceeded(
154 CreateSessionDescriptionObserver* observer, 147 CreateSessionDescriptionObserver* observer,
155 SessionDescriptionInterface* description); 148 SessionDescriptionInterface* description);
156 149
157 void OnIdentityRequestFailed(int error); 150 void OnCertificateRequestFailed();
158 void SetCertificate( 151 void SetCertificate(
159 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); 152 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
160 153
161 std::queue<CreateSessionDescriptionRequest> 154 std::queue<CreateSessionDescriptionRequest>
162 create_session_description_requests_; 155 create_session_description_requests_;
163 rtc::Thread* const signaling_thread_; 156 rtc::Thread* const signaling_thread_;
164 cricket::TransportDescriptionFactory transport_desc_factory_; 157 cricket::TransportDescriptionFactory transport_desc_factory_;
165 cricket::MediaSessionDescriptionFactory session_desc_factory_; 158 cricket::MediaSessionDescriptionFactory session_desc_factory_;
166 uint64_t session_version_; 159 uint64_t session_version_;
167 const std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; 160 const std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator_;
168 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>
169 identity_request_observer_;
170 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. 161 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed.
171 WebRtcSession* const session_; 162 WebRtcSession* const session_;
172 const std::string session_id_; 163 const std::string session_id_;
173 CertificateRequestState certificate_request_state_; 164 CertificateRequestState certificate_request_state_;
174 165
175 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); 166 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory);
176 }; 167 };
177 } // namespace webrtc 168 } // namespace webrtc
178 169
179 #endif // WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ 170 #endif // WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession_unittest.cc ('k') | webrtc/api/webrtcsessiondescriptionfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698