| 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, |
| 11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
| 12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
| 13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
| 14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
| 15 * | 15 * |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 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 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 28 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
| 29 | 29 |
| 30 #include <utility> |
| 31 |
| 30 #include "talk/app/webrtc/dtlsidentitystore.h" | 32 #include "talk/app/webrtc/dtlsidentitystore.h" |
| 31 #include "talk/app/webrtc/jsep.h" | 33 #include "talk/app/webrtc/jsep.h" |
| 32 #include "talk/app/webrtc/jsepsessiondescription.h" | 34 #include "talk/app/webrtc/jsepsessiondescription.h" |
| 33 #include "talk/app/webrtc/mediaconstraintsinterface.h" | 35 #include "talk/app/webrtc/mediaconstraintsinterface.h" |
| 34 #include "talk/app/webrtc/webrtcsession.h" | 36 #include "talk/app/webrtc/webrtcsession.h" |
| 35 #include "webrtc/base/sslidentity.h" | 37 #include "webrtc/base/sslidentity.h" |
| 36 | 38 |
| 37 using cricket::MediaSessionOptions; | 39 using cricket::MediaSessionOptions; |
| 38 | 40 |
| 39 namespace webrtc { | 41 namespace webrtc { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 std::string pem_cert = rtc::SSLIdentity::DerToPem( | 94 std::string pem_cert = rtc::SSLIdentity::DerToPem( |
| 93 rtc::kPemTypeCertificate, | 95 rtc::kPemTypeCertificate, |
| 94 reinterpret_cast<const unsigned char*>(der_cert.data()), | 96 reinterpret_cast<const unsigned char*>(der_cert.data()), |
| 95 der_cert.length()); | 97 der_cert.length()); |
| 96 std::string pem_key = rtc::SSLIdentity::DerToPem( | 98 std::string pem_key = rtc::SSLIdentity::DerToPem( |
| 97 rtc::kPemTypeRsaPrivateKey, | 99 rtc::kPemTypeRsaPrivateKey, |
| 98 reinterpret_cast<const unsigned char*>(der_private_key.data()), | 100 reinterpret_cast<const unsigned char*>(der_private_key.data()), |
| 99 der_private_key.length()); | 101 der_private_key.length()); |
| 100 rtc::scoped_ptr<rtc::SSLIdentity> identity( | 102 rtc::scoped_ptr<rtc::SSLIdentity> identity( |
| 101 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert)); | 103 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert)); |
| 102 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); | 104 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity))); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void WebRtcIdentityRequestObserver::OnSuccess( | 107 void WebRtcIdentityRequestObserver::OnSuccess( |
| 106 rtc::scoped_ptr<rtc::SSLIdentity> identity) { | 108 rtc::scoped_ptr<rtc::SSLIdentity> identity) { |
| 107 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); | 109 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity))); |
| 108 } | 110 } |
| 109 | 111 |
| 110 // static | 112 // static |
| 111 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( | 113 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( |
| 112 const SessionDescriptionInterface* source_desc, | 114 const SessionDescriptionInterface* source_desc, |
| 113 SessionDescriptionInterface* dest_desc) { | 115 SessionDescriptionInterface* dest_desc) { |
| 114 if (!source_desc) | 116 if (!source_desc) |
| 115 return; | 117 return; |
| 116 for (size_t m = 0; m < source_desc->number_of_mediasections() && | 118 for (size_t m = 0; m < source_desc->number_of_mediasections() && |
| 117 m < dest_desc->number_of_mediasections(); ++m) { | 119 m < dest_desc->number_of_mediasections(); ++m) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 WebRtcSession* session, | 138 WebRtcSession* session, |
| 137 const std::string& session_id, | 139 const std::string& session_id, |
| 138 bool dtls_enabled) | 140 bool dtls_enabled) |
| 139 : signaling_thread_(signaling_thread), | 141 : signaling_thread_(signaling_thread), |
| 140 session_desc_factory_(channel_manager, &transport_desc_factory_), | 142 session_desc_factory_(channel_manager, &transport_desc_factory_), |
| 141 // RFC 4566 suggested a Network Time Protocol (NTP) format timestamp | 143 // RFC 4566 suggested a Network Time Protocol (NTP) format timestamp |
| 142 // as the session id and session version. To simplify, it should be fine | 144 // as the session id and session version. To simplify, it should be fine |
| 143 // to just use a random number as session id and start version from | 145 // to just use a random number as session id and start version from |
| 144 // |kInitSessionVersion|. | 146 // |kInitSessionVersion|. |
| 145 session_version_(kInitSessionVersion), | 147 session_version_(kInitSessionVersion), |
| 146 dtls_identity_store_(dtls_identity_store.Pass()), | 148 dtls_identity_store_(std::move(dtls_identity_store)), |
| 147 identity_request_observer_(identity_request_observer), | 149 identity_request_observer_(identity_request_observer), |
| 148 session_(session), | 150 session_(session), |
| 149 session_id_(session_id), | 151 session_id_(session_id), |
| 150 certificate_request_state_(CERTIFICATE_NOT_NEEDED) { | 152 certificate_request_state_(CERTIFICATE_NOT_NEEDED) { |
| 151 session_desc_factory_.set_add_legacy_streams(false); | 153 session_desc_factory_.set_add_legacy_streams(false); |
| 152 // SRTP-SDES is disabled if DTLS is on. | 154 // SRTP-SDES is disabled if DTLS is on. |
| 153 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED); | 155 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED); |
| 154 } | 156 } |
| 155 | 157 |
| 156 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( | 158 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 | 172 |
| 171 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( | 173 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
| 172 rtc::Thread* signaling_thread, | 174 rtc::Thread* signaling_thread, |
| 173 cricket::ChannelManager* channel_manager, | 175 cricket::ChannelManager* channel_manager, |
| 174 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 176 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 175 WebRtcSession* session, | 177 WebRtcSession* session, |
| 176 const std::string& session_id) | 178 const std::string& session_id) |
| 177 : WebRtcSessionDescriptionFactory( | 179 : WebRtcSessionDescriptionFactory( |
| 178 signaling_thread, | 180 signaling_thread, |
| 179 channel_manager, | 181 channel_manager, |
| 180 dtls_identity_store.Pass(), | 182 std::move(dtls_identity_store), |
| 181 new rtc::RefCountedObject<WebRtcIdentityRequestObserver>(), | 183 new rtc::RefCountedObject<WebRtcIdentityRequestObserver>(), |
| 182 session, | 184 session, |
| 183 session_id, | 185 session_id, |
| 184 true) { | 186 true) { |
| 185 RTC_DCHECK(dtls_identity_store_); | 187 RTC_DCHECK(dtls_identity_store_); |
| 186 | 188 |
| 187 certificate_request_state_ = CERTIFICATE_WAITING; | 189 certificate_request_state_ = CERTIFICATE_WAITING; |
| 188 | 190 |
| 189 identity_request_observer_->SignalRequestFailed.connect( | 191 identity_request_observer_->SignalRequestFailed.connect( |
| 190 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed); | 192 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 if (create_session_description_requests_.front().type == | 501 if (create_session_description_requests_.front().type == |
| 500 CreateSessionDescriptionRequest::kOffer) { | 502 CreateSessionDescriptionRequest::kOffer) { |
| 501 InternalCreateOffer(create_session_description_requests_.front()); | 503 InternalCreateOffer(create_session_description_requests_.front()); |
| 502 } else { | 504 } else { |
| 503 InternalCreateAnswer(create_session_description_requests_.front()); | 505 InternalCreateAnswer(create_session_description_requests_.front()); |
| 504 } | 506 } |
| 505 create_session_description_requests_.pop(); | 507 create_session_description_requests_.pop(); |
| 506 } | 508 } |
| 507 } | 509 } |
| 508 } // namespace webrtc | 510 } // namespace webrtc |
| OLD | NEW |