diff options
author | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:21:08 +0000 |
---|---|---|
committer | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:21:08 +0000 |
commit | b804aac1153d19105dd7ac6c6f01b66a914d2c4a (patch) | |
tree | 41e1f9ec26c11176570fe5b3cdb8a39842f6478c /media/cast | |
parent | c6b10ca14c14338c60e19412aa04be5bcde11a89 (diff) | |
download | chromium_src-b804aac1153d19105dd7ac6c6f01b66a914d2c4a.zip chromium_src-b804aac1153d19105dd7ac6c6f01b66a914d2c4a.tar.gz chromium_src-b804aac1153d19105dd7ac6c6f01b66a914d2c4a.tar.bz2 |
Cast: Use difference encoding on RTP timestamps for serializing events
Previously during serialization of raw event logs we write out RTP
timestamp of each frame as a relative value to the first RTP timestamp
seen. This number can get large for later frames. This patch changes
the serialization logic so it writes out the RTP timestamp of each
frame as a relative value to the previous frame. This results in smaller
values being written out for each frame, which results in a smaller
serialization length due to variable length encoding.
The result of this change is that serialized length with compression is
now 19% shorter. (86.5kb vs 70kb for 30 seconds of data)
Test: SerializeDeserializeTest still passes
BUG=338574,301920
Review URL: https://codereview.chromium.org/195943011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast')
-rw-r--r-- | media/cast/logging/log_deserializer.cc | 14 | ||||
-rw-r--r-- | media/cast/logging/log_serializer.cc | 24 |
2 files changed, 33 insertions, 5 deletions
diff --git a/media/cast/logging/log_deserializer.cc b/media/cast/logging/log_deserializer.cc index 49ec2f0..dc1d78d 100644 --- a/media/cast/logging/log_deserializer.cc +++ b/media/cast/logging/log_deserializer.cc @@ -40,7 +40,7 @@ bool DoDeserializeEvents(char* data, PacketEventMap packet_event_map; int num_frame_events = metadata->num_frame_events(); - + RtpTimestamp relative_rtp_timestamp = 0; for (int i = 0; i < num_frame_events; i++) { if (!reader.ReadU16(&proto_size)) return false; @@ -51,6 +51,13 @@ bool DoDeserializeEvents(char* data, if (!reader.Skip(proto_size)) return false; + // During serialization the RTP timestamp in proto is relative to previous + // frame. + // Adjust RTP timestamp back to value relative to first RTP timestamp. + frame_event->set_relative_rtp_timestamp( + frame_event->relative_rtp_timestamp() + relative_rtp_timestamp); + relative_rtp_timestamp = frame_event->relative_rtp_timestamp(); + std::pair<FrameEventMap::iterator, bool> result = frame_event_map.insert( std::make_pair(frame_event->relative_rtp_timestamp(), frame_event)); if (!result.second) { @@ -63,6 +70,7 @@ bool DoDeserializeEvents(char* data, frame_events->swap(frame_event_map); int num_packet_events = metadata->num_packet_events(); + relative_rtp_timestamp = 0; for (int i = 0; i < num_packet_events; i++) { if (!reader.ReadU16(&proto_size)) return false; @@ -73,6 +81,10 @@ bool DoDeserializeEvents(char* data, if (!reader.Skip(proto_size)) return false; + packet_event->set_relative_rtp_timestamp( + packet_event->relative_rtp_timestamp() + relative_rtp_timestamp); + relative_rtp_timestamp = packet_event->relative_rtp_timestamp(); + std::pair<PacketEventMap::iterator, bool> result = packet_event_map.insert( std::make_pair(packet_event->relative_rtp_timestamp(), packet_event)); if (!result.second) { diff --git a/media/cast/logging/log_serializer.cc b/media/cast/logging/log_serializer.cc index ddf5496..3452c90 100644 --- a/media/cast/logging/log_serializer.cc +++ b/media/cast/logging/log_serializer.cc @@ -49,30 +49,46 @@ bool DoSerializeEvents(const LogMetadata& metadata, if (!writer.Skip(proto_size)) return false; + RtpTimestamp prev_rtp_timestamp = 0; for (media::cast::FrameEventMap::const_iterator it = frame_events.begin(); it != frame_events.end(); ++it) { - proto_size = it->second->ByteSize(); + media::cast::proto::AggregatedFrameEvent frame_event(*(it->second)); + + // Adjust relative RTP timestamp so that it is relative to previous frame, + // rather than relative to first RTP timestamp. + // This is done to improve encoding size. + frame_event.set_relative_rtp_timestamp( + frame_event.relative_rtp_timestamp() - prev_rtp_timestamp); + prev_rtp_timestamp = it->first; + + proto_size = frame_event.ByteSize(); // Write size of the proto, then write the proto. if (!writer.WriteU16(proto_size)) return false; - if (!it->second->SerializeToArray(writer.ptr(), writer.remaining())) + if (!frame_event.SerializeToArray(writer.ptr(), writer.remaining())) return false; if (!writer.Skip(proto_size)) return false; } // Write packet events. + prev_rtp_timestamp = 0; for (media::cast::PacketEventMap::const_iterator it = packet_events.begin(); it != packet_events.end(); ++it) { - proto_size = it->second->ByteSize(); + media::cast::proto::AggregatedPacketEvent packet_event(*(it->second)); + packet_event.set_relative_rtp_timestamp( + packet_event.relative_rtp_timestamp() - prev_rtp_timestamp); + prev_rtp_timestamp = it->first; + + proto_size = packet_event.ByteSize(); // Write size of the proto, then write the proto. if (!writer.WriteU16(proto_size)) return false; - if (!it->second->SerializeToArray(writer.ptr(), writer.remaining())) + if (!packet_event.SerializeToArray(writer.ptr(), writer.remaining())) return false; if (!writer.Skip(proto_size)) return false; |