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

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

Issue 388663003: Cast: Reshuffle files under media/cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing includes Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/net/rtcp/rtcp_utility.h ('k') | media/cast/net/rtcp/test_rtcp_packet_builder.h » ('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 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/rtcp_utility.h" 5 #include "media/cast/net/rtcp/rtcp_utility.h"
6 6
7 #include "base/big_endian.h" 7 #include "base/big_endian.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/cast/transport/cast_transport_defines.h" 9 #include "media/cast/net/cast_transport_defines.h"
10 10
11 namespace media { 11 namespace media {
12 namespace cast { 12 namespace cast {
13 13
14 RtcpParser::RtcpParser(const uint8* rtcpData, size_t rtcpDataLength) 14 RtcpParser::RtcpParser(const uint8* rtcpData, size_t rtcpDataLength)
15 : rtcp_data_begin_(rtcpData), 15 : rtcp_data_begin_(rtcpData),
16 rtcp_data_end_(rtcpData + rtcpDataLength), 16 rtcp_data_end_(rtcpData + rtcpDataLength),
17 valid_packet_(false), 17 valid_packet_(false),
18 rtcp_data_(rtcpData), 18 rtcp_data_(rtcpData),
19 rtcp_block_end_(NULL), 19 rtcp_block_end_(NULL),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 bool success = RtcpParseCommonHeader(rtcp_data_, rtcp_data_end_, &header); 99 bool success = RtcpParseCommonHeader(rtcp_data_, rtcp_data_end_, &header);
100 if (!success) 100 if (!success)
101 return; 101 return;
102 102
103 rtcp_block_end_ = rtcp_data_ + header.length_in_octets; 103 rtcp_block_end_ = rtcp_data_ + header.length_in_octets;
104 104
105 if (rtcp_block_end_ > rtcp_data_end_) 105 if (rtcp_block_end_ > rtcp_data_end_)
106 return; // Bad block! 106 return; // Bad block!
107 107
108 switch (header.PT) { 108 switch (header.PT) {
109 case transport::kPacketTypeSenderReport: 109 case kPacketTypeSenderReport:
110 // number of Report blocks 110 // number of Report blocks
111 number_of_blocks_ = header.IC; 111 number_of_blocks_ = header.IC;
112 ParseSR(); 112 ParseSR();
113 return; 113 return;
114 case transport::kPacketTypeReceiverReport: 114 case kPacketTypeReceiverReport:
115 // number of Report blocks 115 // number of Report blocks
116 number_of_blocks_ = header.IC; 116 number_of_blocks_ = header.IC;
117 ParseRR(); 117 ParseRR();
118 return; 118 return;
119 case transport::kPacketTypeSdes: 119 case kPacketTypeSdes:
120 // number of Sdes blocks 120 // number of Sdes blocks
121 number_of_blocks_ = header.IC; 121 number_of_blocks_ = header.IC;
122 if (!ParseSdes()) { 122 if (!ParseSdes()) {
123 break; // Nothing supported found, continue to next block! 123 break; // Nothing supported found, continue to next block!
124 } 124 }
125 return; 125 return;
126 case transport::kPacketTypeBye: 126 case kPacketTypeBye:
127 number_of_blocks_ = header.IC; 127 number_of_blocks_ = header.IC;
128 if (!ParseBye()) { 128 if (!ParseBye()) {
129 // Nothing supported found, continue to next block! 129 // Nothing supported found, continue to next block!
130 break; 130 break;
131 } 131 }
132 return; 132 return;
133 case transport::kPacketTypeApplicationDefined: 133 case kPacketTypeApplicationDefined:
134 if (!ParseApplicationDefined(header.IC)) { 134 if (!ParseApplicationDefined(header.IC)) {
135 // Nothing supported found, continue to next block! 135 // Nothing supported found, continue to next block!
136 break; 136 break;
137 } 137 }
138 return; 138 return;
139 case transport::kPacketTypeGenericRtpFeedback: // Fall through! 139 case kPacketTypeGenericRtpFeedback: // Fall through!
140 case transport::kPacketTypePayloadSpecific: 140 case kPacketTypePayloadSpecific:
141 if (!ParseFeedBackCommon(header)) { 141 if (!ParseFeedBackCommon(header)) {
142 // Nothing supported found, continue to next block! 142 // Nothing supported found, continue to next block!
143 break; 143 break;
144 } 144 }
145 return; 145 return;
146 case transport::kPacketTypeXr: 146 case kPacketTypeXr:
147 if (!ParseExtendedReport()) { 147 if (!ParseExtendedReport()) {
148 break; // Nothing supported found, continue to next block! 148 break; // Nothing supported found, continue to next block!
149 } 149 }
150 return; 150 return;
151 default: 151 default:
152 // Not supported! Skip! 152 // Not supported! Skip!
153 EndCurrentBlock(); 153 EndCurrentBlock();
154 break; 154 break;
155 } 155 }
156 } 156 }
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 field_.cast_receiver_log.delay_delta_or_packet_id.packet_id = 602 field_.cast_receiver_log.delay_delta_or_packet_id.packet_id =
603 delay_delta_or_packet_id; 603 delay_delta_or_packet_id;
604 field_.cast_receiver_log.event_timestamp_delta = 604 field_.cast_receiver_log.event_timestamp_delta =
605 event_type_and_timestamp_delta & 0xfff; 605 event_type_and_timestamp_delta & 0xfff;
606 606
607 field_type_ = kRtcpApplicationSpecificCastReceiverLogEventCode; 607 field_type_ = kRtcpApplicationSpecificCastReceiverLogEventCode;
608 return true; 608 return true;
609 } 609 }
610 610
611 bool RtcpParser::ParseFeedBackCommon(const RtcpCommonHeader& header) { 611 bool RtcpParser::ParseFeedBackCommon(const RtcpCommonHeader& header) {
612 DCHECK((header.PT == transport::kPacketTypeGenericRtpFeedback) || 612 DCHECK((header.PT == kPacketTypeGenericRtpFeedback) ||
613 (header.PT == transport::kPacketTypePayloadSpecific)) 613 (header.PT == kPacketTypePayloadSpecific))
614 << "Invalid state"; 614 << "Invalid state";
615 615
616 ptrdiff_t length = rtcp_block_end_ - rtcp_data_; 616 ptrdiff_t length = rtcp_block_end_ - rtcp_data_;
617 617
618 if (length < 12) { // 4 * 3, RFC4585 section 6.1 618 if (length < 12) { // 4 * 3, RFC4585 section 6.1
619 EndCurrentBlock(); 619 EndCurrentBlock();
620 return false; 620 return false;
621 } 621 }
622 622
623 uint32 sender_ssrc; 623 uint32 sender_ssrc;
624 uint32 media_ssrc; 624 uint32 media_ssrc;
625 base::BigEndianReader big_endian_reader( 625 base::BigEndianReader big_endian_reader(
626 reinterpret_cast<const char*>(rtcp_data_), length); 626 reinterpret_cast<const char*>(rtcp_data_), length);
627 big_endian_reader.Skip(4); // Skip header. 627 big_endian_reader.Skip(4); // Skip header.
628 big_endian_reader.ReadU32(&sender_ssrc); 628 big_endian_reader.ReadU32(&sender_ssrc);
629 big_endian_reader.ReadU32(&media_ssrc); 629 big_endian_reader.ReadU32(&media_ssrc);
630 630
631 rtcp_data_ += 12; 631 rtcp_data_ += 12;
632 632
633 if (header.PT == transport::kPacketTypeGenericRtpFeedback) { 633 if (header.PT == kPacketTypeGenericRtpFeedback) {
634 // Transport layer feedback 634 // Transport layer feedback
635 switch (header.IC) { 635 switch (header.IC) {
636 case 1: 636 case 1:
637 // Nack 637 // Nack
638 field_type_ = kRtcpGenericRtpFeedbackNackCode; 638 field_type_ = kRtcpGenericRtpFeedbackNackCode;
639 field_.nack.sender_ssrc = sender_ssrc; 639 field_.nack.sender_ssrc = sender_ssrc;
640 field_.nack.media_ssrc = media_ssrc; 640 field_.nack.media_ssrc = media_ssrc;
641 state_ = kStateGenericRtpFeedbackNack; 641 state_ = kStateGenericRtpFeedbackNack;
642 return true; 642 return true;
643 case 2: 643 case 2:
(...skipping 12 matching lines...) Expand all
656 field_type_ = kRtcpGenericRtpFeedbackSrReqCode; 656 field_type_ = kRtcpGenericRtpFeedbackSrReqCode;
657 657
658 // Note: No state transition, sender report REQ is empty! 658 // Note: No state transition, sender report REQ is empty!
659 return true; 659 return true;
660 default: 660 default:
661 break; 661 break;
662 } 662 }
663 EndCurrentBlock(); 663 EndCurrentBlock();
664 return false; 664 return false;
665 665
666 } else if (header.PT == transport::kPacketTypePayloadSpecific) { 666 } else if (header.PT == kPacketTypePayloadSpecific) {
667 // Payload specific feedback 667 // Payload specific feedback
668 switch (header.IC) { 668 switch (header.IC) {
669 case 1: 669 case 1:
670 // PLI 670 // PLI
671 field_type_ = kRtcpPayloadSpecificPliCode; 671 field_type_ = kRtcpPayloadSpecificPliCode;
672 field_.pli.sender_ssrc = sender_ssrc; 672 field_.pli.sender_ssrc = sender_ssrc;
673 field_.pli.media_ssrc = media_ssrc; 673 field_.pli.media_ssrc = media_ssrc;
674 674
675 // Note: No state transition, PLI FCI is empty! 675 // Note: No state transition, PLI FCI is empty!
676 return true; 676 return true;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // If the sender adds new log messages we will end up here until we add 1057 // If the sender adds new log messages we will end up here until we add
1058 // the new messages in the receiver. 1058 // the new messages in the receiver.
1059 VLOG(1) << "Unexpected log message received: " << static_cast<int>(event); 1059 VLOG(1) << "Unexpected log message received: " << static_cast<int>(event);
1060 NOTREACHED(); 1060 NOTREACHED();
1061 return UNKNOWN; 1061 return UNKNOWN;
1062 } 1062 }
1063 } 1063 }
1064 1064
1065 } // namespace cast 1065 } // namespace cast
1066 } // namespace media 1066 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/rtcp/rtcp_utility.h ('k') | media/cast/net/rtcp/test_rtcp_packet_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698