Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: media/base/bit_reader.h

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: tidying up prior to review Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_BIT_READER_H_ 5 #ifndef MEDIA_BASE_BIT_READER_H_
6 #define MEDIA_BASE_BIT_READER_H_ 6 #define MEDIA_BASE_BIT_READER_H_
7 7
8 #include <string>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "media/base/bit_reader_core.h" 13 #include "media/base/bit_reader_core.h"
12 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
13 15
14 namespace media { 16 namespace media {
15 17
16 class MEDIA_EXPORT BitReader 18 class MEDIA_EXPORT BitReader
17 : NON_EXPORTED_BASE(private BitReaderCore::ByteStreamProvider) { 19 : NON_EXPORTED_BASE(private BitReaderCore::ByteStreamProvider) {
18 public: 20 public:
19 // Initialize the reader to start reading at |data|, |size| being size 21 // Initialize the reader to start reading at |data|, |size| being size
20 // of |data| in bytes. 22 // of |data| in bytes.
21 BitReader(const uint8* data, int size); 23 BitReader(const uint8* data, int size);
22 ~BitReader() override; 24 ~BitReader() override;
23 25
24 template<typename T> bool ReadBits(int num_bits, T* out) { 26 template<typename T> bool ReadBits(int num_bits, T* out) {
25 return bit_reader_core_.ReadBits(num_bits, out); 27 return bit_reader_core_.ReadBits(num_bits, out);
26 } 28 }
27 29
28 bool ReadFlag(bool* flag) { 30 bool ReadFlag(bool* flag) {
29 return bit_reader_core_.ReadFlag(flag); 31 return bit_reader_core_.ReadFlag(flag);
30 } 32 }
31 33
32 bool SkipBits(int num_bits) { 34 bool SkipBits(int num_bits) {
33 return bit_reader_core_.SkipBits(num_bits); 35 return bit_reader_core_.SkipBits(num_bits);
34 } 36 }
35 37
38 // Read |num_bits| of binary data into |str|. |num_bits| must be a multiple
ddorwin 2015/12/10 20:10:58 nit: move up with the other Read*().
dougsteed 2015/12/14 22:51:46 Done.
39 // of 8. This is not efficient for extracting large strings.
40 bool ReadString(int num_bits, std::string* str);
41
36 int bits_available() const { 42 int bits_available() const {
37 return initial_size_ * 8 - bits_read(); 43 return initial_size_ * 8 - bits_read();
38 } 44 }
39 45
40 int bits_read() const { 46 int bits_read() const {
41 return bit_reader_core_.bits_read(); 47 return bit_reader_core_.bits_read();
42 } 48 }
43 49
44 private: 50 private:
45 // BitReaderCore::ByteStreamProvider implementation. 51 // BitReaderCore::ByteStreamProvider implementation.
46 int GetBytes(int max_n, const uint8** out) override; 52 int GetBytes(int max_n, const uint8** out) override;
47 53
48 // Total number of bytes that was initially passed to BitReader. 54 // Total number of bytes that was initially passed to BitReader.
49 const int initial_size_; 55 const int initial_size_;
50 56
51 // Pointer to the next unread byte in the stream. 57 // Pointer to the next unread byte in the stream.
52 const uint8* data_; 58 const uint8* data_;
53 59
54 // Bytes left in the stream. 60 // Bytes left in the stream.
55 int bytes_left_; 61 int bytes_left_;
56 62
57 BitReaderCore bit_reader_core_; 63 BitReaderCore bit_reader_core_;
58 64
59 DISALLOW_COPY_AND_ASSIGN(BitReader); 65 DISALLOW_COPY_AND_ASSIGN(BitReader);
60 }; 66 };
61 67
62 } // namespace media 68 } // namespace media
63 69
64 #endif // MEDIA_BASE_BIT_READER_H_ 70 #endif // MEDIA_BASE_BIT_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698