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 10 matching lines...) Expand all Loading... | |
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" | |
32 #include "talk/app/webrtc/dtlsidentitystore.h" | |
31 #include "talk/app/webrtc/peerconnectioninterface.h" | 33 #include "talk/app/webrtc/peerconnectioninterface.h" |
32 #include "webrtc/p2p/base/transportdescriptionfactory.h" | 34 #include "webrtc/p2p/base/transportdescriptionfactory.h" |
33 #include "talk/session/media/mediasession.h" | 35 #include "talk/session/media/mediasession.h" |
34 #include "webrtc/base/messagehandler.h" | 36 #include "webrtc/base/messagehandler.h" |
35 | 37 |
36 namespace cricket { | 38 namespace cricket { |
37 class ChannelManager; | 39 class ChannelManager; |
38 class TransportDescriptionFactory; | 40 class TransportDescriptionFactory; |
39 } // namespace cricket | 41 } // namespace cricket |
40 | 42 |
41 namespace webrtc { | 43 namespace webrtc { |
42 class CreateSessionDescriptionObserver; | 44 class CreateSessionDescriptionObserver; |
43 class MediaConstraintsInterface; | 45 class MediaConstraintsInterface; |
44 class MediaStreamSignaling; | 46 class MediaStreamSignaling; |
45 class SessionDescriptionInterface; | 47 class SessionDescriptionInterface; |
46 class WebRtcSession; | 48 class WebRtcSession; |
47 | 49 |
48 // DTLS identity request callback class. | 50 // DTLS identity request callback class. |
49 class WebRtcIdentityRequestObserver : public DTLSIdentityRequestObserver, | 51 class WebRtcIdentityRequestObserver : public DTLSIdentityRequestObserver, |
50 public sigslot::has_slots<> { | 52 public sigslot::has_slots<> { |
51 public: | 53 public: |
52 // DTLSIdentityRequestObserver overrides. | 54 // DTLSIdentityRequestObserver overrides. |
53 void OnFailure(int error) override; | 55 void OnFailure(int error) override; |
54 void OnSuccess(const std::string& der_cert, | 56 void OnSuccess(const std::string& der_cert, |
55 const std::string& der_private_key) override; | 57 const std::string& der_private_key) override; |
56 void OnSuccessWithIdentityObj( | 58 void OnSuccessWithIdentityObj( |
57 rtc::scoped_ptr<rtc::SSLIdentity> identity) override; | 59 rtc::scoped_ptr<rtc::SSLIdentity> identity) override; |
58 | 60 |
59 sigslot::signal1<int> SignalRequestFailed; | 61 sigslot::signal1<int> SignalRequestFailed; |
60 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; | 62 sigslot::signal1<rtc::scoped_refptr<DtlsCertificate>> 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, |
(...skipping 11 matching lines...) Expand all Loading... | |
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: |
90 WebRtcSessionDescriptionFactory( | 92 WebRtcSessionDescriptionFactory( |
91 rtc::Thread* signaling_thread, | 93 rtc::Thread* signaling_thread, |
94 rtc::Thread* worker_thread, | |
92 cricket::ChannelManager* channel_manager, | 95 cricket::ChannelManager* channel_manager, |
93 MediaStreamSignaling* mediastream_signaling, | 96 MediaStreamSignaling* mediastream_signaling, |
94 DTLSIdentityServiceInterface* dtls_identity_service, | 97 DTLSIdentityServiceInterface* dtls_identity_service, |
98 rtc::scoped_refptr<DtlsCertificate> certificate, | |
95 // TODO(jiayl): remove the dependency on session once b/10226852 is fixed. | 99 // TODO(jiayl): remove the dependency on session once b/10226852 is fixed. |
96 WebRtcSession* session, | 100 WebRtcSession* session, |
97 const std::string& session_id, | 101 const std::string& session_id, |
98 cricket::DataChannelType dct, | 102 cricket::DataChannelType dct, |
99 bool dtls_enabled); | 103 bool dtls_enabled); |
100 virtual ~WebRtcSessionDescriptionFactory(); | 104 virtual ~WebRtcSessionDescriptionFactory(); |
101 | 105 |
102 static void CopyCandidatesFromSessionDescription( | 106 static void CopyCandidatesFromSessionDescription( |
103 const SessionDescriptionInterface* source_desc, | 107 const SessionDescriptionInterface* source_desc, |
104 SessionDescriptionInterface* dest_desc); | 108 SessionDescriptionInterface* dest_desc); |
105 | 109 |
106 void CreateOffer( | 110 void CreateOffer( |
107 CreateSessionDescriptionObserver* observer, | 111 CreateSessionDescriptionObserver* observer, |
108 const PeerConnectionInterface::RTCOfferAnswerOptions& options); | 112 const PeerConnectionInterface::RTCOfferAnswerOptions& options); |
109 void CreateAnswer( | 113 void CreateAnswer( |
110 CreateSessionDescriptionObserver* observer, | 114 CreateSessionDescriptionObserver* observer, |
111 const MediaConstraintsInterface* constraints); | 115 const MediaConstraintsInterface* constraints); |
112 | 116 |
113 void SetSdesPolicy(cricket::SecurePolicy secure_policy); | 117 void SetSdesPolicy(cricket::SecurePolicy secure_policy); |
114 cricket::SecurePolicy SdesPolicy() const; | 118 cricket::SecurePolicy SdesPolicy() const; |
115 | 119 |
116 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; | 120 sigslot::signal1<rtc::scoped_refptr<DtlsCertificate>> SignalCertificateReady; |
117 | 121 |
118 // For testing. | 122 // For testing. |
119 bool waiting_for_identity() const { | 123 bool waiting_for_certificate() const { |
120 return identity_request_state_ == IDENTITY_WAITING; | 124 return certificate_request_state_ == CERTIFICATE_WAITING; |
121 } | 125 } |
122 | 126 |
123 private: | 127 private: |
124 enum IdentityRequestState { | 128 enum CertificateRequestState { |
125 IDENTITY_NOT_NEEDED, | 129 CERTIFICATE_NOT_NEEDED, |
126 IDENTITY_WAITING, | 130 CERTIFICATE_WAITING, |
127 IDENTITY_SUCCEEDED, | 131 CERTIFICATE_SUCCEEDED, |
128 IDENTITY_FAILED, | 132 CERTIFICATE_FAILED, |
129 }; | 133 }; |
130 | 134 |
131 // MessageHandler implementation. | 135 // MessageHandler implementation. |
132 virtual void OnMessage(rtc::Message* msg); | 136 virtual void OnMessage(rtc::Message* msg); |
133 | 137 |
134 void InternalCreateOffer(CreateSessionDescriptionRequest request); | 138 void InternalCreateOffer(CreateSessionDescriptionRequest request); |
135 void InternalCreateAnswer(CreateSessionDescriptionRequest request); | 139 void InternalCreateAnswer(CreateSessionDescriptionRequest request); |
136 // Posts failure notifications for all pending session description requests. | 140 // Posts failure notifications for all pending session description requests. |
137 void FailPendingRequests(const std::string& reason); | 141 void FailPendingRequests(const std::string& reason); |
138 void PostCreateSessionDescriptionFailed( | 142 void PostCreateSessionDescriptionFailed( |
139 CreateSessionDescriptionObserver* observer, | 143 CreateSessionDescriptionObserver* observer, |
140 const std::string& error); | 144 const std::string& error); |
141 void PostCreateSessionDescriptionSucceeded( | 145 void PostCreateSessionDescriptionSucceeded( |
142 CreateSessionDescriptionObserver* observer, | 146 CreateSessionDescriptionObserver* observer, |
143 SessionDescriptionInterface* description); | 147 SessionDescriptionInterface* description); |
144 | 148 |
145 void OnIdentityRequestFailed(int error); | 149 void OnIdentityRequestFailed(int error); |
146 void SetIdentity(rtc::SSLIdentity* identity); | 150 void SetCertificate(rtc::scoped_refptr<DtlsCertificate> certificate); |
147 | 151 |
148 std::queue<CreateSessionDescriptionRequest> | 152 std::queue<CreateSessionDescriptionRequest> |
149 create_session_description_requests_; | 153 create_session_description_requests_; |
150 rtc::Thread* const signaling_thread_; | 154 rtc::Thread* const signaling_thread_; |
155 rtc::Thread* const worker_thread_; | |
151 MediaStreamSignaling* const mediastream_signaling_; | 156 MediaStreamSignaling* const mediastream_signaling_; |
152 cricket::TransportDescriptionFactory transport_desc_factory_; | 157 cricket::TransportDescriptionFactory transport_desc_factory_; |
153 cricket::MediaSessionDescriptionFactory session_desc_factory_; | 158 cricket::MediaSessionDescriptionFactory session_desc_factory_; |
154 uint64 session_version_; | 159 uint64 session_version_; |
160 rtc::scoped_ptr<DtlsIdentityStore> identity_store_; | |
155 rtc::scoped_ptr<DTLSIdentityServiceInterface> identity_service_; | 161 rtc::scoped_ptr<DTLSIdentityServiceInterface> identity_service_; |
162 rtc::scoped_refptr<DtlsCertificate> certificate_; | |
Henrik Grunell WebRTC
2015/08/06 14:06:52
As discussed offline, move reference to transport
hbos
2015/08/10 15:10:18
Acknowledged.
| |
156 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_; | 163 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_; |
157 WebRtcSession* const session_; | 164 WebRtcSession* const session_; |
158 const std::string session_id_; | 165 const std::string session_id_; |
159 const cricket::DataChannelType data_channel_type_; | 166 const cricket::DataChannelType data_channel_type_; |
160 IdentityRequestState identity_request_state_; | 167 CertificateRequestState certificate_request_state_; |
161 | 168 |
162 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); | 169 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); |
163 }; | 170 }; |
164 } // namespace webrtc | 171 } // namespace webrtc |
165 | 172 |
166 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ | 173 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ |
OLD | NEW |