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

Side by Side Diff: media/cast/rtcp/rtcp_sender.cc

Issue 69603002: Incorporating logging into Cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding scoped_ptr include Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/rtcp/rtcp_sender.h ('k') | media/cast/rtcp/rtcp_sender_unittest.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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/rtcp/rtcp_sender.h" 5 #include "media/cast/rtcp/rtcp_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "media/cast/cast_environment.h"
12 #include "media/cast/pacing/paced_sender.h" 12 #include "media/cast/pacing/paced_sender.h"
13 #include "media/cast/rtcp/rtcp_utility.h" 13 #include "media/cast/rtcp/rtcp_utility.h"
14 #include "net/base/big_endian.h" 14 #include "net/base/big_endian.h"
15 15
16 namespace media { 16 namespace media {
17 namespace cast { 17 namespace cast {
18 18
19 static const size_t kRtcpMaxNackFields = 253; 19 static const size_t kRtcpMaxNackFields = 253;
20 static const size_t kRtcpMaxCastLossFields = 100; 20 static const size_t kRtcpMaxCastLossFields = 100;
21 21
22 RtcpSender::RtcpSender(PacedPacketSender* outgoing_transport, 22 RtcpSender::RtcpSender(scoped_refptr<CastEnvironment> cast_environment,
23 PacedPacketSender* outgoing_transport,
23 uint32 sending_ssrc, 24 uint32 sending_ssrc,
24 const std::string& c_name) 25 const std::string& c_name)
25 : ssrc_(sending_ssrc), 26 : ssrc_(sending_ssrc),
26 c_name_(c_name), 27 c_name_(c_name),
27 transport_(outgoing_transport) { 28 transport_(outgoing_transport),
29 cast_environment_(cast_environment) {
28 DCHECK_LT(c_name_.length(), kRtcpCnameSize) << "Invalid config"; 30 DCHECK_LT(c_name_.length(), kRtcpCnameSize) << "Invalid config";
29 } 31 }
30 32
31 RtcpSender::~RtcpSender() {} 33 RtcpSender::~RtcpSender() {}
32 34
33 void RtcpSender::SendRtcpFromRtpSender(uint32 packet_type_flags, 35 void RtcpSender::SendRtcpFromRtpSender(uint32 packet_type_flags,
34 const RtcpSenderInfo* sender_info, 36 const RtcpSenderInfo* sender_info,
35 const RtcpDlrrReportBlock* dlrr, 37 const RtcpDlrrReportBlock* dlrr,
36 const RtcpSenderLogMessage* sender_log) { 38 const RtcpSenderLogMessage* sender_log) {
37 if (packet_type_flags & kRtcpRr || 39 if (packet_type_flags & kRtcpRr ||
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 244
243 packet->resize(start_size + 12); 245 packet->resize(start_size + 12);
244 246
245 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 12); 247 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 12);
246 uint8 FMT = 1; // Picture loss indicator. 248 uint8 FMT = 1; // Picture loss indicator.
247 big_endian_writer.WriteU8(0x80 + FMT); 249 big_endian_writer.WriteU8(0x80 + FMT);
248 big_endian_writer.WriteU8(206); 250 big_endian_writer.WriteU8(206);
249 big_endian_writer.WriteU16(2); // Used fixed length of 2. 251 big_endian_writer.WriteU16(2); // Used fixed length of 2.
250 big_endian_writer.WriteU32(ssrc_); // Add our own SSRC. 252 big_endian_writer.WriteU32(ssrc_); // Add our own SSRC.
251 big_endian_writer.WriteU32(remote_ssrc); // Add the remote SSRC. 253 big_endian_writer.WriteU32(remote_ssrc); // Add the remote SSRC.
252 TRACE_EVENT_INSTANT2("cast_rtcp", "RtcpSender::PLI", TRACE_EVENT_SCOPE_THREAD,
253 "remote_ssrc", remote_ssrc,
254 "ssrc", ssrc_);
255 } 254 }
256 255
257 /* 256 /*
258 0 1 2 3 257 0 1 2 3
259 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 258 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
260 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 259 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261 | PB |0| Payload Type| Native Rpsi bit string | 260 | PB |0| Payload Type| Native Rpsi bit string |
262 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 261 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263 | defined per codec ... | Padding (0) | 262 | defined per codec ... | Padding (0) |
264 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 263 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 347
349 big_endian_writer.WriteU8(static_cast<uint8>((bitrate_exponent << 2) + 348 big_endian_writer.WriteU8(static_cast<uint8>((bitrate_exponent << 2) +
350 ((bitrate_mantissa >> 16) & 0x03))); 349 ((bitrate_mantissa >> 16) & 0x03)));
351 big_endian_writer.WriteU8(static_cast<uint8>(bitrate_mantissa >> 8)); 350 big_endian_writer.WriteU8(static_cast<uint8>(bitrate_mantissa >> 8));
352 big_endian_writer.WriteU8(static_cast<uint8>(bitrate_mantissa)); 351 big_endian_writer.WriteU8(static_cast<uint8>(bitrate_mantissa));
353 352
354 std::list<uint32>::const_iterator it = remb->remb_ssrcs.begin(); 353 std::list<uint32>::const_iterator it = remb->remb_ssrcs.begin();
355 for (; it != remb->remb_ssrcs.end(); ++it) { 354 for (; it != remb->remb_ssrcs.end(); ++it) {
356 big_endian_writer.WriteU32(*it); 355 big_endian_writer.WriteU32(*it);
357 } 356 }
358 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::RembBitrate", ssrc_, 357 cast_environment_->Logging()->InsertGenericEvent(kRembBitrate,
359 remb->remb_bitrate); 358 remb->remb_bitrate);
360 } 359 }
361 360
362 void RtcpSender::BuildNack(const RtcpNackMessage* nack, 361 void RtcpSender::BuildNack(const RtcpNackMessage* nack,
363 std::vector<uint8>* packet) const { 362 std::vector<uint8>* packet) const {
364 size_t start_size = packet->size(); 363 size_t start_size = packet->size();
365 DCHECK_LT(start_size + 16, kIpPacketSize) << "Not enough buffer space"; 364 DCHECK_LT(start_size + 16, kIpPacketSize) << "Not enough buffer space";
366 if (start_size + 16 > kIpPacketSize) return; 365 if (start_size + 16 > kIpPacketSize) return;
367 366
368 packet->resize(start_size + 16); 367 packet->resize(start_size + 16);
369 368
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (start_size + 4 > kIpPacketSize) return; 404 if (start_size + 4 > kIpPacketSize) return;
406 405
407 packet->resize(start_size + 4); 406 packet->resize(start_size + 4);
408 net::BigEndianWriter big_endian_nack_writer(&((*packet)[start_size]), 4); 407 net::BigEndianWriter big_endian_nack_writer(&((*packet)[start_size]), 4);
409 big_endian_nack_writer.WriteU16(nack_sequence_number); 408 big_endian_nack_writer.WriteU16(nack_sequence_number);
410 big_endian_nack_writer.WriteU16(bitmask); 409 big_endian_nack_writer.WriteU16(bitmask);
411 number_of_nack_fields++; 410 number_of_nack_fields++;
412 } 411 }
413 DCHECK_GE(kRtcpMaxNackFields, number_of_nack_fields); 412 DCHECK_GE(kRtcpMaxNackFields, number_of_nack_fields);
414 (*packet)[nack_size_pos] = static_cast<uint8>(2 + number_of_nack_fields); 413 (*packet)[nack_size_pos] = static_cast<uint8>(2 + number_of_nack_fields);
415 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::NACK", ssrc_,
416 nack->nack_list.size());
417 } 414 }
418 415
419 void RtcpSender::BuildBye(std::vector<uint8>* packet) const { 416 void RtcpSender::BuildBye(std::vector<uint8>* packet) const {
420 size_t start_size = packet->size(); 417 size_t start_size = packet->size();
421 DCHECK_LT(start_size + 8, kIpPacketSize) << "Not enough buffer space"; 418 DCHECK_LT(start_size + 8, kIpPacketSize) << "Not enough buffer space";
422 if (start_size + 8 > kIpPacketSize) return; 419 if (start_size + 8 > kIpPacketSize) return;
423 420
424 packet->resize(start_size + 8); 421 packet->resize(start_size + 8);
425 422
426 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 8); 423 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 8);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 557 }
561 } 558 }
562 big_endian_nack_writer.WriteU8(bitmask); 559 big_endian_nack_writer.WriteU8(bitmask);
563 ++number_of_loss_fields; 560 ++number_of_loss_fields;
564 } 561 }
565 } 562 }
566 } 563 }
567 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); 564 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields);
568 (*packet)[cast_size_pos] = static_cast<uint8>(4 + number_of_loss_fields); 565 (*packet)[cast_size_pos] = static_cast<uint8>(4 + number_of_loss_fields);
569 (*packet)[cast_loss_field_pos] = static_cast<uint8>(number_of_loss_fields); 566 (*packet)[cast_loss_field_pos] = static_cast<uint8>(number_of_loss_fields);
570
571 // Frames with missing packets.
572 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::CastNACK", ssrc_,
573 cast->missing_frames_and_packets_.size());
574 } 567 }
575 568
576 void RtcpSender::BuildSenderLog(const RtcpSenderLogMessage* sender_log_message, 569 void RtcpSender::BuildSenderLog(const RtcpSenderLogMessage* sender_log_message,
577 std::vector<uint8>* packet) const { 570 std::vector<uint8>* packet) const {
578 // TODO(pwestin): Implement. 571 // TODO(pwestin): Implement.
579 NOTIMPLEMENTED(); 572 NOTIMPLEMENTED();
580 } 573 }
581 574
582 void RtcpSender::BuildReceiverLog( 575 void RtcpSender::BuildReceiverLog(
583 const RtcpReceiverLogMessage* receiver_log_message, 576 const RtcpReceiverLogMessage* receiver_log_message,
584 std::vector<uint8>* packet) const { 577 std::vector<uint8>* packet) const {
585 // TODO(pwestin): Implement. 578 // TODO(pwestin): Implement.
586 NOTIMPLEMENTED(); 579 NOTIMPLEMENTED();
587 } 580 }
588 581
589 } // namespace cast 582 } // namespace cast
590 } // namespace media 583 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtcp/rtcp_sender.h ('k') | media/cast/rtcp/rtcp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698