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 // This is a double check for something that supposedly can't happen. | 732 // This is a double check for something that supposedly can't happen. |
731 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp) | 733 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp) |
732 << " packet when SRTP is inactive and crypto is required"; | 734 << " packet when SRTP is inactive and crypto is required"; |
733 | 735 |
734 RTC_DCHECK(false); | 736 RTC_DCHECK(false); |
735 return false; | 737 return false; |
736 } | 738 } |
737 | 739 |
738 // Bon voyage. | 740 // Bon voyage. |
739 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; | 741 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 if (!res) { | 804 if (!res) { |
803 int type = -1; | 805 int type = -1; |
804 GetRtcpType(data, len, &type); | 806 GetRtcpType(data, len, &type); |
805 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ | 807 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ |
806 << " RTCP packet: size=" << len << ", type=" << type; | 808 << " RTCP packet: size=" << len << ", type=" << type; |
807 return; | 809 return; |
808 } | 810 } |
809 } | 811 } |
810 | 812 |
811 packet->SetSize(len); | 813 packet->SetSize(len); |
812 } else if (secure_required_) { | 814 } else if (srtp_required_) { |
813 // Our session description indicates that SRTP is required, but we got a | 815 // Our session description indicates that SRTP is required, but we got a |
814 // packet before our SRTP filter is active. This means either that | 816 // packet before our SRTP filter is active. This means either that |
815 // a) we got SRTP packets before we received the SDES keys, in which case | 817 // a) we got SRTP packets before we received the SDES keys, in which case |
816 // we can't decrypt it anyway, or | 818 // we can't decrypt it anyway, or |
817 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP | 819 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP |
818 // channels, so we haven't yet extracted keys, even if DTLS did complete | 820 // channels, so we haven't yet extracted keys, even if DTLS did complete |
819 // on the channel that the packets are being sent on. It's really good | 821 // on the channel that the packets are being sent on. It's really good |
820 // practice to wait for both RTP and RTCP to be good to go before sending | 822 // practice to wait for both RTP and RTCP to be good to go before sending |
821 // media, to prevent weird failure modes, so it's fine for us to just eat | 823 // media, to prevent weird failure modes, so it's fine for us to just eat |
822 // packets here. This is all sidestepped if RTCP mux is used anyway. | 824 // 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... |
1078 bool BaseChannel::SetRtpTransportParameters( | 1080 bool BaseChannel::SetRtpTransportParameters( |
1079 const MediaContentDescription* content, | 1081 const MediaContentDescription* content, |
1080 ContentAction action, | 1082 ContentAction action, |
1081 ContentSource src, | 1083 ContentSource src, |
1082 std::string* error_desc) { | 1084 std::string* error_desc) { |
1083 if (action == CA_UPDATE) { | 1085 if (action == CA_UPDATE) { |
1084 // These parameters never get changed by a CA_UDPATE. | 1086 // These parameters never get changed by a CA_UDPATE. |
1085 return true; | 1087 return true; |
1086 } | 1088 } |
1087 | 1089 |
1088 // Cache secure_required_ for belt and suspenders check on SendPacket | 1090 // Cache srtp_required_ for belt and suspenders check on SendPacket |
1089 return network_thread_->Invoke<bool>( | 1091 return network_thread_->Invoke<bool>( |
1090 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, | 1092 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, |
1091 content, action, src, error_desc)); | 1093 content, action, src, error_desc)); |
1092 } | 1094 } |
1093 | 1095 |
1094 bool BaseChannel::SetRtpTransportParameters_n( | 1096 bool BaseChannel::SetRtpTransportParameters_n( |
1095 const MediaContentDescription* content, | 1097 const MediaContentDescription* content, |
1096 ContentAction action, | 1098 ContentAction action, |
1097 ContentSource src, | 1099 ContentSource src, |
1098 std::string* error_desc) { | 1100 std::string* error_desc) { |
1099 RTC_DCHECK(network_thread_->IsCurrent()); | 1101 RTC_DCHECK(network_thread_->IsCurrent()); |
1100 | 1102 |
1101 if (src == CS_LOCAL) { | |
1102 set_secure_required(content->crypto_required() != CT_NONE); | |
1103 } | |
1104 | |
1105 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { | 1103 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { |
1106 return false; | 1104 return false; |
1107 } | 1105 } |
1108 | 1106 |
1109 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { | 1107 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { |
1110 return false; | 1108 return false; |
1111 } | 1109 } |
1112 | 1110 |
1113 return true; | 1111 return true; |
1114 } | 1112 } |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 RTC_DCHECK(worker_thread_->IsCurrent()); | 1461 RTC_DCHECK(worker_thread_->IsCurrent()); |
1464 SignalSentPacket(sent_packet); | 1462 SignalSentPacket(sent_packet); |
1465 } | 1463 } |
1466 | 1464 |
1467 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, | 1465 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, |
1468 rtc::Thread* network_thread, | 1466 rtc::Thread* network_thread, |
1469 MediaEngineInterface* media_engine, | 1467 MediaEngineInterface* media_engine, |
1470 VoiceMediaChannel* media_channel, | 1468 VoiceMediaChannel* media_channel, |
1471 TransportController* transport_controller, | 1469 TransportController* transport_controller, |
1472 const std::string& content_name, | 1470 const std::string& content_name, |
1473 bool rtcp) | 1471 bool rtcp, |
| 1472 bool srtp_required) |
1474 : BaseChannel(worker_thread, | 1473 : BaseChannel(worker_thread, |
1475 network_thread, | 1474 network_thread, |
1476 media_channel, | 1475 media_channel, |
1477 transport_controller, | 1476 transport_controller, |
1478 content_name, | 1477 content_name, |
1479 rtcp), | 1478 rtcp, |
| 1479 srtp_required), |
1480 media_engine_(media_engine), | 1480 media_engine_(media_engine), |
1481 received_media_(false) {} | 1481 received_media_(false) {} |
1482 | 1482 |
1483 VoiceChannel::~VoiceChannel() { | 1483 VoiceChannel::~VoiceChannel() { |
1484 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); | 1484 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); |
1485 StopAudioMonitor(); | 1485 StopAudioMonitor(); |
1486 StopMediaMonitor(); | 1486 StopMediaMonitor(); |
1487 // this can't be done in the base class, since it calls a virtual | 1487 // this can't be done in the base class, since it calls a virtual |
1488 DisableMedia_w(); | 1488 DisableMedia_w(); |
1489 Deinit(); | 1489 Deinit(); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 void VoiceChannel::GetSrtpCryptoSuites_n( | 1876 void VoiceChannel::GetSrtpCryptoSuites_n( |
1877 std::vector<int>* crypto_suites) const { | 1877 std::vector<int>* crypto_suites) const { |
1878 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); | 1878 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); |
1879 } | 1879 } |
1880 | 1880 |
1881 VideoChannel::VideoChannel(rtc::Thread* worker_thread, | 1881 VideoChannel::VideoChannel(rtc::Thread* worker_thread, |
1882 rtc::Thread* network_thread, | 1882 rtc::Thread* network_thread, |
1883 VideoMediaChannel* media_channel, | 1883 VideoMediaChannel* media_channel, |
1884 TransportController* transport_controller, | 1884 TransportController* transport_controller, |
1885 const std::string& content_name, | 1885 const std::string& content_name, |
1886 bool rtcp) | 1886 bool rtcp, |
| 1887 bool srtp_required) |
1887 : BaseChannel(worker_thread, | 1888 : BaseChannel(worker_thread, |
1888 network_thread, | 1889 network_thread, |
1889 media_channel, | 1890 media_channel, |
1890 transport_controller, | 1891 transport_controller, |
1891 content_name, | 1892 content_name, |
1892 rtcp) {} | 1893 rtcp, |
| 1894 srtp_required) {} |
1893 | 1895 |
1894 bool VideoChannel::Init_w(const std::string* bundle_transport_name) { | 1896 bool VideoChannel::Init_w(const std::string* bundle_transport_name) { |
1895 if (!BaseChannel::Init_w(bundle_transport_name)) { | 1897 if (!BaseChannel::Init_w(bundle_transport_name)) { |
1896 return false; | 1898 return false; |
1897 } | 1899 } |
1898 return true; | 1900 return true; |
1899 } | 1901 } |
1900 | 1902 |
1901 VideoChannel::~VideoChannel() { | 1903 VideoChannel::~VideoChannel() { |
1902 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); | 1904 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 void VideoChannel::GetSrtpCryptoSuites_n( | 2139 void VideoChannel::GetSrtpCryptoSuites_n( |
2138 std::vector<int>* crypto_suites) const { | 2140 std::vector<int>* crypto_suites) const { |
2139 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); | 2141 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); |
2140 } | 2142 } |
2141 | 2143 |
2142 DataChannel::DataChannel(rtc::Thread* worker_thread, | 2144 DataChannel::DataChannel(rtc::Thread* worker_thread, |
2143 rtc::Thread* network_thread, | 2145 rtc::Thread* network_thread, |
2144 DataMediaChannel* media_channel, | 2146 DataMediaChannel* media_channel, |
2145 TransportController* transport_controller, | 2147 TransportController* transport_controller, |
2146 const std::string& content_name, | 2148 const std::string& content_name, |
2147 bool rtcp) | 2149 bool rtcp, |
| 2150 bool srtp_required) |
2148 : BaseChannel(worker_thread, | 2151 : BaseChannel(worker_thread, |
2149 network_thread, | 2152 network_thread, |
2150 media_channel, | 2153 media_channel, |
2151 transport_controller, | 2154 transport_controller, |
2152 content_name, | 2155 content_name, |
2153 rtcp), | 2156 rtcp, |
| 2157 srtp_required), |
2154 data_channel_type_(cricket::DCT_NONE), | 2158 data_channel_type_(cricket::DCT_NONE), |
2155 ready_to_send_data_(false) {} | 2159 ready_to_send_data_(false) {} |
2156 | 2160 |
2157 DataChannel::~DataChannel() { | 2161 DataChannel::~DataChannel() { |
2158 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel"); | 2162 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel"); |
2159 StopMediaMonitor(); | 2163 StopMediaMonitor(); |
2160 // this can't be done in the base class, since it calls a virtual | 2164 // this can't be done in the base class, since it calls a virtual |
2161 DisableMedia_w(); | 2165 DisableMedia_w(); |
2162 | 2166 |
2163 Deinit(); | 2167 Deinit(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 } | 2461 } |
2458 | 2462 |
2459 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2463 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2460 rtc::TypedMessageData<uint32_t>* message = | 2464 rtc::TypedMessageData<uint32_t>* message = |
2461 new rtc::TypedMessageData<uint32_t>(sid); | 2465 new rtc::TypedMessageData<uint32_t>(sid); |
2462 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, | 2466 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, |
2463 message); | 2467 message); |
2464 } | 2468 } |
2465 | 2469 |
2466 } // namespace cricket | 2470 } // namespace cricket |
OLD | NEW |