Chromium Code Reviews| 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 PeerConnectionInterface::IceGatheringState | 891 PeerConnectionInterface::IceGatheringState |
| 892 PeerConnection::ice_gathering_state() { | 892 PeerConnection::ice_gathering_state() { |
| 893 return ice_gathering_state_; | 893 return ice_gathering_state_; |
| 894 } | 894 } |
| 895 | 895 |
| 896 rtc::scoped_refptr<DataChannelInterface> | 896 rtc::scoped_refptr<DataChannelInterface> |
| 897 PeerConnection::CreateDataChannel( | 897 PeerConnection::CreateDataChannel( |
| 898 const std::string& label, | 898 const std::string& label, |
| 899 const DataChannelInit* config) { | 899 const DataChannelInit* config) { |
| 900 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); | 900 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); |
| 901 #ifdef HAVE_QUIC | |
| 902 if (session_->data_channel_type() == cricket::DCT_QUIC) { | |
| 903 // TODO(mikescarlett): Handle case when config is NULL. | |
|
pthatcher1
2016/07/27 23:21:49
Maybe we should make these TODO(zhihuang) :).
Zhi Huang
2016/08/01 05:12:28
Done.
| |
| 904 if (!config) { | |
| 905 LOG(LS_ERROR) << "Missing config for QUIC data channel."; | |
| 906 return nullptr; | |
| 907 } | |
| 908 // TODO(mikescarlett): Allow unreliable or ordered QUIC data channels. | |
| 909 if (!config->reliable || config->ordered) { | |
| 910 LOG(LS_ERROR) << "QUIC data channel does not implement unreliable or " | |
| 911 "ordered delivery."; | |
| 912 return nullptr; | |
| 913 } | |
| 914 return session_->quic_data_transport()->CreateDataChannel(label, config); | |
| 915 } | |
| 916 #endif // HAVE_QUIC | |
| 917 | |
| 901 bool first_datachannel = !HasDataChannels(); | 918 bool first_datachannel = !HasDataChannels(); |
| 902 | 919 |
| 903 std::unique_ptr<InternalDataChannelInit> internal_config; | 920 std::unique_ptr<InternalDataChannelInit> internal_config; |
| 904 if (config) { | 921 if (config) { |
| 905 internal_config.reset(new InternalDataChannelInit(*config)); | 922 internal_config.reset(new InternalDataChannelInit(*config)); |
| 906 } | 923 } |
| 907 rtc::scoped_refptr<DataChannelInterface> channel( | 924 rtc::scoped_refptr<DataChannelInterface> channel( |
| 908 InternalCreateDataChannel(label, internal_config.get())); | 925 InternalCreateDataChannel(label, internal_config.get())); |
| 909 if (!channel.get()) { | 926 if (!channel.get()) { |
| 910 return nullptr; | 927 return nullptr; |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1572 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) { | 1589 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) { |
| 1573 session_options->recv_video = | 1590 session_options->recv_video = |
| 1574 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) || | 1591 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) || |
| 1575 !remote_video_tracks_.empty(); | 1592 !remote_video_tracks_.empty(); |
| 1576 } | 1593 } |
| 1577 session_options->bundle_enabled = | 1594 session_options->bundle_enabled = |
| 1578 session_options->bundle_enabled && | 1595 session_options->bundle_enabled && |
| 1579 (session_options->has_audio() || session_options->has_video() || | 1596 (session_options->has_audio() || session_options->has_video() || |
| 1580 session_options->has_data()); | 1597 session_options->has_data()); |
| 1581 | 1598 |
| 1582 if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) { | 1599 if (HasDataChannels()) { |
| 1583 session_options->data_channel_type = cricket::DCT_SCTP; | 1600 session_options->data_channel_type = session_->data_channel_type(); |
| 1584 } | 1601 } |
| 1585 | 1602 |
| 1586 session_options->rtcp_cname = rtcp_cname_; | 1603 session_options->rtcp_cname = rtcp_cname_; |
| 1587 return true; | 1604 return true; |
| 1588 } | 1605 } |
| 1589 | 1606 |
| 1590 void PeerConnection::FinishOptionsForAnswer( | 1607 void PeerConnection::FinishOptionsForAnswer( |
| 1591 cricket::MediaSessionOptions* session_options) { | 1608 cricket::MediaSessionOptions* session_options) { |
| 1592 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of | 1609 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of |
| 1593 // ContentInfos. | 1610 // ContentInfos. |
| 1594 if (session_->remote_description()) { | 1611 if (session_->remote_description()) { |
| 1595 // Initialize the transport_options map. | 1612 // Initialize the transport_options map. |
| 1596 for (const cricket::ContentInfo& content : | 1613 for (const cricket::ContentInfo& content : |
| 1597 session_->remote_description()->description()->contents()) { | 1614 session_->remote_description()->description()->contents()) { |
| 1598 session_options->transport_options[content.name] = | 1615 session_options->transport_options[content.name] = |
| 1599 cricket::TransportOptions(); | 1616 cricket::TransportOptions(); |
| 1600 } | 1617 } |
| 1601 } | 1618 } |
| 1602 AddSendStreams(session_options, senders_, rtp_data_channels_); | 1619 AddSendStreams(session_options, senders_, rtp_data_channels_); |
| 1603 session_options->bundle_enabled = | 1620 session_options->bundle_enabled = |
| 1604 session_options->bundle_enabled && | 1621 session_options->bundle_enabled && |
| 1605 (session_options->has_audio() || session_options->has_video() || | 1622 (session_options->has_audio() || session_options->has_video() || |
| 1606 session_options->has_data()); | 1623 session_options->has_data()); |
| 1607 | 1624 |
| 1608 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams | 1625 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams |
| 1609 // are not signaled in the SDP so does not go through that path and must be | 1626 // are not signaled in the SDP so does not go through that path and must be |
| 1610 // handled here. | 1627 // handled here. |
| 1611 if (session_->data_channel_type() == cricket::DCT_SCTP) { | 1628 session_options->data_channel_type = session_->data_channel_type(); |
| 1612 session_options->data_channel_type = cricket::DCT_SCTP; | |
| 1613 } | |
| 1614 } | 1629 } |
| 1615 | 1630 |
| 1616 bool PeerConnection::GetOptionsForAnswer( | 1631 bool PeerConnection::GetOptionsForAnswer( |
| 1617 const MediaConstraintsInterface* constraints, | 1632 const MediaConstraintsInterface* constraints, |
| 1618 cricket::MediaSessionOptions* session_options) { | 1633 cricket::MediaSessionOptions* session_options) { |
| 1619 session_options->recv_audio = false; | 1634 session_options->recv_audio = false; |
| 1620 session_options->recv_video = false; | 1635 session_options->recv_video = false; |
| 1621 if (!ParseConstraintsForAnswer(constraints, session_options)) { | 1636 if (!ParseConstraintsForAnswer(constraints, session_options)) { |
| 1622 return false; | 1637 return false; |
| 1623 } | 1638 } |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2006 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP); | 2021 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP); |
| 2007 sctp_data_channels_.push_back(channel); | 2022 sctp_data_channels_.push_back(channel); |
| 2008 channel->SignalClosed.connect(this, | 2023 channel->SignalClosed.connect(this, |
| 2009 &PeerConnection::OnSctpDataChannelClosed); | 2024 &PeerConnection::OnSctpDataChannelClosed); |
| 2010 } | 2025 } |
| 2011 | 2026 |
| 2012 return channel; | 2027 return channel; |
| 2013 } | 2028 } |
| 2014 | 2029 |
| 2015 bool PeerConnection::HasDataChannels() const { | 2030 bool PeerConnection::HasDataChannels() const { |
| 2031 #ifdef HAVE_QUIC | |
| 2032 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty() || | |
| 2033 (session_->quic_data_transport() && | |
| 2034 session_->quic_data_transport()->HasDataChannels()); | |
| 2035 #else | |
| 2016 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty(); | 2036 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty(); |
| 2037 #endif // HAVE_QUIC | |
| 2017 } | 2038 } |
| 2018 | 2039 |
| 2019 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) { | 2040 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) { |
| 2020 for (const auto& channel : sctp_data_channels_) { | 2041 for (const auto& channel : sctp_data_channels_) { |
| 2021 if (channel->id() < 0) { | 2042 if (channel->id() < 0) { |
| 2022 int sid; | 2043 int sid; |
| 2023 if (!sid_allocator_.AllocateSid(role, &sid)) { | 2044 if (!sid_allocator_.AllocateSid(role, &sid)) { |
| 2024 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; | 2045 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; |
| 2025 continue; | 2046 continue; |
| 2026 } | 2047 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2250 | 2271 |
| 2251 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, | 2272 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, |
| 2252 int64_t max_size_bytes) { | 2273 int64_t max_size_bytes) { |
| 2253 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); | 2274 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); |
| 2254 } | 2275 } |
| 2255 | 2276 |
| 2256 void PeerConnection::StopRtcEventLog_w() { | 2277 void PeerConnection::StopRtcEventLog_w() { |
| 2257 media_controller_->call_w()->StopEventLog(); | 2278 media_controller_->call_w()->StopEventLog(); |
| 2258 } | 2279 } |
| 2259 } // namespace webrtc | 2280 } // namespace webrtc |
| OLD | NEW |