OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 const std::vector<webrtc::RtpExtension>& extensions, | 256 const std::vector<webrtc::RtpExtension>& extensions, |
257 const std::string& name) { | 257 const std::string& name) { |
258 for (const auto& kv : extensions) { | 258 for (const auto& kv : extensions) { |
259 if (kv.name == name) { | 259 if (kv.name == name) { |
260 return true; | 260 return true; |
261 } | 261 } |
262 } | 262 } |
263 return false; | 263 return false; |
264 } | 264 } |
265 | 265 |
266 // Merges two fec configs and logs an error if a conflict arises | |
267 // such that merging in different order would trigger a different output. | |
268 static void MergeFecConfig(const webrtc::FecConfig& other, | |
269 webrtc::FecConfig* output) { | |
270 if (other.ulpfec_payload_type != -1) { | |
271 if (output->ulpfec_payload_type != -1 && | |
272 output->ulpfec_payload_type != other.ulpfec_payload_type) { | |
273 LOG(LS_WARNING) << "Conflict merging ulpfec_payload_type configs: " | |
274 << output->ulpfec_payload_type << " and " | |
275 << other.ulpfec_payload_type; | |
276 } | |
277 output->ulpfec_payload_type = other.ulpfec_payload_type; | |
278 } | |
279 if (other.red_payload_type != -1) { | |
280 if (output->red_payload_type != -1 && | |
281 output->red_payload_type != other.red_payload_type) { | |
282 LOG(LS_WARNING) << "Conflict merging red_payload_type configs: " | |
283 << output->red_payload_type << " and " | |
284 << other.red_payload_type; | |
285 } | |
286 output->red_payload_type = other.red_payload_type; | |
287 } | |
288 if (other.red_rtx_payload_type != -1) { | |
289 if (output->red_rtx_payload_type != -1 && | |
290 output->red_rtx_payload_type != other.red_rtx_payload_type) { | |
291 LOG(LS_WARNING) << "Conflict merging red_rtx_payload_type configs: " | |
292 << output->red_rtx_payload_type << " and " | |
293 << other.red_rtx_payload_type; | |
294 } | |
295 output->red_rtx_payload_type = other.red_rtx_payload_type; | |
296 } | |
297 } | |
298 | |
299 // Returns true if the given codec is disallowed from doing simulcast. | 266 // Returns true if the given codec is disallowed from doing simulcast. |
300 bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) { | 267 bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) { |
301 return CodecNamesEq(codec_name, kH264CodecName) || | 268 return CodecNamesEq(codec_name, kH264CodecName) || |
302 CodecNamesEq(codec_name, kVp9CodecName); | 269 CodecNamesEq(codec_name, kVp9CodecName); |
303 } | 270 } |
304 | 271 |
305 // The selected thresholds for QVGA and VGA corresponded to a QP around 10. | 272 // The selected thresholds for QVGA and VGA corresponded to a QP around 10. |
306 // The change in QP declined above the selected bitrates. | 273 // The change in QP declined above the selected bitrates. |
307 static int GetMaxDefaultVideoBitrateKbps(int width, int height) { | 274 static int GetMaxDefaultVideoBitrateKbps(int width, int height) { |
308 if (width * height <= 320 * 240) { | 275 if (width * height <= 320 * 240) { |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 const VideoOptions& options, | 642 const VideoOptions& options, |
676 const std::vector<VideoCodec>& recv_codecs, | 643 const std::vector<VideoCodec>& recv_codecs, |
677 WebRtcVideoEncoderFactory* external_encoder_factory, | 644 WebRtcVideoEncoderFactory* external_encoder_factory, |
678 WebRtcVideoDecoderFactory* external_decoder_factory) | 645 WebRtcVideoDecoderFactory* external_decoder_factory) |
679 : VideoMediaChannel(config), | 646 : VideoMediaChannel(config), |
680 call_(call), | 647 call_(call), |
681 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 648 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
682 video_config_(config.video), | 649 video_config_(config.video), |
683 external_encoder_factory_(external_encoder_factory), | 650 external_encoder_factory_(external_encoder_factory), |
684 external_decoder_factory_(external_decoder_factory), | 651 external_decoder_factory_(external_decoder_factory), |
685 default_send_options_(options) { | 652 default_send_options_(options), |
653 red_disabled_by_remote_side_(false) { | |
686 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 654 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
687 | 655 |
688 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 656 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
689 sending_ = false; | 657 sending_ = false; |
690 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); | 658 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); |
691 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); | 659 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); |
692 } | 660 } |
693 | 661 |
694 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 662 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
695 for (auto& kv : send_streams_) | 663 for (auto& kv : send_streams_) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 "codec or RTCP mode has changed."; | 833 "codec or RTCP mode has changed."; |
866 for (auto& kv : receive_streams_) { | 834 for (auto& kv : receive_streams_) { |
867 RTC_DCHECK(kv.second != nullptr); | 835 RTC_DCHECK(kv.second != nullptr); |
868 kv.second->SetFeedbackParameters( | 836 kv.second->SetFeedbackParameters( |
869 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), | 837 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), |
870 HasTransportCc(send_codec_->codec), | 838 HasTransportCc(send_codec_->codec), |
871 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 839 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
872 : webrtc::RtcpMode::kCompound); | 840 : webrtc::RtcpMode::kCompound); |
873 } | 841 } |
874 } | 842 } |
843 if (changed_params.codec) { | |
844 bool red_was_disabled = red_disabled_by_remote_side_; | |
845 red_disabled_by_remote_side_ = | |
846 changed_params.codec->fec.red_payload_type == -1; | |
847 if (red_was_disabled != red_disabled_by_remote_side_) { | |
pbos-webrtc
2016/05/16 16:48:26
check inside streams instead (one red_disabled.. i
stefan-webrtc
2016/05/17 11:44:35
I need to track this to be able to pass it in when
| |
848 for (auto& kv : receive_streams_) { | |
849 // In practice VideoChannel::SetRemoteContent appears to most of the | |
850 // time also call UpdateRemoteStreams, which recreates the receive | |
851 // streams. If that's always true this call isn't needed. | |
852 kv.second->SetDisableFec(red_disabled_by_remote_side_); | |
853 } | |
854 } | |
855 } | |
875 } | 856 } |
876 send_params_ = params; | 857 send_params_ = params; |
877 return true; | 858 return true; |
878 } | 859 } |
879 | 860 |
880 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpParameters( | 861 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpParameters( |
881 uint32_t ssrc) const { | 862 uint32_t ssrc) const { |
882 rtc::CritScope stream_lock(&stream_crit_); | 863 rtc::CritScope stream_lock(&stream_crit_); |
883 auto it = send_streams_.find(ssrc); | 864 auto it = send_streams_.find(ssrc); |
884 if (it == send_streams_.end()) { | 865 if (it == send_streams_.end()) { |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 config.sync_group = sp.sync_label; | 1165 config.sync_group = sp.sync_label; |
1185 | 1166 |
1186 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1167 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
1187 config.rtp.transport_cc = | 1168 config.rtp.transport_cc = |
1188 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1169 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
1189 config.disable_prerenderer_smoothing = | 1170 config.disable_prerenderer_smoothing = |
1190 video_config_.disable_prerenderer_smoothing; | 1171 video_config_.disable_prerenderer_smoothing; |
1191 | 1172 |
1192 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( | 1173 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
1193 call_, sp, config, external_decoder_factory_, default_stream, | 1174 call_, sp, config, external_decoder_factory_, default_stream, |
1194 recv_codecs_); | 1175 recv_codecs_, red_disabled_by_remote_side_); |
1195 | 1176 |
1196 return true; | 1177 return true; |
1197 } | 1178 } |
1198 | 1179 |
1199 void WebRtcVideoChannel2::ConfigureReceiverRtp( | 1180 void WebRtcVideoChannel2::ConfigureReceiverRtp( |
1200 webrtc::VideoReceiveStream::Config* config, | 1181 webrtc::VideoReceiveStream::Config* config, |
1201 const StreamParams& sp) const { | 1182 const StreamParams& sp) const { |
1202 uint32_t ssrc = sp.first_ssrc(); | 1183 uint32_t ssrc = sp.first_ssrc(); |
1203 | 1184 |
1204 config->rtp.remote_ssrc = ssrc; | 1185 config->rtp.remote_ssrc = ssrc; |
(...skipping 15 matching lines...) Expand all Loading... | |
1220 // (receive-only) or know a good local SSRC. | 1201 // (receive-only) or know a good local SSRC. |
1221 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) { | 1202 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) { |
1222 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) { | 1203 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) { |
1223 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc; | 1204 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc; |
1224 } else { | 1205 } else { |
1225 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1; | 1206 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1; |
1226 } | 1207 } |
1227 } | 1208 } |
1228 | 1209 |
1229 for (size_t i = 0; i < recv_codecs_.size(); ++i) { | 1210 for (size_t i = 0; i < recv_codecs_.size(); ++i) { |
1230 MergeFecConfig(recv_codecs_[i].fec, &config->rtp.fec); | |
1231 } | |
1232 | |
1233 for (size_t i = 0; i < recv_codecs_.size(); ++i) { | |
1234 uint32_t rtx_ssrc; | 1211 uint32_t rtx_ssrc; |
1235 if (recv_codecs_[i].rtx_payload_type != -1 && | 1212 if (recv_codecs_[i].rtx_payload_type != -1 && |
1236 sp.GetFidSsrc(ssrc, &rtx_ssrc)) { | 1213 sp.GetFidSsrc(ssrc, &rtx_ssrc)) { |
1237 webrtc::VideoReceiveStream::Config::Rtp::Rtx& rtx = | 1214 webrtc::VideoReceiveStream::Config::Rtp::Rtx& rtx = |
1238 config->rtp.rtx[recv_codecs_[i].codec.id]; | 1215 config->rtp.rtx[recv_codecs_[i].codec.id]; |
1239 rtx.ssrc = rtx_ssrc; | 1216 rtx.ssrc = rtx_ssrc; |
1240 rtx.payload_type = recv_codecs_[i].rtx_payload_type; | 1217 rtx.payload_type = recv_codecs_[i].rtx_payload_type; |
1241 } | 1218 } |
1242 } | 1219 } |
1243 } | 1220 } |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2185 stream_->Start(); | 2162 stream_->Start(); |
2186 } | 2163 } |
2187 } | 2164 } |
2188 | 2165 |
2189 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2166 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
2190 webrtc::Call* call, | 2167 webrtc::Call* call, |
2191 const StreamParams& sp, | 2168 const StreamParams& sp, |
2192 const webrtc::VideoReceiveStream::Config& config, | 2169 const webrtc::VideoReceiveStream::Config& config, |
2193 WebRtcVideoDecoderFactory* external_decoder_factory, | 2170 WebRtcVideoDecoderFactory* external_decoder_factory, |
2194 bool default_stream, | 2171 bool default_stream, |
2195 const std::vector<VideoCodecSettings>& recv_codecs) | 2172 const std::vector<VideoCodecSettings>& recv_codecs, |
2173 bool red_disabled_by_remote_side) | |
2196 : call_(call), | 2174 : call_(call), |
2197 ssrcs_(sp.ssrcs), | 2175 ssrcs_(sp.ssrcs), |
2198 ssrc_groups_(sp.ssrc_groups), | 2176 ssrc_groups_(sp.ssrc_groups), |
2199 stream_(NULL), | 2177 stream_(NULL), |
2200 default_stream_(default_stream), | 2178 default_stream_(default_stream), |
2201 config_(config), | 2179 config_(config), |
2180 red_disabled_by_remote_side_(red_disabled_by_remote_side), | |
2202 external_decoder_factory_(external_decoder_factory), | 2181 external_decoder_factory_(external_decoder_factory), |
2203 sink_(NULL), | 2182 sink_(NULL), |
2204 last_width_(-1), | 2183 last_width_(-1), |
2205 last_height_(-1), | 2184 last_height_(-1), |
2206 first_frame_timestamp_(-1), | 2185 first_frame_timestamp_(-1), |
2207 estimated_remote_start_ntp_time_ms_(0) { | 2186 estimated_remote_start_ntp_time_ms_(0) { |
2208 config_.renderer = this; | 2187 config_.renderer = this; |
2209 std::vector<AllocatedDecoder> old_decoders; | 2188 std::vector<AllocatedDecoder> old_decoders; |
2210 ConfigureCodecs(recv_codecs, &old_decoders); | 2189 ConfigureCodecs(recv_codecs, &old_decoders); |
2211 RecreateWebRtcStream(); | 2190 RecreateWebRtcStream(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2367 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; | 2346 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; |
2368 RecreateWebRtcStream(); | 2347 RecreateWebRtcStream(); |
2369 ClearDecoders(&old_decoders); | 2348 ClearDecoders(&old_decoders); |
2370 } | 2349 } |
2371 } | 2350 } |
2372 | 2351 |
2373 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2352 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
2374 if (stream_ != NULL) { | 2353 if (stream_ != NULL) { |
2375 call_->DestroyVideoReceiveStream(stream_); | 2354 call_->DestroyVideoReceiveStream(stream_); |
2376 } | 2355 } |
2377 stream_ = call_->CreateVideoReceiveStream(config_); | 2356 webrtc::VideoReceiveStream::Config config = config_; |
2357 if (red_disabled_by_remote_side_) { | |
2358 config.rtp.fec.red_payload_type = -1; | |
2359 config.rtp.fec.ulpfec_payload_type = -1; | |
2360 config.rtp.fec.red_rtx_payload_type = -1; | |
2361 } | |
2362 stream_ = call_->CreateVideoReceiveStream(config); | |
2378 stream_->Start(); | 2363 stream_->Start(); |
2379 } | 2364 } |
2380 | 2365 |
2381 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( | 2366 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( |
2382 std::vector<AllocatedDecoder>* allocated_decoders) { | 2367 std::vector<AllocatedDecoder>* allocated_decoders) { |
2383 for (size_t i = 0; i < allocated_decoders->size(); ++i) { | 2368 for (size_t i = 0; i < allocated_decoders->size(); ++i) { |
2384 if ((*allocated_decoders)[i].external) { | 2369 if ((*allocated_decoders)[i].external) { |
2385 external_decoder_factory_->DestroyVideoDecoder( | 2370 external_decoder_factory_->DestroyVideoDecoder( |
2386 (*allocated_decoders)[i].external_decoder); | 2371 (*allocated_decoders)[i].external_decoder); |
2387 } | 2372 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2475 | 2460 |
2476 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type); | 2461 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type); |
2477 | 2462 |
2478 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; | 2463 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; |
2479 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; | 2464 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; |
2480 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; | 2465 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; |
2481 | 2466 |
2482 return info; | 2467 return info; |
2483 } | 2468 } |
2484 | 2469 |
2470 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely( | |
2471 bool disable) { | |
2472 red_disabled_by_remote_side_ = disable; | |
2473 RecreateWebRtcStream(); | |
2474 } | |
2475 | |
2485 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() | 2476 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() |
2486 : rtx_payload_type(-1) {} | 2477 : rtx_payload_type(-1) {} |
2487 | 2478 |
2488 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( | 2479 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( |
2489 const WebRtcVideoChannel2::VideoCodecSettings& other) const { | 2480 const WebRtcVideoChannel2::VideoCodecSettings& other) const { |
2490 return codec == other.codec && | 2481 return codec == other.codec && |
2491 fec.ulpfec_payload_type == other.fec.ulpfec_payload_type && | 2482 fec.ulpfec_payload_type == other.fec.ulpfec_payload_type && |
2492 fec.red_payload_type == other.fec.red_payload_type && | 2483 fec.red_payload_type == other.fec.red_payload_type && |
2493 fec.red_rtx_payload_type == other.fec.red_rtx_payload_type && | 2484 fec.red_rtx_payload_type == other.fec.red_rtx_payload_type && |
2494 rtx_payload_type == other.rtx_payload_type; | 2485 rtx_payload_type == other.rtx_payload_type; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2588 rtx_mapping[video_codecs[i].codec.id] != | 2579 rtx_mapping[video_codecs[i].codec.id] != |
2589 fec_settings.red_payload_type) { | 2580 fec_settings.red_payload_type) { |
2590 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2581 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2591 } | 2582 } |
2592 } | 2583 } |
2593 | 2584 |
2594 return video_codecs; | 2585 return video_codecs; |
2595 } | 2586 } |
2596 | 2587 |
2597 } // namespace cricket | 2588 } // namespace cricket |
OLD | NEW |