OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; | 227 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; |
228 return false; | 228 return false; |
229 } | 229 } |
230 } | 230 } |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 static bool GetTrackIdBySsrc(const SessionDescription* session_description, | 234 static bool GetTrackIdBySsrc(const SessionDescription* session_description, |
235 uint32_t ssrc, | 235 uint32_t ssrc, |
236 std::string* track_id) { | 236 std::string* track_id) { |
237 RTC_DCHECK(track_id != NULL); | 237 RTC_DCHECK(track_id != nullptr); |
238 | 238 |
239 const cricket::ContentInfo* audio_info = | 239 const cricket::ContentInfo* audio_info = |
240 cricket::GetFirstAudioContent(session_description); | 240 cricket::GetFirstAudioContent(session_description); |
241 if (audio_info) { | 241 if (audio_info) { |
242 const cricket::MediaContentDescription* audio_content = | 242 const cricket::MediaContentDescription* audio_content = |
243 static_cast<const cricket::MediaContentDescription*>( | 243 static_cast<const cricket::MediaContentDescription*>( |
244 audio_info->description); | 244 audio_info->description); |
245 | 245 |
246 const auto* found = | 246 const auto* found = |
247 cricket::GetStreamBySsrc(audio_content->streams(), ssrc); | 247 cricket::GetStreamBySsrc(audio_content->streams(), ssrc); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 worker_thread_(worker_thread), | 448 worker_thread_(worker_thread), |
449 signaling_thread_(signaling_thread), | 449 signaling_thread_(signaling_thread), |
450 // RFC 3264: The numeric value of the session id and version in the | 450 // RFC 3264: The numeric value of the session id and version in the |
451 // o line MUST be representable with a "64 bit signed integer". | 451 // o line MUST be representable with a "64 bit signed integer". |
452 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. | 452 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. |
453 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), | 453 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), |
454 transport_controller_(std::move(transport_controller)), | 454 transport_controller_(std::move(transport_controller)), |
455 sctp_factory_(std::move(sctp_factory)), | 455 sctp_factory_(std::move(sctp_factory)), |
456 media_controller_(media_controller), | 456 media_controller_(media_controller), |
457 channel_manager_(media_controller_->channel_manager()), | 457 channel_manager_(media_controller_->channel_manager()), |
458 ice_observer_(NULL), | 458 ice_observer_(nullptr), |
459 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 459 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
460 ice_connection_receiving_(true), | 460 ice_connection_receiving_(true), |
461 older_version_remote_peer_(false), | 461 older_version_remote_peer_(false), |
462 dtls_enabled_(false), | 462 dtls_enabled_(false), |
463 data_channel_type_(cricket::DCT_NONE), | 463 data_channel_type_(cricket::DCT_NONE), |
464 metrics_observer_(NULL) { | 464 metrics_observer_(nullptr) { |
465 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED); | 465 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED); |
466 transport_controller_->SignalConnectionState.connect( | 466 transport_controller_->SignalConnectionState.connect( |
467 this, &WebRtcSession::OnTransportControllerConnectionState); | 467 this, &WebRtcSession::OnTransportControllerConnectionState); |
468 transport_controller_->SignalReceiving.connect( | 468 transport_controller_->SignalReceiving.connect( |
469 this, &WebRtcSession::OnTransportControllerReceiving); | 469 this, &WebRtcSession::OnTransportControllerReceiving); |
470 transport_controller_->SignalGatheringState.connect( | 470 transport_controller_->SignalGatheringState.connect( |
471 this, &WebRtcSession::OnTransportControllerGatheringState); | 471 this, &WebRtcSession::OnTransportControllerGatheringState); |
472 transport_controller_->SignalCandidatesGathered.connect( | 472 transport_controller_->SignalCandidatesGathered.connect( |
473 this, &WebRtcSession::OnTransportControllerCandidatesGathered); | 473 this, &WebRtcSession::OnTransportControllerCandidatesGathered); |
474 transport_controller_->SignalCandidatesRemoved.connect( | 474 transport_controller_->SignalCandidatesRemoved.connect( |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 } | 1103 } |
1104 | 1104 |
1105 bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) { | 1105 bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) { |
1106 if (!remote_description()) { | 1106 if (!remote_description()) { |
1107 LOG(LS_ERROR) << "ProcessIceMessage: ICE candidates can't be added " | 1107 LOG(LS_ERROR) << "ProcessIceMessage: ICE candidates can't be added " |
1108 << "without any remote session description."; | 1108 << "without any remote session description."; |
1109 return false; | 1109 return false; |
1110 } | 1110 } |
1111 | 1111 |
1112 if (!candidate) { | 1112 if (!candidate) { |
1113 LOG(LS_ERROR) << "ProcessIceMessage: Candidate is NULL."; | 1113 LOG(LS_ERROR) << "ProcessIceMessage: Candidate is null."; |
1114 return false; | 1114 return false; |
1115 } | 1115 } |
1116 | 1116 |
1117 bool valid = false; | 1117 bool valid = false; |
1118 bool ready = ReadyToUseRemoteCandidate(candidate, NULL, &valid); | 1118 bool ready = ReadyToUseRemoteCandidate(candidate, nullptr, &valid); |
1119 if (!valid) { | 1119 if (!valid) { |
1120 return false; | 1120 return false; |
1121 } | 1121 } |
1122 | 1122 |
1123 // Add this candidate to the remote session description. | 1123 // Add this candidate to the remote session description. |
1124 if (!mutable_remote_description()->AddCandidate(candidate)) { | 1124 if (!mutable_remote_description()->AddCandidate(candidate)) { |
1125 LOG(LS_ERROR) << "ProcessIceMessage: Candidate cannot be used."; | 1125 LOG(LS_ERROR) << "ProcessIceMessage: Candidate cannot be used."; |
1126 return false; | 1126 return false; |
1127 } | 1127 } |
1128 | 1128 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 std::ostringstream desc; | 1223 std::ostringstream desc; |
1224 desc << "Called in wrong state: " << GetStateString(state); | 1224 desc << "Called in wrong state: " << GetStateString(state); |
1225 return desc.str(); | 1225 return desc.str(); |
1226 } | 1226 } |
1227 | 1227 |
1228 bool WebRtcSession::SendData(const cricket::SendDataParams& params, | 1228 bool WebRtcSession::SendData(const cricket::SendDataParams& params, |
1229 const rtc::CopyOnWriteBuffer& payload, | 1229 const rtc::CopyOnWriteBuffer& payload, |
1230 cricket::SendDataResult* result) { | 1230 cricket::SendDataResult* result) { |
1231 if (!rtp_data_channel_ && !sctp_transport_) { | 1231 if (!rtp_data_channel_ && !sctp_transport_) { |
1232 LOG(LS_ERROR) << "SendData called when rtp_data_channel_ " | 1232 LOG(LS_ERROR) << "SendData called when rtp_data_channel_ " |
1233 << "and sctp_transport_ are NULL."; | 1233 << "and sctp_transport_ are null."; |
1234 return false; | 1234 return false; |
1235 } | 1235 } |
1236 return rtp_data_channel_ | 1236 return rtp_data_channel_ |
1237 ? rtp_data_channel_->SendData(params, payload, result) | 1237 ? rtp_data_channel_->SendData(params, payload, result) |
1238 : network_thread_->Invoke<bool>( | 1238 : network_thread_->Invoke<bool>( |
1239 RTC_FROM_HERE, | 1239 RTC_FROM_HERE, |
1240 Bind(&cricket::SctpTransportInternal::SendData, | 1240 Bind(&cricket::SctpTransportInternal::SendData, |
1241 sctp_transport_.get(), params, payload, result)); | 1241 sctp_transport_.get(), params, payload, result)); |
1242 } | 1242 } |
1243 | 1243 |
(...skipping 16 matching lines...) Expand all Loading... |
1260 &DataChannel::OnDataReceived); | 1260 &DataChannel::OnDataReceived); |
1261 SignalSctpStreamClosedRemotely.connect( | 1261 SignalSctpStreamClosedRemotely.connect( |
1262 webrtc_data_channel, &DataChannel::OnStreamClosedRemotely); | 1262 webrtc_data_channel, &DataChannel::OnStreamClosedRemotely); |
1263 } | 1263 } |
1264 return true; | 1264 return true; |
1265 } | 1265 } |
1266 | 1266 |
1267 void WebRtcSession::DisconnectDataChannel(DataChannel* webrtc_data_channel) { | 1267 void WebRtcSession::DisconnectDataChannel(DataChannel* webrtc_data_channel) { |
1268 if (!rtp_data_channel_ && !sctp_transport_) { | 1268 if (!rtp_data_channel_ && !sctp_transport_) { |
1269 LOG(LS_ERROR) << "DisconnectDataChannel called when rtp_data_channel_ and " | 1269 LOG(LS_ERROR) << "DisconnectDataChannel called when rtp_data_channel_ and " |
1270 "sctp_transport_ are NULL."; | 1270 "sctp_transport_ are null."; |
1271 return; | 1271 return; |
1272 } | 1272 } |
1273 if (rtp_data_channel_) { | 1273 if (rtp_data_channel_) { |
1274 rtp_data_channel_->SignalReadyToSendData.disconnect(webrtc_data_channel); | 1274 rtp_data_channel_->SignalReadyToSendData.disconnect(webrtc_data_channel); |
1275 rtp_data_channel_->SignalDataReceived.disconnect(webrtc_data_channel); | 1275 rtp_data_channel_->SignalDataReceived.disconnect(webrtc_data_channel); |
1276 } else { | 1276 } else { |
1277 SignalSctpReadyToSendData.disconnect(webrtc_data_channel); | 1277 SignalSctpReadyToSendData.disconnect(webrtc_data_channel); |
1278 SignalSctpDataReceived.disconnect(webrtc_data_channel); | 1278 SignalSctpDataReceived.disconnect(webrtc_data_channel); |
1279 SignalSctpStreamClosedRemotely.disconnect(webrtc_data_channel); | 1279 SignalSctpStreamClosedRemotely.disconnect(webrtc_data_channel); |
1280 } | 1280 } |
1281 } | 1281 } |
1282 | 1282 |
1283 void WebRtcSession::AddSctpDataStream(int sid) { | 1283 void WebRtcSession::AddSctpDataStream(int sid) { |
1284 if (!sctp_transport_) { | 1284 if (!sctp_transport_) { |
1285 LOG(LS_ERROR) << "AddSctpDataStream called when sctp_transport_ is NULL."; | 1285 LOG(LS_ERROR) << "AddSctpDataStream called when sctp_transport_ is null."; |
1286 return; | 1286 return; |
1287 } | 1287 } |
1288 network_thread_->Invoke<void>( | 1288 network_thread_->Invoke<void>( |
1289 RTC_FROM_HERE, rtc::Bind(&cricket::SctpTransportInternal::OpenStream, | 1289 RTC_FROM_HERE, rtc::Bind(&cricket::SctpTransportInternal::OpenStream, |
1290 sctp_transport_.get(), sid)); | 1290 sctp_transport_.get(), sid)); |
1291 } | 1291 } |
1292 | 1292 |
1293 void WebRtcSession::RemoveSctpDataStream(int sid) { | 1293 void WebRtcSession::RemoveSctpDataStream(int sid) { |
1294 if (!sctp_transport_) { | 1294 if (!sctp_transport_) { |
1295 LOG(LS_ERROR) << "RemoveSctpDataStream called when sctp_transport_ is " | 1295 LOG(LS_ERROR) << "RemoveSctpDataStream called when sctp_transport_ is " |
1296 << "NULL."; | 1296 << "null."; |
1297 return; | 1297 return; |
1298 } | 1298 } |
1299 network_thread_->Invoke<void>( | 1299 network_thread_->Invoke<void>( |
1300 RTC_FROM_HERE, rtc::Bind(&cricket::SctpTransportInternal::ResetStream, | 1300 RTC_FROM_HERE, rtc::Bind(&cricket::SctpTransportInternal::ResetStream, |
1301 sctp_transport_.get(), sid)); | 1301 sctp_transport_.get(), sid)); |
1302 } | 1302 } |
1303 | 1303 |
1304 bool WebRtcSession::ReadyToSendData() const { | 1304 bool WebRtcSession::ReadyToSendData() const { |
1305 return (rtp_data_channel_ && rtp_data_channel_->ready_to_send_data()) || | 1305 return (rtp_data_channel_ && rtp_data_channel_->ready_to_send_data()) || |
1306 sctp_ready_to_send_data_; | 1306 sctp_ready_to_send_data_; |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 } | 1990 } |
1991 | 1991 |
1992 // Returns false if bundle is enabled and rtcp_mux is disabled. | 1992 // Returns false if bundle is enabled and rtcp_mux is disabled. |
1993 bool WebRtcSession::ValidateBundleSettings(const SessionDescription* desc) { | 1993 bool WebRtcSession::ValidateBundleSettings(const SessionDescription* desc) { |
1994 bool bundle_enabled = desc->HasGroup(cricket::GROUP_TYPE_BUNDLE); | 1994 bool bundle_enabled = desc->HasGroup(cricket::GROUP_TYPE_BUNDLE); |
1995 if (!bundle_enabled) | 1995 if (!bundle_enabled) |
1996 return true; | 1996 return true; |
1997 | 1997 |
1998 const cricket::ContentGroup* bundle_group = | 1998 const cricket::ContentGroup* bundle_group = |
1999 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); | 1999 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); |
2000 RTC_DCHECK(bundle_group != NULL); | 2000 RTC_DCHECK(bundle_group != nullptr); |
2001 | 2001 |
2002 const cricket::ContentInfos& contents = desc->contents(); | 2002 const cricket::ContentInfos& contents = desc->contents(); |
2003 for (cricket::ContentInfos::const_iterator citer = contents.begin(); | 2003 for (cricket::ContentInfos::const_iterator citer = contents.begin(); |
2004 citer != contents.end(); ++citer) { | 2004 citer != contents.end(); ++citer) { |
2005 const cricket::ContentInfo* content = (&*citer); | 2005 const cricket::ContentInfo* content = (&*citer); |
2006 RTC_DCHECK(content != NULL); | 2006 RTC_DCHECK(content != nullptr); |
2007 if (bundle_group->HasContentName(content->name) && | 2007 if (bundle_group->HasContentName(content->name) && |
2008 !content->rejected && content->type == cricket::NS_JINGLE_RTP) { | 2008 !content->rejected && content->type == cricket::NS_JINGLE_RTP) { |
2009 if (!HasRtcpMuxEnabled(content)) | 2009 if (!HasRtcpMuxEnabled(content)) |
2010 return false; | 2010 return false; |
2011 } | 2011 } |
2012 } | 2012 } |
2013 // RTCP-MUX is enabled in all the contents. | 2013 // RTCP-MUX is enabled in all the contents. |
2014 return true; | 2014 return true; |
2015 } | 2015 } |
2016 | 2016 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 if (transport_controller_->GetStats(name, &stats)) { | 2191 if (transport_controller_->GetStats(name, &stats)) { |
2192 ReportBestConnectionState(stats); | 2192 ReportBestConnectionState(stats); |
2193 ReportNegotiatedCiphers(stats); | 2193 ReportNegotiatedCiphers(stats); |
2194 } | 2194 } |
2195 } | 2195 } |
2196 } | 2196 } |
2197 // Walk through the ConnectionInfos to gather best connection usage | 2197 // Walk through the ConnectionInfos to gather best connection usage |
2198 // for IPv4 and IPv6. | 2198 // for IPv4 and IPv6. |
2199 void WebRtcSession::ReportBestConnectionState( | 2199 void WebRtcSession::ReportBestConnectionState( |
2200 const cricket::TransportStats& stats) { | 2200 const cricket::TransportStats& stats) { |
2201 RTC_DCHECK(metrics_observer_ != NULL); | 2201 RTC_DCHECK(metrics_observer_ != nullptr); |
2202 for (cricket::TransportChannelStatsList::const_iterator it = | 2202 for (cricket::TransportChannelStatsList::const_iterator it = |
2203 stats.channel_stats.begin(); | 2203 stats.channel_stats.begin(); |
2204 it != stats.channel_stats.end(); ++it) { | 2204 it != stats.channel_stats.end(); ++it) { |
2205 for (cricket::ConnectionInfos::const_iterator it_info = | 2205 for (cricket::ConnectionInfos::const_iterator it_info = |
2206 it->connection_infos.begin(); | 2206 it->connection_infos.begin(); |
2207 it_info != it->connection_infos.end(); ++it_info) { | 2207 it_info != it->connection_infos.end(); ++it_info) { |
2208 if (!it_info->best_connection) { | 2208 if (!it_info->best_connection) { |
2209 continue; | 2209 continue; |
2210 } | 2210 } |
2211 | 2211 |
(...skipping 29 matching lines...) Expand all Loading... |
2241 RTC_CHECK(0); | 2241 RTC_CHECK(0); |
2242 } | 2242 } |
2243 | 2243 |
2244 return; | 2244 return; |
2245 } | 2245 } |
2246 } | 2246 } |
2247 } | 2247 } |
2248 | 2248 |
2249 void WebRtcSession::ReportNegotiatedCiphers( | 2249 void WebRtcSession::ReportNegotiatedCiphers( |
2250 const cricket::TransportStats& stats) { | 2250 const cricket::TransportStats& stats) { |
2251 RTC_DCHECK(metrics_observer_ != NULL); | 2251 RTC_DCHECK(metrics_observer_ != nullptr); |
2252 if (!dtls_enabled_ || stats.channel_stats.empty()) { | 2252 if (!dtls_enabled_ || stats.channel_stats.empty()) { |
2253 return; | 2253 return; |
2254 } | 2254 } |
2255 | 2255 |
2256 int srtp_crypto_suite = stats.channel_stats[0].srtp_crypto_suite; | 2256 int srtp_crypto_suite = stats.channel_stats[0].srtp_crypto_suite; |
2257 int ssl_cipher_suite = stats.channel_stats[0].ssl_cipher_suite; | 2257 int ssl_cipher_suite = stats.channel_stats[0].ssl_cipher_suite; |
2258 if (srtp_crypto_suite == rtc::SRTP_INVALID_CRYPTO_SUITE && | 2258 if (srtp_crypto_suite == rtc::SRTP_INVALID_CRYPTO_SUITE && |
2259 ssl_cipher_suite == rtc::TLS_NULL_WITH_NULL_NULL) { | 2259 ssl_cipher_suite == rtc::TLS_NULL_WITH_NULL_NULL) { |
2260 return; | 2260 return; |
2261 } | 2261 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2359 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); | 2359 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); |
2360 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); | 2360 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); |
2361 transport_controller_->DestroyDtlsTransport( | 2361 transport_controller_->DestroyDtlsTransport( |
2362 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 2362 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
2363 if (need_to_delete_rtcp) { | 2363 if (need_to_delete_rtcp) { |
2364 transport_controller_->DestroyDtlsTransport( | 2364 transport_controller_->DestroyDtlsTransport( |
2365 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 2365 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
2366 } | 2366 } |
2367 } | 2367 } |
2368 } // namespace webrtc | 2368 } // namespace webrtc |
OLD | NEW |