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

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

Issue 1311453002: Use RtcpPacket to send APP in RtcpSender (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 5 years, 3 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 | webrtc/modules/rtp_rtcp/source/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 /* 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 775 }
776 } 776 }
777 uint16_t length = static_cast<uint16_t>(2 + 2 * numBoundingSet); 777 uint16_t length = static_cast<uint16_t>(2 + 2 * numBoundingSet);
778 ctx->buffer[posLength++] = static_cast<uint8_t>(length >> 8); 778 ctx->buffer[posLength++] = static_cast<uint8_t>(length >> 8);
779 ctx->buffer[posLength] = static_cast<uint8_t>(length); 779 ctx->buffer[posLength] = static_cast<uint8_t>(length);
780 780
781 return BuildResult::kSuccess; 781 return BuildResult::kSuccess;
782 } 782 }
783 783
784 RTCPSender::BuildResult RTCPSender::BuildAPP(RtcpContext* ctx) { 784 RTCPSender::BuildResult RTCPSender::BuildAPP(RtcpContext* ctx) {
785 // sanity 785 rtcp::App app;
786 if (app_data_ == NULL) { 786 app.From(ssrc_);
787 LOG(LS_WARNING) << "Failed to build app specific."; 787 app.WithSubType(app_sub_type_);
788 return BuildResult::kError; 788 app.WithName(app_name_);
789 } 789 app.WithData(app_data_.get(), app_length_);
790 if (ctx->position + 12 + app_length_ >= IP_PACKET_SIZE) { 790
791 LOG(LS_WARNING) << "Failed to build app specific."; 791 PacketBuiltCallback callback(ctx);
792 if (!callback.BuildPacket(app))
792 return BuildResult::kTruncated; 793 return BuildResult::kTruncated;
793 }
794 *ctx->AllocateData(1) = 0x80 + app_sub_type_;
795
796 // Add APP ID
797 *ctx->AllocateData(1) = 204;
798
799 uint16_t length = (app_length_ >> 2) + 2; // include SSRC and name
800 *ctx->AllocateData(1) = static_cast<uint8_t>(length >> 8);
801 *ctx->AllocateData(1) = static_cast<uint8_t>(length);
802
803 // Add our own SSRC
804 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_);
805
806 // Add our application name
807 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), app_name_);
808
809 // Add the data
810 memcpy(ctx->AllocateData(app_length_), app_data_.get(), app_length_);
811 794
812 return BuildResult::kSuccess; 795 return BuildResult::kSuccess;
813 } 796 }
814 797
815 RTCPSender::BuildResult RTCPSender::BuildNACK(RtcpContext* ctx) { 798 RTCPSender::BuildResult RTCPSender::BuildNACK(RtcpContext* ctx) {
816 // sanity 799 // sanity
817 if (ctx->position + 16 >= IP_PACKET_SIZE) { 800 if (ctx->position + 16 >= IP_PACKET_SIZE) {
818 LOG(LS_WARNING) << "Failed to build NACK."; 801 LOG(LS_WARNING) << "Failed to build NACK.";
819 return BuildResult::kTruncated; 802 return BuildResult::kTruncated;
820 } 803 }
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 1331
1349 bool RTCPSender::AllVolatileFlagsConsumed() const { 1332 bool RTCPSender::AllVolatileFlagsConsumed() const {
1350 for (const ReportFlag& flag : report_flags_) { 1333 for (const ReportFlag& flag : report_flags_) {
1351 if (flag.is_volatile) 1334 if (flag.is_volatile)
1352 return false; 1335 return false;
1353 } 1336 }
1354 return true; 1337 return true;
1355 } 1338 }
1356 1339
1357 } // namespace webrtc 1340 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698