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 #include "media/cast/logging/log_deserializer.h" | 5 #include "media/cast/logging/log_deserializer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/big_endian.h" | 9 #include "base/big_endian.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 to->set_target_bitrate(from.target_bitrate()); | 65 to->set_target_bitrate(from.target_bitrate()); |
66 } | 66 } |
67 | 67 |
68 bool PopulateDeserializedLog(base::BigEndianReader* reader, | 68 bool PopulateDeserializedLog(base::BigEndianReader* reader, |
69 media::cast::DeserializedLog* log) { | 69 media::cast::DeserializedLog* log) { |
70 FrameEventMap frame_event_map; | 70 FrameEventMap frame_event_map; |
71 PacketEventMap packet_event_map; | 71 PacketEventMap packet_event_map; |
72 | 72 |
73 int num_frame_events = log->metadata.num_frame_events(); | 73 int num_frame_events = log->metadata.num_frame_events(); |
74 RtpTimestamp relative_rtp_timestamp = 0; | 74 RtpTimestamp relative_rtp_timestamp = 0; |
75 uint16 proto_size = 0; | 75 uint16_t proto_size = 0; |
76 for (int i = 0; i < num_frame_events; i++) { | 76 for (int i = 0; i < num_frame_events; i++) { |
77 if (!reader->ReadU16(&proto_size)) | 77 if (!reader->ReadU16(&proto_size)) |
78 return false; | 78 return false; |
79 | 79 |
80 linked_ptr<AggregatedFrameEvent> frame_event(new AggregatedFrameEvent); | 80 linked_ptr<AggregatedFrameEvent> frame_event(new AggregatedFrameEvent); |
81 if (!frame_event->ParseFromArray(reader->ptr(), proto_size)) | 81 if (!frame_event->ParseFromArray(reader->ptr(), proto_size)) |
82 return false; | 82 return false; |
83 if (!reader->Skip(proto_size)) | 83 if (!reader->Skip(proto_size)) |
84 return false; | 84 return false; |
85 | 85 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 bool DoDeserializeEvents(const char* data, | 140 bool DoDeserializeEvents(const char* data, |
141 int data_bytes, | 141 int data_bytes, |
142 media::cast::DeserializedLog* audio_log, | 142 media::cast::DeserializedLog* audio_log, |
143 media::cast::DeserializedLog* video_log) { | 143 media::cast::DeserializedLog* video_log) { |
144 bool got_audio = false; | 144 bool got_audio = false; |
145 bool got_video = false; | 145 bool got_video = false; |
146 base::BigEndianReader reader(data, data_bytes); | 146 base::BigEndianReader reader(data, data_bytes); |
147 | 147 |
148 LogMetadata metadata; | 148 LogMetadata metadata; |
149 uint16 proto_size = 0; | 149 uint16_t proto_size = 0; |
150 while (reader.remaining() > 0) { | 150 while (reader.remaining() > 0) { |
151 if (!reader.ReadU16(&proto_size)) | 151 if (!reader.ReadU16(&proto_size)) |
152 return false; | 152 return false; |
153 if (!metadata.ParseFromArray(reader.ptr(), proto_size)) | 153 if (!metadata.ParseFromArray(reader.ptr(), proto_size)) |
154 return false; | 154 return false; |
155 reader.Skip(proto_size); | 155 reader.Skip(proto_size); |
156 | 156 |
157 if (metadata.is_audio()) { | 157 if (metadata.is_audio()) { |
158 if (got_audio) { | 158 if (got_audio) { |
159 VLOG(1) << "Got audio data twice."; | 159 VLOG(1) << "Got audio data twice."; |
(...skipping 19 matching lines...) Expand all Loading... |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
182 bool Uncompress(const char* data, | 182 bool Uncompress(const char* data, |
183 int data_bytes, | 183 int data_bytes, |
184 int max_uncompressed_bytes, | 184 int max_uncompressed_bytes, |
185 char* uncompressed, | 185 char* uncompressed, |
186 int* uncompressed_bytes) { | 186 int* uncompressed_bytes) { |
187 z_stream stream = {0}; | 187 z_stream stream = {0}; |
188 | 188 |
189 stream.next_in = reinterpret_cast<uint8*>(const_cast<char*>(data)); | 189 stream.next_in = reinterpret_cast<uint8_t*>(const_cast<char*>(data)); |
190 stream.avail_in = data_bytes; | 190 stream.avail_in = data_bytes; |
191 stream.next_out = reinterpret_cast<uint8*>(uncompressed); | 191 stream.next_out = reinterpret_cast<uint8_t*>(uncompressed); |
192 stream.avail_out = max_uncompressed_bytes; | 192 stream.avail_out = max_uncompressed_bytes; |
193 | 193 |
194 bool success = false; | 194 bool success = false; |
195 while (stream.avail_in > 0 && stream.avail_out > 0) { | 195 while (stream.avail_in > 0 && stream.avail_out > 0) { |
196 // 16 is added to read in gzip format. | 196 // 16 is added to read in gzip format. |
197 int result = inflateInit2(&stream, MAX_WBITS + 16); | 197 int result = inflateInit2(&stream, MAX_WBITS + 16); |
198 DCHECK_EQ(Z_OK, result); | 198 DCHECK_EQ(Z_OK, result); |
199 | 199 |
200 result = inflate(&stream, Z_FINISH); | 200 result = inflate(&stream, Z_FINISH); |
201 success = (result == Z_STREAM_END); | 201 success = (result == Z_STREAM_END); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } else { | 242 } else { |
243 return DoDeserializeEvents(data, data_bytes, audio_log, video_log); | 243 return DoDeserializeEvents(data, data_bytes, audio_log, video_log); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 DeserializedLog::DeserializedLog() {} | 247 DeserializedLog::DeserializedLog() {} |
248 DeserializedLog::~DeserializedLog() {} | 248 DeserializedLog::~DeserializedLog() {} |
249 | 249 |
250 } // namespace cast | 250 } // namespace cast |
251 } // namespace media | 251 } // namespace media |
OLD | NEW |