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

Side by Side Diff: media/cast/net/rtcp/rtcp_builder.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/net/rtcp/rtcp_builder.h" 5 #include "media/cast/net/rtcp/rtcp_builder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 << ", NACK: " << nack_string_builder.GetString(); 296 << ", NACK: " << nack_string_builder.GetString();
297 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); 297 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields);
298 *cast_loss_field_pos = static_cast<uint8>(number_of_loss_fields); 298 *cast_loss_field_pos = static_cast<uint8>(number_of_loss_fields);
299 } 299 }
300 300
301 void RtcpBuilder::AddSR(const RtcpSenderInfo& sender_info) { 301 void RtcpBuilder::AddSR(const RtcpSenderInfo& sender_info) {
302 AddRtcpHeader(kPacketTypeSenderReport, 0); 302 AddRtcpHeader(kPacketTypeSenderReport, 0);
303 writer_.WriteU32(ssrc_); 303 writer_.WriteU32(ssrc_);
304 writer_.WriteU32(sender_info.ntp_seconds); 304 writer_.WriteU32(sender_info.ntp_seconds);
305 writer_.WriteU32(sender_info.ntp_fraction); 305 writer_.WriteU32(sender_info.ntp_fraction);
306 writer_.WriteU32(sender_info.rtp_timestamp); 306 writer_.WriteU32(sender_info.rtp_timestamp.lower_32_bits());
307 writer_.WriteU32(sender_info.send_packet_count); 307 writer_.WriteU32(sender_info.send_packet_count);
308 writer_.WriteU32(static_cast<uint32>(sender_info.send_octet_count)); 308 writer_.WriteU32(static_cast<uint32>(sender_info.send_octet_count));
309 } 309 }
310 310
311 /* 311 /*
312 0 1 2 3 312 0 1 2 3
313 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 313 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 |V=2|P|reserved | PT=XR=207 | length | 315 |V=2|P|reserved | PT=XR=207 | length |
316 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 316 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 AddRtcpHeader(kPacketTypeApplicationDefined, kReceiverLogSubtype); 350 AddRtcpHeader(kPacketTypeApplicationDefined, kReceiverLogSubtype);
351 writer_.WriteU32(ssrc_); // Add our own SSRC. 351 writer_.WriteU32(ssrc_); // Add our own SSRC.
352 writer_.WriteU32(kCast); 352 writer_.WriteU32(kCast);
353 353
354 while (!receiver_log_message.empty() && 354 while (!receiver_log_message.empty() &&
355 total_number_of_messages_to_send > 0) { 355 total_number_of_messages_to_send > 0) {
356 RtcpReceiverFrameLogMessage& frame_log_messages( 356 RtcpReceiverFrameLogMessage& frame_log_messages(
357 receiver_log_message.front()); 357 receiver_log_message.front());
358 358
359 // Add our frame header. 359 // Add our frame header.
360 writer_.WriteU32(frame_log_messages.rtp_timestamp_); 360 writer_.WriteU32(frame_log_messages.rtp_timestamp_.lower_32_bits());
361 size_t messages_in_frame = frame_log_messages.event_log_messages_.size(); 361 size_t messages_in_frame = frame_log_messages.event_log_messages_.size();
362 if (messages_in_frame > total_number_of_messages_to_send) { 362 if (messages_in_frame > total_number_of_messages_to_send) {
363 // We are running out of space. 363 // We are running out of space.
364 messages_in_frame = total_number_of_messages_to_send; 364 messages_in_frame = total_number_of_messages_to_send;
365 } 365 }
366 // Keep track of how many messages we have left to send. 366 // Keep track of how many messages we have left to send.
367 total_number_of_messages_to_send -= messages_in_frame; 367 total_number_of_messages_to_send -= messages_in_frame;
368 368
369 // On the wire format is number of messages - 1. 369 // On the wire format is number of messages - 1.
370 writer_.WriteU8(static_cast<uint8>(messages_in_frame - 1)); 370 writer_.WriteU8(static_cast<uint8>(messages_in_frame - 1));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 // Account for the RTCP header for an application-defined packet. 429 // Account for the RTCP header for an application-defined packet.
430 remaining_space -= kRtcpCastLogHeaderSize; 430 remaining_space -= kRtcpCastLogHeaderSize;
431 431
432 ReceiverRtcpEventSubscriber::RtcpEvents::const_reverse_iterator rit = 432 ReceiverRtcpEventSubscriber::RtcpEvents::const_reverse_iterator rit =
433 rtcp_events.rbegin(); 433 rtcp_events.rbegin();
434 434
435 while (rit != rtcp_events.rend() && 435 while (rit != rtcp_events.rend() &&
436 remaining_space >= 436 remaining_space >=
437 kRtcpReceiverFrameLogSize + kRtcpReceiverEventLogSize) { 437 kRtcpReceiverFrameLogSize + kRtcpReceiverEventLogSize) {
438 const RtpTimestamp rtp_timestamp = rit->first; 438 const RtpTimeTicks rtp_timestamp = rit->first;
439 RtcpReceiverFrameLogMessage frame_log(rtp_timestamp); 439 RtcpReceiverFrameLogMessage frame_log(rtp_timestamp);
440 remaining_space -= kRtcpReceiverFrameLogSize; 440 remaining_space -= kRtcpReceiverFrameLogSize;
441 ++number_of_frames; 441 ++number_of_frames;
442 442
443 // Get all events of a single frame. 443 // Get all events of a single frame.
444 sorted_log_messages.clear(); 444 sorted_log_messages.clear();
445 do { 445 do {
446 RtcpReceiverEventLogMessage event_log_message; 446 RtcpReceiverEventLogMessage event_log_message;
447 event_log_message.type = rit->second.type; 447 event_log_message.type = rit->second.type;
448 event_log_message.event_timestamp = rit->second.timestamp; 448 event_log_message.event_timestamp = rit->second.timestamp;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 receiver_log_message->push_front(frame_log); 480 receiver_log_message->push_front(frame_log);
481 } 481 }
482 482
483 VLOG(3) << "number of frames: " << number_of_frames; 483 VLOG(3) << "number of frames: " << number_of_frames;
484 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send; 484 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send;
485 return number_of_frames > 0; 485 return number_of_frames > 0;
486 } 486 }
487 487
488 } // namespace cast 488 } // namespace cast
489 } // namespace media 489 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698