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

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

Issue 1308023004: Add support for negotiating RTCP with reduced size. Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/session/media/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // side to cause recreation of the stream. 882 // side to cause recreation of the stream.
883 before[i].codec.preference = 0; 883 before[i].codec.preference = 0;
884 after[i].codec.preference = 0; 884 after[i].codec.preference = 0;
885 if (before[i] != after[i]) { 885 if (before[i] != after[i]) {
886 return true; 886 return true;
887 } 887 }
888 } 888 }
889 return false; 889 return false;
890 } 890 }
891 891
892 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { 892 bool WebRtcVideoChannel2::SetSendParameters(
893 const VideoSendParameters& send_params) {
893 // TODO(pbos): Refactor this to only recreate the send streams once 894 // TODO(pbos): Refactor this to only recreate the send streams once
894 // instead of 4 times. 895 // instead of 4 times.
895 return (SetSendCodecs(params.codecs) && 896 if (!SetSendCodecs(send_params.codecs) ||
896 SetSendRtpHeaderExtensions(params.extensions) && 897 !SetSendRtpHeaderExtensions(send_params.extensions) ||
897 SetMaxSendBandwidth(params.max_bandwidth_bps) && 898 !SetMaxSendBandwidth(send_params.max_bandwidth_bps) ||
898 SetOptions(params.options)); 899 !SetOptions(send_params.options)) {
900 return false;
901 }
902 send_params_ = send_params;
903 return true;
899 } 904 }
900 905
901 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { 906 bool WebRtcVideoChannel2::SetRecvParameters(
907 const VideoRecvParameters& recv_params) {
902 // TODO(pbos): Refactor this to only recreate the recv streams once 908 // TODO(pbos): Refactor this to only recreate the recv streams once
903 // instead of twice. 909 // instead of twice.
904 return (SetRecvCodecs(params.codecs) && 910 if (!SetRecvCodecs(recv_params.codecs) ||
905 SetRecvRtpHeaderExtensions(params.extensions)); 911 !SetRecvRtpHeaderExtensions(recv_params.extensions)) {
912 return false;
913 }
914 recv_params_ = recv_params;
915 return true;
906 } 916 }
907 917
908 std::string WebRtcVideoChannel2::CodecSettingsVectorToString( 918 std::string WebRtcVideoChannel2::CodecSettingsVectorToString(
909 const std::vector<VideoCodecSettings>& codecs) { 919 const std::vector<VideoCodecSettings>& codecs) {
910 std::stringstream out; 920 std::stringstream out;
911 out << '{'; 921 out << '{';
912 for (size_t i = 0; i < codecs.size(); ++i) { 922 for (size_t i = 0; i < codecs.size(); ++i) {
913 out << codecs[i].codec.ToString(); 923 out << codecs[i].codec.ToString();
914 if (i != codecs.size() - 1) { 924 if (i != codecs.size() - 1) {
915 out << ", "; 925 out << ", ";
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 return false; 1114 return false;
1105 1115
1106 rtc::CritScope stream_lock(&stream_crit_); 1116 rtc::CritScope stream_lock(&stream_crit_);
1107 1117
1108 if (!ValidateSendSsrcAvailability(sp)) 1118 if (!ValidateSendSsrcAvailability(sp))
1109 return false; 1119 return false;
1110 1120
1111 for (uint32 used_ssrc : sp.ssrcs) 1121 for (uint32 used_ssrc : sp.ssrcs)
1112 send_ssrcs_.insert(used_ssrc); 1122 send_ssrcs_.insert(used_ssrc);
1113 1123
1114 WebRtcVideoSendStream* stream = 1124 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream(
1115 new WebRtcVideoSendStream(call_.get(), 1125 call_.get(), external_encoder_factory_, options_,
1116 external_encoder_factory_, 1126 bitrate_config_.max_bitrate_bps, send_codec_, sp, send_rtp_extensions_,
1117 options_, 1127 send_params_);
1118 bitrate_config_.max_bitrate_bps,
1119 send_codec_,
1120 sp,
1121 send_rtp_extensions_);
1122 1128
1123 uint32 ssrc = sp.first_ssrc(); 1129 uint32 ssrc = sp.first_ssrc();
1124 DCHECK(ssrc != 0); 1130 DCHECK(ssrc != 0);
1125 send_streams_[ssrc] = stream; 1131 send_streams_[ssrc] = stream;
1126 1132
1127 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { 1133 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
1128 rtcp_receiver_report_ssrc_ = ssrc; 1134 rtcp_receiver_report_ssrc_ = ssrc;
1129 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " 1135 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added "
1130 "a send stream."; 1136 "a send stream.";
1131 for (auto& kv : receive_streams_) 1137 for (auto& kv : receive_streams_)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 1248
1243 void WebRtcVideoChannel2::ConfigureReceiverRtp( 1249 void WebRtcVideoChannel2::ConfigureReceiverRtp(
1244 webrtc::VideoReceiveStream::Config* config, 1250 webrtc::VideoReceiveStream::Config* config,
1245 const StreamParams& sp) const { 1251 const StreamParams& sp) const {
1246 uint32 ssrc = sp.first_ssrc(); 1252 uint32 ssrc = sp.first_ssrc();
1247 1253
1248 config->rtp.remote_ssrc = ssrc; 1254 config->rtp.remote_ssrc = ssrc;
1249 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_; 1255 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_;
1250 1256
1251 config->rtp.extensions = recv_rtp_extensions_; 1257 config->rtp.extensions = recv_rtp_extensions_;
1258 config->rtp.rtcp_mode = recv_params_.rtcp.reduced_size
1259 ? webrtc::newapi::kRtcpReducedSize
1260 : webrtc::newapi::kRtcpCompound;
1252 1261
1253 // TODO(pbos): This protection is against setting the same local ssrc as 1262 // TODO(pbos): This protection is against setting the same local ssrc as
1254 // remote which is not permitted by the lower-level API. RTCP requires a 1263 // remote which is not permitted by the lower-level API. RTCP requires a
1255 // corresponding sender SSRC. Figure out what to do when we don't have 1264 // corresponding sender SSRC. Figure out what to do when we don't have
1256 // (receive-only) or know a good local SSRC. 1265 // (receive-only) or know a good local SSRC.
1257 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) { 1266 if (config->rtp.remote_ssrc == config->rtp.local_ssrc) {
1258 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) { 1267 if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) {
1259 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc; 1268 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc;
1260 } else { 1269 } else {
1261 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1; 1270 config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 } 1733 }
1725 } 1734 }
1726 1735
1727 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( 1736 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
1728 webrtc::Call* call, 1737 webrtc::Call* call,
1729 WebRtcVideoEncoderFactory* external_encoder_factory, 1738 WebRtcVideoEncoderFactory* external_encoder_factory,
1730 const VideoOptions& options, 1739 const VideoOptions& options,
1731 int max_bitrate_bps, 1740 int max_bitrate_bps,
1732 const Settable<VideoCodecSettings>& codec_settings, 1741 const Settable<VideoCodecSettings>& codec_settings,
1733 const StreamParams& sp, 1742 const StreamParams& sp,
1734 const std::vector<webrtc::RtpExtension>& rtp_extensions) 1743 const std::vector<webrtc::RtpExtension>& rtp_extensions,
1744 // TODO(pbos): Don't duplicate information between send_params,
1745 // rtp_extensions, options, etc.
1746 const VideoSendParameters& send_params)
1735 : ssrcs_(sp.ssrcs), 1747 : ssrcs_(sp.ssrcs),
1736 ssrc_groups_(sp.ssrc_groups), 1748 ssrc_groups_(sp.ssrc_groups),
1737 call_(call), 1749 call_(call),
1738 external_encoder_factory_(external_encoder_factory), 1750 external_encoder_factory_(external_encoder_factory),
1739 stream_(NULL), 1751 stream_(NULL),
1740 parameters_(webrtc::VideoSendStream::Config(), 1752 parameters_(webrtc::VideoSendStream::Config(),
1741 options, 1753 options,
1742 max_bitrate_bps, 1754 max_bitrate_bps,
1743 codec_settings), 1755 codec_settings),
1744 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), 1756 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false),
1745 capturer_(NULL), 1757 capturer_(NULL),
1746 sending_(false), 1758 sending_(false),
1747 muted_(false), 1759 muted_(false),
1748 old_adapt_changes_(0), 1760 old_adapt_changes_(0),
1749 first_frame_timestamp_ms_(0), 1761 first_frame_timestamp_ms_(0),
1750 last_frame_timestamp_ms_(0) { 1762 last_frame_timestamp_ms_(0) {
1751 parameters_.config.rtp.max_packet_size = kVideoMtu; 1763 parameters_.config.rtp.max_packet_size = kVideoMtu;
1752 1764
1753 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1765 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1754 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1766 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1755 &parameters_.config.rtp.rtx.ssrcs); 1767 &parameters_.config.rtp.rtx.ssrcs);
1756 parameters_.config.rtp.c_name = sp.cname; 1768 parameters_.config.rtp.c_name = sp.cname;
1757 parameters_.config.rtp.extensions = rtp_extensions; 1769 parameters_.config.rtp.extensions = rtp_extensions;
1770 // TODO(pbos): Add this to send stream when we support it.
1771 // parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size ?
1772 // webrtc::newapi::kRtcpReducedSize : webrtc::newapi::kRtcpCompound;
1758 1773
1759 VideoCodecSettings params; 1774 VideoCodecSettings params;
1760 if (codec_settings.Get(&params)) { 1775 if (codec_settings.Get(&params)) {
1761 SetCodec(params); 1776 SetCodec(params);
1762 } 1777 }
1763 } 1778 }
1764 1779
1765 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { 1780 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
1766 DisconnectCapturer(); 1781 DisconnectCapturer();
1767 if (stream_ != NULL) { 1782 if (stream_ != NULL) {
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2737 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2723 } 2738 }
2724 } 2739 }
2725 2740
2726 return video_codecs; 2741 return video_codecs;
2727 } 2742 }
2728 2743
2729 } // namespace cricket 2744 } // namespace cricket
2730 2745
2731 #endif // HAVE_WEBRTC_VIDEO 2746 #endif // HAVE_WEBRTC_VIDEO
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/session/media/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698