OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // The serialization format is as follows: | 5 // The serialization format is as follows: |
6 // 16-bit integer describing the following LogMetadata proto size in bytes. | 6 // 16-bit integer describing the following LogMetadata proto size in bytes. |
7 // The LogMetadata proto. | 7 // The LogMetadata proto. |
8 // 32-bit integer describing number of frame events. | 8 // 32-bit integer describing number of frame events. |
9 // (The following repeated for number of frame events): | 9 // (The following repeated for number of frame events): |
10 // 16-bit integer describing the following AggregatedFrameEvent proto size | 10 // 16-bit integer describing the following AggregatedFrameEvent proto size |
11 // in bytes. | 11 // in bytes. |
12 // The AggregatedFrameEvent proto. | 12 // The AggregatedFrameEvent proto. |
13 // 32-bit integer describing number of packet events. | 13 // 32-bit integer describing number of packet events. |
14 // (The following repeated for number of packet events): | 14 // (The following repeated for number of packet events): |
15 // 16-bit integer describing the following AggregatedPacketEvent proto | 15 // 16-bit integer describing the following AggregatedPacketEvent proto |
16 // size in bytes. | 16 // size in bytes. |
17 // The AggregatedPacketEvent proto. | 17 // The AggregatedPacketEvent proto. |
18 | 18 |
19 #include "media/cast/logging/log_serializer.h" | 19 #include "media/cast/logging/log_serializer.h" |
20 | 20 |
21 #include <stdint.h> | 21 #include <stdint.h> |
22 | 22 |
| 23 #include <memory> |
| 24 |
23 #include "base/big_endian.h" | 25 #include "base/big_endian.h" |
24 #include "base/logging.h" | 26 #include "base/logging.h" |
25 #include "base/memory/scoped_ptr.h" | |
26 #include "third_party/zlib/zlib.h" | 27 #include "third_party/zlib/zlib.h" |
27 | 28 |
28 namespace media { | 29 namespace media { |
29 namespace cast { | 30 namespace cast { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 using media::cast::proto::AggregatedFrameEvent; | 34 using media::cast::proto::AggregatedFrameEvent; |
34 using media::cast::proto::AggregatedPacketEvent; | 35 using media::cast::proto::AggregatedPacketEvent; |
35 using media::cast::proto::LogMetadata; | 36 using media::cast::proto::LogMetadata; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 bool compress, | 158 bool compress, |
158 int max_output_bytes, | 159 int max_output_bytes, |
159 char* output, | 160 char* output, |
160 int* output_bytes) { | 161 int* output_bytes) { |
161 DCHECK_GT(max_output_bytes, 0); | 162 DCHECK_GT(max_output_bytes, 0); |
162 DCHECK(output); | 163 DCHECK(output); |
163 DCHECK(output_bytes); | 164 DCHECK(output_bytes); |
164 | 165 |
165 if (compress) { | 166 if (compress) { |
166 // Allocate a reasonably large temp buffer to hold uncompressed data. | 167 // Allocate a reasonably large temp buffer to hold uncompressed data. |
167 scoped_ptr<char[]> uncompressed_buffer(new char[kMaxUncompressedBytes]); | 168 std::unique_ptr<char[]> uncompressed_buffer( |
| 169 new char[kMaxUncompressedBytes]); |
168 int uncompressed_bytes; | 170 int uncompressed_bytes; |
169 bool success = DoSerializeEvents(log_metadata, | 171 bool success = DoSerializeEvents(log_metadata, |
170 frame_events, | 172 frame_events, |
171 packet_events, | 173 packet_events, |
172 kMaxUncompressedBytes, | 174 kMaxUncompressedBytes, |
173 uncompressed_buffer.get(), | 175 uncompressed_buffer.get(), |
174 &uncompressed_bytes); | 176 &uncompressed_bytes); |
175 if (!success) | 177 if (!success) |
176 return false; | 178 return false; |
177 return Compress(uncompressed_buffer.get(), | 179 return Compress(uncompressed_buffer.get(), |
178 uncompressed_bytes, | 180 uncompressed_bytes, |
179 max_output_bytes, | 181 max_output_bytes, |
180 output, | 182 output, |
181 output_bytes); | 183 output_bytes); |
182 } else { | 184 } else { |
183 return DoSerializeEvents(log_metadata, | 185 return DoSerializeEvents(log_metadata, |
184 frame_events, | 186 frame_events, |
185 packet_events, | 187 packet_events, |
186 max_output_bytes, | 188 max_output_bytes, |
187 output, | 189 output, |
188 output_bytes); | 190 output_bytes); |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 } // namespace cast | 194 } // namespace cast |
193 } // namespace media | 195 } // namespace media |
OLD | NEW |