webrtc maintenance method 2 (RtcEventLog data capture and analysis)

1, Introduction

Webrtc provides a RtcEventLog interface for real-time data capture. Through this interface, RTP header data, audio and video configuration parameters, detection data of webrtc in and out of webrtc can be captured in real time. For details, refer to the RtcEventLogImpl class definition.

  void LogVideoReceiveStreamConfig(const rtclog::StreamConfig& config) override;
  void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override;
  void LogAudioReceiveStreamConfig(const rtclog::StreamConfig& config) override;
  void LogAudioSendStreamConfig(const rtclog::StreamConfig& config) override;
  void LogRtpHeader(PacketDirection direction,
                    const uint8_t* header,
                    size_t packet_length) override;
  void LogRtpHeader(PacketDirection direction,
                    const uint8_t* header,
                    size_t packet_length,
                    int probe_cluster_id) override;
  void LogRtcpPacket(PacketDirection direction,
                     const uint8_t* packet,
                     size_t length) override;
  void LogAudioPlayout(uint32_t ssrc) override;
  void LogLossBasedBweUpdate(int32_t bitrate_bps,
                             uint8_t fraction_loss,
                             int32_t total_packets) override;
  void LogDelayBasedBweUpdate(int32_t bitrate_bps,
                              BandwidthUsage detector_state) override;
  void LogAudioNetworkAdaptation(
      const AudioEncoderRuntimeConfig& 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;

2, Implementation

1. Data storage format

webrtc uses protobuf protocol to store these data. For the introduction of protobuf protocol, please refer to the Google official website link:

Protocol Buffers: https://developers.google.com/protocol-buffers

Therefore, in order to start RtcEventLog data capture, you need to turn on the RTC ﹣ enable ﹣ protobuf = true switch in the webrtc compilation option.

2. Code architecture

The RTC event log core code is concentrated in the webrtc \ logging \ RTC event log folder:

  • 1) Data storage interface and implementation document

             rtc_event_log.cc
             rtc_event_log.h
             rtc_event_log.proto
             rtc_event_log_factory.cc
             rtc_event_log_factory.h
             rtc_event_log_factory_interface.h




RTC event log.proto is the data storage format interface. We can add the private interface of this project in RTC event log.proto according to the needs of the project.

  • 2) Data analysis tool implementation file

             rtc_event_log2rtp_dump.cc
             rtc_event_log2stats.cc
             rtc_event_log2text.cc
             rtc_event_log_parser.cc
             rtc_event_log_parser.h



Maybe this is just an internal debugging tool of webrtc. After opening RTC  enable  protobuf = true RTC  include  tests = true, only one RTC  event  log2rtp  dump.exe file can be generated. The RTP header information in the captured data can be printed out.

To generate RTC ﹣ event ﹣ log2stats.exe/rtc ﹣ event ﹣ log2text, you need to modify the Makefile files at / src/webrtc/BUILD.gn and / src/webrtc/logging/BUILD.gn. And this function needs to be further optimized. At present, printing information is messy.

3, Tool use

Two tools are required to analyze the captured dump file:

1)rtc_event_log2rtp_dump.exe

The tool can extract the RTP data in the captured dump file, but the extracted data is still stored in protobuf. The command line is:

 

2)rtp_analyze.exe

The tool can print RTP data stored in protobuf format into text format. The command line is:

3) Analysis on the transformation from txt format to csv format

The text file generated by RTP ﹣ analyze tool is printed as follows, which contains some basic information of RTP message header. At this time, we can use the column mode of ultraedit or Notepad to convert the text file into a csv file for data analysis.

Keywords: Google Makefile

Added by miltonos on Sun, 26 Apr 2020 06:04:29 +0300