Chromoting: Fix connection failure strings to match Directory Service
[chromium-blink-merge.git] / media / base / bit_reader.h
blobfda854162a64f23478302625af58c8f39dbe8dba
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_BIT_READER_H_
6 #define MEDIA_BASE_BIT_READER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "media/base/bit_reader_core.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 class MEDIA_EXPORT BitReader
17 : NON_EXPORTED_BASE(private BitReaderCore::ByteStreamProvider) {
18 public:
19 // Initialize the reader to start reading at |data|, |size| being size
20 // of |data| in bytes.
21 BitReader(const uint8* data, int size);
22 ~BitReader() override;
24 template<typename T> bool ReadBits(int num_bits, T* out) {
25 return bit_reader_core_.ReadBits(num_bits, out);
28 bool ReadFlag(bool* flag) {
29 return bit_reader_core_.ReadFlag(flag);
32 bool SkipBits(int num_bits) {
33 return bit_reader_core_.SkipBits(num_bits);
36 int bits_available() const {
37 return initial_size_ * 8 - bits_read();
40 int bits_read() const {
41 return bit_reader_core_.bits_read();
44 private:
45 // BitReaderCore::ByteStreamProvider implementation.
46 int GetBytes(int max_n, const uint8** out) override;
48 // Total number of bytes that was initially passed to BitReader.
49 const int initial_size_;
51 // Pointer to the next unread byte in the stream.
52 const uint8* data_;
54 // Bytes left in the stream.
55 int bytes_left_;
57 BitReaderCore bit_reader_core_;
59 DISALLOW_COPY_AND_ASSIGN(BitReader);
62 } // namespace media
64 #endif // MEDIA_BASE_BIT_READER_H_