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

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

Issue 1262153003: Use RtcpPacket to send PLI in RtcpSender (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // TODO(sprang): Once all builders use RtcpPacket, call SendToNetwork() here. 114 // TODO(sprang): Once all builders use RtcpPacket, call SendToNetwork() here.
115 class RTCPSender::PacketBuiltCallback 115 class RTCPSender::PacketBuiltCallback
116 : public rtcp::RtcpPacket::PacketReadyCallback { 116 : public rtcp::RtcpPacket::PacketReadyCallback {
117 public: 117 public:
118 PacketBuiltCallback(RtcpContext* context) : context_(context) {} 118 PacketBuiltCallback(RtcpContext* context) : context_(context) {}
119 virtual ~PacketBuiltCallback() {} 119 virtual ~PacketBuiltCallback() {}
120 void OnPacketReady(uint8_t* data, size_t length) override { 120 void OnPacketReady(uint8_t* data, size_t length) override {
121 context_->position += length; 121 context_->position += length;
122 } 122 }
123 bool BuildPacket(const rtcp::RtcpPacket& packet) {
124 return packet.BuildExternalBuffer(
125 &context_->buffer[context_->position],
126 context_->buffer_size - context_->position,
127 this);
åsapersson 2015/07/31 13:36:42 nit: remove extra space
sprang_webrtc 2015/07/31 14:15:53 Done.
128 }
123 129
124 private: 130 private:
125 RtcpContext* const context_; 131 RtcpContext* const context_;
126 }; 132 };
127 133
128 RTCPSender::RTCPSender( 134 RTCPSender::RTCPSender(
129 int32_t id, 135 int32_t id,
130 bool audio, 136 bool audio,
131 Clock* clock, 137 Clock* clock,
132 ReceiveStatistics* receive_statistics, 138 ReceiveStatistics* receive_statistics,
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 report.WithNtpSec(ctx->ntp_sec); 500 report.WithNtpSec(ctx->ntp_sec);
495 report.WithNtpFrac(ctx->ntp_frac); 501 report.WithNtpFrac(ctx->ntp_frac);
496 report.WithRtpTimestamp(rtp_timestamp); 502 report.WithRtpTimestamp(rtp_timestamp);
497 report.WithPacketCount(ctx->feedback_state.packets_sent); 503 report.WithPacketCount(ctx->feedback_state.packets_sent);
498 report.WithOctetCount(ctx->feedback_state.media_bytes_sent); 504 report.WithOctetCount(ctx->feedback_state.media_bytes_sent);
499 505
500 for (auto it : report_blocks_) 506 for (auto it : report_blocks_)
501 report.WithReportBlock(it.second); 507 report.WithReportBlock(it.second);
502 508
503 PacketBuiltCallback callback(ctx); 509 PacketBuiltCallback callback(ctx);
504 if (!report.BuildExternalBuffer(&ctx->buffer[ctx->position], 510 if (!callback.BuildPacket(report))
505 ctx->buffer_size - ctx->position,
506 &callback)) {
507 return BuildResult::kTruncated; 511 return BuildResult::kTruncated;
508 }
509 512
510 report_blocks_.clear(); 513 report_blocks_.clear();
511 return BuildResult::kSuccess; 514 return BuildResult::kSuccess;
512 } 515 }
513 516
514 RTCPSender::BuildResult RTCPSender::BuildSDES(RtcpContext* ctx) { 517 RTCPSender::BuildResult RTCPSender::BuildSDES(RtcpContext* ctx) {
515 size_t length_cname = cname_.length(); 518 size_t length_cname = cname_.length();
516 CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE)); 519 CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE));
517 520
518 rtcp::Sdes sdes; 521 rtcp::Sdes sdes;
519 sdes.WithCName(ssrc_, cname_); 522 sdes.WithCName(ssrc_, cname_);
520 523
521 for (const auto it : csrc_cnames_) 524 for (const auto it : csrc_cnames_)
522 sdes.WithCName(it.first, it.second); 525 sdes.WithCName(it.first, it.second);
523 526
524 PacketBuiltCallback callback(ctx); 527 PacketBuiltCallback callback(ctx);
525 if (!sdes.BuildExternalBuffer(&ctx->buffer[ctx->position], 528 if (!callback.BuildPacket(sdes))
526 ctx->buffer_size - ctx->position, &callback)) {
527 return BuildResult::kTruncated; 529 return BuildResult::kTruncated;
528 }
529 530
530 return BuildResult::kSuccess; 531 return BuildResult::kSuccess;
531 } 532 }
532 533
533 RTCPSender::BuildResult RTCPSender::BuildRR(RtcpContext* ctx) { 534 RTCPSender::BuildResult RTCPSender::BuildRR(RtcpContext* ctx) {
534 rtcp::ReceiverReport report; 535 rtcp::ReceiverReport report;
535 report.From(ssrc_); 536 report.From(ssrc_);
536 for (auto it : report_blocks_) 537 for (auto it : report_blocks_)
537 report.WithReportBlock(it.second); 538 report.WithReportBlock(it.second);
538 539
539 PacketBuiltCallback callback(ctx); 540 PacketBuiltCallback callback(ctx);
540 if (!report.BuildExternalBuffer(&ctx->buffer[ctx->position], 541 if (!callback.BuildPacket(report))
541 ctx->buffer_size - ctx->position,
542 &callback)) {
543 return BuildResult::kTruncated; 542 return BuildResult::kTruncated;
544 }
545 543
546 report_blocks_.clear(); 544 report_blocks_.clear();
547 545
548 return BuildResult::kSuccess; 546 return BuildResult::kSuccess;
549 } 547 }
550 548
551 RTCPSender::BuildResult RTCPSender::BuildPLI(RtcpContext* ctx) { 549 RTCPSender::BuildResult RTCPSender::BuildPLI(RtcpContext* ctx) {
552 // sanity 550 rtcp::Pli pli;
553 if (ctx->position + 12 >= IP_PACKET_SIZE) 551 pli.From(ssrc_);
552 pli.To(remote_ssrc_);
553
554 PacketBuiltCallback callback(ctx);
555 if (!callback.BuildPacket(pli))
554 return BuildResult::kTruncated; 556 return BuildResult::kTruncated;
555 557
556 // add picture loss indicator
557 uint8_t FMT = 1;
558 *ctx->AllocateData(1) = 0x80 + FMT;
559 *ctx->AllocateData(1) = 206;
560
561 // Used fixed length of 2
562 *ctx->AllocateData(1) = 0;
563 *ctx->AllocateData(1) = 2;
564
565 // Add our own SSRC
566 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_);
567
568 // Add the remote SSRC
569 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remote_ssrc_);
570
571 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 558 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
572 "RTCPSender::PLI"); 559 "RTCPSender::PLI");
573 ++packet_type_counter_.pli_packets; 560 ++packet_type_counter_.pli_packets;
574 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_PLICount", 561 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_PLICount",
575 ssrc_, packet_type_counter_.pli_packets); 562 ssrc_, packet_type_counter_.pli_packets);
576 563
577 return BuildResult::kSuccess; 564 return BuildResult::kSuccess;
578 } 565 }
579 566
580 RTCPSender::BuildResult RTCPSender::BuildFIR(RtcpContext* ctx) { 567 RTCPSender::BuildResult RTCPSender::BuildFIR(RtcpContext* ctx) {
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 1489
1503 bool RTCPSender::AllVolatileFlagsConsumed() const { 1490 bool RTCPSender::AllVolatileFlagsConsumed() const {
1504 for (const ReportFlag& flag : report_flags_) { 1491 for (const ReportFlag& flag : report_flags_) {
1505 if (flag.is_volatile) 1492 if (flag.is_volatile)
1506 return false; 1493 return false;
1507 } 1494 }
1508 return true; 1495 return true;
1509 } 1496 }
1510 1497
1511 } // namespace webrtc 1498 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698