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

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

Issue 74613004: Cast: Add capabity to send Receiver and Sender log messages over RTCP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rtcp_logging
Patch Set: Fixed nits 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
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/test_rtcp_packet_builder.h" 5 #include "media/cast/rtcp/test_rtcp_packet_builder.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 big_endian_writer_.WriteU16(kRtcpCastAllPacketsLost); 204 big_endian_writer_.WriteU16(kRtcpCastAllPacketsLost);
205 big_endian_writer_.WriteU8(0); // Lost packet id mask. 205 big_endian_writer_.WriteU8(0); // Lost packet id mask.
206 big_endian_writer_.WriteU8(kFrameIdWithLostPackets); 206 big_endian_writer_.WriteU8(kFrameIdWithLostPackets);
207 big_endian_writer_.WriteU16(kLostPacketId1); 207 big_endian_writer_.WriteU16(kLostPacketId1);
208 big_endian_writer_.WriteU8(0x2); // Lost packet id mask. 208 big_endian_writer_.WriteU8(0x2); // Lost packet id mask.
209 big_endian_writer_.WriteU8(kFrameIdWithLostPackets); 209 big_endian_writer_.WriteU8(kFrameIdWithLostPackets);
210 big_endian_writer_.WriteU16(kLostPacketId3); 210 big_endian_writer_.WriteU16(kLostPacketId3);
211 big_endian_writer_.WriteU8(0); // Lost packet id mask. 211 big_endian_writer_.WriteU8(0); // Lost packet id mask.
212 } 212 }
213 213
214 void TestRtcpPacketBuilder::AddSenderLog(uint32 sender_ssrc) {
215 AddRtcpHeader(204, 1);
216 big_endian_writer_.WriteU32(sender_ssrc);
217 big_endian_writer_.WriteU8('C');
218 big_endian_writer_.WriteU8('A');
219 big_endian_writer_.WriteU8('S');
220 big_endian_writer_.WriteU8('T');
221 }
222
223 void TestRtcpPacketBuilder::AddSenderFrameLog(uint8 event_id,
224 uint32 rtp_timestamp) {
225 big_endian_writer_.WriteU32(
226 (static_cast<uint32>(event_id) << 24) + (rtp_timestamp & 0xffffff));
227 }
228
229 void TestRtcpPacketBuilder::AddReceiverLog(uint32 sender_ssrc) {
230 AddRtcpHeader(204, 2);
231 big_endian_writer_.WriteU32(sender_ssrc);
232 big_endian_writer_.WriteU8('C');
233 big_endian_writer_.WriteU8('A');
234 big_endian_writer_.WriteU8('S');
235 big_endian_writer_.WriteU8('T');
236 }
237
238 void TestRtcpPacketBuilder::AddReceiverFrameLog(uint32 rtp_timestamp,
239 int num_events, uint32 event_timesamp_base) {
240 big_endian_writer_.WriteU32(rtp_timestamp);
241 big_endian_writer_.WriteU8(static_cast<uint8>(num_events - 1));
242 big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base >> 16));
243 big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base >> 8));
244 big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base));
245 }
246
247 void TestRtcpPacketBuilder::AddReceiverEventLog(uint16 event_data,
248 uint8 event_id, uint16 event_timesamp_delta) {
249 big_endian_writer_.WriteU16(event_data);
250 uint16 type_and_delta = static_cast<uint16>(event_id) << 12;
251 type_and_delta += event_timesamp_delta & 0x0fff;
252 big_endian_writer_.WriteU16(type_and_delta);
253 }
254
214 const uint8* TestRtcpPacketBuilder::Packet() { 255 const uint8* TestRtcpPacketBuilder::Packet() {
215 PatchLengthField(); 256 PatchLengthField();
216 return buffer_; 257 return buffer_;
217 } 258 }
218 259
219 void TestRtcpPacketBuilder::PatchLengthField() { 260 void TestRtcpPacketBuilder::PatchLengthField() {
220 if (ptr_of_length_) { 261 if (ptr_of_length_) {
221 // Back-patch the packet length. The client must have taken 262 // Back-patch the packet length. The client must have taken
222 // care of proper padding to 32-bit words. 263 // care of proper padding to 32-bit words.
223 int this_packet_length = (big_endian_writer_.ptr() - ptr_of_length_ - 2); 264 int this_packet_length = (big_endian_writer_.ptr() - ptr_of_length_ - 2);
(...skipping 13 matching lines...) Expand all
237 big_endian_writer_.WriteU8(0x80 | (format_or_count & 0x1F)); 278 big_endian_writer_.WriteU8(0x80 | (format_or_count & 0x1F));
238 big_endian_writer_.WriteU8(payload); 279 big_endian_writer_.WriteU8(payload);
239 ptr_of_length_ = big_endian_writer_.ptr(); 280 ptr_of_length_ = big_endian_writer_.ptr();
240 281
241 // Initialize length to "clearly illegal". 282 // Initialize length to "clearly illegal".
242 big_endian_writer_.WriteU16(0xDEAD); 283 big_endian_writer_.WriteU16(0xDEAD);
243 } 284 }
244 285
245 } // namespace cast 286 } // namespace cast
246 } // namespace media 287 } // namespace media
OLDNEW
« media/cast/rtcp/rtcp_utility.h ('K') | « media/cast/rtcp/test_rtcp_packet_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698