| 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 25 matching lines...) Expand all Loading... |
| 36 #include "webrtc/base/rtccertificate.h" | 36 #include "webrtc/base/rtccertificate.h" |
| 37 | 37 |
| 38 namespace cricket { | 38 namespace cricket { |
| 39 class ChannelManager; | 39 class ChannelManager; |
| 40 class TransportDescriptionFactory; | 40 class TransportDescriptionFactory; |
| 41 } // namespace cricket | 41 } // namespace cricket |
| 42 | 42 |
| 43 namespace webrtc { | 43 namespace webrtc { |
| 44 class CreateSessionDescriptionObserver; | 44 class CreateSessionDescriptionObserver; |
| 45 class MediaConstraintsInterface; | 45 class MediaConstraintsInterface; |
| 46 class MediaStreamSignaling; | |
| 47 class SessionDescriptionInterface; | 46 class SessionDescriptionInterface; |
| 48 class WebRtcSession; | 47 class WebRtcSession; |
| 49 | 48 |
| 50 // DTLS identity request callback class. | 49 // DTLS identity request callback class. |
| 51 class WebRtcIdentityRequestObserver : public DtlsIdentityRequestObserver, | 50 class WebRtcIdentityRequestObserver : public DtlsIdentityRequestObserver, |
| 52 public sigslot::has_slots<> { | 51 public sigslot::has_slots<> { |
| 53 public: | 52 public: |
| 54 // DtlsIdentityRequestObserver overrides. | 53 // DtlsIdentityRequestObserver overrides. |
| 55 void OnFailure(int error) override; | 54 void OnFailure(int error) override; |
| 56 void OnSuccess(const std::string& der_cert, | 55 void OnSuccess(const std::string& der_cert, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 // the async DTLS identity generation for WebRtcSession. | 84 // the async DTLS identity generation for WebRtcSession. |
| 86 // It queues the create offer/answer request until the DTLS identity | 85 // It queues the create offer/answer request until the DTLS identity |
| 87 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady | 86 // request has completed, i.e. when OnIdentityRequestFailed or OnIdentityReady |
| 88 // is called. | 87 // is called. |
| 89 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, | 88 class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, |
| 90 public sigslot::has_slots<> { | 89 public sigslot::has_slots<> { |
| 91 public: | 90 public: |
| 92 // Construct with DTLS disabled. | 91 // Construct with DTLS disabled. |
| 93 WebRtcSessionDescriptionFactory(rtc::Thread* signaling_thread, | 92 WebRtcSessionDescriptionFactory(rtc::Thread* signaling_thread, |
| 94 cricket::ChannelManager* channel_manager, | 93 cricket::ChannelManager* channel_manager, |
| 95 MediaStreamSignaling* mediastream_signaling, | |
| 96 WebRtcSession* session, | 94 WebRtcSession* session, |
| 97 const std::string& session_id, | 95 const std::string& session_id); |
| 98 cricket::DataChannelType dct); | |
| 99 | 96 |
| 100 // Construct with DTLS enabled using the specified |dtls_identity_store| to | 97 // Construct with DTLS enabled using the specified |dtls_identity_store| to |
| 101 // generate a certificate. | 98 // generate a certificate. |
| 102 WebRtcSessionDescriptionFactory( | 99 WebRtcSessionDescriptionFactory( |
| 103 rtc::Thread* signaling_thread, | 100 rtc::Thread* signaling_thread, |
| 104 cricket::ChannelManager* channel_manager, | 101 cricket::ChannelManager* channel_manager, |
| 105 MediaStreamSignaling* mediastream_signaling, | |
| 106 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 102 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 107 WebRtcSession* session, | 103 WebRtcSession* session, |
| 108 const std::string& session_id, | 104 const std::string& session_id); |
| 109 cricket::DataChannelType dct); | |
| 110 | 105 |
| 111 // Construct with DTLS enabled using the specified (already generated) | 106 // Construct with DTLS enabled using the specified (already generated) |
| 112 // |certificate|. | 107 // |certificate|. |
| 113 WebRtcSessionDescriptionFactory( | 108 WebRtcSessionDescriptionFactory( |
| 114 rtc::Thread* signaling_thread, | 109 rtc::Thread* signaling_thread, |
| 115 cricket::ChannelManager* channel_manager, | 110 cricket::ChannelManager* channel_manager, |
| 116 MediaStreamSignaling* mediastream_signaling, | |
| 117 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate, | 111 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate, |
| 118 WebRtcSession* session, | 112 WebRtcSession* session, |
| 119 const std::string& session_id, | 113 const std::string& session_id); |
| 120 cricket::DataChannelType dct); | |
| 121 virtual ~WebRtcSessionDescriptionFactory(); | 114 virtual ~WebRtcSessionDescriptionFactory(); |
| 122 | 115 |
| 123 static void CopyCandidatesFromSessionDescription( | 116 static void CopyCandidatesFromSessionDescription( |
| 124 const SessionDescriptionInterface* source_desc, | 117 const SessionDescriptionInterface* source_desc, |
| 125 SessionDescriptionInterface* dest_desc); | 118 SessionDescriptionInterface* dest_desc); |
| 126 | 119 |
| 127 void CreateOffer( | 120 void CreateOffer( |
| 128 CreateSessionDescriptionObserver* observer, | 121 CreateSessionDescriptionObserver* observer, |
| 129 const PeerConnectionInterface::RTCOfferAnswerOptions& options); | 122 const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 130 void CreateAnswer( | 123 const cricket::MediaSessionOptions& session_options); |
| 131 CreateSessionDescriptionObserver* observer, | 124 void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 132 const MediaConstraintsInterface* constraints); | 125 const MediaConstraintsInterface* constraints, |
| 126 const cricket::MediaSessionOptions& session_options); |
| 133 | 127 |
| 134 void SetSdesPolicy(cricket::SecurePolicy secure_policy); | 128 void SetSdesPolicy(cricket::SecurePolicy secure_policy); |
| 135 cricket::SecurePolicy SdesPolicy() const; | 129 cricket::SecurePolicy SdesPolicy() const; |
| 136 | 130 |
| 137 sigslot::signal1<const rtc::scoped_refptr<rtc::RTCCertificate>&> | 131 sigslot::signal1<const rtc::scoped_refptr<rtc::RTCCertificate>&> |
| 138 SignalCertificateReady; | 132 SignalCertificateReady; |
| 139 | 133 |
| 140 // For testing. | 134 // For testing. |
| 141 bool waiting_for_certificate_for_testing() const { | 135 bool waiting_for_certificate_for_testing() const { |
| 142 return certificate_request_state_ == CERTIFICATE_WAITING; | 136 return certificate_request_state_ == CERTIFICATE_WAITING; |
| 143 } | 137 } |
| 144 | 138 |
| 145 private: | 139 private: |
| 146 enum CertificateRequestState { | 140 enum CertificateRequestState { |
| 147 CERTIFICATE_NOT_NEEDED, | 141 CERTIFICATE_NOT_NEEDED, |
| 148 CERTIFICATE_WAITING, | 142 CERTIFICATE_WAITING, |
| 149 CERTIFICATE_SUCCEEDED, | 143 CERTIFICATE_SUCCEEDED, |
| 150 CERTIFICATE_FAILED, | 144 CERTIFICATE_FAILED, |
| 151 }; | 145 }; |
| 152 | 146 |
| 153 WebRtcSessionDescriptionFactory( | 147 WebRtcSessionDescriptionFactory( |
| 154 rtc::Thread* signaling_thread, | 148 rtc::Thread* signaling_thread, |
| 155 cricket::ChannelManager* channel_manager, | 149 cricket::ChannelManager* channel_manager, |
| 156 MediaStreamSignaling* mediastream_signaling, | |
| 157 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 150 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 158 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& | 151 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& |
| 159 identity_request_observer, | 152 identity_request_observer, |
| 160 WebRtcSession* session, | 153 WebRtcSession* session, |
| 161 const std::string& session_id, | 154 const std::string& session_id, |
| 162 cricket::DataChannelType dct, | |
| 163 bool dtls_enabled); | 155 bool dtls_enabled); |
| 164 | 156 |
| 165 // MessageHandler implementation. | 157 // MessageHandler implementation. |
| 166 virtual void OnMessage(rtc::Message* msg); | 158 virtual void OnMessage(rtc::Message* msg); |
| 167 | 159 |
| 168 void InternalCreateOffer(CreateSessionDescriptionRequest request); | 160 void InternalCreateOffer(CreateSessionDescriptionRequest request); |
| 169 void InternalCreateAnswer(CreateSessionDescriptionRequest request); | 161 void InternalCreateAnswer(CreateSessionDescriptionRequest request); |
| 170 // Posts failure notifications for all pending session description requests. | 162 // Posts failure notifications for all pending session description requests. |
| 171 void FailPendingRequests(const std::string& reason); | 163 void FailPendingRequests(const std::string& reason); |
| 172 void PostCreateSessionDescriptionFailed( | 164 void PostCreateSessionDescriptionFailed( |
| 173 CreateSessionDescriptionObserver* observer, | 165 CreateSessionDescriptionObserver* observer, |
| 174 const std::string& error); | 166 const std::string& error); |
| 175 void PostCreateSessionDescriptionSucceeded( | 167 void PostCreateSessionDescriptionSucceeded( |
| 176 CreateSessionDescriptionObserver* observer, | 168 CreateSessionDescriptionObserver* observer, |
| 177 SessionDescriptionInterface* description); | 169 SessionDescriptionInterface* description); |
| 178 | 170 |
| 179 void OnIdentityRequestFailed(int error); | 171 void OnIdentityRequestFailed(int error); |
| 180 void SetCertificate( | 172 void SetCertificate( |
| 181 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 173 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 182 | 174 |
| 183 std::queue<CreateSessionDescriptionRequest> | 175 std::queue<CreateSessionDescriptionRequest> |
| 184 create_session_description_requests_; | 176 create_session_description_requests_; |
| 185 rtc::Thread* const signaling_thread_; | 177 rtc::Thread* const signaling_thread_; |
| 186 MediaStreamSignaling* const mediastream_signaling_; | |
| 187 cricket::TransportDescriptionFactory transport_desc_factory_; | 178 cricket::TransportDescriptionFactory transport_desc_factory_; |
| 188 cricket::MediaSessionDescriptionFactory session_desc_factory_; | 179 cricket::MediaSessionDescriptionFactory session_desc_factory_; |
| 189 uint64_t session_version_; | 180 uint64_t session_version_; |
| 190 const rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; | 181 const rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_; |
| 191 const rtc::scoped_refptr<WebRtcIdentityRequestObserver> | 182 const rtc::scoped_refptr<WebRtcIdentityRequestObserver> |
| 192 identity_request_observer_; | 183 identity_request_observer_; |
| 193 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. | 184 // TODO(jiayl): remove the dependency on session once bug 2264 is fixed. |
| 194 WebRtcSession* const session_; | 185 WebRtcSession* const session_; |
| 195 const std::string session_id_; | 186 const std::string session_id_; |
| 196 const cricket::DataChannelType data_channel_type_; | |
| 197 CertificateRequestState certificate_request_state_; | 187 CertificateRequestState certificate_request_state_; |
| 198 | 188 |
| 199 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); | 189 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSessionDescriptionFactory); |
| 200 }; | 190 }; |
| 201 } // namespace webrtc | 191 } // namespace webrtc |
| 202 | 192 |
| 203 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ | 193 #endif // TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ |
| OLD | NEW |