OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
12 | 12 |
| 13 #include <utility> |
| 14 |
13 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
17 | 19 |
18 namespace webrtc { | 20 namespace webrtc { |
19 namespace rtcp { | 21 namespace rtcp { |
| 22 constexpr uint8_t Sdes::kPacketType; |
20 // Source Description (SDES) (RFC 3550). | 23 // Source Description (SDES) (RFC 3550). |
21 // | 24 // |
22 // 0 1 2 3 | 25 // 0 1 2 3 |
23 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 26 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
24 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
25 // header |V=2|P| SC | PT=SDES=202 | length | | 28 // header |V=2|P| SC | PT=SDES=202 | length | |
26 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 29 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
27 // chunk | SSRC/CSRC_1 | | 30 // chunk | SSRC/CSRC_1 | |
28 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 31 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
29 // | SDES items | | 32 // | SDES items | |
(...skipping 23 matching lines...) Expand all Loading... |
53 size_t padding_size = 4 - (chunk_payload_size % 4); // Minimum 1. | 56 size_t padding_size = 4 - (chunk_payload_size % 4); // Minimum 1. |
54 return chunk_payload_size + padding_size; | 57 return chunk_payload_size + padding_size; |
55 } | 58 } |
56 } // namespace | 59 } // namespace |
57 | 60 |
58 Sdes::Sdes() : block_length_(RtcpPacket::kHeaderLength) {} | 61 Sdes::Sdes() : block_length_(RtcpPacket::kHeaderLength) {} |
59 | 62 |
60 Sdes::~Sdes() {} | 63 Sdes::~Sdes() {} |
61 | 64 |
62 bool Sdes::Parse(const CommonHeader& packet) { | 65 bool Sdes::Parse(const CommonHeader& packet) { |
63 RTC_DCHECK(packet.type() == kPacketType); | 66 RTC_DCHECK_EQ(packet.type(), kPacketType); |
64 | 67 |
65 uint8_t number_of_chunks = packet.count(); | 68 uint8_t number_of_chunks = packet.count(); |
66 std::vector<Chunk> chunks; // Read chunk into temporary array, so that in | 69 std::vector<Chunk> chunks; // Read chunk into temporary array, so that in |
67 // case of an error original array would stay | 70 // case of an error original array would stay |
68 // unchanged. | 71 // unchanged. |
69 size_t block_length = kHeaderLength; | 72 size_t block_length = kHeaderLength; |
70 | 73 |
71 if (packet.payload_size_bytes() % 4 != 0) { | 74 if (packet.payload_size_bytes() % 4 != 0) { |
72 LOG(LS_WARNING) << "Invalid payload size " << packet.payload_size_bytes() | 75 LOG(LS_WARNING) << "Invalid payload size " << packet.payload_size_bytes() |
73 << " bytes for a valid Sdes packet. Size should be" | 76 << " bytes for a valid Sdes packet. Size should be" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 const int kPadding = 0; | 180 const int kPadding = 0; |
178 memset(packet + *index, kPadding, padding_size); | 181 memset(packet + *index, kPadding, padding_size); |
179 *index += padding_size; | 182 *index += padding_size; |
180 } | 183 } |
181 | 184 |
182 RTC_CHECK_EQ(*index, index_end); | 185 RTC_CHECK_EQ(*index, index_end); |
183 return true; | 186 return true; |
184 } | 187 } |
185 } // namespace rtcp | 188 } // namespace rtcp |
186 } // namespace webrtc | 189 } // namespace webrtc |
OLD | NEW |