OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 protected: | 75 protected: |
76 const uint8_t* const bytes_; | 76 const uint8_t* const bytes_; |
77 // The total size of |bytes_|. | 77 // The total size of |bytes_|. |
78 size_t byte_count_; | 78 size_t byte_count_; |
79 // The current offset, in bytes, from the start of |bytes_|. | 79 // The current offset, in bytes, from the start of |bytes_|. |
80 size_t byte_offset_; | 80 size_t byte_offset_; |
81 // The current offset, in bits, into the current byte. | 81 // The current offset, in bits, into the current byte. |
82 size_t bit_offset_; | 82 size_t bit_offset_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(BitBuffer); | 84 RTC_DISALLOW_COPY_AND_ASSIGN(BitBuffer); |
85 }; | 85 }; |
86 | 86 |
87 // A BitBuffer API for write operations. Supports symmetric write APIs to the | 87 // A BitBuffer API for write operations. Supports symmetric write APIs to the |
88 // reading APIs of BitBuffer. Note that the read/write offset is shared with the | 88 // reading APIs of BitBuffer. Note that the read/write offset is shared with the |
89 // BitBuffer API, so both reading and writing will consume bytes/bits. | 89 // BitBuffer API, so both reading and writing will consume bytes/bits. |
90 class BitBufferWriter : public BitBuffer { | 90 class BitBufferWriter : public BitBuffer { |
91 public: | 91 public: |
92 // Constructs a bit buffer for the writable buffer of |bytes|. | 92 // Constructs a bit buffer for the writable buffer of |bytes|. |
93 BitBufferWriter(uint8_t* bytes, size_t byte_count); | 93 BitBufferWriter(uint8_t* bytes, size_t byte_count); |
94 | 94 |
95 // Writes byte-sized values from the buffer. Returns false if there isn't | 95 // Writes byte-sized values from the buffer. Returns false if there isn't |
96 // enough data left for the specified type. | 96 // enough data left for the specified type. |
97 bool WriteUInt8(uint8_t val); | 97 bool WriteUInt8(uint8_t val); |
98 bool WriteUInt16(uint16_t val); | 98 bool WriteUInt16(uint16_t val); |
99 bool WriteUInt32(uint32_t val); | 99 bool WriteUInt32(uint32_t val); |
100 | 100 |
101 // Writes bit-sized values to the buffer. Returns false if there isn't enough | 101 // Writes bit-sized values to the buffer. Returns false if there isn't enough |
102 // room left for the specified number of bits. | 102 // room left for the specified number of bits. |
103 bool WriteBits(uint64_t val, size_t bit_count); | 103 bool WriteBits(uint64_t val, size_t bit_count); |
104 | 104 |
105 // Writes the exponential golomb encoded version of the supplied value. | 105 // Writes the exponential golomb encoded version of the supplied value. |
106 // Returns false if there isn't enough room left for the value. | 106 // Returns false if there isn't enough room left for the value. |
107 bool WriteExponentialGolomb(uint32_t val); | 107 bool WriteExponentialGolomb(uint32_t val); |
108 | 108 |
109 private: | 109 private: |
110 // The buffer, as a writable array. | 110 // The buffer, as a writable array. |
111 uint8_t* const writable_bytes_; | 111 uint8_t* const writable_bytes_; |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(BitBufferWriter); | 113 RTC_DISALLOW_COPY_AND_ASSIGN(BitBufferWriter); |
114 }; | 114 }; |
115 | 115 |
116 } // namespace rtc | 116 } // namespace rtc |
117 | 117 |
118 #endif // WEBRTC_BASE_BITBUFFER_H_ | 118 #endif // WEBRTC_BASE_BITBUFFER_H_ |
OLD | NEW |