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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc

Issue 2131913003: Revert of Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 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 | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.h ('k') | webrtc/video/end_to_end_tests.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 * 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 13 matching lines...) Expand all
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 enum { REDForFECHeaderLength = 1 }; 30 enum { REDForFECHeaderLength = 1 };
31 31
32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) 32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender)
33 : _rtpSender(*rtpSender), 33 : _rtpSender(*rtpSender),
34 clock_(clock),
35 _videoType(kRtpVideoGeneric), 34 _videoType(kRtpVideoGeneric),
36 _retransmissionSettings(kRetransmitBaseLayer), 35 _retransmissionSettings(kRetransmitBaseLayer),
37 // Generic FEC 36 // Generic FEC
38 fec_(), 37 fec_(),
39 fec_enabled_(false), 38 fec_enabled_(false),
40 red_payload_type_(0), 39 red_payload_type_(0),
41 fec_payload_type_(0), 40 fec_payload_type_(0),
42 delta_fec_params_(), 41 delta_fec_params_(),
43 key_fec_params_(), 42 key_fec_params_(),
44 producer_fec_(&fec_), 43 producer_fec_(&fec_),
45 fec_bitrate_(1000, RateStatistics::kBpsScale), 44 _fecOverheadRate(clock, NULL),
46 video_bitrate_(1000, RateStatistics::kBpsScale) { 45 _videoBitrate(clock, NULL) {
47 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); 46 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_));
48 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); 47 memset(&key_fec_params_, 0, sizeof(key_fec_params_));
49 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; 48 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
50 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type = 49 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
51 kFecMaskRandom; 50 kFecMaskRandom;
52 } 51 }
53 52
54 RTPSenderVideo::~RTPSenderVideo() { 53 RTPSenderVideo::~RTPSenderVideo() {
55 } 54 }
56 55
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, 88 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
90 const size_t payload_length, 89 const size_t payload_length,
91 const size_t rtp_header_length, 90 const size_t rtp_header_length,
92 uint16_t seq_num, 91 uint16_t seq_num,
93 const uint32_t capture_timestamp, 92 const uint32_t capture_timestamp,
94 int64_t capture_time_ms, 93 int64_t capture_time_ms,
95 StorageType storage) { 94 StorageType storage) {
96 if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length, 95 if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length,
97 capture_time_ms, storage, 96 capture_time_ms, storage,
98 RtpPacketSender::kLowPriority) == 0) { 97 RtpPacketSender::kLowPriority) == 0) {
99 rtc::CritScope cs(&stats_crit_); 98 _videoBitrate.Update(payload_length + rtp_header_length);
100 video_bitrate_.Update(payload_length + rtp_header_length,
101 clock_->TimeInMilliseconds());
102 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 99 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
103 "Video::PacketNormal", "timestamp", capture_timestamp, 100 "Video::PacketNormal", "timestamp", capture_timestamp,
104 "seqnum", seq_num); 101 "seqnum", seq_num);
105 } else { 102 } else {
106 LOG(LS_WARNING) << "Failed to send video packet " << seq_num; 103 LOG(LS_WARNING) << "Failed to send video packet " << seq_num;
107 } 104 }
108 } 105 }
109 106
110 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, 107 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
111 const size_t payload_length, 108 const size_t payload_length,
(...skipping 25 matching lines...) Expand all
137 rtp_header_length); 134 rtp_header_length);
138 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); 135 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size());
139 if (_retransmissionSettings & kRetransmitFECPackets) 136 if (_retransmissionSettings & kRetransmitFECPackets)
140 fec_storage = kAllowRetransmission; 137 fec_storage = kAllowRetransmission;
141 } 138 }
142 } 139 }
143 if (_rtpSender.SendToNetwork( 140 if (_rtpSender.SendToNetwork(
144 red_packet->data(), red_packet->length() - rtp_header_length, 141 red_packet->data(), red_packet->length() - rtp_header_length,
145 rtp_header_length, capture_time_ms, media_packet_storage, 142 rtp_header_length, capture_time_ms, media_packet_storage,
146 RtpPacketSender::kLowPriority) == 0) { 143 RtpPacketSender::kLowPriority) == 0) {
147 rtc::CritScope cs(&stats_crit_); 144 _videoBitrate.Update(red_packet->length());
148 video_bitrate_.Update(red_packet->length(), clock_->TimeInMilliseconds());
149 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 145 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
150 "Video::PacketRed", "timestamp", capture_timestamp, 146 "Video::PacketRed", "timestamp", capture_timestamp,
151 "seqnum", media_seq_num); 147 "seqnum", media_seq_num);
152 } else { 148 } else {
153 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num; 149 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num;
154 } 150 }
155 for (RedPacket* fec_packet : fec_packets) { 151 for (RedPacket* fec_packet : fec_packets) {
156 if (_rtpSender.SendToNetwork( 152 if (_rtpSender.SendToNetwork(
157 fec_packet->data(), fec_packet->length() - rtp_header_length, 153 fec_packet->data(), fec_packet->length() - rtp_header_length,
158 rtp_header_length, capture_time_ms, fec_storage, 154 rtp_header_length, capture_time_ms, fec_storage,
159 RtpPacketSender::kLowPriority) == 0) { 155 RtpPacketSender::kLowPriority) == 0) {
160 rtc::CritScope cs(&stats_crit_); 156 _fecOverheadRate.Update(fec_packet->length());
161 fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds());
162 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 157 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
163 "Video::PacketFec", "timestamp", capture_timestamp, 158 "Video::PacketFec", "timestamp", capture_timestamp,
164 "seqnum", next_fec_sequence_number); 159 "seqnum", next_fec_sequence_number);
165 } else { 160 } else {
166 LOG(LS_WARNING) << "Failed to send FEC packet " 161 LOG(LS_WARNING) << "Failed to send FEC packet "
167 << next_fec_sequence_number; 162 << next_fec_sequence_number;
168 } 163 }
169 delete fec_packet; 164 delete fec_packet;
170 ++next_fec_sequence_number; 165 ++next_fec_sequence_number;
171 } 166 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 330 }
336 } 331 }
337 first = false; 332 first = false;
338 } 333 }
339 334
340 TRACE_EVENT_ASYNC_END1( 335 TRACE_EVENT_ASYNC_END1(
341 "webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp()); 336 "webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp());
342 return 0; 337 return 0;
343 } 338 }
344 339
340 void RTPSenderVideo::ProcessBitrate() {
341 _videoBitrate.Process();
342 _fecOverheadRate.Process();
343 }
344
345 uint32_t RTPSenderVideo::VideoBitrateSent() const { 345 uint32_t RTPSenderVideo::VideoBitrateSent() const {
346 rtc::CritScope cs(&stats_crit_); 346 return _videoBitrate.BitrateLast();
347 return video_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0);
348 } 347 }
349 348
350 uint32_t RTPSenderVideo::FecOverheadRate() const { 349 uint32_t RTPSenderVideo::FecOverheadRate() const {
351 rtc::CritScope cs(&stats_crit_); 350 return _fecOverheadRate.BitrateLast();
352 return fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0);
353 } 351 }
354 352
355 int RTPSenderVideo::SelectiveRetransmissions() const { 353 int RTPSenderVideo::SelectiveRetransmissions() const {
356 rtc::CritScope cs(&crit_); 354 rtc::CritScope cs(&crit_);
357 return _retransmissionSettings; 355 return _retransmissionSettings;
358 } 356 }
359 357
360 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { 358 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
361 rtc::CritScope cs(&crit_); 359 rtc::CritScope cs(&crit_);
362 _retransmissionSettings = settings; 360 _retransmissionSettings = settings;
363 } 361 }
364 362
365 } // namespace webrtc 363 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.h ('k') | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698