OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 10 matching lines...) Expand all Loading... | |
21 #include "webrtc/base/trace_event.h" | 21 #include "webrtc/base/trace_event.h" |
22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
24 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" | 24 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" |
28 | 28 |
29 namespace webrtc { | 29 namespace webrtc { |
30 | 30 |
31 enum { REDForFECHeaderLength = 1 }; | 31 enum { RedForFecHeaderLength = 1 }; |
danilchap
2016/08/22 13:00:41
constexpr size_t kRedForFecHeaderLength = 1;
i.e.
brandtr
2016/08/23 08:19:11
Done, see https://codereview.webrtc.org/2275443002
| |
32 | 32 |
33 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSender* rtp_sender) | 33 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSender* rtp_sender) |
34 : rtp_sender_(rtp_sender), | 34 : rtp_sender_(rtp_sender), |
35 clock_(clock), | 35 clock_(clock), |
36 // Generic FEC | |
37 producer_fec_(&fec_), | |
38 fec_bitrate_(1000, RateStatistics::kBpsScale), | 36 fec_bitrate_(1000, RateStatistics::kBpsScale), |
39 video_bitrate_(1000, RateStatistics::kBpsScale) {} | 37 video_bitrate_(1000, RateStatistics::kBpsScale) {} |
40 | 38 |
41 RTPSenderVideo::~RTPSenderVideo() {} | 39 RTPSenderVideo::~RTPSenderVideo() {} |
42 | 40 |
43 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) { | 41 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) { |
44 video_type_ = video_type; | 42 video_type_ = video_type; |
45 } | 43 } |
46 | 44 |
47 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { | 45 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 168 |
171 void RTPSenderVideo::GenericFECStatus(bool* enable, | 169 void RTPSenderVideo::GenericFECStatus(bool* enable, |
172 uint8_t* payload_type_red, | 170 uint8_t* payload_type_red, |
173 uint8_t* payload_type_fec) const { | 171 uint8_t* payload_type_fec) const { |
174 rtc::CritScope cs(&crit_); | 172 rtc::CritScope cs(&crit_); |
175 *enable = fec_enabled_; | 173 *enable = fec_enabled_; |
176 *payload_type_red = red_payload_type_; | 174 *payload_type_red = red_payload_type_; |
177 *payload_type_fec = fec_payload_type_; | 175 *payload_type_fec = fec_payload_type_; |
178 } | 176 } |
179 | 177 |
180 size_t RTPSenderVideo::FECPacketOverhead() const { | 178 size_t RTPSenderVideo::FecPacketOverhead() const { |
181 rtc::CritScope cs(&crit_); | 179 rtc::CritScope cs(&crit_); |
182 size_t overhead = 0; | 180 size_t overhead = 0; |
183 if (red_payload_type_ != 0) { | 181 if (red_payload_type_ != 0) { |
184 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 182 // Overhead is FEC headers plus RED for FEC header plus anything in RTP |
185 // header beyond the 12 bytes base header (CSRC list, extensions...) | 183 // header beyond the 12 bytes base header (CSRC list, extensions...) |
186 // This reason for the header extensions to be included here is that | 184 // This reason for the header extensions to be included here is that |
187 // from an FEC viewpoint, they are part of the payload to be protected. | 185 // from an FEC viewpoint, they are part of the payload to be protected. |
188 // (The base RTP header is already protected by the FEC header.) | 186 // (The base RTP header is already protected by the FEC header.) |
189 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + | 187 return producer_fec_.MaxPacketOverhead() + RedForFecHeaderLength + |
190 (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); | 188 (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); |
191 } | 189 } |
192 if (fec_enabled_) | 190 if (fec_enabled_) |
193 overhead += ForwardErrorCorrection::PacketOverhead(); | 191 overhead += producer_fec_.MaxPacketOverhead(); |
194 return overhead; | 192 return overhead; |
195 } | 193 } |
196 | 194 |
197 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, | 195 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
198 const FecProtectionParams* key_params) { | 196 const FecProtectionParams* key_params) { |
199 rtc::CritScope cs(&crit_); | 197 rtc::CritScope cs(&crit_); |
200 RTC_DCHECK(delta_params); | 198 RTC_DCHECK(delta_params); |
201 RTC_DCHECK(key_params); | 199 RTC_DCHECK(key_params); |
202 if (fec_enabled_) { | 200 if (fec_enabled_) { |
203 delta_fec_params_ = *delta_params; | 201 delta_fec_params_ = *delta_params; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 rtc::CritScope cs(&crit_); | 341 rtc::CritScope cs(&crit_); |
344 return retransmission_settings_; | 342 return retransmission_settings_; |
345 } | 343 } |
346 | 344 |
347 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 345 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
348 rtc::CritScope cs(&crit_); | 346 rtc::CritScope cs(&crit_); |
349 retransmission_settings_ = settings; | 347 retransmission_settings_ = settings; |
350 } | 348 } |
351 | 349 |
352 } // namespace webrtc | 350 } // namespace webrtc |
OLD | NEW |