OLD | NEW |
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/rtp/rtp_parser.h" | 5 #include "media/cast/net/rtp/rtp_parser.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/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
10 #include "media/cast/net/rtp/rtp_defines.h" | 10 #include "media/cast/net/rtp/rtp_defines.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 namespace cast { | 13 namespace cast { |
14 | 14 |
| 15 // static |
| 16 bool RtpParser::ParseSsrc(const uint8* packet, |
| 17 size_t length, |
| 18 uint32* ssrc) { |
| 19 base::BigEndianReader big_endian_reader( |
| 20 reinterpret_cast<const char*>(packet), length); |
| 21 return big_endian_reader.Skip(8) && big_endian_reader.ReadU32(ssrc); |
| 22 } |
| 23 |
15 RtpParser::RtpParser(uint32 expected_sender_ssrc, uint8 expected_payload_type) | 24 RtpParser::RtpParser(uint32 expected_sender_ssrc, uint8 expected_payload_type) |
16 : expected_sender_ssrc_(expected_sender_ssrc), | 25 : expected_sender_ssrc_(expected_sender_ssrc), |
17 expected_payload_type_(expected_payload_type) {} | 26 expected_payload_type_(expected_payload_type) {} |
18 | 27 |
19 RtpParser::~RtpParser() {} | 28 RtpParser::~RtpParser() {} |
20 | 29 |
21 bool RtpParser::ParsePacket(const uint8* packet, | 30 bool RtpParser::ParsePacket(const uint8* packet, |
22 size_t length, | 31 size_t length, |
23 RtpCastHeader* header, | 32 RtpCastHeader* header, |
24 const uint8** payload_data, | 33 const uint8** payload_data, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 128 |
120 // All remaining data in the packet is the payload. | 129 // All remaining data in the packet is the payload. |
121 *payload_data = reinterpret_cast<const uint8*>(reader.ptr()); | 130 *payload_data = reinterpret_cast<const uint8*>(reader.ptr()); |
122 *payload_size = reader.remaining(); | 131 *payload_size = reader.remaining(); |
123 | 132 |
124 return true; | 133 return true; |
125 } | 134 } |
126 | 135 |
127 } // namespace cast | 136 } // namespace cast |
128 } // namespace media | 137 } // namespace media |
OLD | NEW |