Chromium Code Reviews| Index: webrtc/logging/rtc_event_log/rtc_event_log.cc |
| diff --git a/webrtc/logging/rtc_event_log/rtc_event_log.cc b/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| index b545d6453d7197f34341a61b1c5ca3a6a1dd8600..3fa9f4f0ebb698f77c7bd9b5970b6b29c47b28a6 100644 |
| --- a/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| +++ b/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| @@ -69,6 +69,11 @@ class RtcEventLogImpl final : public RtcEventLog { |
| MediaType media_type, |
| const uint8_t* header, |
| size_t packet_length) override; |
| + void LogRtpHeader(PacketDirection direction, |
|
terelius
2017/02/01 13:38:19
Assuming we always log outgoing packets by calling
philipel
2017/02/17 15:15:02
We could do that, but we will still log outgoing p
terelius
2017/02/17 15:50:43
As far as I can tell, all outgoing packets will ha
philipel
2017/02/20 09:46:47
If we want to do this change I think we should do
|
| + MediaType media_type, |
| + const uint8_t* header, |
| + size_t packet_length, |
| + int probe_cluster_id) override; |
| void LogRtcpPacket(PacketDirection direction, |
| MediaType media_type, |
| const uint8_t* packet, |
| @@ -79,9 +84,19 @@ class RtcEventLogImpl final : public RtcEventLog { |
| int32_t total_packets) override; |
| void LogAudioNetworkAdaptation( |
| const AudioNetworkAdaptor::EncoderRuntimeConfig& config) override; |
| + void LogProbeClusterCreated(int id, |
| + int bitrate_bps, |
| + int min_probes, |
| + int min_bytes) override; |
| + void LogProbeResultSuccess(int id, int bitrate_bps) override; |
| + void LogProbeResultFailure(int id, |
| + ProbeFailureReason failure_reason) override; |
| private: |
| void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
| + void LogProbeResult(int id, |
| + rtclog::BweProbeResult::ResultType result, |
| + int bitrate_bps); |
| // Message queue for passing control messages to the logging thread. |
| SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
| @@ -338,6 +353,15 @@ void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
| MediaType media_type, |
| const uint8_t* header, |
| size_t packet_length) { |
| + LogRtpHeader(direction, media_type, header, packet_length, |
| + PacketInfo::kNotAProbe); |
| +} |
| + |
| +void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
| + MediaType media_type, |
| + const uint8_t* header, |
| + size_t packet_length, |
| + int probe_cluster_id) { |
| // Read header length (in bytes) from packet data. |
| if (packet_length < 12u) { |
| return; // Don't read outside the packet. |
| @@ -361,6 +385,8 @@ void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
| rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
| rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
| rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
| + if (probe_cluster_id != PacketInfo::kNotAProbe) |
| + rtp_event->mutable_rtp_packet()->set_probe_cluster_id(probe_cluster_id); |
| StoreEvent(&rtp_event); |
| } |
| @@ -459,6 +485,58 @@ void RtcEventLogImpl::LogAudioNetworkAdaptation( |
| StoreEvent(&event); |
| } |
| +void RtcEventLogImpl::LogProbeClusterCreated(int id, |
|
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
|
| + int bitrate_bps, |
| + int min_probes, |
| + int min_bytes) { |
| + std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| + event->set_type(rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT); |
| + |
| + auto probe_cluster = event->mutable_probe_cluster(); |
| + probe_cluster->set_id(id); |
| + probe_cluster->set_bitrate_bps(bitrate_bps); |
| + probe_cluster->set_min_probes(min_probes); |
| + probe_cluster->set_min_bytes(min_bytes); |
| + StoreEvent(&event); |
| +} |
| + |
| +void RtcEventLogImpl::LogProbeResultSuccess(int id, int bitrate_bps) { |
|
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
|
| + LogProbeResult(id, rtclog::BweProbeResult::SUCCESS, bitrate_bps); |
| +} |
| + |
| +void RtcEventLogImpl::LogProbeResultFailure(int id, |
|
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
|
| + ProbeFailureReason failure_reason) { |
| + rtclog::BweProbeResult::ResultType result; |
| + switch (failure_reason) { |
| + case kInvalidSendReceiveInterval: |
| + result = rtclog::BweProbeResult::INVALID_SEND_RECEIVE_INTERVAL; |
| + break; |
| + case kInvalidSendReceiveRatio: |
| + result = rtclog::BweProbeResult::INVALID_SEND_RECEIVE_RATIO; |
| + break; |
| + case kTimeout: |
| + result = rtclog::BweProbeResult::TIMEOUT; |
| + break; |
| + } |
| + LogProbeResult(id, result, -1); |
| +} |
| + |
| +void RtcEventLogImpl::LogProbeResult(int id, |
| + rtclog::BweProbeResult::ResultType result, |
| + int bitrate_bps) { |
| + std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| + event->set_type(rtclog::Event::BWE_PROBE_RESULT_EVENT); |
| + |
| + auto probe_result = event->mutable_probe_result(); |
| + probe_result->set_id(id); |
| + probe_result->set_result(result); |
| + if (result == rtclog::BweProbeResult::SUCCESS) |
| + probe_result->set_bitrate_bps(bitrate_bps); |
| + StoreEvent(&event); |
| +} |
| + |
| void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { |
| if (!event_queue_.Insert(event)) { |
| LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; |