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