| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 if (tinfo->description.ice_ufrag.empty() || | 225 if (tinfo->description.ice_ufrag.empty() || |
| 226 tinfo->description.ice_pwd.empty()) { | 226 tinfo->description.ice_pwd.empty()) { |
| 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 GetAudioSsrcByTrackId(const SessionDescription* session_description, | |
| 235 const std::string& track_id, | |
| 236 uint32_t* ssrc) { | |
| 237 const cricket::ContentInfo* audio_info = | |
| 238 cricket::GetFirstAudioContent(session_description); | |
| 239 if (!audio_info) { | |
| 240 LOG(LS_ERROR) << "Audio not used in this call"; | |
| 241 return false; | |
| 242 } | |
| 243 | |
| 244 const cricket::MediaContentDescription* audio_content = | |
| 245 static_cast<const cricket::MediaContentDescription*>( | |
| 246 audio_info->description); | |
| 247 const cricket::StreamParams* stream = | |
| 248 cricket::GetStreamByIds(audio_content->streams(), "", track_id); | |
| 249 if (!stream) { | |
| 250 return false; | |
| 251 } | |
| 252 | |
| 253 *ssrc = stream->first_ssrc(); | |
| 254 return true; | |
| 255 } | |
| 256 | |
| 257 static bool GetTrackIdBySsrc(const SessionDescription* session_description, | 234 static bool GetTrackIdBySsrc(const SessionDescription* session_description, |
| 258 uint32_t ssrc, | 235 uint32_t ssrc, |
| 259 std::string* track_id) { | 236 std::string* track_id) { |
| 260 RTC_DCHECK(track_id != NULL); | 237 RTC_DCHECK(track_id != NULL); |
| 261 | 238 |
| 262 const cricket::ContentInfo* audio_info = | 239 const cricket::ContentInfo* audio_info = |
| 263 cricket::GetFirstAudioContent(session_description); | 240 cricket::GetFirstAudioContent(session_description); |
| 264 if (audio_info) { | 241 if (audio_info) { |
| 265 const cricket::MediaContentDescription* audio_content = | 242 const cricket::MediaContentDescription* audio_content = |
| 266 static_cast<const cricket::MediaContentDescription*>( | 243 static_cast<const cricket::MediaContentDescription*>( |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 if (sctp_transport_) { | 493 if (sctp_transport_) { |
| 517 SignalDataChannelDestroyed(); | 494 SignalDataChannelDestroyed(); |
| 518 network_thread_->Invoke<void>( | 495 network_thread_->Invoke<void>( |
| 519 RTC_FROM_HERE, rtc::Bind(&WebRtcSession::DestroySctpTransport_n, this)); | 496 RTC_FROM_HERE, rtc::Bind(&WebRtcSession::DestroySctpTransport_n, this)); |
| 520 } | 497 } |
| 521 #ifdef HAVE_QUIC | 498 #ifdef HAVE_QUIC |
| 522 if (quic_data_transport_) { | 499 if (quic_data_transport_) { |
| 523 quic_data_transport_.reset(); | 500 quic_data_transport_.reset(); |
| 524 } | 501 } |
| 525 #endif | 502 #endif |
| 526 SignalDestroyed(); | |
| 527 | 503 |
| 528 LOG(LS_INFO) << "Session: " << id() << " is destroyed."; | 504 LOG(LS_INFO) << "Session: " << id() << " is destroyed."; |
| 529 } | 505 } |
| 530 | 506 |
| 531 bool WebRtcSession::Initialize( | 507 bool WebRtcSession::Initialize( |
| 532 const PeerConnectionFactoryInterface::Options& options, | 508 const PeerConnectionFactoryInterface::Options& options, |
| 533 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 509 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
| 534 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 510 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
| 535 bundle_policy_ = rtc_configuration.bundle_policy; | 511 bundle_policy_ = rtc_configuration.bundle_policy; |
| 536 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; | 512 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 return webrtc::GetTrackIdBySsrc(remote_description()->description(), ssrc, | 1217 return webrtc::GetTrackIdBySsrc(remote_description()->description(), ssrc, |
| 1242 track_id); | 1218 track_id); |
| 1243 } | 1219 } |
| 1244 | 1220 |
| 1245 std::string WebRtcSession::BadStateErrMsg(State state) { | 1221 std::string WebRtcSession::BadStateErrMsg(State state) { |
| 1246 std::ostringstream desc; | 1222 std::ostringstream desc; |
| 1247 desc << "Called in wrong state: " << GetStateString(state); | 1223 desc << "Called in wrong state: " << GetStateString(state); |
| 1248 return desc.str(); | 1224 return desc.str(); |
| 1249 } | 1225 } |
| 1250 | 1226 |
| 1251 bool WebRtcSession::CanInsertDtmf(const std::string& track_id) { | |
| 1252 RTC_DCHECK(signaling_thread()->IsCurrent()); | |
| 1253 if (!voice_channel_) { | |
| 1254 LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists."; | |
| 1255 return false; | |
| 1256 } | |
| 1257 uint32_t send_ssrc = 0; | |
| 1258 // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc | |
| 1259 // exists. | |
| 1260 if (!local_description() || | |
| 1261 !GetAudioSsrcByTrackId(local_description()->description(), track_id, | |
| 1262 &send_ssrc)) { | |
| 1263 LOG(LS_ERROR) << "CanInsertDtmf: Track does not exist: " << track_id; | |
| 1264 return false; | |
| 1265 } | |
| 1266 return voice_channel_->CanInsertDtmf(); | |
| 1267 } | |
| 1268 | |
| 1269 bool WebRtcSession::InsertDtmf(const std::string& track_id, | |
| 1270 int code, int duration) { | |
| 1271 RTC_DCHECK(signaling_thread()->IsCurrent()); | |
| 1272 if (!voice_channel_) { | |
| 1273 LOG(LS_ERROR) << "InsertDtmf: No audio channel exists."; | |
| 1274 return false; | |
| 1275 } | |
| 1276 uint32_t send_ssrc = 0; | |
| 1277 if (!(local_description() && | |
| 1278 GetAudioSsrcByTrackId(local_description()->description(), | |
| 1279 track_id, &send_ssrc))) { | |
| 1280 LOG(LS_ERROR) << "InsertDtmf: Track does not exist: " << track_id; | |
| 1281 return false; | |
| 1282 } | |
| 1283 if (!voice_channel_->InsertDtmf(send_ssrc, code, duration)) { | |
| 1284 LOG(LS_ERROR) << "Failed to insert DTMF to channel."; | |
| 1285 return false; | |
| 1286 } | |
| 1287 return true; | |
| 1288 } | |
| 1289 | |
| 1290 sigslot::signal0<>* WebRtcSession::GetOnDestroyedSignal() { | |
| 1291 return &SignalDestroyed; | |
| 1292 } | |
| 1293 | |
| 1294 bool WebRtcSession::SendData(const cricket::SendDataParams& params, | 1227 bool WebRtcSession::SendData(const cricket::SendDataParams& params, |
| 1295 const rtc::CopyOnWriteBuffer& payload, | 1228 const rtc::CopyOnWriteBuffer& payload, |
| 1296 cricket::SendDataResult* result) { | 1229 cricket::SendDataResult* result) { |
| 1297 if (!rtp_data_channel_ && !sctp_transport_) { | 1230 if (!rtp_data_channel_ && !sctp_transport_) { |
| 1298 LOG(LS_ERROR) << "SendData called when rtp_data_channel_ " | 1231 LOG(LS_ERROR) << "SendData called when rtp_data_channel_ " |
| 1299 << "and sctp_transport_ are NULL."; | 1232 << "and sctp_transport_ are NULL."; |
| 1300 return false; | 1233 return false; |
| 1301 } | 1234 } |
| 1302 return rtp_data_channel_ | 1235 return rtp_data_channel_ |
| 1303 ? rtp_data_channel_->SendData(params, payload, result) | 1236 ? rtp_data_channel_->SendData(params, payload, result) |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); | 2358 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); |
| 2426 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); | 2359 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); |
| 2427 transport_controller_->DestroyDtlsTransport( | 2360 transport_controller_->DestroyDtlsTransport( |
| 2428 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 2361 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 2429 if (need_to_delete_rtcp) { | 2362 if (need_to_delete_rtcp) { |
| 2430 transport_controller_->DestroyDtlsTransport( | 2363 transport_controller_->DestroyDtlsTransport( |
| 2431 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 2364 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
| 2432 } | 2365 } |
| 2433 } | 2366 } |
| 2434 } // namespace webrtc | 2367 } // namespace webrtc |
| OLD | NEW |