OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 // // Write an unsigned 8 byte integer in little endian format | 29 // // Write an unsigned 8 byte integer in little endian format |
30 // ByteWriter<uint64_t>::WriteLittleEndian(buffer, val); | 30 // ByteWriter<uint64_t>::WriteLittleEndian(buffer, val); |
31 // | 31 // |
32 // Write an unsigned 40-bit (5 byte) integer in big endian format | 32 // Write an unsigned 40-bit (5 byte) integer in big endian format |
33 // ByteWriter<uint64_t, 5>::WriteBigEndian(buffer, val); | 33 // ByteWriter<uint64_t, 5>::WriteBigEndian(buffer, val); |
34 // | 34 // |
35 // These classes are implemented as recursive templetizations, inteded to make | 35 // These classes are implemented as recursive templetizations, inteded to make |
36 // it easy for the compiler to completely inline the reading/writing. | 36 // it easy for the compiler to completely inline the reading/writing. |
37 | 37 |
38 | 38 |
39 #include <stddef.h> | |
eladalon
2017/09/12 14:45:07
By the way, for my information, don't we prefer to
danilchap
2017/09/12 15:17:18
I've reverted this file alltogether,
but generally
eladalon
2017/09/12 15:25:24
Acknowledged.
| |
40 #include <stdint.h> | |
41 | |
39 #include <limits> | 42 #include <limits> |
40 | 43 |
41 #include "webrtc/typedefs.h" | |
42 | |
43 namespace webrtc { | 44 namespace webrtc { |
44 | 45 |
45 // According to ISO C standard ISO/IEC 9899, section 6.2.6.2 (2), the three | 46 // According to ISO C standard ISO/IEC 9899, section 6.2.6.2 (2), the three |
46 // representations of signed integers allowed are two's complement, one's | 47 // representations of signed integers allowed are two's complement, one's |
47 // complement and sign/magnitude. We can detect which is used by looking at | 48 // complement and sign/magnitude. We can detect which is used by looking at |
48 // the two last bits of -1, which will be 11 in two's complement, 10 in one's | 49 // the two last bits of -1, which will be 11 in two's complement, 10 in one's |
49 // complement and 01 in sign/magnitude. | 50 // complement and 01 in sign/magnitude. |
50 // TODO(sprang): In the unlikely event that we actually need to support a | 51 // TODO(sprang): In the unlikely event that we actually need to support a |
51 // platform that doesn't use two's complement, implement conversion to/from | 52 // platform that doesn't use two's complement, implement conversion to/from |
52 // wire format. | 53 // wire format. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 data[1] = val >> 8; | 397 data[1] = val >> 8; |
397 data[2] = val >> 16; | 398 data[2] = val >> 16; |
398 data[3] = val >> 24; | 399 data[3] = val >> 24; |
399 data[4] = val >> 32; | 400 data[4] = val >> 32; |
400 data[5] = val >> 40; | 401 data[5] = val >> 40; |
401 data[6] = val >> 48; | 402 data[6] = val >> 48; |
402 data[7] = val >> 56; | 403 data[7] = val >> 56; |
403 } | 404 } |
404 }; | 405 }; |
405 | 406 |
407 // Round up to the nearest size that is a multiple of 4. | |
408 inline size_t Word32Align(size_t size) { | |
409 // Same as increment by 3 and clear last two bits. | |
410 return (size + 3) & ~0x3; | |
eladalon
2017/09/12 14:45:07
Is this the safest way to do this?
1. There are so
danilchap
2017/09/12 15:17:17
2. Moved inside rtp_header_extension_map where siz
| |
411 } | |
412 | |
406 } // namespace webrtc | 413 } // namespace webrtc |
407 | 414 |
408 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ | 415 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ |
OLD | NEW |