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

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

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