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

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

Issue 1418123003: Adding reduced size RTCP configuration down to the video stream level. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing patch conflicts Created 5 years 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 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 return true; 784 return true;
785 } 785 }
786 } 786 }
787 return false; 787 return false;
788 } 788 }
789 789
790 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { 790 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) {
791 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); 791 LOG(LS_INFO) << "SetSendParameters: " << params.ToString();
792 // TODO(pbos): Refactor this to only recreate the send streams once 792 // TODO(pbos): Refactor this to only recreate the send streams once
793 // instead of 4 times. 793 // instead of 4 times.
794 return (SetSendCodecs(params.codecs) && 794 if (!SetSendCodecs(params.codecs) ||
795 SetSendRtpHeaderExtensions(params.extensions) && 795 !SetSendRtpHeaderExtensions(params.extensions) ||
796 SetMaxSendBandwidth(params.max_bandwidth_bps) && 796 !SetMaxSendBandwidth(params.max_bandwidth_bps) ||
797 SetOptions(params.options)); 797 !SetOptions(params.options)) {
798 return false;
799 }
800 if (send_params_.rtcp.reduced_size != params.rtcp.reduced_size) {
801 rtc::CritScope stream_lock(&stream_crit_);
802 for (auto& kv : send_streams_) {
803 kv.second->SetSendParameters(params);
804 }
805 }
806 send_params_ = params;
807 return true;
798 } 808 }
799 809
800 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { 810 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) {
801 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); 811 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString();
802 // TODO(pbos): Refactor this to only recreate the recv streams once 812 // TODO(pbos): Refactor this to only recreate the recv streams once
803 // instead of twice. 813 // instead of twice.
804 return (SetRecvCodecs(params.codecs) && 814 if (!SetRecvCodecs(params.codecs) ||
805 SetRecvRtpHeaderExtensions(params.extensions)); 815 !SetRecvRtpHeaderExtensions(params.extensions)) {
816 return false;
817 }
818 if (recv_params_.rtcp.reduced_size != params.rtcp.reduced_size) {
819 rtc::CritScope stream_lock(&stream_crit_);
820 for (auto& kv : receive_streams_) {
821 kv.second->SetRecvParameters(params);
822 }
823 }
824 recv_params_ = params;
825 return true;
806 } 826 }
807 827
808 std::string WebRtcVideoChannel2::CodecSettingsVectorToString( 828 std::string WebRtcVideoChannel2::CodecSettingsVectorToString(
809 const std::vector<VideoCodecSettings>& codecs) { 829 const std::vector<VideoCodecSettings>& codecs) {
810 std::stringstream out; 830 std::stringstream out;
811 out << '{'; 831 out << '{';
812 for (size_t i = 0; i < codecs.size(); ++i) { 832 for (size_t i = 0; i < codecs.size(); ++i) {
813 out << codecs[i].codec.ToString(); 833 out << codecs[i].codec.ToString();
814 if (i != codecs.size() - 1) { 834 if (i != codecs.size() - 1) {
815 out << ", "; 835 out << ", ";
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 1036
1017 if (!ValidateSendSsrcAvailability(sp)) 1037 if (!ValidateSendSsrcAvailability(sp))
1018 return false; 1038 return false;
1019 1039
1020 for (uint32_t used_ssrc : sp.ssrcs) 1040 for (uint32_t used_ssrc : sp.ssrcs)
1021 send_ssrcs_.insert(used_ssrc); 1041 send_ssrcs_.insert(used_ssrc);
1022 1042
1023 webrtc::VideoSendStream::Config config(this); 1043 webrtc::VideoSendStream::Config config(this);
1024 config.overuse_callback = this; 1044 config.overuse_callback = this;
1025 1045
1026 WebRtcVideoSendStream* stream = 1046 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream(
1027 new WebRtcVideoSendStream(call_, 1047 call_, sp, config, external_encoder_factory_, options_,
1028 sp, 1048 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_,
1029 config, 1049 send_params_);
1030 external_encoder_factory_,
1031 options_,
1032 bitrate_config_.max_bitrate_bps,
1033 send_codec_,
1034 send_rtp_extensions_);
1035 1050
1036 uint32_t ssrc = sp.first_ssrc(); 1051 uint32_t ssrc = sp.first_ssrc();
1037 RTC_DCHECK(ssrc != 0); 1052 RTC_DCHECK(ssrc != 0);
1038 send_streams_[ssrc] = stream; 1053 send_streams_[ssrc] = stream;
1039 1054
1040 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { 1055 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
1041 rtcp_receiver_report_ssrc_ = ssrc; 1056 rtcp_receiver_report_ssrc_ = ssrc;
1042 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " 1057 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added "
1043 "a send stream."; 1058 "a send stream.";
1044 for (auto& kv : receive_streams_) 1059 for (auto& kv : receive_streams_)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 1181
1167 void WebRtcVideoChannel2::ConfigureReceiverRtp( 1182 void WebRtcVideoChannel2::ConfigureReceiverRtp(
1168 webrtc::VideoReceiveStream::Config* config, 1183 webrtc::VideoReceiveStream::Config* config,
1169 const StreamParams& sp) const { 1184 const StreamParams& sp) const {
1170 uint32_t ssrc = sp.first_ssrc(); 1185 uint32_t ssrc = sp.first_ssrc();
1171 1186
1172 config->rtp.remote_ssrc = ssrc; 1187 config->rtp.remote_ssrc = ssrc;
1173 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_; 1188 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_;
1174 1189
1175 config->rtp.extensions = recv_rtp_extensions_; 1190 config->rtp.extensions = recv_rtp_extensions_;
1191 config->rtp.rtcp_mode = recv_params_.rtcp.reduced_size
1192 ? webrtc::RtcpMode::kReducedSize
1193 : webrtc::RtcpMode::kCompound;
1176 1194
1177 // TODO(pbos): This protection is against setting the same local ssrc as 1195 // TODO(pbos): This protection is against setting the same local ssrc as
1178 // remote which is not permitted by the lower-level API. RTCP requires a 1196 // remote which is not permitted by the lower-level API. RTCP requires a
1179 // corresponding sender SSRC. Figure out what to do when we don't have 1197 // corresponding sender SSRC. Figure out what to do when we don't have
1180 // (receive-only) or know a good local SSRC. 1198 // (receive-only) or know a good local SSRC.
1181 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) { 1199 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) {
1182 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) { 1200 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) {
1183 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc; 1201 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc;
1184 } else { 1202 } else {
1185 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1; 1203 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1;
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1670 }
1653 1671
1654 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( 1672 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
1655 webrtc::Call* call, 1673 webrtc::Call* call,
1656 const StreamParams& sp, 1674 const StreamParams& sp,
1657 const webrtc::VideoSendStream::Config& config, 1675 const webrtc::VideoSendStream::Config& config,
1658 WebRtcVideoEncoderFactory* external_encoder_factory, 1676 WebRtcVideoEncoderFactory* external_encoder_factory,
1659 const VideoOptions& options, 1677 const VideoOptions& options,
1660 int max_bitrate_bps, 1678 int max_bitrate_bps,
1661 const rtc::Optional<VideoCodecSettings>& codec_settings, 1679 const rtc::Optional<VideoCodecSettings>& codec_settings,
1662 const std::vector<webrtc::RtpExtension>& rtp_extensions) 1680 const std::vector<webrtc::RtpExtension>& rtp_extensions,
1681 // TODO(deadbeef): Don't duplicate information between send_params,
1682 // rtp_extensions, options, etc.
1683 const VideoSendParameters& send_params)
1663 : ssrcs_(sp.ssrcs), 1684 : ssrcs_(sp.ssrcs),
1664 ssrc_groups_(sp.ssrc_groups), 1685 ssrc_groups_(sp.ssrc_groups),
1665 call_(call), 1686 call_(call),
1666 external_encoder_factory_(external_encoder_factory), 1687 external_encoder_factory_(external_encoder_factory),
1667 stream_(NULL), 1688 stream_(NULL),
1668 parameters_(config, options, max_bitrate_bps, codec_settings), 1689 parameters_(config, options, max_bitrate_bps, codec_settings),
1669 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), 1690 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false),
1670 capturer_(NULL), 1691 capturer_(NULL),
1671 sending_(false), 1692 sending_(false),
1672 muted_(false), 1693 muted_(false),
1673 old_adapt_changes_(0), 1694 old_adapt_changes_(0),
1674 first_frame_timestamp_ms_(0), 1695 first_frame_timestamp_ms_(0),
1675 last_frame_timestamp_ms_(0) { 1696 last_frame_timestamp_ms_(0) {
1676 parameters_.config.rtp.max_packet_size = kVideoMtu; 1697 parameters_.config.rtp.max_packet_size = kVideoMtu;
1677 1698
1678 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1699 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1679 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1700 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1680 &parameters_.config.rtp.rtx.ssrcs); 1701 &parameters_.config.rtp.rtx.ssrcs);
1681 parameters_.config.rtp.c_name = sp.cname; 1702 parameters_.config.rtp.c_name = sp.cname;
1682 parameters_.config.rtp.extensions = rtp_extensions; 1703 parameters_.config.rtp.extensions = rtp_extensions;
1704 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
1705 ? webrtc::RtcpMode::kReducedSize
1706 : webrtc::RtcpMode::kCompound;
1683 1707
1684 if (codec_settings) { 1708 if (codec_settings) {
1685 SetCodec(*codec_settings); 1709 SetCodec(*codec_settings);
1686 } 1710 }
1687 } 1711 }
1688 1712
1689 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { 1713 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
1690 DisconnectCapturer(); 1714 DisconnectCapturer();
1691 if (stream_ != NULL) { 1715 if (stream_ != NULL) {
1692 call_->DestroyVideoSendStream(stream_); 1716 call_->DestroyVideoSendStream(stream_);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( 2013 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions(
1990 const std::vector<webrtc::RtpExtension>& rtp_extensions) { 2014 const std::vector<webrtc::RtpExtension>& rtp_extensions) {
1991 rtc::CritScope cs(&lock_); 2015 rtc::CritScope cs(&lock_);
1992 parameters_.config.rtp.extensions = rtp_extensions; 2016 parameters_.config.rtp.extensions = rtp_extensions;
1993 if (stream_ != nullptr) { 2017 if (stream_ != nullptr) {
1994 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions"; 2018 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions";
1995 RecreateWebRtcStream(); 2019 RecreateWebRtcStream();
1996 } 2020 }
1997 } 2021 }
1998 2022
2023 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters(
2024 const VideoSendParameters& send_params) {
2025 rtc::CritScope cs(&lock_);
2026 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
2027 ? webrtc::RtcpMode::kReducedSize
2028 : webrtc::RtcpMode::kCompound;
2029 if (stream_ != nullptr) {
2030 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters";
2031 RecreateWebRtcStream();
2032 }
2033 }
2034
1999 webrtc::VideoEncoderConfig 2035 webrtc::VideoEncoderConfig
2000 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( 2036 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
2001 const Dimensions& dimensions, 2037 const Dimensions& dimensions,
2002 const VideoCodec& codec) const { 2038 const VideoCodec& codec) const {
2003 webrtc::VideoEncoderConfig encoder_config; 2039 webrtc::VideoEncoderConfig encoder_config;
2004 if (dimensions.is_screencast) { 2040 if (dimensions.is_screencast) {
2005 RTC_CHECK(parameters_.options.screencast_min_bitrate); 2041 RTC_CHECK(parameters_.options.screencast_min_bitrate);
2006 encoder_config.min_transmit_bitrate_bps = 2042 encoder_config.min_transmit_bitrate_bps =
2007 *parameters_.options.screencast_min_bitrate * 1000; 2043 *parameters_.options.screencast_min_bitrate * 1000;
2008 encoder_config.content_type = 2044 encoder_config.content_type =
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 RecreateWebRtcStream(); 2462 RecreateWebRtcStream();
2427 } 2463 }
2428 2464
2429 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRtpExtensions( 2465 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRtpExtensions(
2430 const std::vector<webrtc::RtpExtension>& extensions) { 2466 const std::vector<webrtc::RtpExtension>& extensions) {
2431 config_.rtp.extensions = extensions; 2467 config_.rtp.extensions = extensions;
2432 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRtpExtensions"; 2468 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRtpExtensions";
2433 RecreateWebRtcStream(); 2469 RecreateWebRtcStream();
2434 } 2470 }
2435 2471
2472 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters(
2473 const VideoRecvParameters& recv_params) {
2474 config_.rtp.rtcp_mode = recv_params.rtcp.reduced_size
2475 ? webrtc::RtcpMode::kReducedSize
2476 : webrtc::RtcpMode::kCompound;
2477 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters";
2478 RecreateWebRtcStream();
2479 }
2480
2436 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { 2481 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() {
2437 if (stream_ != NULL) { 2482 if (stream_ != NULL) {
2438 call_->DestroyVideoReceiveStream(stream_); 2483 call_->DestroyVideoReceiveStream(stream_);
2439 } 2484 }
2440 stream_ = call_->CreateVideoReceiveStream(config_); 2485 stream_ = call_->CreateVideoReceiveStream(config_);
2441 stream_->Start(); 2486 stream_->Start();
2442 } 2487 }
2443 2488
2444 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( 2489 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders(
2445 std::vector<AllocatedDecoder>* allocated_decoders) { 2490 std::vector<AllocatedDecoder>* allocated_decoders) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2728 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2684 } 2729 }
2685 } 2730 }
2686 2731
2687 return video_codecs; 2732 return video_codecs;
2688 } 2733 }
2689 2734
2690 } // namespace cricket 2735 } // namespace cricket
2691 2736
2692 #endif // HAVE_WEBRTC_VIDEO 2737 #endif // HAVE_WEBRTC_VIDEO
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/media/webrtc/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698