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

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

Issue 2067673004: Style cleanups in RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix compilation Created 4 years, 6 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
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 11 matching lines...) Expand all
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 enum { REDForFECHeaderLength = 1 }; 30 enum { REDForFECHeaderLength = 1 };
31 31
32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) 32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtp_sender)
33 : _rtpSender(*rtpSender), 33 : rtp_sender_(rtp_sender),
34 _videoType(kRtpVideoGeneric),
35 _retransmissionSettings(kRetransmitBaseLayer),
36 // Generic FEC 34 // Generic FEC
37 fec_(),
38 fec_enabled_(false),
39 red_payload_type_(0),
40 fec_payload_type_(0),
41 delta_fec_params_(),
42 key_fec_params_(),
43 producer_fec_(&fec_), 35 producer_fec_(&fec_),
44 _fecOverheadRate(clock, NULL), 36 fec_overhead_rate_(clock, nullptr),
45 _videoBitrate(clock, NULL) { 37 video_bitrate_(clock, nullptr) {
46 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); 38 delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
danilchap 2016/06/15 13:40:01 may be initialize this variables inside class defi
Sergey Ulanov 2016/06/15 18:27:53 done
47 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); 39 key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
48 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 kFecMaskRandom;
51 } 40 }
52 41
53 RTPSenderVideo::~RTPSenderVideo() { 42 RTPSenderVideo::~RTPSenderVideo() {}
54 }
55 43
56 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes videoType) { 44 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) {
57 _videoType = videoType; 45 video_type_ = video_type;
58 } 46 }
59 47
60 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { 48 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const {
61 return _videoType; 49 return video_type_;
62 } 50 }
63 51
64 // Static. 52 // Static.
65 RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload( 53 RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload(
66 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 54 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
67 const int8_t payloadType) { 55 const int8_t payload_type) {
68 RtpVideoCodecTypes videoType = kRtpVideoGeneric; 56 RtpVideoCodecTypes video_type = kRtpVideoGeneric;
69 if (RtpUtility::StringCompare(payloadName, "VP8", 3)) { 57 if (RtpUtility::StringCompare(payloadName, "VP8", 3)) {
70 videoType = kRtpVideoVp8; 58 video_type = kRtpVideoVp8;
71 } else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) { 59 } else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) {
72 videoType = kRtpVideoVp9; 60 video_type = kRtpVideoVp9;
73 } else if (RtpUtility::StringCompare(payloadName, "H264", 4)) { 61 } else if (RtpUtility::StringCompare(payloadName, "H264", 4)) {
74 videoType = kRtpVideoH264; 62 video_type = kRtpVideoH264;
75 } else if (RtpUtility::StringCompare(payloadName, "I420", 4)) { 63 } else if (RtpUtility::StringCompare(payloadName, "I420", 4)) {
76 videoType = kRtpVideoGeneric; 64 video_type = kRtpVideoGeneric;
77 } else { 65 } else {
78 videoType = kRtpVideoGeneric; 66 video_type = kRtpVideoGeneric;
79 } 67 }
80 RtpUtility::Payload* payload = new RtpUtility::Payload(); 68 RtpUtility::Payload* payload = new RtpUtility::Payload();
81 payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; 69 payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
82 strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); 70 strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
83 payload->typeSpecific.Video.videoCodecType = videoType; 71 payload->typeSpecific.Video.videoCodecType = video_type;
84 payload->audio = false; 72 payload->audio = false;
85 return payload; 73 return payload;
86 } 74 }
87 75
88 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, 76 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
89 const size_t payload_length, 77 const size_t payload_length,
90 const size_t rtp_header_length, 78 const size_t rtp_header_length,
91 uint16_t seq_num, 79 uint16_t seq_num,
92 const uint32_t capture_timestamp, 80 const uint32_t capture_timestamp,
93 int64_t capture_time_ms, 81 int64_t capture_time_ms,
94 StorageType storage) { 82 StorageType storage) {
95 if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length, 83 if (rtp_sender_->SendToNetwork(data_buffer, payload_length, rtp_header_length,
96 capture_time_ms, storage, 84 capture_time_ms, storage,
97 RtpPacketSender::kLowPriority) == 0) { 85 RtpPacketSender::kLowPriority) == 0) {
98 _videoBitrate.Update(payload_length + rtp_header_length); 86 video_bitrate_.Update(payload_length + rtp_header_length);
99 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 87 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
100 "Video::PacketNormal", "timestamp", capture_timestamp, 88 "Video::PacketNormal", "timestamp", capture_timestamp,
101 "seqnum", seq_num); 89 "seqnum", seq_num);
102 } else { 90 } else {
103 LOG(LS_WARNING) << "Failed to send video packet " << seq_num; 91 LOG(LS_WARNING) << "Failed to send video packet " << seq_num;
104 } 92 }
105 } 93 }
106 94
107 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, 95 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
108 const size_t payload_length, 96 const size_t payload_length,
(...skipping 12 matching lines...) Expand all
121 rtc::CritScope cs(&crit_); 109 rtc::CritScope cs(&crit_);
122 red_packet.reset(producer_fec_.BuildRedPacket( 110 red_packet.reset(producer_fec_.BuildRedPacket(
123 data_buffer, payload_length, rtp_header_length, red_payload_type_)); 111 data_buffer, payload_length, rtp_header_length, red_payload_type_));
124 if (protect) { 112 if (protect) {
125 producer_fec_.AddRtpPacketAndGenerateFec(data_buffer, payload_length, 113 producer_fec_.AddRtpPacketAndGenerateFec(data_buffer, payload_length,
126 rtp_header_length); 114 rtp_header_length);
127 } 115 }
128 uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets(); 116 uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets();
129 if (num_fec_packets > 0) { 117 if (num_fec_packets > 0) {
130 next_fec_sequence_number = 118 next_fec_sequence_number =
131 _rtpSender.AllocateSequenceNumber(num_fec_packets); 119 rtp_sender_->AllocateSequenceNumber(num_fec_packets);
132 fec_packets = producer_fec_.GetFecPackets( 120 fec_packets = producer_fec_.GetFecPackets(
133 red_payload_type_, fec_payload_type_, next_fec_sequence_number, 121 red_payload_type_, fec_payload_type_, next_fec_sequence_number,
134 rtp_header_length); 122 rtp_header_length);
135 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); 123 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size());
136 if (_retransmissionSettings & kRetransmitFECPackets) 124 if (retransmission_settings_ & kRetransmitFECPackets)
137 fec_storage = kAllowRetransmission; 125 fec_storage = kAllowRetransmission;
138 } 126 }
139 } 127 }
140 if (_rtpSender.SendToNetwork( 128 if (rtp_sender_->SendToNetwork(
141 red_packet->data(), red_packet->length() - rtp_header_length, 129 red_packet->data(), red_packet->length() - rtp_header_length,
142 rtp_header_length, capture_time_ms, media_packet_storage, 130 rtp_header_length, capture_time_ms, media_packet_storage,
143 RtpPacketSender::kLowPriority) == 0) { 131 RtpPacketSender::kLowPriority) == 0) {
144 _videoBitrate.Update(red_packet->length()); 132 video_bitrate_.Update(red_packet->length());
145 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 133 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
146 "Video::PacketRed", "timestamp", capture_timestamp, 134 "Video::PacketRed", "timestamp", capture_timestamp,
147 "seqnum", media_seq_num); 135 "seqnum", media_seq_num);
148 } else { 136 } else {
149 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num; 137 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num;
150 } 138 }
151 for (RedPacket* fec_packet : fec_packets) { 139 for (RedPacket* fec_packet : fec_packets) {
152 if (_rtpSender.SendToNetwork( 140 if (rtp_sender_->SendToNetwork(
153 fec_packet->data(), fec_packet->length() - rtp_header_length, 141 fec_packet->data(), fec_packet->length() - rtp_header_length,
154 rtp_header_length, capture_time_ms, fec_storage, 142 rtp_header_length, capture_time_ms, fec_storage,
155 RtpPacketSender::kLowPriority) == 0) { 143 RtpPacketSender::kLowPriority) == 0) {
156 _fecOverheadRate.Update(fec_packet->length()); 144 fec_overhead_rate_.Update(fec_packet->length());
157 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 145 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
158 "Video::PacketFec", "timestamp", capture_timestamp, 146 "Video::PacketFec", "timestamp", capture_timestamp,
159 "seqnum", next_fec_sequence_number); 147 "seqnum", next_fec_sequence_number);
160 } else { 148 } else {
161 LOG(LS_WARNING) << "Failed to send FEC packet " 149 LOG(LS_WARNING) << "Failed to send FEC packet "
162 << next_fec_sequence_number; 150 << next_fec_sequence_number;
163 } 151 }
164 delete fec_packet; 152 delete fec_packet;
165 ++next_fec_sequence_number; 153 ++next_fec_sequence_number;
166 } 154 }
167 } 155 }
168 156
169 void RTPSenderVideo::SetGenericFECStatus(const bool enable, 157 void RTPSenderVideo::SetGenericFECStatus(const bool enable,
170 const uint8_t payloadTypeRED, 158 const uint8_t payload_type_red,
171 const uint8_t payloadTypeFEC) { 159 const uint8_t payload_type_fec) {
172 RTC_DCHECK(!enable || payloadTypeRED > 0); 160 RTC_DCHECK(!enable || payload_type_red > 0);
173 rtc::CritScope cs(&crit_); 161 rtc::CritScope cs(&crit_);
174 fec_enabled_ = enable; 162 fec_enabled_ = enable;
175 red_payload_type_ = payloadTypeRED; 163 red_payload_type_ = payload_type_red;
176 fec_payload_type_ = payloadTypeFEC; 164 fec_payload_type_ = payload_type_fec;
177 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); 165 delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
178 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); 166 key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
179 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
180 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
181 kFecMaskRandom;
182 } 167 }
183 168
184 void RTPSenderVideo::GenericFECStatus(bool* enable, 169 void RTPSenderVideo::GenericFECStatus(bool* enable,
185 uint8_t* payloadTypeRED, 170 uint8_t* payload_type_red,
186 uint8_t* payloadTypeFEC) const { 171 uint8_t* payload_type_fec) const {
187 rtc::CritScope cs(&crit_); 172 rtc::CritScope cs(&crit_);
188 *enable = fec_enabled_; 173 *enable = fec_enabled_;
189 *payloadTypeRED = red_payload_type_; 174 *payload_type_red = red_payload_type_;
190 *payloadTypeFEC = fec_payload_type_; 175 *payload_type_fec = fec_payload_type_;
191 } 176 }
192 177
193 size_t RTPSenderVideo::FECPacketOverhead() const { 178 size_t RTPSenderVideo::FECPacketOverhead() const {
194 rtc::CritScope cs(&crit_); 179 rtc::CritScope cs(&crit_);
195 size_t overhead = 0; 180 size_t overhead = 0;
196 if (red_payload_type_ != 0) { 181 if (red_payload_type_ != 0) {
197 // 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
198 // header beyond the 12 bytes base header (CSRC list, extensions...) 183 // header beyond the 12 bytes base header (CSRC list, extensions...)
199 // 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
200 // 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.
201 // (The base RTP header is already protected by the FEC header.) 186 // (The base RTP header is already protected by the FEC header.)
202 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + 187 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength +
203 (_rtpSender.RtpHeaderLength() - kRtpHeaderSize); 188 (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize);
204 } 189 }
205 if (fec_enabled_) 190 if (fec_enabled_)
206 overhead += ForwardErrorCorrection::PacketOverhead(); 191 overhead += ForwardErrorCorrection::PacketOverhead();
207 return overhead; 192 return overhead;
208 } 193 }
209 194
210 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, 195 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params,
211 const FecProtectionParams* key_params) { 196 const FecProtectionParams* key_params) {
212 rtc::CritScope cs(&crit_); 197 rtc::CritScope cs(&crit_);
213 RTC_DCHECK(delta_params); 198 RTC_DCHECK(delta_params);
214 RTC_DCHECK(key_params); 199 RTC_DCHECK(key_params);
215 if (fec_enabled_) { 200 if (fec_enabled_) {
216 delta_fec_params_ = *delta_params; 201 delta_fec_params_ = *delta_params;
217 key_fec_params_ = *key_params; 202 key_fec_params_ = *key_params;
218 } 203 }
219 } 204 }
220 205
221 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, 206 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes video_type,
222 const FrameType frameType, 207 const FrameType frameType,
223 const int8_t payloadType, 208 const int8_t payload_type,
224 const uint32_t captureTimeStamp, 209 const uint32_t capture_timestamp,
225 int64_t capture_time_ms, 210 int64_t capture_time_ms,
226 const uint8_t* payloadData, 211 const uint8_t* payload_data,
227 const size_t payloadSize, 212 const size_t payload_size,
228 const RTPFragmentationHeader* fragmentation, 213 const RTPFragmentationHeader* fragmentation,
229 const RTPVideoHeader* video_header) { 214 const RTPVideoHeader* video_header) {
230 if (payloadSize == 0) { 215 if (payload_size == 0) {
231 return -1; 216 return -1;
232 } 217 }
233 218
234 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( 219 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create(
235 videoType, _rtpSender.MaxDataPayloadLength(), 220 video_type, rtp_sender_->MaxDataPayloadLength(),
236 video_header ? &(video_header->codecHeader) : nullptr, frameType)); 221 video_header ? &(video_header->codecHeader) : nullptr, frameType));
237 222
238 StorageType storage; 223 StorageType storage;
239 int red_payload_type; 224 int red_payload_type;
240 bool first_frame = first_frame_sent_(); 225 bool first_frame = first_frame_sent_();
241 { 226 {
242 rtc::CritScope cs(&crit_); 227 rtc::CritScope cs(&crit_);
243 FecProtectionParams* fec_params = 228 FecProtectionParams* fec_params =
244 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; 229 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_;
245 producer_fec_.SetFecParameters(fec_params, 0); 230 producer_fec_.SetFecParameters(fec_params, 0);
246 storage = packetizer->GetStorageType(_retransmissionSettings); 231 storage = packetizer->GetStorageType(retransmission_settings_);
247 red_payload_type = red_payload_type_; 232 red_payload_type = red_payload_type_;
248 } 233 }
249 234
250 // Register CVO rtp header extension at the first time when we receive a frame 235 // Register CVO rtp header extension at the first time when we receive a frame
251 // with pending rotation. 236 // with pending rotation.
252 bool video_rotation_active = false; 237 bool video_rotation_active = false;
253 if (video_header && video_header->rotation != kVideoRotation_0) { 238 if (video_header && video_header->rotation != kVideoRotation_0) {
254 video_rotation_active = _rtpSender.ActivateCVORtpHeaderExtension(); 239 video_rotation_active = rtp_sender_->ActivateCVORtpHeaderExtension();
255 } 240 }
256 241
257 int rtp_header_length = _rtpSender.RtpHeaderLength(); 242 int rtp_header_length = rtp_sender_->RtpHeaderLength();
258 size_t payload_bytes_to_send = payloadSize; 243 size_t payload_bytes_to_send = payload_size;
259 const uint8_t* data = payloadData; 244 const uint8_t* data = payload_data;
260 245
261 // TODO(changbin): we currently don't support to configure the codec to 246 // TODO(changbin): we currently don't support to configure the codec to
262 // output multiple partitions for VP8. Should remove below check after the 247 // output multiple partitions for VP8. Should remove below check after the
263 // issue is fixed. 248 // issue is fixed.
264 const RTPFragmentationHeader* frag = 249 const RTPFragmentationHeader* frag =
265 (videoType == kRtpVideoVp8) ? NULL : fragmentation; 250 (video_type == kRtpVideoVp8) ? NULL : fragmentation;
266 251
267 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); 252 packetizer->SetPayloadData(data, payload_bytes_to_send, frag);
268 253
269 bool first = true; 254 bool first = true;
270 bool last = false; 255 bool last = false;
271 while (!last) { 256 while (!last) {
272 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; 257 uint8_t dataBuffer[IP_PACKET_SIZE] = {0};
273 size_t payload_bytes_in_packet = 0; 258 size_t payload_bytes_in_packet = 0;
274 259
275 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], 260 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length],
276 &payload_bytes_in_packet, &last)) { 261 &payload_bytes_in_packet, &last)) {
277 return -1; 262 return -1;
278 } 263 }
279 264
280 // Write RTP header. 265 // Write RTP header.
281 _rtpSender.BuildRTPheader( 266 rtp_sender_->BuildRtpHeader(
282 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); 267 dataBuffer, payload_type, last, capture_timestamp, capture_time_ms);
283 268
284 // According to 269 // According to
285 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ 270 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
286 // ts_126114v120700p.pdf Section 7.4.5: 271 // ts_126114v120700p.pdf Section 7.4.5:
287 // The MTSI client shall add the payload bytes as defined in this clause 272 // The MTSI client shall add the payload bytes as defined in this clause
288 // onto the last RTP packet in each group of packets which make up a key 273 // onto the last RTP packet in each group of packets which make up a key
289 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 274 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265
290 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP 275 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP
291 // packet in each group of packets which make up another type of frame 276 // packet in each group of packets which make up another type of frame
292 // (e.g. a P-Frame) only if the current value is different from the previous 277 // (e.g. a P-Frame) only if the current value is different from the previous
293 // value sent. 278 // value sent.
294 // Here we are adding it to every packet of every frame at this point. 279 // Here we are adding it to every packet of every frame at this point.
295 if (!video_header) { 280 if (!video_header) {
296 RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( 281 RTC_DCHECK(!rtp_sender_->IsRtpHeaderExtensionRegistered(
297 kRtpExtensionVideoRotation)); 282 kRtpExtensionVideoRotation));
298 } else if (video_rotation_active) { 283 } else if (video_rotation_active) {
299 // Checking whether CVO header extension is registered will require taking 284 // Checking whether CVO header extension is registered will require taking
300 // a lock. It'll be a no-op if it's not registered. 285 // a lock. It'll be a no-op if it's not registered.
301 // TODO(guoweis): For now, all packets sent will carry the CVO such that 286 // TODO(guoweis): For now, all packets sent will carry the CVO such that
302 // the RTP header length is consistent, although the receiver side will 287 // the RTP header length is consistent, although the receiver side will
303 // only exam the packets with marker bit set. 288 // only exam the packets with marker bit set.
304 size_t packetSize = payloadSize + rtp_header_length; 289 size_t packetSize = payload_size + rtp_header_length;
305 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); 290 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize);
306 RTPHeader rtp_header; 291 RTPHeader rtp_header;
307 rtp_parser.Parse(&rtp_header); 292 rtp_parser.Parse(&rtp_header);
308 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, 293 rtp_sender_->UpdateVideoRotation(dataBuffer, packetSize, rtp_header,
309 video_header->rotation); 294 video_header->rotation);
310 } 295 }
311 if (red_payload_type != 0) { 296 if (red_payload_type != 0) {
312 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, 297 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet,
313 rtp_header_length, _rtpSender.SequenceNumber(), 298 rtp_header_length, rtp_sender_->SequenceNumber(),
314 captureTimeStamp, capture_time_ms, storage, 299 capture_timestamp, capture_time_ms, storage,
315 packetizer->GetProtectionType() == kProtectedPacket); 300 packetizer->GetProtectionType() == kProtectedPacket);
316 } else { 301 } else {
317 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, 302 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length,
318 _rtpSender.SequenceNumber(), captureTimeStamp, 303 rtp_sender_->SequenceNumber(), capture_timestamp,
319 capture_time_ms, storage); 304 capture_time_ms, storage);
320 } 305 }
321 306
322 if (first_frame) { 307 if (first_frame) {
323 if (first) { 308 if (first) {
324 LOG(LS_INFO) 309 LOG(LS_INFO)
325 << "Sent first RTP packet of the first video frame (pre-pacer)"; 310 << "Sent first RTP packet of the first video frame (pre-pacer)";
326 } 311 }
327 if (last) { 312 if (last) {
328 LOG(LS_INFO) 313 LOG(LS_INFO)
329 << "Sent last RTP packet of the first video frame (pre-pacer)"; 314 << "Sent last RTP packet of the first video frame (pre-pacer)";
330 } 315 }
331 } 316 }
332 first = false; 317 first = false;
333 } 318 }
334 319
335 TRACE_EVENT_ASYNC_END1( 320 TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms, "timestamp",
336 "webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp()); 321 rtp_sender_->Timestamp());
337 return 0; 322 return 0;
338 } 323 }
339 324
340 void RTPSenderVideo::ProcessBitrate() { 325 void RTPSenderVideo::ProcessBitrate() {
341 _videoBitrate.Process(); 326 video_bitrate_.Process();
342 _fecOverheadRate.Process(); 327 fec_overhead_rate_.Process();
343 } 328 }
344 329
345 uint32_t RTPSenderVideo::VideoBitrateSent() const { 330 uint32_t RTPSenderVideo::VideoBitrateSent() const {
346 return _videoBitrate.BitrateLast(); 331 return video_bitrate_.BitrateLast();
347 } 332 }
348 333
349 uint32_t RTPSenderVideo::FecOverheadRate() const { 334 uint32_t RTPSenderVideo::FecOverheadRate() const {
350 return _fecOverheadRate.BitrateLast(); 335 return fec_overhead_rate_.BitrateLast();
351 } 336 }
352 337
353 int RTPSenderVideo::SelectiveRetransmissions() const { 338 int RTPSenderVideo::SelectiveRetransmissions() const {
354 rtc::CritScope cs(&crit_); 339 rtc::CritScope cs(&crit_);
355 return _retransmissionSettings; 340 return retransmission_settings_;
356 } 341 }
357 342
358 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { 343 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
359 rtc::CritScope cs(&crit_); 344 rtc::CritScope cs(&crit_);
360 _retransmissionSettings = settings; 345 retransmission_settings_ = settings;
361 } 346 }
362 347
363 } // namespace webrtc 348 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698