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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 } | 506 } |
507 | 507 |
508 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, | 508 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, |
509 &mandatory_constraints_satisfied)) { | 509 &mandatory_constraints_satisfied)) { |
510 session_options->bundle_enabled = value; | 510 session_options->bundle_enabled = value; |
511 } else { | 511 } else { |
512 // kUseRtpMux defaults to true according to spec. | 512 // kUseRtpMux defaults to true according to spec. |
513 session_options->bundle_enabled = true; | 513 session_options->bundle_enabled = true; |
514 } | 514 } |
515 | 515 |
516 bool ice_restart = false; | |
517 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, | |
518 &value, &mandatory_constraints_satisfied)) { | |
519 // kIceRestart defaults to false according to spec. | |
520 ice_restart = true; | |
521 } | |
522 for (auto& kv : session_options->transport_options) { | |
523 kv.second.ice_restart = ice_restart; | |
524 } | |
525 | |
pthatcher1
2016/08/22 23:02:29
There is so much refactoring in this CL now that i
honghaiz3
2016/08/23 00:52:28
Reverted this change. This part is basically a no-
| |
526 if (!constraints) { | 516 if (!constraints) { |
527 return true; | 517 return true; |
528 } | 518 } |
529 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); | 519 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); |
530 } | 520 } |
531 | 521 |
532 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, | 522 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, |
533 cricket::ServerAddresses* stun_servers, | 523 cricket::ServerAddresses* stun_servers, |
534 std::vector<cricket::RelayServerConfig>* turn_servers) { | 524 std::vector<cricket::RelayServerConfig>* turn_servers) { |
535 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { | 525 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 | 614 |
625 session_.reset(new WebRtcSession( | 615 session_.reset(new WebRtcSession( |
626 media_controller_.get(), factory_->network_thread(), | 616 media_controller_.get(), factory_->network_thread(), |
627 factory_->worker_thread(), factory_->signaling_thread(), | 617 factory_->worker_thread(), factory_->signaling_thread(), |
628 port_allocator_.get(), | 618 port_allocator_.get(), |
629 std::unique_ptr<cricket::TransportController>( | 619 std::unique_ptr<cricket::TransportController>( |
630 factory_->CreateTransportController(port_allocator_.get())))); | 620 factory_->CreateTransportController(port_allocator_.get())))); |
631 | 621 |
632 stats_.reset(new StatsCollector(this)); | 622 stats_.reset(new StatsCollector(this)); |
633 | 623 |
624 ice_renomination_ = configuration.ice_renomination; | |
625 | |
634 // Initialize the WebRtcSession. It creates transport channels etc. | 626 // Initialize the WebRtcSession. It creates transport channels etc. |
635 if (!session_->Initialize(factory_->options(), std::move(cert_generator), | 627 if (!session_->Initialize(factory_->options(), std::move(cert_generator), |
636 configuration)) { | 628 configuration)) { |
637 return false; | 629 return false; |
638 } | 630 } |
639 | 631 |
640 // Register PeerConnection as receiver of local ice candidates. | 632 // Register PeerConnection as receiver of local ice candidates. |
641 // All the callbacks will be posted to the application from PeerConnection. | 633 // All the callbacks will be posted to the application from PeerConnection. |
642 session_->RegisterIceObserver(this); | 634 session_->RegisterIceObserver(this); |
643 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); | 635 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 if (!network_thread()->Invoke<bool>( | 1245 if (!network_thread()->Invoke<bool>( |
1254 RTC_FROM_HERE, | 1246 RTC_FROM_HERE, |
1255 rtc::Bind(&PeerConnection::ReconfigurePortAllocator_n, this, | 1247 rtc::Bind(&PeerConnection::ReconfigurePortAllocator_n, this, |
1256 configuration))) { | 1248 configuration))) { |
1257 return false; | 1249 return false; |
1258 } | 1250 } |
1259 } | 1251 } |
1260 | 1252 |
1261 // TODO(deadbeef): Shouldn't have to hop to the worker thread twice... | 1253 // TODO(deadbeef): Shouldn't have to hop to the worker thread twice... |
1262 session_->SetIceConfig(session_->ParseIceConfig(configuration)); | 1254 session_->SetIceConfig(session_->ParseIceConfig(configuration)); |
1255 | |
1256 ice_renomination_ = configuration.ice_renomination; | |
1263 return true; | 1257 return true; |
1264 } | 1258 } |
1265 | 1259 |
1266 bool PeerConnection::AddIceCandidate( | 1260 bool PeerConnection::AddIceCandidate( |
1267 const IceCandidateInterface* ice_candidate) { | 1261 const IceCandidateInterface* ice_candidate) { |
1268 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); | 1262 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
1269 if (IsClosed()) { | 1263 if (IsClosed()) { |
1270 return false; | 1264 return false; |
1271 } | 1265 } |
1272 return session_->ProcessIceMessage(ice_candidate); | 1266 return session_->ProcessIceMessage(ice_candidate); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 msg->error = error; | 1593 msg->error = error; |
1600 signaling_thread()->Post(RTC_FROM_HERE, this, | 1594 signaling_thread()->Post(RTC_FROM_HERE, this, |
1601 MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg); | 1595 MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg); |
1602 } | 1596 } |
1603 | 1597 |
1604 bool PeerConnection::GetOptionsForOffer( | 1598 bool PeerConnection::GetOptionsForOffer( |
1605 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 1599 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
1606 cricket::MediaSessionOptions* session_options) { | 1600 cricket::MediaSessionOptions* session_options) { |
1607 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of | 1601 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of |
1608 // ContentInfos. | 1602 // ContentInfos. |
1609 if (session_->local_description()) { | 1603 InitializeMediaSessionOptions(true, session_options); |
pthatcher1
2016/08/22 23:02:29
Can you put a "bool is_offer = true" and then Init
honghaiz3
2016/08/23 00:52:28
This method is removed now.
| |
1610 for (const cricket::ContentInfo& content : | 1604 |
1611 session_->local_description()->description()->contents()) { | |
1612 session_options->transport_options[content.name] = | |
1613 cricket::TransportOptions(); | |
1614 } | |
1615 } | |
1616 if (!ExtractMediaSessionOptions(rtc_options, true, session_options)) { | 1605 if (!ExtractMediaSessionOptions(rtc_options, true, session_options)) { |
1617 return false; | 1606 return false; |
1618 } | 1607 } |
1619 | 1608 |
1620 AddSendStreams(session_options, senders_, rtp_data_channels_); | 1609 AddSendStreams(session_options, senders_, rtp_data_channels_); |
1621 // Offer to receive audio/video if the constraint is not set and there are | 1610 // Offer to receive audio/video if the constraint is not set and there are |
1622 // send streams, or we're currently receiving. | 1611 // send streams, or we're currently receiving. |
1623 if (rtc_options.offer_to_receive_audio == RTCOfferAnswerOptions::kUndefined) { | 1612 if (rtc_options.offer_to_receive_audio == RTCOfferAnswerOptions::kUndefined) { |
1624 session_options->recv_audio = | 1613 session_options->recv_audio = |
1625 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO) || | 1614 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO) || |
(...skipping 16 matching lines...) Expand all Loading... | |
1642 // people won't try to use them. | 1631 // people won't try to use them. |
1643 if (HasDataChannels() && session_->data_channel_type() != cricket::DCT_RTP) { | 1632 if (HasDataChannels() && session_->data_channel_type() != cricket::DCT_RTP) { |
1644 session_options->data_channel_type = session_->data_channel_type(); | 1633 session_options->data_channel_type = session_->data_channel_type(); |
1645 } | 1634 } |
1646 | 1635 |
1647 session_options->rtcp_cname = rtcp_cname_; | 1636 session_options->rtcp_cname = rtcp_cname_; |
1648 session_options->crypto_options = factory_->options().crypto_options; | 1637 session_options->crypto_options = factory_->options().crypto_options; |
1649 return true; | 1638 return true; |
1650 } | 1639 } |
1651 | 1640 |
1641 void PeerConnection::InitializeMediaSessionOptions( | |
1642 bool is_offer, | |
1643 cricket::MediaSessionOptions* session_options) { | |
1644 if (is_offer) { | |
1645 if (session_->local_description()) { | |
1646 for (const cricket::ContentInfo& content : | |
1647 session_->local_description()->description()->contents()) { | |
1648 session_options->transport_options[content.name] = | |
1649 MakeTransportOptions(); | |
1650 } | |
1651 } | |
1652 } else { | |
1653 session_options->recv_audio = false; | |
1654 session_options->recv_video = false; | |
1655 if (session_->remote_description()) { | |
1656 // Initialize the transport_options map. | |
1657 for (const cricket::ContentInfo& content : | |
1658 session_->remote_description()->description()->contents()) { | |
1659 session_options->transport_options[content.name] = | |
1660 MakeTransportOptions(); | |
1661 } | |
1662 } | |
1663 } | |
1664 // Add transport options so that ice_renomination can be set properly to the | |
1665 // respective transport option. | |
1666 if (session_options->transport_options.empty()) { | |
1667 std::vector<std::string> content_names = { | |
1668 cricket::CN_AUDIO, cricket::CN_VIDEO, cricket::CN_DATA}; | |
pthatcher1
2016/08/22 23:02:29
Isn't it kind of dangerous to assume we want these
honghaiz3
2016/08/23 00:52:27
Done.
| |
1669 for (auto& content_name : content_names) { | |
1670 session_options->transport_options[content_name] = MakeTransportOptions(); | |
1671 } | |
1672 } | |
1673 } | |
1674 | |
1652 void PeerConnection::FinishOptionsForAnswer( | 1675 void PeerConnection::FinishOptionsForAnswer( |
1653 cricket::MediaSessionOptions* session_options) { | 1676 cricket::MediaSessionOptions* session_options) { |
1654 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of | 1677 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of |
1655 // ContentInfos. | 1678 // ContentInfos. |
1656 if (session_->remote_description()) { | |
1657 // Initialize the transport_options map. | |
1658 for (const cricket::ContentInfo& content : | |
1659 session_->remote_description()->description()->contents()) { | |
1660 session_options->transport_options[content.name] = | |
1661 cricket::TransportOptions(); | |
1662 } | |
1663 } | |
1664 AddSendStreams(session_options, senders_, rtp_data_channels_); | 1679 AddSendStreams(session_options, senders_, rtp_data_channels_); |
1665 session_options->bundle_enabled = | 1680 session_options->bundle_enabled = |
1666 session_options->bundle_enabled && | 1681 session_options->bundle_enabled && |
1667 (session_options->has_audio() || session_options->has_video() || | 1682 (session_options->has_audio() || session_options->has_video() || |
1668 session_options->has_data()); | 1683 session_options->has_data()); |
1669 | 1684 |
1670 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams | 1685 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams |
1671 // are not signaled in the SDP so does not go through that path and must be | 1686 // are not signaled in the SDP so does not go through that path and must be |
1672 // handled here. | 1687 // handled here. |
1673 // Intentionally unset the data channel type for RTP data channel. Otherwise | 1688 // Intentionally unset the data channel type for RTP data channel. Otherwise |
1674 // the RTP data channels would be successfully negotiated by default and the | 1689 // the RTP data channels would be successfully negotiated by default and the |
1675 // unit tests in WebRtcDataBrowserTest will fail when building with chromium. | 1690 // unit tests in WebRtcDataBrowserTest will fail when building with chromium. |
1676 // We want to leave RTP data channels broken, so people won't try to use them. | 1691 // We want to leave RTP data channels broken, so people won't try to use them. |
1677 if (session_->data_channel_type() != cricket::DCT_RTP) { | 1692 if (session_->data_channel_type() != cricket::DCT_RTP) { |
1678 session_options->data_channel_type = session_->data_channel_type(); | 1693 session_options->data_channel_type = session_->data_channel_type(); |
1679 } | 1694 } |
1680 session_options->crypto_options = factory_->options().crypto_options; | 1695 session_options->crypto_options = factory_->options().crypto_options; |
1681 } | 1696 } |
1682 | 1697 |
1683 bool PeerConnection::GetOptionsForAnswer( | 1698 bool PeerConnection::GetOptionsForAnswer( |
1684 const MediaConstraintsInterface* constraints, | 1699 const MediaConstraintsInterface* constraints, |
1685 cricket::MediaSessionOptions* session_options) { | 1700 cricket::MediaSessionOptions* session_options) { |
1686 session_options->recv_audio = false; | 1701 InitializeMediaSessionOptions(false, session_options); |
1687 session_options->recv_video = false; | |
1688 if (!ParseConstraintsForAnswer(constraints, session_options)) { | 1702 if (!ParseConstraintsForAnswer(constraints, session_options)) { |
1689 return false; | 1703 return false; |
1690 } | 1704 } |
1691 session_options->rtcp_cname = rtcp_cname_; | 1705 session_options->rtcp_cname = rtcp_cname_; |
1692 | 1706 |
1693 FinishOptionsForAnswer(session_options); | 1707 FinishOptionsForAnswer(session_options); |
1694 return true; | 1708 return true; |
1695 } | 1709 } |
1696 | 1710 |
1697 bool PeerConnection::GetOptionsForAnswer( | 1711 bool PeerConnection::GetOptionsForAnswer( |
1698 const RTCOfferAnswerOptions& options, | 1712 const RTCOfferAnswerOptions& options, |
1699 cricket::MediaSessionOptions* session_options) { | 1713 cricket::MediaSessionOptions* session_options) { |
1700 session_options->recv_audio = false; | 1714 InitializeMediaSessionOptions(false, session_options); |
1701 session_options->recv_video = false; | |
1702 if (!ExtractMediaSessionOptions(options, false, session_options)) { | 1715 if (!ExtractMediaSessionOptions(options, false, session_options)) { |
1703 return false; | 1716 return false; |
1704 } | 1717 } |
1705 session_options->rtcp_cname = rtcp_cname_; | 1718 session_options->rtcp_cname = rtcp_cname_; |
1706 | 1719 |
1707 FinishOptionsForAnswer(session_options); | 1720 FinishOptionsForAnswer(session_options); |
1708 return true; | 1721 return true; |
1709 } | 1722 } |
1710 | 1723 |
1711 void PeerConnection::RemoveTracks(cricket::MediaType media_type) { | 1724 void PeerConnection::RemoveTracks(cricket::MediaType media_type) { |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2323 | 2336 |
2324 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, | 2337 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, |
2325 int64_t max_size_bytes) { | 2338 int64_t max_size_bytes) { |
2326 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); | 2339 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); |
2327 } | 2340 } |
2328 | 2341 |
2329 void PeerConnection::StopRtcEventLog_w() { | 2342 void PeerConnection::StopRtcEventLog_w() { |
2330 media_controller_->call_w()->StopEventLog(); | 2343 media_controller_->call_w()->StopEventLog(); |
2331 } | 2344 } |
2332 } // namespace webrtc | 2345 } // namespace webrtc |
OLD | NEW |