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

Side by Side Diff: media/cast/net/rtcp/rtcp_utility.cc

Issue 499433002: Minor code redundancy cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 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 | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | media/cast/net/rtcp/rtcp_utility_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/net/rtcp/rtcp_utility.h" 5 #include "media/cast/net/rtcp/rtcp_utility.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/cast/net/cast_transport_defines.h" 8 #include "media/cast/net/cast_transport_defines.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 switch (block_type) { 306 switch (block_type) {
307 case 4: // RRTR. RFC3611 Section 4.4. 307 case 4: // RRTR. RFC3611 Section 4.4.
308 if (block_length != 2) 308 if (block_length != 2)
309 return false; 309 return false;
310 if (!ParseExtendedReportReceiverReferenceTimeReport(reader, 310 if (!ParseExtendedReportReceiverReferenceTimeReport(reader,
311 remote_ssrc)) 311 remote_ssrc))
312 return false; 312 return false;
313 break; 313 break;
314 314
315 case 5: // DLRR. RFC3611 Section 4.5.
316 if (block_length % 3 != 0)
317 return false;
318 for (int block = 0; block < block_length / 3; block++)
319 if (!ParseExtendedReportDelaySinceLastReceiverReport(reader))
320 return false;
321 return true;
322
323 default: 315 default:
324 // Skip unknown item. 316 // Skip unknown item.
325 if (!reader->Skip(block_length * 4)) 317 if (!reader->Skip(block_length * 4))
326 return false; 318 return false;
327 } 319 }
328 } 320 }
329 321
330 return true; 322 return true;
331 } 323 }
332 324
333 bool RtcpParser::ParseExtendedReportReceiverReferenceTimeReport( 325 bool RtcpParser::ParseExtendedReportReceiverReferenceTimeReport(
334 base::BigEndianReader* reader, 326 base::BigEndianReader* reader,
335 uint32 remote_ssrc) { 327 uint32 remote_ssrc) {
336 receiver_reference_time_report_.remote_ssrc = remote_ssrc; 328 receiver_reference_time_report_.remote_ssrc = remote_ssrc;
337 if(!reader->ReadU32(&receiver_reference_time_report_.ntp_seconds) || 329 if(!reader->ReadU32(&receiver_reference_time_report_.ntp_seconds) ||
338 !reader->ReadU32(&receiver_reference_time_report_.ntp_fraction)) 330 !reader->ReadU32(&receiver_reference_time_report_.ntp_fraction))
339 return false; 331 return false;
340 332
341 has_receiver_reference_time_report_ = true; 333 has_receiver_reference_time_report_ = true;
342 return true; 334 return true;
343 } 335 }
344 336
345 bool RtcpParser::ParseExtendedReportDelaySinceLastReceiverReport(
346 base::BigEndianReader* reader) {
347 uint32 ssrc, last_report, delay;
348 if (!reader->ReadU32(&ssrc) ||
349 !reader->ReadU32(&last_report) ||
350 !reader->ReadU32(&delay))
351 return false;
352
353 if (ssrc == remote_ssrc_) {
354 last_report_ = last_report;
355 delay_since_last_report_ = delay;
356 has_last_report_ = true;
357 }
358
359 has_last_report_ = true;
360 return true;
361 }
362
363 // Converts a log event type to an integer value. 337 // Converts a log event type to an integer value.
364 // NOTE: We have only allocated 4 bits to represent the type of event over the 338 // NOTE: We have only allocated 4 bits to represent the type of event over the
365 // wire. Therefore, this function can only return values from 0 to 15. 339 // wire. Therefore, this function can only return values from 0 to 15.
366 uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event) { 340 uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event) {
367 switch (event) { 341 switch (event) {
368 case FRAME_ACK_SENT: 342 case FRAME_ACK_SENT:
369 return 11; 343 return 11;
370 case FRAME_PLAYOUT: 344 case FRAME_PLAYOUT:
371 return 12; 345 return 12;
372 case FRAME_DECODED: 346 case FRAME_DECODED:
(...skipping 29 matching lines...) Expand all
402 default: 376 default:
403 // If the sender adds new log messages we will end up here until we add 377 // If the sender adds new log messages we will end up here until we add
404 // the new messages in the receiver. 378 // the new messages in the receiver.
405 VLOG(1) << "Unexpected log message received: " << static_cast<int>(event); 379 VLOG(1) << "Unexpected log message received: " << static_cast<int>(event);
406 return UNKNOWN; 380 return UNKNOWN;
407 } 381 }
408 } 382 }
409 383
410 } // namespace cast 384 } // namespace cast
411 } // namespace media 385 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | media/cast/net/rtcp/rtcp_utility_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698