OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 } | 454 } |
455 | 455 |
456 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) { | 456 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) { |
457 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0); | 457 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0); |
458 } | 458 } |
459 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) { | 459 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) { |
460 session_options->recv_video = (rtc_options.offer_to_receive_video > 0); | 460 session_options->recv_video = (rtc_options.offer_to_receive_video > 0); |
461 } | 461 } |
462 | 462 |
463 session_options->vad_enabled = rtc_options.voice_activity_detection; | 463 session_options->vad_enabled = rtc_options.voice_activity_detection; |
464 session_options->transport_options.ice_restart = rtc_options.ice_restart; | 464 session_options->audio_transport_options.ice_restart = |
465 rtc_options.ice_restart; | |
466 session_options->video_transport_options.ice_restart = | |
467 rtc_options.ice_restart; | |
468 session_options->data_transport_options.ice_restart = rtc_options.ice_restart; | |
465 session_options->bundle_enabled = rtc_options.use_rtp_mux; | 469 session_options->bundle_enabled = rtc_options.use_rtp_mux; |
466 | 470 |
467 return true; | 471 return true; |
468 } | 472 } |
469 | 473 |
470 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, | 474 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, |
471 cricket::MediaSessionOptions* session_options) { | 475 cricket::MediaSessionOptions* session_options) { |
472 bool value = false; | 476 bool value = false; |
473 size_t mandatory_constraints_satisfied = 0; | 477 size_t mandatory_constraints_satisfied = 0; |
474 | 478 |
(...skipping 25 matching lines...) Expand all Loading... | |
500 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, | 504 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, |
501 &mandatory_constraints_satisfied)) { | 505 &mandatory_constraints_satisfied)) { |
502 session_options->bundle_enabled = value; | 506 session_options->bundle_enabled = value; |
503 } else { | 507 } else { |
504 // kUseRtpMux defaults to true according to spec. | 508 // kUseRtpMux defaults to true according to spec. |
505 session_options->bundle_enabled = true; | 509 session_options->bundle_enabled = true; |
506 } | 510 } |
507 | 511 |
508 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, | 512 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, |
509 &value, &mandatory_constraints_satisfied)) { | 513 &value, &mandatory_constraints_satisfied)) { |
510 session_options->transport_options.ice_restart = value; | 514 session_options->audio_transport_options.ice_restart = value; |
515 session_options->video_transport_options.ice_restart = value; | |
516 session_options->data_transport_options.ice_restart = value; | |
511 } else { | 517 } else { |
512 // kIceRestart defaults to false according to spec. | 518 // kIceRestart defaults to false according to spec. |
513 session_options->transport_options.ice_restart = false; | 519 session_options->audio_transport_options.ice_restart = false; |
520 session_options->video_transport_options.ice_restart = false; | |
521 session_options->data_transport_options.ice_restart = false; | |
514 } | 522 } |
515 | 523 |
516 if (!constraints) { | 524 if (!constraints) { |
517 return true; | 525 return true; |
518 } | 526 } |
519 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); | 527 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); |
520 } | 528 } |
521 | 529 |
522 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, | 530 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, |
523 cricket::ServerAddresses* stun_servers, | 531 cricket::ServerAddresses* stun_servers, |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 std::string error; | 963 std::string error; |
956 if (!session_->SetLocalDescription(desc, &error)) { | 964 if (!session_->SetLocalDescription(desc, &error)) { |
957 PostSetSessionDescriptionFailure(observer, error); | 965 PostSetSessionDescriptionFailure(observer, error); |
958 return; | 966 return; |
959 } | 967 } |
960 | 968 |
961 // If setting the description decided our SSL role, allocate any necessary | 969 // If setting the description decided our SSL role, allocate any necessary |
962 // SCTP sids. | 970 // SCTP sids. |
963 rtc::SSLRole role; | 971 rtc::SSLRole role; |
964 if (session_->data_channel_type() == cricket::DCT_SCTP && | 972 if (session_->data_channel_type() == cricket::DCT_SCTP && |
965 session_->GetSslRole(&role)) { | 973 session_->data_channel() && |
974 session_->GetSslRole(session_->data_channel()->transport_name(), &role)) { | |
pthatcher1
2016/01/07 21:12:02
Can you make a method so you can call like this?
Taylor Brandstetter
2016/01/07 22:25:55
This method will probably be refactored away when
| |
966 AllocateSctpSids(role); | 975 AllocateSctpSids(role); |
967 } | 976 } |
968 | 977 |
969 // Update state and SSRC of local MediaStreams and DataChannels based on the | 978 // Update state and SSRC of local MediaStreams and DataChannels based on the |
970 // local session description. | 979 // local session description. |
971 const cricket::ContentInfo* audio_content = | 980 const cricket::ContentInfo* audio_content = |
972 GetFirstAudioContent(desc->description()); | 981 GetFirstAudioContent(desc->description()); |
973 if (audio_content) { | 982 if (audio_content) { |
974 if (audio_content->rejected) { | 983 if (audio_content->rejected) { |
975 RemoveTracks(cricket::MEDIA_TYPE_AUDIO); | 984 RemoveTracks(cricket::MEDIA_TYPE_AUDIO); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1033 std::string error; | 1042 std::string error; |
1034 if (!session_->SetRemoteDescription(desc, &error)) { | 1043 if (!session_->SetRemoteDescription(desc, &error)) { |
1035 PostSetSessionDescriptionFailure(observer, error); | 1044 PostSetSessionDescriptionFailure(observer, error); |
1036 return; | 1045 return; |
1037 } | 1046 } |
1038 | 1047 |
1039 // If setting the description decided our SSL role, allocate any necessary | 1048 // If setting the description decided our SSL role, allocate any necessary |
1040 // SCTP sids. | 1049 // SCTP sids. |
1041 rtc::SSLRole role; | 1050 rtc::SSLRole role; |
1042 if (session_->data_channel_type() == cricket::DCT_SCTP && | 1051 if (session_->data_channel_type() == cricket::DCT_SCTP && |
1043 session_->GetSslRole(&role)) { | 1052 session_->data_channel() && |
1053 session_->GetSslRole(session_->data_channel()->transport_name(), &role)) { | |
1044 AllocateSctpSids(role); | 1054 AllocateSctpSids(role); |
1045 } | 1055 } |
1046 | 1056 |
1047 const cricket::SessionDescription* remote_desc = desc->description(); | 1057 const cricket::SessionDescription* remote_desc = desc->description(); |
1048 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); | 1058 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); |
1049 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); | 1059 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); |
1050 const cricket::AudioContentDescription* audio_desc = | 1060 const cricket::AudioContentDescription* audio_desc = |
1051 GetFirstAudioContentDescription(remote_desc); | 1061 GetFirstAudioContentDescription(remote_desc); |
1052 const cricket::VideoContentDescription* video_desc = | 1062 const cricket::VideoContentDescription* video_desc = |
1053 GetFirstVideoContentDescription(remote_desc); | 1063 GetFirstVideoContentDescription(remote_desc); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1826 if (session_->data_channel_type() == cricket::DCT_NONE) { | 1836 if (session_->data_channel_type() == cricket::DCT_NONE) { |
1827 LOG(LS_ERROR) | 1837 LOG(LS_ERROR) |
1828 << "InternalCreateDataChannel: Data is not supported in this call."; | 1838 << "InternalCreateDataChannel: Data is not supported in this call."; |
1829 return nullptr; | 1839 return nullptr; |
1830 } | 1840 } |
1831 InternalDataChannelInit new_config = | 1841 InternalDataChannelInit new_config = |
1832 config ? (*config) : InternalDataChannelInit(); | 1842 config ? (*config) : InternalDataChannelInit(); |
1833 if (session_->data_channel_type() == cricket::DCT_SCTP) { | 1843 if (session_->data_channel_type() == cricket::DCT_SCTP) { |
1834 if (new_config.id < 0) { | 1844 if (new_config.id < 0) { |
1835 rtc::SSLRole role; | 1845 rtc::SSLRole role; |
1836 if (session_->GetSslRole(&role) && | 1846 if ((session_->data_channel() && |
1847 session_->GetSslRole(session_->data_channel()->transport_name(), | |
1848 &role)) && | |
1837 !sid_allocator_.AllocateSid(role, &new_config.id)) { | 1849 !sid_allocator_.AllocateSid(role, &new_config.id)) { |
1838 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel."; | 1850 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel."; |
1839 return nullptr; | 1851 return nullptr; |
1840 } | 1852 } |
1841 } else if (!sid_allocator_.ReserveSid(new_config.id)) { | 1853 } else if (!sid_allocator_.ReserveSid(new_config.id)) { |
1842 LOG(LS_ERROR) << "Failed to create a SCTP data channel " | 1854 LOG(LS_ERROR) << "Failed to create a SCTP data channel " |
1843 << "because the id is already in use or out of range."; | 1855 << "because the id is already in use or out of range."; |
1844 return nullptr; | 1856 return nullptr; |
1845 } | 1857 } |
1846 } | 1858 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2007 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2019 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2008 for (const auto& channel : sctp_data_channels_) { | 2020 for (const auto& channel : sctp_data_channels_) { |
2009 if (channel->id() == sid) { | 2021 if (channel->id() == sid) { |
2010 return channel; | 2022 return channel; |
2011 } | 2023 } |
2012 } | 2024 } |
2013 return nullptr; | 2025 return nullptr; |
2014 } | 2026 } |
2015 | 2027 |
2016 } // namespace webrtc | 2028 } // namespace webrtc |
OLD | NEW |