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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc

Issue 2348623003: Unify rtcp packet setters (Closed)
Patch Set: +call/rtc_event_log_unittest Created 4 years, 2 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return false; 44 return false;
45 } 45 }
46 sub_type_ = packet.fmt(); 46 sub_type_ = packet.fmt();
47 ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[0]); 47 ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[0]);
48 name_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[4]); 48 name_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[4]);
49 data_.SetData(packet.payload() + kAppBaseLength, 49 data_.SetData(packet.payload() + kAppBaseLength,
50 packet.payload_size_bytes() - kAppBaseLength); 50 packet.payload_size_bytes() - kAppBaseLength);
51 return true; 51 return true;
52 } 52 }
53 53
54 void App::WithSubType(uint8_t subtype) { 54 void App::SetSubType(uint8_t subtype) {
55 RTC_DCHECK_LE(subtype, 0x1f); 55 RTC_DCHECK_LE(subtype, 0x1f);
56 sub_type_ = subtype; 56 sub_type_ = subtype;
57 } 57 }
58 58
59 void App::WithData(const uint8_t* data, size_t data_length) { 59 void App::SetData(const uint8_t* data, size_t data_length) {
60 RTC_DCHECK(data); 60 RTC_DCHECK(data);
61 RTC_DCHECK_EQ(data_length % 4, 0u) << "Data must be 32 bits aligned."; 61 RTC_DCHECK_EQ(data_length % 4, 0u) << "Data must be 32 bits aligned.";
62 RTC_DCHECK_LE(data_length, kMaxDataSize) << "App data size " << data_length 62 RTC_DCHECK_LE(data_length, kMaxDataSize) << "App data size " << data_length
63 << " exceed maximum of " 63 << " exceed maximum of "
64 << kMaxDataSize << " bytes."; 64 << kMaxDataSize << " bytes.";
65 data_.SetData(data, data_length); 65 data_.SetData(data, data_length);
66 } 66 }
67 67
68 bool App::Create(uint8_t* packet, 68 bool App::Create(uint8_t* packet,
69 size_t* index, 69 size_t* index,
70 size_t max_length, 70 size_t max_length,
71 RtcpPacket::PacketReadyCallback* callback) const { 71 RtcpPacket::PacketReadyCallback* callback) const {
72 while (*index + BlockLength() > max_length) { 72 while (*index + BlockLength() > max_length) {
73 if (!OnBufferFull(packet, index, callback)) 73 if (!OnBufferFull(packet, index, callback))
74 return false; 74 return false;
75 } 75 }
76 const size_t index_end = *index + BlockLength(); 76 const size_t index_end = *index + BlockLength();
77 CreateHeader(sub_type_, kPacketType, HeaderLength(), packet, index); 77 CreateHeader(sub_type_, kPacketType, HeaderLength(), packet, index);
78 78
79 ByteWriter<uint32_t>::WriteBigEndian(&packet[*index + 0], ssrc_); 79 ByteWriter<uint32_t>::WriteBigEndian(&packet[*index + 0], ssrc_);
80 ByteWriter<uint32_t>::WriteBigEndian(&packet[*index + 4], name_); 80 ByteWriter<uint32_t>::WriteBigEndian(&packet[*index + 4], name_);
81 memcpy(&packet[*index + 8], data_.data(), data_.size()); 81 memcpy(&packet[*index + 8], data_.data(), data_.size());
82 *index += (8 + data_.size()); 82 *index += (8 + data_.size());
83 RTC_DCHECK_EQ(index_end, *index); 83 RTC_DCHECK_EQ(index_end, *index);
84 return true; 84 return true;
85 } 85 }
86 86
87 } // namespace rtcp 87 } // namespace rtcp
88 } // namespace webrtc 88 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698