Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2911913002: Recreate FlexfecReceiveStream separately from VideoReceiveStream. (Closed)
Patch Set: Change. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 video_config_(config.video), 642 video_config_(config.video),
643 external_encoder_factory_(external_encoder_factory), 643 external_encoder_factory_(external_encoder_factory),
644 external_decoder_factory_(external_decoder_factory), 644 external_decoder_factory_(external_decoder_factory),
645 default_send_options_(options), 645 default_send_options_(options),
646 last_stats_log_ms_(-1) { 646 last_stats_log_ms_(-1) {
647 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 647 RTC_DCHECK(thread_checker_.CalledOnValidThread());
648 648
649 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; 649 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
650 sending_ = false; 650 sending_ = false;
651 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory)); 651 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory));
652 recv_flexfec_payload_type_ = recv_codecs_.front().flexfec_payload_type;
652 } 653 }
653 654
654 WebRtcVideoChannel2::~WebRtcVideoChannel2() { 655 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
655 for (auto& kv : send_streams_) 656 for (auto& kv : send_streams_)
656 delete kv.second; 657 delete kv.second;
657 for (auto& kv : receive_streams_) 658 for (auto& kv : receive_streams_)
658 delete kv.second; 659 delete kv.second;
659 } 660 }
660 661
661 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings> 662 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>
662 WebRtcVideoChannel2::SelectSendVideoCodec( 663 WebRtcVideoChannel2::SelectSendVideoCodec(
663 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const { 664 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const {
664 const std::vector<VideoCodec> local_supported_codecs = 665 const std::vector<VideoCodec> local_supported_codecs =
665 GetSupportedCodecs(external_encoder_factory_); 666 GetSupportedCodecs(external_encoder_factory_);
666 // Select the first remote codec that is supported locally. 667 // Select the first remote codec that is supported locally.
667 for (const VideoCodecSettings& remote_mapped_codec : remote_mapped_codecs) { 668 for (const VideoCodecSettings& remote_mapped_codec : remote_mapped_codecs) {
668 // For H264, we will limit the encode level to the remote offered level 669 // For H264, we will limit the encode level to the remote offered level
669 // regardless if level asymmetry is allowed or not. This is strictly not 670 // regardless if level asymmetry is allowed or not. This is strictly not
670 // following the spec in https://tools.ietf.org/html/rfc6184#section-8.2.2 671 // following the spec in https://tools.ietf.org/html/rfc6184#section-8.2.2
671 // since we should limit the encode level to the lower of local and remote 672 // since we should limit the encode level to the lower of local and remote
672 // level when level asymmetry is not allowed. 673 // level when level asymmetry is not allowed.
673 if (FindMatchingCodec(local_supported_codecs, remote_mapped_codec.codec)) 674 if (FindMatchingCodec(local_supported_codecs, remote_mapped_codec.codec))
674 return rtc::Optional<VideoCodecSettings>(remote_mapped_codec); 675 return rtc::Optional<VideoCodecSettings>(remote_mapped_codec);
675 } 676 }
676 // No remote codec was supported. 677 // No remote codec was supported.
677 return rtc::Optional<VideoCodecSettings>(); 678 return rtc::Optional<VideoCodecSettings>();
678 } 679 }
679 680
680 bool WebRtcVideoChannel2::ReceiveCodecsHaveChanged( 681 bool WebRtcVideoChannel2::NonFlexfecReceiveCodecsHaveChanged(
681 std::vector<VideoCodecSettings> before, 682 std::vector<VideoCodecSettings> before,
682 std::vector<VideoCodecSettings> after) { 683 std::vector<VideoCodecSettings> after) {
683 if (before.size() != after.size()) { 684 if (before.size() != after.size()) {
684 return true; 685 return true;
685 } 686 }
687
686 // The receive codec order doesn't matter, so we sort the codecs before 688 // The receive codec order doesn't matter, so we sort the codecs before
687 // comparing. This is necessary because currently the 689 // comparing. This is necessary because currently the
688 // only way to change the send codec is to munge SDP, which causes 690 // only way to change the send codec is to munge SDP, which causes
689 // the receive codec list to change order, which causes the streams 691 // the receive codec list to change order, which causes the streams
690 // to be recreates which causes a "blink" of black video. In order 692 // to be recreates which causes a "blink" of black video. In order
691 // to support munging the SDP in this way without recreating receive 693 // to support munging the SDP in this way without recreating receive
692 // streams, we ignore the order of the received codecs so that 694 // streams, we ignore the order of the received codecs so that
693 // changing the order doesn't cause this "blink". 695 // changing the order doesn't cause this "blink".
694 auto comparison = 696 auto comparison =
695 [](const VideoCodecSettings& codec1, const VideoCodecSettings& codec2) { 697 [](const VideoCodecSettings& codec1, const VideoCodecSettings& codec2) {
696 return codec1.codec.id > codec2.codec.id; 698 return codec1.codec.id > codec2.codec.id;
697 }; 699 };
698 std::sort(before.begin(), before.end(), comparison); 700 std::sort(before.begin(), before.end(), comparison);
699 std::sort(after.begin(), after.end(), comparison); 701 std::sort(after.begin(), after.end(), comparison);
700 return before != after; 702
703 // Changes in FlexFEC payload type are handled separately in
704 // WebRtcVideoChannel2::GetChangedRecvParameters, so disregard FlexFEC in the
705 // comparison here.
706 return !std::equal(before.begin(), before.end(), after.begin(),
707 VideoCodecSettings::EqualsDisregardingFlexfec);
701 } 708 }
702 709
703 bool WebRtcVideoChannel2::GetChangedSendParameters( 710 bool WebRtcVideoChannel2::GetChangedSendParameters(
704 const VideoSendParameters& params, 711 const VideoSendParameters& params,
705 ChangedSendParameters* changed_params) const { 712 ChangedSendParameters* changed_params) const {
706 if (!ValidateCodecFormats(params.codecs) || 713 if (!ValidateCodecFormats(params.codecs) ||
707 !ValidateRtpExtensions(params.extensions)) { 714 !ValidateRtpExtensions(params.extensions)) {
708 return false; 715 return false;
709 } 716 }
710 717
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 const std::vector<VideoCodec> local_supported_codecs = 977 const std::vector<VideoCodec> local_supported_codecs =
971 GetSupportedCodecs(external_encoder_factory_); 978 GetSupportedCodecs(external_encoder_factory_);
972 for (const VideoCodecSettings& mapped_codec : mapped_codecs) { 979 for (const VideoCodecSettings& mapped_codec : mapped_codecs) {
973 if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) { 980 if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) {
974 LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codec: " 981 LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codec: "
975 << mapped_codec.codec.ToString(); 982 << mapped_codec.codec.ToString();
976 return false; 983 return false;
977 } 984 }
978 } 985 }
979 986
980 if (ReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) { 987 if (NonFlexfecReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) {
981 changed_params->codec_settings = 988 changed_params->codec_settings =
982 rtc::Optional<std::vector<VideoCodecSettings>>(mapped_codecs); 989 rtc::Optional<std::vector<VideoCodecSettings>>(mapped_codecs);
983 } 990 }
984 991
985 // Handle RTP header extensions. 992 // Handle RTP header extensions.
986 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( 993 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions(
987 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, false); 994 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, false);
988 if (filtered_extensions != recv_rtp_extensions_) { 995 if (filtered_extensions != recv_rtp_extensions_) {
989 changed_params->rtp_header_extensions = 996 changed_params->rtp_header_extensions =
990 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); 997 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions);
991 } 998 }
992 999
1000 int flexfec_payload_type = mapped_codecs.front().flexfec_payload_type;
1001 if (flexfec_payload_type != recv_flexfec_payload_type_) {
1002 changed_params->flexfec_payload_type =
1003 rtc::Optional<int>(flexfec_payload_type);
1004 }
1005
993 return true; 1006 return true;
994 } 1007 }
995 1008
996 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { 1009 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) {
997 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters"); 1010 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters");
998 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); 1011 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString();
999 ChangedRecvParameters changed_params; 1012 ChangedRecvParameters changed_params;
1000 if (!GetChangedRecvParameters(params, &changed_params)) { 1013 if (!GetChangedRecvParameters(params, &changed_params)) {
1001 return false; 1014 return false;
1002 } 1015 }
1016 if (changed_params.flexfec_payload_type) {
1017 LOG(LS_INFO) << "Changing FlexFEC payload type (recv) from "
1018 << recv_flexfec_payload_type_ << " to "
1019 << *changed_params.flexfec_payload_type;
1020 recv_flexfec_payload_type_ = *changed_params.flexfec_payload_type;
1021 }
1003 if (changed_params.rtp_header_extensions) { 1022 if (changed_params.rtp_header_extensions) {
1004 recv_rtp_extensions_ = *changed_params.rtp_header_extensions; 1023 recv_rtp_extensions_ = *changed_params.rtp_header_extensions;
1005 } 1024 }
1006 if (changed_params.codec_settings) { 1025 if (changed_params.codec_settings) {
1007 LOG(LS_INFO) << "Changing recv codecs from " 1026 LOG(LS_INFO) << "Changing recv codecs from "
1008 << CodecSettingsVectorToString(recv_codecs_) << " to " 1027 << CodecSettingsVectorToString(recv_codecs_) << " to "
1009 << CodecSettingsVectorToString(*changed_params.codec_settings); 1028 << CodecSettingsVectorToString(*changed_params.codec_settings);
1010 recv_codecs_ = *changed_params.codec_settings; 1029 recv_codecs_ = *changed_params.codec_settings;
1011 } 1030 }
1012 1031
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 1295
1277 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; 1296 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false;
1278 config->rtp.transport_cc = 1297 config->rtp.transport_cc =
1279 send_codec_ ? HasTransportCc(send_codec_->codec) : false; 1298 send_codec_ ? HasTransportCc(send_codec_->codec) : false;
1280 1299
1281 sp.GetFidSsrc(ssrc, &config->rtp.rtx_ssrc); 1300 sp.GetFidSsrc(ssrc, &config->rtp.rtx_ssrc);
1282 1301
1283 config->rtp.extensions = recv_rtp_extensions_; 1302 config->rtp.extensions = recv_rtp_extensions_;
1284 1303
1285 // TODO(brandtr): Generalize when we add support for multistream protection. 1304 // TODO(brandtr): Generalize when we add support for multistream protection.
1305 flexfec_config->payload_type = recv_flexfec_payload_type_;
1286 if (IsFlexfecAdvertisedFieldTrialEnabled() && 1306 if (IsFlexfecAdvertisedFieldTrialEnabled() &&
1287 sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) { 1307 sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) {
1288 flexfec_config->protected_media_ssrcs = {ssrc}; 1308 flexfec_config->protected_media_ssrcs = {ssrc};
1289 flexfec_config->local_ssrc = config->rtp.local_ssrc; 1309 flexfec_config->local_ssrc = config->rtp.local_ssrc;
1290 flexfec_config->rtcp_mode = config->rtp.rtcp_mode; 1310 flexfec_config->rtcp_mode = config->rtp.rtcp_mode;
1291 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here 1311 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here
1292 // based on the rtcp-fb for the FlexFEC codec, not the media codec. 1312 // based on the rtcp-fb for the FlexFEC codec, not the media codec.
1293 flexfec_config->transport_cc = config->rtp.transport_cc; 1313 flexfec_config->transport_cc = config->rtp.transport_cc;
1294 flexfec_config->rtp_header_extensions = config->rtp.extensions; 1314 flexfec_config->rtp_header_extensions = config->rtp.extensions;
1295 } 1315 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } 1470 }
1451 1471
1452 // See if this payload_type is registered as one that usually gets its own 1472 // See if this payload_type is registered as one that usually gets its own
1453 // SSRC (RTX) or at least is safe to drop either way (FEC). If it is, and 1473 // SSRC (RTX) or at least is safe to drop either way (FEC). If it is, and
1454 // it wasn't handled above by DeliverPacket, that means we don't know what 1474 // it wasn't handled above by DeliverPacket, that means we don't know what
1455 // stream it associates with, and we shouldn't ever create an implicit channel 1475 // stream it associates with, and we shouldn't ever create an implicit channel
1456 // for these. 1476 // for these.
1457 for (auto& codec : recv_codecs_) { 1477 for (auto& codec : recv_codecs_) {
1458 if (payload_type == codec.rtx_payload_type || 1478 if (payload_type == codec.rtx_payload_type ||
1459 payload_type == codec.ulpfec.red_rtx_payload_type || 1479 payload_type == codec.ulpfec.red_rtx_payload_type ||
1460 payload_type == codec.ulpfec.ulpfec_payload_type || 1480 payload_type == codec.ulpfec.ulpfec_payload_type) {
1461 payload_type == codec.flexfec_payload_type) {
1462 return; 1481 return;
1463 } 1482 }
1464 } 1483 }
1484 if (payload_type == recv_flexfec_payload_type_) {
1485 return;
1486 }
1465 1487
1466 switch (unsignalled_ssrc_handler_->OnUnsignalledSsrc(this, ssrc)) { 1488 switch (unsignalled_ssrc_handler_->OnUnsignalledSsrc(this, ssrc)) {
1467 case UnsignalledSsrcHandler::kDropPacket: 1489 case UnsignalledSsrcHandler::kDropPacket:
1468 return; 1490 return;
1469 case UnsignalledSsrcHandler::kDeliverPacket: 1491 case UnsignalledSsrcHandler::kDeliverPacket:
1470 break; 1492 break;
1471 } 1493 }
1472 1494
1473 if (call_->Receiver()->DeliverPacket( 1495 if (call_->Receiver()->DeliverPacket(
1474 webrtc::MediaType::VIDEO, 1496 webrtc::MediaType::VIDEO,
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 config_(std::move(config)), 2195 config_(std::move(config)),
2174 flexfec_config_(flexfec_config), 2196 flexfec_config_(flexfec_config),
2175 flexfec_stream_(nullptr), 2197 flexfec_stream_(nullptr),
2176 external_decoder_factory_(external_decoder_factory), 2198 external_decoder_factory_(external_decoder_factory),
2177 sink_(NULL), 2199 sink_(NULL),
2178 first_frame_timestamp_(-1), 2200 first_frame_timestamp_(-1),
2179 estimated_remote_start_ntp_time_ms_(0) { 2201 estimated_remote_start_ntp_time_ms_(0) {
2180 config_.renderer = this; 2202 config_.renderer = this;
2181 std::vector<AllocatedDecoder> old_decoders; 2203 std::vector<AllocatedDecoder> old_decoders;
2182 ConfigureCodecs(recv_codecs, &old_decoders); 2204 ConfigureCodecs(recv_codecs, &old_decoders);
2183 RecreateWebRtcStream(); 2205 ConfigureFlexfecCodec(flexfec_config.payload_type);
2206 MaybeRecreateWebRtcFlexfecStream();
2207 RecreateWebRtcVideoStream();
2184 RTC_DCHECK(old_decoders.empty()); 2208 RTC_DCHECK(old_decoders.empty());
2185 } 2209 }
2186 2210
2187 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: 2211 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder::
2188 AllocatedDecoder(webrtc::VideoDecoder* decoder, 2212 AllocatedDecoder(webrtc::VideoDecoder* decoder,
2189 webrtc::VideoCodecType type, 2213 webrtc::VideoCodecType type,
2190 bool external) 2214 bool external)
2191 : decoder(decoder), 2215 : decoder(decoder),
2192 external_decoder(nullptr), 2216 external_decoder(nullptr),
2193 type(type), 2217 type(type),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 config_.decoders.push_back(decoder); 2299 config_.decoders.push_back(decoder);
2276 } 2300 }
2277 2301
2278 config_.rtp.rtx_payload_types.clear(); 2302 config_.rtp.rtx_payload_types.clear();
2279 for (const VideoCodecSettings& recv_codec : recv_codecs) { 2303 for (const VideoCodecSettings& recv_codec : recv_codecs) {
2280 config_.rtp.rtx_payload_types[recv_codec.codec.id] = 2304 config_.rtp.rtx_payload_types[recv_codec.codec.id] =
2281 recv_codec.rtx_payload_type; 2305 recv_codec.rtx_payload_type;
2282 } 2306 }
2283 2307
2284 config_.rtp.ulpfec = recv_codecs.front().ulpfec; 2308 config_.rtp.ulpfec = recv_codecs.front().ulpfec;
2285 flexfec_config_.payload_type = recv_codecs.front().flexfec_payload_type;
2286 2309
2287 config_.rtp.nack.rtp_history_ms = 2310 config_.rtp.nack.rtp_history_ms =
2288 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; 2311 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0;
2289 } 2312 }
2290 2313
2314 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ConfigureFlexfecCodec(
2315 int flexfec_payload_type) {
2316 flexfec_config_.payload_type = flexfec_payload_type;
2317 }
2318
2291 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( 2319 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc(
2292 uint32_t local_ssrc) { 2320 uint32_t local_ssrc) {
2293 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You 2321 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You
2294 // should not be able to create a sender with the same SSRC as a receiver, but 2322 // should not be able to create a sender with the same SSRC as a receiver, but
2295 // right now this can't be done due to unittests depending on receiving what 2323 // right now this can't be done due to unittests depending on receiving what
2296 // they are sending from the same MediaChannel. 2324 // they are sending from the same MediaChannel.
2297 if (local_ssrc == config_.rtp.remote_ssrc) { 2325 if (local_ssrc == config_.rtp.remote_ssrc) {
2298 LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are " 2326 LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are "
2299 "unchanged; local_ssrc=" << local_ssrc; 2327 "unchanged; local_ssrc=" << local_ssrc;
2300 return; 2328 return;
2301 } 2329 }
2302 2330
2303 config_.rtp.local_ssrc = local_ssrc; 2331 config_.rtp.local_ssrc = local_ssrc;
2304 flexfec_config_.local_ssrc = local_ssrc; 2332 flexfec_config_.local_ssrc = local_ssrc;
2305 LOG(LS_INFO) 2333 LOG(LS_INFO)
2306 << "RecreateWebRtcStream (recv) because of SetLocalSsrc; local_ssrc=" 2334 << "RecreateWebRtcStream (recv) because of SetLocalSsrc; local_ssrc="
2307 << local_ssrc; 2335 << local_ssrc;
2308 RecreateWebRtcStream(); 2336 MaybeRecreateWebRtcFlexfecStream();
2337 RecreateWebRtcVideoStream();
2309 } 2338 }
2310 2339
2311 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFeedbackParameters( 2340 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFeedbackParameters(
2312 bool nack_enabled, 2341 bool nack_enabled,
2313 bool remb_enabled, 2342 bool remb_enabled,
2314 bool transport_cc_enabled, 2343 bool transport_cc_enabled,
2315 webrtc::RtcpMode rtcp_mode) { 2344 webrtc::RtcpMode rtcp_mode) {
2316 int nack_history_ms = nack_enabled ? kNackHistoryMs : 0; 2345 int nack_history_ms = nack_enabled ? kNackHistoryMs : 0;
2317 if (config_.rtp.nack.rtp_history_ms == nack_history_ms && 2346 if (config_.rtp.nack.rtp_history_ms == nack_history_ms &&
2318 config_.rtp.remb == remb_enabled && 2347 config_.rtp.remb == remb_enabled &&
(...skipping 11 matching lines...) Expand all
2330 config_.rtp.transport_cc = transport_cc_enabled; 2359 config_.rtp.transport_cc = transport_cc_enabled;
2331 config_.rtp.rtcp_mode = rtcp_mode; 2360 config_.rtp.rtcp_mode = rtcp_mode;
2332 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here 2361 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here
2333 // based on the rtcp-fb for the FlexFEC codec, not the media codec. 2362 // based on the rtcp-fb for the FlexFEC codec, not the media codec.
2334 flexfec_config_.transport_cc = config_.rtp.transport_cc; 2363 flexfec_config_.transport_cc = config_.rtp.transport_cc;
2335 flexfec_config_.rtcp_mode = config_.rtp.rtcp_mode; 2364 flexfec_config_.rtcp_mode = config_.rtp.rtcp_mode;
2336 LOG(LS_INFO) 2365 LOG(LS_INFO)
2337 << "RecreateWebRtcStream (recv) because of SetFeedbackParameters; nack=" 2366 << "RecreateWebRtcStream (recv) because of SetFeedbackParameters; nack="
2338 << nack_enabled << ", remb=" << remb_enabled 2367 << nack_enabled << ", remb=" << remb_enabled
2339 << ", transport_cc=" << transport_cc_enabled; 2368 << ", transport_cc=" << transport_cc_enabled;
2340 RecreateWebRtcStream(); 2369 MaybeRecreateWebRtcFlexfecStream();
2370 RecreateWebRtcVideoStream();
2341 } 2371 }
2342 2372
2343 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters( 2373 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters(
2344 const ChangedRecvParameters& params) { 2374 const ChangedRecvParameters& params) {
2345 bool needs_recreation = false; 2375 bool video_needs_recreation = false;
2376 bool flexfec_needs_recreation = false;
2346 std::vector<AllocatedDecoder> old_decoders; 2377 std::vector<AllocatedDecoder> old_decoders;
2347 if (params.codec_settings) { 2378 if (params.codec_settings) {
2348 ConfigureCodecs(*params.codec_settings, &old_decoders); 2379 ConfigureCodecs(*params.codec_settings, &old_decoders);
2349 needs_recreation = true; 2380 video_needs_recreation = true;
2350 } 2381 }
2351 if (params.rtp_header_extensions) { 2382 if (params.rtp_header_extensions) {
2352 config_.rtp.extensions = *params.rtp_header_extensions; 2383 config_.rtp.extensions = *params.rtp_header_extensions;
2353 flexfec_config_.rtp_header_extensions = *params.rtp_header_extensions; 2384 flexfec_config_.rtp_header_extensions = *params.rtp_header_extensions;
2354 needs_recreation = true; 2385 video_needs_recreation = true;
2386 flexfec_needs_recreation = true;
2355 } 2387 }
2356 if (needs_recreation) { 2388 if (params.flexfec_payload_type) {
2357 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; 2389 ConfigureFlexfecCodec(*params.flexfec_payload_type);
2358 RecreateWebRtcStream(); 2390 flexfec_needs_recreation = true;
2391 }
2392 if (flexfec_needs_recreation) {
2393 LOG(LS_INFO) << "MaybeRecreateWebRtcFlexfecStream (recv) because of "
2394 "SetRecvParameters";
2395 MaybeRecreateWebRtcFlexfecStream();
2396 }
2397 if (video_needs_recreation) {
2398 LOG(LS_INFO)
2399 << "RecreateWebRtcVideoStream (recv) because of SetRecvParameters";
2400 RecreateWebRtcVideoStream();
2359 ClearDecoders(&old_decoders); 2401 ClearDecoders(&old_decoders);
2360 } 2402 }
2361 } 2403 }
2362 2404
2363 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { 2405 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::
2406 RecreateWebRtcVideoStream() {
2364 if (stream_) { 2407 if (stream_) {
2365 call_->DestroyVideoReceiveStream(stream_); 2408 call_->DestroyVideoReceiveStream(stream_);
2366 stream_ = nullptr; 2409 stream_ = nullptr;
2367 } 2410 }
2411 // TODO(nisse): There are way too many copies here. And why isn't
2412 // the argument to CreateVideoReceiveStream a const ref?
2413 webrtc::VideoReceiveStream::Config config = config_.Copy();
2414 config.rtp.protected_by_flexfec = (flexfec_stream_ != nullptr);
2415 stream_ = call_->CreateVideoReceiveStream(config.Copy());
perkj_webrtc 2017/05/30 05:49:54 why config.copy? The config supports move.
brandtr 2017/05/30 07:57:34 Done.
2416 stream_->Start();
2417 }
2418
2419 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::
2420 MaybeRecreateWebRtcFlexfecStream() {
2368 if (flexfec_stream_) { 2421 if (flexfec_stream_) {
2369 call_->DestroyFlexfecReceiveStream(flexfec_stream_); 2422 call_->DestroyFlexfecReceiveStream(flexfec_stream_);
2370 flexfec_stream_ = nullptr; 2423 flexfec_stream_ = nullptr;
2371 } 2424 }
2372 const bool use_flexfec = flexfec_config_.IsCompleteAndEnabled(); 2425 if (flexfec_config_.IsCompleteAndEnabled()) {
2373 // TODO(nisse): There are way too many copies here. And why isn't
2374 // the argument to CreateVideoReceiveStream a const ref?
2375 webrtc::VideoReceiveStream::Config config = config_.Copy();
2376 config.rtp.protected_by_flexfec = use_flexfec;
2377 stream_ = call_->CreateVideoReceiveStream(config.Copy());
2378 stream_->Start();
2379
2380 if (use_flexfec) {
2381 flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_); 2426 flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_);
2382 flexfec_stream_->Start(); 2427 flexfec_stream_->Start();
2383 } 2428 }
2384 } 2429 }
2385 2430
2386 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( 2431 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders(
2387 std::vector<AllocatedDecoder>* allocated_decoders) { 2432 std::vector<AllocatedDecoder>* allocated_decoders) {
2388 for (size_t i = 0; i < allocated_decoders->size(); ++i) { 2433 for (size_t i = 0; i < allocated_decoders->size(); ++i) {
2389 if ((*allocated_decoders)[i].external) { 2434 if ((*allocated_decoders)[i].external) {
2390 external_decoder_factory_->DestroyVideoDecoder( 2435 external_decoder_factory_->DestroyVideoDecoder(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() 2542 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings()
2498 : flexfec_payload_type(-1), rtx_payload_type(-1) {} 2543 : flexfec_payload_type(-1), rtx_payload_type(-1) {}
2499 2544
2500 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( 2545 bool WebRtcVideoChannel2::VideoCodecSettings::operator==(
2501 const WebRtcVideoChannel2::VideoCodecSettings& other) const { 2546 const WebRtcVideoChannel2::VideoCodecSettings& other) const {
2502 return codec == other.codec && ulpfec == other.ulpfec && 2547 return codec == other.codec && ulpfec == other.ulpfec &&
2503 flexfec_payload_type == other.flexfec_payload_type && 2548 flexfec_payload_type == other.flexfec_payload_type &&
2504 rtx_payload_type == other.rtx_payload_type; 2549 rtx_payload_type == other.rtx_payload_type;
2505 } 2550 }
2506 2551
2552 bool WebRtcVideoChannel2::VideoCodecSettings::EqualsDisregardingFlexfec(
2553 const WebRtcVideoChannel2::VideoCodecSettings& a,
2554 const WebRtcVideoChannel2::VideoCodecSettings& b) {
2555 return a.codec == b.codec && a.ulpfec == b.ulpfec &&
2556 a.rtx_payload_type == b.rtx_payload_type;
2557 }
2558
2507 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( 2559 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=(
2508 const WebRtcVideoChannel2::VideoCodecSettings& other) const { 2560 const WebRtcVideoChannel2::VideoCodecSettings& other) const {
2509 return !(*this == other); 2561 return !(*this == other);
2510 } 2562 }
2511 2563
2512 std::vector<WebRtcVideoChannel2::VideoCodecSettings> 2564 std::vector<WebRtcVideoChannel2::VideoCodecSettings>
2513 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) { 2565 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) {
2514 RTC_DCHECK(!codecs.empty()); 2566 RTC_DCHECK(!codecs.empty());
2515 2567
2516 std::vector<VideoCodecSettings> video_codecs; 2568 std::vector<VideoCodecSettings> video_codecs;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 rtx_mapping[video_codecs[i].codec.id] != 2659 rtx_mapping[video_codecs[i].codec.id] !=
2608 ulpfec_config.red_payload_type) { 2660 ulpfec_config.red_payload_type) {
2609 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2661 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2610 } 2662 }
2611 } 2663 }
2612 2664
2613 return video_codecs; 2665 return video_codecs;
2614 } 2666 }
2615 2667
2616 } // namespace cricket 2668 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698