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 15 matching lines...) Expand all Loading... | |
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/dtlsidentitystore.h" | 31 #include "talk/app/webrtc/dtlsidentitystore.h" |
32 #include "talk/app/webrtc/peerconnectioninterface.h" | 32 #include "talk/app/webrtc/peerconnectioninterface.h" |
33 #include "talk/session/media/mediasession.h" | 33 #include "talk/session/media/mediasession.h" |
34 #include "webrtc/p2p/base/transportdescriptionfactory.h" | 34 #include "webrtc/p2p/base/transportdescriptionfactory.h" |
35 #include "webrtc/base/messagehandler.h" | 35 #include "webrtc/base/messagehandler.h" |
36 #include "webrtc/base/rtccertificate.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; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 }; | 81 }; |
81 | 82 |
82 // This class is used to create offer/answer session description with regards to | 83 // This class is used to create offer/answer session description with regards to |
83 // the async DTLS identity generation for WebRtcSession. | 84 // the async DTLS identity generation for WebRtcSession. |
84 // It queues the create offer/answer request until the DTLS identity | 85 // It queues the create offer/answer request until the DTLS identity |
85 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady | 86 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady |
86 // is called. | 87 // is called. |
87 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, | 88 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, |
88 public sigslot::has_slots<> { | 89 public sigslot::has_slots<> { |
89 public: | 90 public: |
91 // Construct with DTLS disabled. | |
92 WebRtcSessionDescriptionFactory( | |
93 rtc::Thread* signaling_thread, | |
94 cricket::ChannelManager* channel_manager, | |
95 MediaStreamSignaling* mediastream_signaling, | |
96 WebRtcSession* session, | |
97 const std::string& session_id, | |
98 cricket::DataChannelType dct); | |
99 // Construct with DTLS enabled using the specified |dtls_identity_store| to | |
tommi
2015/08/20 14:58:11
nit: add an empty line above this comment. same be
hbos
2015/08/20 16:06:11
Done.
| |
100 // generate a certificate. | |
90 WebRtcSessionDescriptionFactory( | 101 WebRtcSessionDescriptionFactory( |
91 rtc::Thread* signaling_thread, | 102 rtc::Thread* signaling_thread, |
92 cricket::ChannelManager* channel_manager, | 103 cricket::ChannelManager* channel_manager, |
93 MediaStreamSignaling* mediastream_signaling, | 104 MediaStreamSignaling* mediastream_signaling, |
94 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 105 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
95 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. | |
96 WebRtcSession* session, | 106 WebRtcSession* session, |
97 const std::string& session_id, | 107 const std::string& session_id, |
98 cricket::DataChannelType dct, | 108 cricket::DataChannelType dct); |
99 bool dtls_enabled); | 109 // Construct with DTLS enabled using the specified (already generated) |
110 // |certificate|. | |
111 WebRtcSessionDescriptionFactory( | |
112 rtc::Thread* signaling_thread, | |
113 cricket::ChannelManager* channel_manager, | |
114 MediaStreamSignaling* mediastream_signaling, | |
115 rtc::scoped_refptr<rtc::RTCCertificate> certificate, | |
116 WebRtcSession* session, | |
117 const std::string& session_id, | |
118 cricket::DataChannelType dct); | |
100 virtual ~WebRtcSessionDescriptionFactory(); | 119 virtual ~WebRtcSessionDescriptionFactory(); |
101 | 120 |
102 static void CopyCandidatesFromSessionDescription( | 121 static void CopyCandidatesFromSessionDescription( |
103 const SessionDescriptionInterface* source_desc, | 122 const SessionDescriptionInterface* source_desc, |
104 SessionDescriptionInterface* dest_desc); | 123 SessionDescriptionInterface* dest_desc); |
105 | 124 |
106 void CreateOffer( | 125 void CreateOffer( |
107 CreateSessionDescriptionObserver* observer, | 126 CreateSessionDescriptionObserver* observer, |
108 const PeerConnectionInterface::RTCOfferAnswerOptions& options); | 127 const PeerConnectionInterface::RTCOfferAnswerOptions& options); |
109 void CreateAnswer( | 128 void CreateAnswer( |
110 CreateSessionDescriptionObserver* observer, | 129 CreateSessionDescriptionObserver* observer, |
111 const MediaConstraintsInterface* constraints); | 130 const MediaConstraintsInterface* constraints); |
112 | 131 |
113 void SetSdesPolicy(cricket::SecurePolicy secure_policy); | 132 void SetSdesPolicy(cricket::SecurePolicy secure_policy); |
114 cricket::SecurePolicy SdesPolicy() const; | 133 cricket::SecurePolicy SdesPolicy() const; |
115 | 134 |
116 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; | 135 sigslot::signal1<rtc::SSLIdentity*> SignalIdentityReady; |
117 | 136 |
118 // For testing. | 137 // For testing. |
119 bool waiting_for_identity() const { | 138 bool waiting_for_certificate() const { |
tommi
2015/08/20 14:58:11
can we call this:
waiting_for_certificate_for_tes
hbos
2015/08/20 16:06:11
Done.
| |
120 return identity_request_state_ == IDENTITY_WAITING; | 139 return certificate_request_state_ == CERTIFICATE_WAITING; |
121 } | 140 } |
122 | 141 |
123 private: | 142 private: |
124 enum IdentityRequestState { | 143 enum CertificateRequestState { |
125 IDENTITY_NOT_NEEDED, | 144 CERTIFICATE_NOT_NEEDED, |
126 IDENTITY_WAITING, | 145 CERTIFICATE_WAITING, |
127 IDENTITY_SUCCEEDED, | 146 CERTIFICATE_SUCCEEDED, |
128 IDENTITY_FAILED, | 147 CERTIFICATE_FAILED, |
129 }; | 148 }; |
130 | 149 |
150 WebRtcSessionDescriptionFactory( | |
151 rtc::Thread* signaling_thread, | |
152 cricket::ChannelManager* channel_manager, | |
153 MediaStreamSignaling* mediastream_signaling, | |
154 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | |
155 WebRtcSession* session, | |
156 const std::string& session_id, | |
157 cricket::DataChannelType dct, | |
158 bool dtls_enabled); | |
159 | |
131 // MessageHandler implementation. | 160 // MessageHandler implementation. |
132 virtual void OnMessage(rtc::Message* msg); | 161 virtual void OnMessage(rtc::Message* msg); |
133 | 162 |
134 void InternalCreateOffer(CreateSessionDescriptionRequest request); | 163 void InternalCreateOffer(CreateSessionDescriptionRequest request); |
135 void InternalCreateAnswer(CreateSessionDescriptionRequest request); | 164 void InternalCreateAnswer(CreateSessionDescriptionRequest request); |
136 // Posts failure notifications for all pending session description requests. | 165 // Posts failure notifications for all pending session description requests. |
137 void FailPendingRequests(const std::string& reason); | 166 void FailPendingRequests(const std::string& reason); |
138 void PostCreateSessionDescriptionFailed( | 167 void PostCreateSessionDescriptionFailed( |
139 CreateSessionDescriptionObserver* observer, | 168 CreateSessionDescriptionObserver* observer, |
140 const std::string& error); | 169 const std::string& error); |
141 void PostCreateSessionDescriptionSucceeded( | 170 void PostCreateSessionDescriptionSucceeded( |
142 CreateSessionDescriptionObserver* observer, | 171 CreateSessionDescriptionObserver* observer, |
143 SessionDescriptionInterface* description); | 172 SessionDescriptionInterface* description); |
144 | 173 |
145 void OnIdentityRequestFailed(int error); | 174 void OnIdentityRequestFailed(int error); |
146 void SetIdentity(rtc::SSLIdentity* identity); | 175 void SetIdentity(rtc::SSLIdentity* identity); |
147 | 176 |
148 std::queue<CreateSessionDescriptionRequest> | 177 std::queue<CreateSessionDescriptionRequest> |
149 create_session_description_requests_; | 178 create_session_description_requests_; |
150 rtc::Thread* const signaling_thread_; | 179 rtc::Thread* const signaling_thread_; |
151 MediaStreamSignaling* const mediastream_signaling_; | 180 MediaStreamSignaling* const mediastream_signaling_; |
152 cricket::TransportDescriptionFactory transport_desc_factory_; | 181 cricket::TransportDescriptionFactory transport_desc_factory_; |
153 cricket::MediaSessionDescriptionFactory session_desc_factory_; | 182 cricket::MediaSessionDescriptionFactory session_desc_factory_; |
154 uint64 session_version_; | 183 uint64 session_version_; |
155 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; | 184 const rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; |
156 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_; | 185 rtc::scoped_refptr<WebRtcIdentityRequestObserver> identity_request_observer_; |
186 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. | |
157 WebRtcSession* const session_; | 187 WebRtcSession* const session_; |
158 const std::string session_id_; | 188 const std::string session_id_; |
159 const cricket::DataChannelType data_channel_type_; | 189 const cricket::DataChannelType data_channel_type_; |
160 IdentityRequestState identity_request_state_; | 190 CertificateRequestState certificate_request_state_; |
161 | 191 |
162 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); | 192 DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); |
163 }; | 193 }; |
164 } // namespace webrtc | 194 } // namespace webrtc |
165 | 195 |
166 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ | 196 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ |
OLD | NEW |