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

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

Issue 2469093003: Remove RED/RTX workaround from sender/receiver and VideoEngine2. (Closed)
Patch Set: Remove RED/RTX workaround from sender/receiver and VideoEngine2. Created 4 years, 1 month 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 const std::vector<VideoCodec>& recv_codecs, 667 const std::vector<VideoCodec>& recv_codecs,
668 WebRtcVideoEncoderFactory* external_encoder_factory, 668 WebRtcVideoEncoderFactory* external_encoder_factory,
669 WebRtcVideoDecoderFactory* external_decoder_factory) 669 WebRtcVideoDecoderFactory* external_decoder_factory)
670 : VideoMediaChannel(config), 670 : VideoMediaChannel(config),
671 call_(call), 671 call_(call),
672 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), 672 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
673 video_config_(config.video), 673 video_config_(config.video),
674 external_encoder_factory_(external_encoder_factory), 674 external_encoder_factory_(external_encoder_factory),
675 external_decoder_factory_(external_decoder_factory), 675 external_decoder_factory_(external_decoder_factory),
676 default_send_options_(options), 676 default_send_options_(options),
677 red_disabled_by_remote_side_(false),
678 last_stats_log_ms_(-1) { 677 last_stats_log_ms_(-1) {
679 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 678 RTC_DCHECK(thread_checker_.CalledOnValidThread());
680 679
681 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; 680 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
682 sending_ = false; 681 sending_ = false;
683 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); 682 RTC_DCHECK(ValidateCodecFormats(recv_codecs));
684 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); 683 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs));
685 } 684 }
686 685
687 WebRtcVideoChannel2::~WebRtcVideoChannel2() { 686 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 "codec or RTCP mode has changed."; 839 "codec or RTCP mode has changed.";
841 for (auto& kv : receive_streams_) { 840 for (auto& kv : receive_streams_) {
842 RTC_DCHECK(kv.second != nullptr); 841 RTC_DCHECK(kv.second != nullptr);
843 kv.second->SetFeedbackParameters( 842 kv.second->SetFeedbackParameters(
844 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), 843 HasNack(send_codec_->codec), HasRemb(send_codec_->codec),
845 HasTransportCc(send_codec_->codec), 844 HasTransportCc(send_codec_->codec),
846 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize 845 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize
847 : webrtc::RtcpMode::kCompound); 846 : webrtc::RtcpMode::kCompound);
848 } 847 }
849 } 848 }
850 if (changed_params.codec) {
851 bool red_was_disabled = red_disabled_by_remote_side_;
852 red_disabled_by_remote_side_ =
853 changed_params.codec->ulpfec.red_payload_type == -1;
854 if (red_was_disabled != red_disabled_by_remote_side_) {
855 for (auto& kv : receive_streams_) {
856 // In practice VideoChannel::SetRemoteContent appears to most of the
857 // time also call UpdateRemoteStreams, which recreates the receive
858 // streams. If that's always true this call isn't needed.
859 kv.second->SetUlpfecDisabledRemotely(red_disabled_by_remote_side_);
860 }
861 }
862 }
863 } 849 }
864 send_params_ = params; 850 send_params_ = params;
865 return true; 851 return true;
866 } 852 }
867 853
868 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters( 854 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters(
869 uint32_t ssrc) const { 855 uint32_t ssrc) const {
870 rtc::CritScope stream_lock(&stream_crit_); 856 rtc::CritScope stream_lock(&stream_crit_);
871 auto it = send_streams_.find(ssrc); 857 auto it = send_streams_.find(ssrc);
872 if (it == send_streams_.end()) { 858 if (it == send_streams_.end()) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 config.sync_group = sp.sync_label; 1215 config.sync_group = sp.sync_label;
1230 1216
1231 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; 1217 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false;
1232 config.rtp.transport_cc = 1218 config.rtp.transport_cc =
1233 send_codec_ ? HasTransportCc(send_codec_->codec) : false; 1219 send_codec_ ? HasTransportCc(send_codec_->codec) : false;
1234 config.disable_prerenderer_smoothing = 1220 config.disable_prerenderer_smoothing =
1235 video_config_.disable_prerenderer_smoothing; 1221 video_config_.disable_prerenderer_smoothing;
1236 1222
1237 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( 1223 receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
1238 call_, sp, std::move(config), external_decoder_factory_, default_stream, 1224 call_, sp, std::move(config), external_decoder_factory_, default_stream,
1239 recv_codecs_, red_disabled_by_remote_side_); 1225 recv_codecs_);
1240 1226
1241 return true; 1227 return true;
1242 } 1228 }
1243 1229
1244 void WebRtcVideoChannel2::ConfigureReceiverRtp( 1230 void WebRtcVideoChannel2::ConfigureReceiverRtp(
1245 webrtc::VideoReceiveStream::Config* config, 1231 webrtc::VideoReceiveStream::Config* config,
1246 const StreamParams& sp) const { 1232 const StreamParams& sp) const {
1247 uint32_t ssrc = sp.first_ssrc(); 1233 uint32_t ssrc = sp.first_ssrc();
1248 1234
1249 config->rtp.remote_ssrc = ssrc; 1235 config->rtp.remote_ssrc = ssrc;
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 // Call stream_->Start() if necessary conditions are met. 2103 // Call stream_->Start() if necessary conditions are met.
2118 UpdateSendState(); 2104 UpdateSendState();
2119 } 2105 }
2120 2106
2121 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( 2107 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
2122 webrtc::Call* call, 2108 webrtc::Call* call,
2123 const StreamParams& sp, 2109 const StreamParams& sp,
2124 webrtc::VideoReceiveStream::Config config, 2110 webrtc::VideoReceiveStream::Config config,
2125 WebRtcVideoDecoderFactory* external_decoder_factory, 2111 WebRtcVideoDecoderFactory* external_decoder_factory,
2126 bool default_stream, 2112 bool default_stream,
2127 const std::vector<VideoCodecSettings>& recv_codecs, 2113 const std::vector<VideoCodecSettings>& recv_codecs)
2128 bool red_disabled_by_remote_side)
2129 : call_(call), 2114 : call_(call),
2130 stream_params_(sp), 2115 stream_params_(sp),
2131 stream_(NULL), 2116 stream_(NULL),
2132 default_stream_(default_stream), 2117 default_stream_(default_stream),
2133 config_(std::move(config)), 2118 config_(std::move(config)),
2134 red_disabled_by_remote_side_(red_disabled_by_remote_side),
2135 external_decoder_factory_(external_decoder_factory), 2119 external_decoder_factory_(external_decoder_factory),
2136 sink_(NULL), 2120 sink_(NULL),
2137 first_frame_timestamp_(-1), 2121 first_frame_timestamp_(-1),
2138 estimated_remote_start_ntp_time_ms_(0) { 2122 estimated_remote_start_ntp_time_ms_(0) {
2139 config_.renderer = this; 2123 config_.renderer = this;
2140 std::vector<AllocatedDecoder> old_decoders; 2124 std::vector<AllocatedDecoder> old_decoders;
2141 ConfigureCodecs(recv_codecs, &old_decoders); 2125 ConfigureCodecs(recv_codecs, &old_decoders);
2142 RecreateWebRtcStream(); 2126 RecreateWebRtcStream();
2143 RTC_DCHECK(old_decoders.empty()); 2127 RTC_DCHECK(old_decoders.empty());
2144 } 2128 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; 2311 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters";
2328 RecreateWebRtcStream(); 2312 RecreateWebRtcStream();
2329 ClearDecoders(&old_decoders); 2313 ClearDecoders(&old_decoders);
2330 } 2314 }
2331 } 2315 }
2332 2316
2333 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { 2317 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() {
2334 if (stream_ != NULL) { 2318 if (stream_ != NULL) {
2335 call_->DestroyVideoReceiveStream(stream_); 2319 call_->DestroyVideoReceiveStream(stream_);
2336 } 2320 }
2337 webrtc::VideoReceiveStream::Config config = config_.Copy(); 2321 stream_ = call_->CreateVideoReceiveStream(config_.Copy());
2338 if (red_disabled_by_remote_side_) {
2339 config.rtp.ulpfec.red_payload_type = -1;
2340 config.rtp.ulpfec.ulpfec_payload_type = -1;
2341 config.rtp.ulpfec.red_rtx_payload_type = -1;
2342 }
2343 stream_ = call_->CreateVideoReceiveStream(std::move(config));
2344 stream_->Start(); 2322 stream_->Start();
2345 } 2323 }
2346 2324
2347 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( 2325 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders(
2348 std::vector<AllocatedDecoder>* allocated_decoders) { 2326 std::vector<AllocatedDecoder>* allocated_decoders) {
2349 for (size_t i = 0; i < allocated_decoders->size(); ++i) { 2327 for (size_t i = 0; i < allocated_decoders->size(); ++i) {
2350 if ((*allocated_decoders)[i].external) { 2328 if ((*allocated_decoders)[i].external) {
2351 external_decoder_factory_->DestroyVideoDecoder( 2329 external_decoder_factory_->DestroyVideoDecoder(
2352 (*allocated_decoders)[i].external_decoder); 2330 (*allocated_decoders)[i].external_decoder);
2353 } 2331 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2440 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; 2418 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets;
2441 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; 2419 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets;
2442 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; 2420 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets;
2443 2421
2444 if (log_stats) 2422 if (log_stats)
2445 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); 2423 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis());
2446 2424
2447 return info; 2425 return info;
2448 } 2426 }
2449 2427
2450 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetUlpfecDisabledRemotely(
2451 bool disable) {
2452 red_disabled_by_remote_side_ = disable;
2453 RecreateWebRtcStream();
2454 }
2455
2456 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() 2428 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings()
2457 : rtx_payload_type(-1) {} 2429 : rtx_payload_type(-1) {}
2458 2430
2459 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( 2431 bool WebRtcVideoChannel2::VideoCodecSettings::operator==(
2460 const WebRtcVideoChannel2::VideoCodecSettings& other) const { 2432 const WebRtcVideoChannel2::VideoCodecSettings& other) const {
2461 return codec == other.codec && 2433 return codec == other.codec &&
2462 ulpfec.ulpfec_payload_type == other.ulpfec.ulpfec_payload_type && 2434 ulpfec.ulpfec_payload_type == other.ulpfec.ulpfec_payload_type &&
2463 ulpfec.red_payload_type == other.ulpfec.red_payload_type && 2435 ulpfec.red_payload_type == other.ulpfec.red_payload_type &&
2464 ulpfec.red_rtx_payload_type == other.ulpfec.red_rtx_payload_type && 2436 ulpfec.red_rtx_payload_type == other.ulpfec.red_rtx_payload_type &&
2465 rtx_payload_type == other.rtx_payload_type; 2437 rtx_payload_type == other.rtx_payload_type;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 rtx_mapping[video_codecs[i].codec.id] != 2531 rtx_mapping[video_codecs[i].codec.id] !=
2560 ulpfec_config.red_payload_type) { 2532 ulpfec_config.red_payload_type) {
2561 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2533 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2562 } 2534 }
2563 } 2535 }
2564 2536
2565 return video_codecs; 2537 return video_codecs;
2566 } 2538 }
2567 2539
2568 } // namespace cricket 2540 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698