/* * Copyright 2021 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef RTC_BASE_BITSTREAM_READER_H_ #define RTC_BASE_BITSTREAM_READER_H_ #include <stdint.h> #include "absl/base/attributes.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" namespace webrtc { // A class to parse sequence of bits. Byte order is assumed big-endian/network. // This class is optimized for successful parsing and binary size. // Individual calls to `Read` and `ConsumeBits` never fail. Instead they may // change the class state into 'failure state'. User of this class should verify // parsing by checking if class is in that 'failure state' by calling `Ok`. // That verification can be done once after multiple reads. class BitstreamReader { … }; inline BitstreamReader::BitstreamReader(rtc::ArrayView<const uint8_t> bytes) : … { … } inline BitstreamReader::BitstreamReader(absl::string_view bytes) : … { … } inline BitstreamReader::~BitstreamReader() { … } inline void BitstreamReader::set_last_read_is_verified(bool value) const { … } inline int BitstreamReader::RemainingBitCount() const { … } } // namespace webrtc #endif // RTC_BASE_BITSTREAM_READER_H_