| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 RtpSendParameters<Codec>* send_params) { | 157 RtpSendParameters<Codec>* send_params) { |
| 158 RtpParametersFromMediaDescription(desc, send_params); | 158 RtpParametersFromMediaDescription(desc, send_params); |
| 159 send_params->max_bandwidth_bps = desc->bandwidth(); | 159 send_params->max_bandwidth_bps = desc->bandwidth(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 BaseChannel::BaseChannel(rtc::Thread* worker_thread, | 162 BaseChannel::BaseChannel(rtc::Thread* worker_thread, |
| 163 rtc::Thread* network_thread, | 163 rtc::Thread* network_thread, |
| 164 MediaChannel* media_channel, | 164 MediaChannel* media_channel, |
| 165 TransportController* transport_controller, | 165 TransportController* transport_controller, |
| 166 const std::string& content_name, | 166 const std::string& content_name, |
| 167 bool rtcp) | 167 bool rtcp, |
| 168 bool srtp_required) |
| 168 : worker_thread_(worker_thread), | 169 : worker_thread_(worker_thread), |
| 169 network_thread_(network_thread), | 170 network_thread_(network_thread), |
| 170 | 171 |
| 171 content_name_(content_name), | 172 content_name_(content_name), |
| 172 | 173 |
| 173 transport_controller_(transport_controller), | 174 transport_controller_(transport_controller), |
| 174 rtcp_enabled_(rtcp), | 175 rtcp_enabled_(rtcp), |
| 176 srtp_required_(srtp_required), |
| 175 media_channel_(media_channel), | 177 media_channel_(media_channel), |
| 176 selected_candidate_pair_(nullptr) { | 178 selected_candidate_pair_(nullptr) { |
| 177 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 179 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 178 if (transport_controller) { | 180 if (transport_controller) { |
| 179 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); | 181 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); |
| 180 } | 182 } |
| 181 LOG(LS_INFO) << "Created channel for " << content_name; | 183 LOG(LS_INFO) << "Created channel for " << content_name; |
| 182 } | 184 } |
| 183 | 185 |
| 184 BaseChannel::~BaseChannel() { | 186 BaseChannel::~BaseChannel() { |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 int type = -1; | 721 int type = -1; |
| 720 GetRtcpType(data, len, &type); | 722 GetRtcpType(data, len, &type); |
| 721 LOG(LS_ERROR) << "Failed to protect " << content_name_ | 723 LOG(LS_ERROR) << "Failed to protect " << content_name_ |
| 722 << " RTCP packet: size=" << len << ", type=" << type; | 724 << " RTCP packet: size=" << len << ", type=" << type; |
| 723 return false; | 725 return false; |
| 724 } | 726 } |
| 725 } | 727 } |
| 726 | 728 |
| 727 // Update the length of the packet now that we've added the auth tag. | 729 // Update the length of the packet now that we've added the auth tag. |
| 728 packet->SetSize(len); | 730 packet->SetSize(len); |
| 729 } else if (secure_required_) { | 731 } else if (srtp_required_) { |
| 730 // The audio/video engines may attempt to send RTCP packets as soon as the | 732 // The audio/video engines may attempt to send RTCP packets as soon as the |
| 731 // streams are created, so don't treat this as an error for RTCP. | 733 // streams are created, so don't treat this as an error for RTCP. |
| 732 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=6809 | 734 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=6809 |
| 733 if (rtcp) { | 735 if (rtcp) { |
| 734 return false; | 736 return false; |
| 735 } | 737 } |
| 736 // However, there shouldn't be any RTP packets sent before SRTP is set up | 738 // However, there shouldn't be any RTP packets sent before SRTP is set up |
| 737 // (and SetSend(true) is called). | 739 // (and SetSend(true) is called). |
| 738 LOG(LS_ERROR) << "Can't send outgoing RTP packet when SRTP is inactive" | 740 LOG(LS_ERROR) << "Can't send outgoing RTP packet when SRTP is inactive" |
| 739 << " and crypto is required"; | 741 << " and crypto is required"; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 if (!res) { | 810 if (!res) { |
| 809 int type = -1; | 811 int type = -1; |
| 810 GetRtcpType(data, len, &type); | 812 GetRtcpType(data, len, &type); |
| 811 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ | 813 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ |
| 812 << " RTCP packet: size=" << len << ", type=" << type; | 814 << " RTCP packet: size=" << len << ", type=" << type; |
| 813 return; | 815 return; |
| 814 } | 816 } |
| 815 } | 817 } |
| 816 | 818 |
| 817 packet->SetSize(len); | 819 packet->SetSize(len); |
| 818 } else if (secure_required_) { | 820 } else if (srtp_required_) { |
| 819 // Our session description indicates that SRTP is required, but we got a | 821 // Our session description indicates that SRTP is required, but we got a |
| 820 // packet before our SRTP filter is active. This means either that | 822 // packet before our SRTP filter is active. This means either that |
| 821 // a) we got SRTP packets before we received the SDES keys, in which case | 823 // a) we got SRTP packets before we received the SDES keys, in which case |
| 822 // we can't decrypt it anyway, or | 824 // we can't decrypt it anyway, or |
| 823 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP | 825 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP |
| 824 // channels, so we haven't yet extracted keys, even if DTLS did complete | 826 // channels, so we haven't yet extracted keys, even if DTLS did complete |
| 825 // on the channel that the packets are being sent on. It's really good | 827 // on the channel that the packets are being sent on. It's really good |
| 826 // practice to wait for both RTP and RTCP to be good to go before sending | 828 // practice to wait for both RTP and RTCP to be good to go before sending |
| 827 // media, to prevent weird failure modes, so it's fine for us to just eat | 829 // media, to prevent weird failure modes, so it's fine for us to just eat |
| 828 // packets here. This is all sidestepped if RTCP mux is used anyway. | 830 // packets here. This is all sidestepped if RTCP mux is used anyway. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 bool BaseChannel::SetRtpTransportParameters( | 1086 bool BaseChannel::SetRtpTransportParameters( |
| 1085 const MediaContentDescription* content, | 1087 const MediaContentDescription* content, |
| 1086 ContentAction action, | 1088 ContentAction action, |
| 1087 ContentSource src, | 1089 ContentSource src, |
| 1088 std::string* error_desc) { | 1090 std::string* error_desc) { |
| 1089 if (action == CA_UPDATE) { | 1091 if (action == CA_UPDATE) { |
| 1090 // These parameters never get changed by a CA_UDPATE. | 1092 // These parameters never get changed by a CA_UDPATE. |
| 1091 return true; | 1093 return true; |
| 1092 } | 1094 } |
| 1093 | 1095 |
| 1094 // Cache secure_required_ for belt and suspenders check on SendPacket | 1096 // Cache srtp_required_ for belt and suspenders check on SendPacket |
| 1095 return network_thread_->Invoke<bool>( | 1097 return network_thread_->Invoke<bool>( |
| 1096 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, | 1098 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, |
| 1097 content, action, src, error_desc)); | 1099 content, action, src, error_desc)); |
| 1098 } | 1100 } |
| 1099 | 1101 |
| 1100 bool BaseChannel::SetRtpTransportParameters_n( | 1102 bool BaseChannel::SetRtpTransportParameters_n( |
| 1101 const MediaContentDescription* content, | 1103 const MediaContentDescription* content, |
| 1102 ContentAction action, | 1104 ContentAction action, |
| 1103 ContentSource src, | 1105 ContentSource src, |
| 1104 std::string* error_desc) { | 1106 std::string* error_desc) { |
| 1105 RTC_DCHECK(network_thread_->IsCurrent()); | 1107 RTC_DCHECK(network_thread_->IsCurrent()); |
| 1106 | 1108 |
| 1107 if (src == CS_LOCAL) { | |
| 1108 set_secure_required(content->crypto_required() != CT_NONE); | |
| 1109 } | |
| 1110 | |
| 1111 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { | 1109 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { |
| 1112 return false; | 1110 return false; |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { | 1113 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { |
| 1116 return false; | 1114 return false; |
| 1117 } | 1115 } |
| 1118 | 1116 |
| 1119 return true; | 1117 return true; |
| 1120 } | 1118 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 RTC_DCHECK(worker_thread_->IsCurrent()); | 1467 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 1470 SignalSentPacket(sent_packet); | 1468 SignalSentPacket(sent_packet); |
| 1471 } | 1469 } |
| 1472 | 1470 |
| 1473 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, | 1471 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, |
| 1474 rtc::Thread* network_thread, | 1472 rtc::Thread* network_thread, |
| 1475 MediaEngineInterface* media_engine, | 1473 MediaEngineInterface* media_engine, |
| 1476 VoiceMediaChannel* media_channel, | 1474 VoiceMediaChannel* media_channel, |
| 1477 TransportController* transport_controller, | 1475 TransportController* transport_controller, |
| 1478 const std::string& content_name, | 1476 const std::string& content_name, |
| 1479 bool rtcp) | 1477 bool rtcp, |
| 1478 bool srtp_required) |
| 1480 : BaseChannel(worker_thread, | 1479 : BaseChannel(worker_thread, |
| 1481 network_thread, | 1480 network_thread, |
| 1482 media_channel, | 1481 media_channel, |
| 1483 transport_controller, | 1482 transport_controller, |
| 1484 content_name, | 1483 content_name, |
| 1485 rtcp), | 1484 rtcp, |
| 1485 srtp_required), |
| 1486 media_engine_(media_engine), | 1486 media_engine_(media_engine), |
| 1487 received_media_(false) {} | 1487 received_media_(false) {} |
| 1488 | 1488 |
| 1489 VoiceChannel::~VoiceChannel() { | 1489 VoiceChannel::~VoiceChannel() { |
| 1490 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); | 1490 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); |
| 1491 StopAudioMonitor(); | 1491 StopAudioMonitor(); |
| 1492 StopMediaMonitor(); | 1492 StopMediaMonitor(); |
| 1493 // this can't be done in the base class, since it calls a virtual | 1493 // this can't be done in the base class, since it calls a virtual |
| 1494 DisableMedia_w(); | 1494 DisableMedia_w(); |
| 1495 Deinit(); | 1495 Deinit(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 void VoiceChannel::GetSrtpCryptoSuites_n( | 1882 void VoiceChannel::GetSrtpCryptoSuites_n( |
| 1883 std::vector<int>* crypto_suites) const { | 1883 std::vector<int>* crypto_suites) const { |
| 1884 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); | 1884 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); |
| 1885 } | 1885 } |
| 1886 | 1886 |
| 1887 VideoChannel::VideoChannel(rtc::Thread* worker_thread, | 1887 VideoChannel::VideoChannel(rtc::Thread* worker_thread, |
| 1888 rtc::Thread* network_thread, | 1888 rtc::Thread* network_thread, |
| 1889 VideoMediaChannel* media_channel, | 1889 VideoMediaChannel* media_channel, |
| 1890 TransportController* transport_controller, | 1890 TransportController* transport_controller, |
| 1891 const std::string& content_name, | 1891 const std::string& content_name, |
| 1892 bool rtcp) | 1892 bool rtcp, |
| 1893 bool srtp_required) |
| 1893 : BaseChannel(worker_thread, | 1894 : BaseChannel(worker_thread, |
| 1894 network_thread, | 1895 network_thread, |
| 1895 media_channel, | 1896 media_channel, |
| 1896 transport_controller, | 1897 transport_controller, |
| 1897 content_name, | 1898 content_name, |
| 1898 rtcp) {} | 1899 rtcp, |
| 1900 srtp_required) {} |
| 1899 | 1901 |
| 1900 bool VideoChannel::Init_w(const std::string* bundle_transport_name) { | 1902 bool VideoChannel::Init_w(const std::string* bundle_transport_name) { |
| 1901 if (!BaseChannel::Init_w(bundle_transport_name)) { | 1903 if (!BaseChannel::Init_w(bundle_transport_name)) { |
| 1902 return false; | 1904 return false; |
| 1903 } | 1905 } |
| 1904 return true; | 1906 return true; |
| 1905 } | 1907 } |
| 1906 | 1908 |
| 1907 VideoChannel::~VideoChannel() { | 1909 VideoChannel::~VideoChannel() { |
| 1908 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); | 1910 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 void VideoChannel::GetSrtpCryptoSuites_n( | 2145 void VideoChannel::GetSrtpCryptoSuites_n( |
| 2144 std::vector<int>* crypto_suites) const { | 2146 std::vector<int>* crypto_suites) const { |
| 2145 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); | 2147 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); |
| 2146 } | 2148 } |
| 2147 | 2149 |
| 2148 DataChannel::DataChannel(rtc::Thread* worker_thread, | 2150 DataChannel::DataChannel(rtc::Thread* worker_thread, |
| 2149 rtc::Thread* network_thread, | 2151 rtc::Thread* network_thread, |
| 2150 DataMediaChannel* media_channel, | 2152 DataMediaChannel* media_channel, |
| 2151 TransportController* transport_controller, | 2153 TransportController* transport_controller, |
| 2152 const std::string& content_name, | 2154 const std::string& content_name, |
| 2153 bool rtcp) | 2155 bool rtcp, |
| 2156 bool srtp_required) |
| 2154 : BaseChannel(worker_thread, | 2157 : BaseChannel(worker_thread, |
| 2155 network_thread, | 2158 network_thread, |
| 2156 media_channel, | 2159 media_channel, |
| 2157 transport_controller, | 2160 transport_controller, |
| 2158 content_name, | 2161 content_name, |
| 2159 rtcp), | 2162 rtcp, |
| 2163 srtp_required), |
| 2160 data_channel_type_(cricket::DCT_NONE), | 2164 data_channel_type_(cricket::DCT_NONE), |
| 2161 ready_to_send_data_(false) {} | 2165 ready_to_send_data_(false) {} |
| 2162 | 2166 |
| 2163 DataChannel::~DataChannel() { | 2167 DataChannel::~DataChannel() { |
| 2164 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel"); | 2168 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel"); |
| 2165 StopMediaMonitor(); | 2169 StopMediaMonitor(); |
| 2166 // this can't be done in the base class, since it calls a virtual | 2170 // this can't be done in the base class, since it calls a virtual |
| 2167 DisableMedia_w(); | 2171 DisableMedia_w(); |
| 2168 | 2172 |
| 2169 Deinit(); | 2173 Deinit(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 } | 2467 } |
| 2464 | 2468 |
| 2465 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2469 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
| 2466 rtc::TypedMessageData<uint32_t>* message = | 2470 rtc::TypedMessageData<uint32_t>* message = |
| 2467 new rtc::TypedMessageData<uint32_t>(sid); | 2471 new rtc::TypedMessageData<uint32_t>(sid); |
| 2468 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, | 2472 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, |
| 2469 message); | 2473 message); |
| 2470 } | 2474 } |
| 2471 | 2475 |
| 2472 } // namespace cricket | 2476 } // namespace cricket |
| OLD | NEW |