OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // CompoundBuffer implements a data buffer that is composed of several pieces, | 5 // CompoundBuffer implements a data buffer that is composed of several pieces, |
6 // each stored in a refcounted IOBuffer. It is needed for encoding/decoding | 6 // each stored in a refcounted IOBuffer. It is needed for encoding/decoding |
7 // video pipeline to represent data packet and minimize data copying. | 7 // video pipeline to represent data packet and minimize data copying. |
8 // It is particularly useful for splitting data between multiple RTP packets | 8 // It is particularly useful for splitting data between multiple RTP packets |
9 // and assembling them into one buffer on the receiving side. | 9 // and assembling them into one buffer on the receiving side. |
10 // | 10 // |
11 // CompoundBufferInputStream implements ZeroCopyInputStream interface | 11 // CompoundBufferInputStream implements ZeroCopyInputStream interface |
12 // to be used by protobuf to decode data stored in CompoundBuffer into | 12 // to be used by protobuf to decode data stored in CompoundBuffer into |
13 // a protocol buffer message. | 13 // a protocol buffer message. |
14 // | 14 // |
15 // Mutations to the buffer are not thread-safe. Immutability can be ensured | 15 // Mutations to the buffer are not thread-safe. Immutability can be ensured |
16 // with the Lock() method. | 16 // with the Lock() method. |
17 | 17 |
18 #ifndef REMOTING_BASE_COMPOUND_BUFFER_H_ | 18 #ifndef REMOTING_BASE_COMPOUND_BUFFER_H_ |
19 #define REMOTING_BASE_COMPOUND_BUFFER_H_ | 19 #define REMOTING_BASE_COMPOUND_BUFFER_H_ |
20 | 20 |
| 21 #include <stddef.h> |
| 22 #include <stdint.h> |
| 23 |
21 #include <deque> | 24 #include <deque> |
22 | 25 |
23 #include "base/basictypes.h" | 26 #include "base/macros.h" |
24 #include "base/memory/ref_counted.h" | 27 #include "base/memory/ref_counted.h" |
25 #include "google/protobuf/io/zero_copy_stream.h" | 28 #include "google/protobuf/io/zero_copy_stream.h" |
26 | 29 |
27 namespace net { | 30 namespace net { |
28 class IOBuffer; | 31 class IOBuffer; |
29 class IOBufferWithSize; | 32 class IOBufferWithSize; |
30 } // namespace net | 33 } // namespace net |
31 | 34 |
32 namespace remoting { | 35 namespace remoting { |
33 | 36 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Caller keeps ownership of |buffer|. |buffer| must be locked. | 107 // Caller keeps ownership of |buffer|. |buffer| must be locked. |
105 explicit CompoundBufferInputStream(const CompoundBuffer* buffer); | 108 explicit CompoundBufferInputStream(const CompoundBuffer* buffer); |
106 ~CompoundBufferInputStream() override; | 109 ~CompoundBufferInputStream() override; |
107 | 110 |
108 int position() const { return position_; } | 111 int position() const { return position_; } |
109 | 112 |
110 // google::protobuf::io::ZeroCopyInputStream interface. | 113 // google::protobuf::io::ZeroCopyInputStream interface. |
111 bool Next(const void** data, int* size) override; | 114 bool Next(const void** data, int* size) override; |
112 void BackUp(int count) override; | 115 void BackUp(int count) override; |
113 bool Skip(int count) override; | 116 bool Skip(int count) override; |
114 int64 ByteCount() const override; | 117 int64_t ByteCount() const override; |
115 | 118 |
116 private: | 119 private: |
117 const CompoundBuffer* buffer_; | 120 const CompoundBuffer* buffer_; |
118 | 121 |
119 size_t current_chunk_; | 122 size_t current_chunk_; |
120 int current_chunk_position_; | 123 int current_chunk_position_; |
121 int position_; | 124 int position_; |
122 int last_returned_size_; | 125 int last_returned_size_; |
123 }; | 126 }; |
124 | 127 |
125 } // namespace remoting | 128 } // namespace remoting |
126 | 129 |
127 #endif // REMOTING_BASE_COMPOUND_BUFFER_H_ | 130 #endif // REMOTING_BASE_COMPOUND_BUFFER_H_ |
OLD | NEW |