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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 const VideoOptions& options, | 670 const VideoOptions& options, |
671 WebRtcVideoEncoderFactory* external_encoder_factory, | 671 WebRtcVideoEncoderFactory* external_encoder_factory, |
672 WebRtcVideoDecoderFactory* external_decoder_factory) | 672 WebRtcVideoDecoderFactory* external_decoder_factory) |
673 : VideoMediaChannel(config), | 673 : VideoMediaChannel(config), |
674 call_(call), | 674 call_(call), |
675 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 675 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
676 video_config_(config.video), | 676 video_config_(config.video), |
677 external_encoder_factory_(external_encoder_factory), | 677 external_encoder_factory_(external_encoder_factory), |
678 external_decoder_factory_(external_decoder_factory), | 678 external_decoder_factory_(external_decoder_factory), |
679 default_send_options_(options), | 679 default_send_options_(options), |
680 red_disabled_by_remote_side_(false), | |
681 last_stats_log_ms_(-1) { | 680 last_stats_log_ms_(-1) { |
682 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 681 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
683 | 682 |
684 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 683 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
685 sending_ = false; | 684 sending_ = false; |
686 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory)); | 685 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory)); |
687 } | 686 } |
688 | 687 |
689 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 688 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
690 for (auto& kv : send_streams_) | 689 for (auto& kv : send_streams_) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 "codec or RTCP mode has changed."; | 840 "codec or RTCP mode has changed."; |
842 for (auto& kv : receive_streams_) { | 841 for (auto& kv : receive_streams_) { |
843 RTC_DCHECK(kv.second != nullptr); | 842 RTC_DCHECK(kv.second != nullptr); |
844 kv.second->SetFeedbackParameters( | 843 kv.second->SetFeedbackParameters( |
845 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), | 844 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), |
846 HasTransportCc(send_codec_->codec), | 845 HasTransportCc(send_codec_->codec), |
847 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 846 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
848 : webrtc::RtcpMode::kCompound); | 847 : webrtc::RtcpMode::kCompound); |
849 } | 848 } |
850 } | 849 } |
851 if (changed_params.codec) { | |
852 bool red_was_disabled = red_disabled_by_remote_side_; | |
853 red_disabled_by_remote_side_ = | |
854 changed_params.codec->ulpfec.red_payload_type == -1; | |
855 if (red_was_disabled != red_disabled_by_remote_side_) { | |
856 for (auto& kv : receive_streams_) { | |
857 // In practice VideoChannel::SetRemoteContent appears to most of the | |
858 // time also call UpdateRemoteStreams, which recreates the receive | |
859 // streams. If that's always true this call isn't needed. | |
860 kv.second->SetUlpfecDisabledRemotely(red_disabled_by_remote_side_); | |
861 } | |
862 } | |
863 } | |
864 } | 850 } |
865 send_params_ = params; | 851 send_params_ = params; |
866 return true; | 852 return true; |
867 } | 853 } |
868 | 854 |
869 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters( | 855 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters( |
870 uint32_t ssrc) const { | 856 uint32_t ssrc) const { |
871 rtc::CritScope stream_lock(&stream_crit_); | 857 rtc::CritScope stream_lock(&stream_crit_); |
872 auto it = send_streams_.find(ssrc); | 858 auto it = send_streams_.find(ssrc); |
873 if (it == send_streams_.end()) { | 859 if (it == send_streams_.end()) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 config.sync_group = sp.sync_label; | 1219 config.sync_group = sp.sync_label; |
1234 | 1220 |
1235 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1221 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
1236 config.rtp.transport_cc = | 1222 config.rtp.transport_cc = |
1237 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1223 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
1238 config.disable_prerenderer_smoothing = | 1224 config.disable_prerenderer_smoothing = |
1239 video_config_.disable_prerenderer_smoothing; | 1225 video_config_.disable_prerenderer_smoothing; |
1240 | 1226 |
1241 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( | 1227 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
1242 call_, sp, std::move(config), external_decoder_factory_, default_stream, | 1228 call_, sp, std::move(config), external_decoder_factory_, default_stream, |
1243 recv_codecs_, red_disabled_by_remote_side_); | 1229 recv_codecs_); |
1244 | 1230 |
1245 return true; | 1231 return true; |
1246 } | 1232 } |
1247 | 1233 |
1248 void WebRtcVideoChannel2::ConfigureReceiverRtp( | 1234 void WebRtcVideoChannel2::ConfigureReceiverRtp( |
1249 webrtc::VideoReceiveStream::Config* config, | 1235 webrtc::VideoReceiveStream::Config* config, |
1250 const StreamParams& sp) const { | 1236 const StreamParams& sp) const { |
1251 uint32_t ssrc = sp.first_ssrc(); | 1237 uint32_t ssrc = sp.first_ssrc(); |
1252 | 1238 |
1253 config->rtp.remote_ssrc = ssrc; | 1239 config->rtp.remote_ssrc = ssrc; |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 // Call stream_->Start() if necessary conditions are met. | 2113 // Call stream_->Start() if necessary conditions are met. |
2128 UpdateSendState(); | 2114 UpdateSendState(); |
2129 } | 2115 } |
2130 | 2116 |
2131 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2117 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
2132 webrtc::Call* call, | 2118 webrtc::Call* call, |
2133 const StreamParams& sp, | 2119 const StreamParams& sp, |
2134 webrtc::VideoReceiveStream::Config config, | 2120 webrtc::VideoReceiveStream::Config config, |
2135 WebRtcVideoDecoderFactory* external_decoder_factory, | 2121 WebRtcVideoDecoderFactory* external_decoder_factory, |
2136 bool default_stream, | 2122 bool default_stream, |
2137 const std::vector<VideoCodecSettings>& recv_codecs, | 2123 const std::vector<VideoCodecSettings>& recv_codecs) |
2138 bool red_disabled_by_remote_side) | |
2139 : call_(call), | 2124 : call_(call), |
2140 stream_params_(sp), | 2125 stream_params_(sp), |
2141 stream_(NULL), | 2126 stream_(NULL), |
2142 default_stream_(default_stream), | 2127 default_stream_(default_stream), |
2143 config_(std::move(config)), | 2128 config_(std::move(config)), |
2144 red_disabled_by_remote_side_(red_disabled_by_remote_side), | |
2145 external_decoder_factory_(external_decoder_factory), | 2129 external_decoder_factory_(external_decoder_factory), |
2146 sink_(NULL), | 2130 sink_(NULL), |
2147 first_frame_timestamp_(-1), | 2131 first_frame_timestamp_(-1), |
2148 estimated_remote_start_ntp_time_ms_(0) { | 2132 estimated_remote_start_ntp_time_ms_(0) { |
2149 config_.renderer = this; | 2133 config_.renderer = this; |
2150 std::vector<AllocatedDecoder> old_decoders; | 2134 std::vector<AllocatedDecoder> old_decoders; |
2151 ConfigureCodecs(recv_codecs, &old_decoders); | 2135 ConfigureCodecs(recv_codecs, &old_decoders); |
2152 RecreateWebRtcStream(); | 2136 RecreateWebRtcStream(); |
2153 RTC_DCHECK(old_decoders.empty()); | 2137 RTC_DCHECK(old_decoders.empty()); |
2154 } | 2138 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; | 2321 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; |
2338 RecreateWebRtcStream(); | 2322 RecreateWebRtcStream(); |
2339 ClearDecoders(&old_decoders); | 2323 ClearDecoders(&old_decoders); |
2340 } | 2324 } |
2341 } | 2325 } |
2342 | 2326 |
2343 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2327 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
2344 if (stream_ != NULL) { | 2328 if (stream_ != NULL) { |
2345 call_->DestroyVideoReceiveStream(stream_); | 2329 call_->DestroyVideoReceiveStream(stream_); |
2346 } | 2330 } |
2347 webrtc::VideoReceiveStream::Config config = config_.Copy(); | 2331 stream_ = call_->CreateVideoReceiveStream(config_.Copy()); |
2348 if (red_disabled_by_remote_side_) { | |
2349 config.rtp.ulpfec.red_payload_type = -1; | |
2350 config.rtp.ulpfec.ulpfec_payload_type = -1; | |
2351 config.rtp.ulpfec.red_rtx_payload_type = -1; | |
2352 } | |
2353 stream_ = call_->CreateVideoReceiveStream(std::move(config)); | |
2354 stream_->Start(); | 2332 stream_->Start(); |
2355 } | 2333 } |
2356 | 2334 |
2357 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( | 2335 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( |
2358 std::vector<AllocatedDecoder>* allocated_decoders) { | 2336 std::vector<AllocatedDecoder>* allocated_decoders) { |
2359 for (size_t i = 0; i < allocated_decoders->size(); ++i) { | 2337 for (size_t i = 0; i < allocated_decoders->size(); ++i) { |
2360 if ((*allocated_decoders)[i].external) { | 2338 if ((*allocated_decoders)[i].external) { |
2361 external_decoder_factory_->DestroyVideoDecoder( | 2339 external_decoder_factory_->DestroyVideoDecoder( |
2362 (*allocated_decoders)[i].external_decoder); | 2340 (*allocated_decoders)[i].external_decoder); |
2363 } | 2341 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; | 2428 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; |
2451 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; | 2429 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; |
2452 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; | 2430 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; |
2453 | 2431 |
2454 if (log_stats) | 2432 if (log_stats) |
2455 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); | 2433 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); |
2456 | 2434 |
2457 return info; | 2435 return info; |
2458 } | 2436 } |
2459 | 2437 |
2460 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetUlpfecDisabledRemotely( | |
2461 bool disable) { | |
2462 red_disabled_by_remote_side_ = disable; | |
2463 RecreateWebRtcStream(); | |
2464 } | |
2465 | |
2466 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() | 2438 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() |
2467 : rtx_payload_type(-1) {} | 2439 : rtx_payload_type(-1) {} |
2468 | 2440 |
2469 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( | 2441 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( |
2470 const WebRtcVideoChannel2::VideoCodecSettings& other) const { | 2442 const WebRtcVideoChannel2::VideoCodecSettings& other) const { |
2471 return codec == other.codec && | 2443 return codec == other.codec && |
2472 ulpfec.ulpfec_payload_type == other.ulpfec.ulpfec_payload_type && | 2444 ulpfec.ulpfec_payload_type == other.ulpfec.ulpfec_payload_type && |
2473 ulpfec.red_payload_type == other.ulpfec.red_payload_type && | 2445 ulpfec.red_payload_type == other.ulpfec.red_payload_type && |
2474 ulpfec.red_rtx_payload_type == other.ulpfec.red_rtx_payload_type && | 2446 ulpfec.red_rtx_payload_type == other.ulpfec.red_rtx_payload_type && |
2475 rtx_payload_type == other.rtx_payload_type; | 2447 rtx_payload_type == other.rtx_payload_type; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2574 rtx_mapping[video_codecs[i].codec.id] != | 2546 rtx_mapping[video_codecs[i].codec.id] != |
2575 ulpfec_config.red_payload_type) { | 2547 ulpfec_config.red_payload_type) { |
2576 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2548 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2577 } | 2549 } |
2578 } | 2550 } |
2579 | 2551 |
2580 return video_codecs; | 2552 return video_codecs; |
2581 } | 2553 } |
2582 | 2554 |
2583 } // namespace cricket | 2555 } // namespace cricket |
OLD | NEW |