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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 int proto_size = metadata.ByteSize(); | 48 int proto_size = metadata.ByteSize(); |
49 DCHECK(proto_size <= kMaxSerializedProtoBytes); | 49 DCHECK(proto_size <= kMaxSerializedProtoBytes); |
50 if (!writer.WriteU16(static_cast<uint16>(proto_size))) | 50 if (!writer.WriteU16(static_cast<uint16>(proto_size))) |
51 return false; | 51 return false; |
52 if (!metadata.SerializeToArray(writer.ptr(), writer.remaining())) | 52 if (!metadata.SerializeToArray(writer.ptr(), writer.remaining())) |
53 return false; | 53 return false; |
54 if (!writer.Skip(proto_size)) | 54 if (!writer.Skip(proto_size)) |
55 return false; | 55 return false; |
56 | 56 |
57 RtpTimestamp prev_rtp_timestamp = 0; | 57 RtpTimeTicks prev_rtp_timestamp; |
58 for (media::cast::FrameEventList::const_iterator it = frame_events.begin(); | 58 for (media::cast::FrameEventList::const_iterator it = frame_events.begin(); |
59 it != frame_events.end(); | 59 it != frame_events.end(); |
60 ++it) { | 60 ++it) { |
61 media::cast::proto::AggregatedFrameEvent frame_event(**it); | 61 media::cast::proto::AggregatedFrameEvent frame_event(**it); |
62 | 62 |
63 // Adjust relative RTP timestamp so that it is relative to previous frame, | 63 // Adjust relative RTP timestamp so that it is relative to previous frame, |
64 // rather than relative to first RTP timestamp. | 64 // rather than relative to first RTP timestamp. |
65 // This is done to improve encoding size. | 65 // This is done to improve encoding size. |
66 RtpTimestamp old_relative_rtp_timestamp = | 66 const RtpTimeTicks rtp_timestamp = |
67 frame_event.relative_rtp_timestamp(); | 67 prev_rtp_timestamp.Expand(frame_event.relative_rtp_timestamp()); |
68 frame_event.set_relative_rtp_timestamp( | 68 frame_event.set_relative_rtp_timestamp( |
69 old_relative_rtp_timestamp - prev_rtp_timestamp); | 69 (rtp_timestamp - prev_rtp_timestamp).lower_32_bits()); |
70 prev_rtp_timestamp = old_relative_rtp_timestamp; | 70 prev_rtp_timestamp = rtp_timestamp; |
71 | 71 |
72 proto_size = frame_event.ByteSize(); | 72 proto_size = frame_event.ByteSize(); |
73 DCHECK(proto_size <= kMaxSerializedProtoBytes); | 73 DCHECK(proto_size <= kMaxSerializedProtoBytes); |
74 | 74 |
75 // Write size of the proto, then write the proto. | 75 // Write size of the proto, then write the proto. |
76 if (!writer.WriteU16(static_cast<uint16>(proto_size))) | 76 if (!writer.WriteU16(static_cast<uint16>(proto_size))) |
77 return false; | 77 return false; |
78 if (!frame_event.SerializeToArray(writer.ptr(), writer.remaining())) | 78 if (!frame_event.SerializeToArray(writer.ptr(), writer.remaining())) |
79 return false; | 79 return false; |
80 if (!writer.Skip(proto_size)) | 80 if (!writer.Skip(proto_size)) |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 // Write packet events. | 84 // Write packet events. |
85 prev_rtp_timestamp = 0; | 85 prev_rtp_timestamp = RtpTimeTicks(); |
86 for (media::cast::PacketEventList::const_iterator it = packet_events.begin(); | 86 for (media::cast::PacketEventList::const_iterator it = packet_events.begin(); |
87 it != packet_events.end(); | 87 it != packet_events.end(); |
88 ++it) { | 88 ++it) { |
89 media::cast::proto::AggregatedPacketEvent packet_event(**it); | 89 media::cast::proto::AggregatedPacketEvent packet_event(**it); |
90 RtpTimestamp old_relative_rtp_timestamp = | 90 |
91 packet_event.relative_rtp_timestamp(); | 91 const RtpTimeTicks rtp_timestamp = |
| 92 prev_rtp_timestamp.Expand(packet_event.relative_rtp_timestamp()); |
92 packet_event.set_relative_rtp_timestamp( | 93 packet_event.set_relative_rtp_timestamp( |
93 old_relative_rtp_timestamp - prev_rtp_timestamp); | 94 (rtp_timestamp - prev_rtp_timestamp).lower_32_bits()); |
94 prev_rtp_timestamp = old_relative_rtp_timestamp; | 95 prev_rtp_timestamp = rtp_timestamp; |
95 | 96 |
96 proto_size = packet_event.ByteSize(); | 97 proto_size = packet_event.ByteSize(); |
97 DCHECK(proto_size <= kMaxSerializedProtoBytes); | 98 DCHECK(proto_size <= kMaxSerializedProtoBytes); |
98 | 99 |
99 // Write size of the proto, then write the proto. | 100 // Write size of the proto, then write the proto. |
100 if (!writer.WriteU16(static_cast<uint16>(proto_size))) | 101 if (!writer.WriteU16(static_cast<uint16>(proto_size))) |
101 return false; | 102 return false; |
102 if (!packet_event.SerializeToArray(writer.ptr(), writer.remaining())) | 103 if (!packet_event.SerializeToArray(writer.ptr(), writer.remaining())) |
103 return false; | 104 return false; |
104 if (!writer.Skip(proto_size)) | 105 if (!writer.Skip(proto_size)) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 frame_events, | 182 frame_events, |
182 packet_events, | 183 packet_events, |
183 max_output_bytes, | 184 max_output_bytes, |
184 output, | 185 output, |
185 output_bytes); | 186 output_bytes); |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 } // namespace cast | 190 } // namespace cast |
190 } // namespace media | 191 } // namespace media |
OLD | NEW |