| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/big_endian.h" | 5 #include "base/big_endian.h" |
| 6 #include "base/debug/trace_event.h" | 6 #include "base/debug/trace_event.h" |
| 7 #include "media/cast/logging/logging_impl.h" | 7 #include "media/cast/logging/logging_impl.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 namespace cast { | 10 namespace cast { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 if (config_.enable_tracing) { | 74 if (config_.enable_tracing) { |
| 75 std::string event_string = CastLoggingToString(event); | 75 std::string event_string = CastLoggingToString(event); |
| 76 TRACE_EVENT_INSTANT2(event_string.c_str(), "FED", TRACE_EVENT_SCOPE_THREAD, | 76 TRACE_EVENT_INSTANT2(event_string.c_str(), "FED", TRACE_EVENT_SCOPE_THREAD, |
| 77 "rtp_timestamp", rtp_timestamp, "delay", | 77 "rtp_timestamp", rtp_timestamp, "delay", |
| 78 delay.InMilliseconds()); | 78 delay.InMilliseconds()); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, |
| 83 CastLoggingEvent event, |
| 84 const Packet& packet) { |
| 85 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 86 |
| 87 // Parse basic properties. |
| 88 uint32 rtp_timestamp; |
| 89 uint16 packet_id, max_packet_id; |
| 90 const uint8* packet_data = &packet[0]; |
| 91 base::BigEndianReader big_endian_reader( |
| 92 reinterpret_cast<const char*>(packet_data + 4), 4); |
| 93 big_endian_reader.ReadU32(&rtp_timestamp); |
| 94 base::BigEndianReader cast_big_endian_reader( |
| 95 reinterpret_cast<const char*>(packet_data + 12 + 2), 4); |
| 96 cast_big_endian_reader.ReadU16(&packet_id); |
| 97 cast_big_endian_reader.ReadU16(&max_packet_id); |
| 98 |
| 99 // rtp_timestamp is enough - no need for frame_id as well. |
| 100 InsertPacketEvent(time_of_event, |
| 101 event, |
| 102 rtp_timestamp, |
| 103 kFrameIdUnknown, |
| 104 packet_id, |
| 105 max_packet_id, |
| 106 packet.size()); |
| 107 } |
| 108 |
| 82 void LoggingImpl::InsertPacketListEvent(const base::TimeTicks& time_of_event, | 109 void LoggingImpl::InsertPacketListEvent(const base::TimeTicks& time_of_event, |
| 83 CastLoggingEvent event, | 110 CastLoggingEvent event, |
| 84 const PacketList& packets) { | 111 const PacketList& packets) { |
| 85 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); | 112 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 86 for (unsigned int i = 0; i < packets.size(); ++i) { | 113 for (PacketList::const_iterator it = packets.begin(); it != packets.end(); |
| 87 const Packet& packet = packets[i]; | 114 ++it) { |
| 88 // Parse basic properties. | 115 InsertSinglePacketEvent(time_of_event, event, *it); |
| 89 uint32 rtp_timestamp; | |
| 90 uint16 packet_id, max_packet_id; | |
| 91 const uint8* packet_data = &packet[0]; | |
| 92 base::BigEndianReader big_endian_reader( | |
| 93 reinterpret_cast<const char*>(packet_data + 4), 4); | |
| 94 big_endian_reader.ReadU32(&rtp_timestamp); | |
| 95 base::BigEndianReader cast_big_endian_reader( | |
| 96 reinterpret_cast<const char*>(packet_data + 12 + 2), 4); | |
| 97 cast_big_endian_reader.ReadU16(&packet_id); | |
| 98 cast_big_endian_reader.ReadU16(&max_packet_id); | |
| 99 // rtp_timestamp is enough - no need for frame_id as well. | |
| 100 InsertPacketEvent(time_of_event, event, rtp_timestamp, kFrameIdUnknown, | |
| 101 packet_id, max_packet_id, packet.size()); | |
| 102 } | 116 } |
| 103 } | 117 } |
| 104 | 118 |
| 105 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event, | 119 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event, |
| 106 CastLoggingEvent event, | 120 CastLoggingEvent event, |
| 107 uint32 rtp_timestamp, uint32 frame_id, | 121 uint32 rtp_timestamp, uint32 frame_id, |
| 108 uint16 packet_id, uint16 max_packet_id, | 122 uint16 packet_id, uint16 max_packet_id, |
| 109 size_t size) { | 123 size_t size) { |
| 110 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); | 124 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 111 if (config_.enable_raw_data_collection) { | 125 if (config_.enable_raw_data_collection) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return stats_.GetGenericStatsData(); | 178 return stats_.GetGenericStatsData(); |
| 165 } | 179 } |
| 166 | 180 |
| 167 void LoggingImpl::ResetStats() { | 181 void LoggingImpl::ResetStats() { |
| 168 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); | 182 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 169 stats_.Reset(); | 183 stats_.Reset(); |
| 170 } | 184 } |
| 171 | 185 |
| 172 } // namespace cast | 186 } // namespace cast |
| 173 } // namespace media | 187 } // namespace media |
| OLD | NEW |