LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/logging/rtc_event_log - rtc_event_log.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 21 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
      12             : #define WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
      13             : 
      14             : #include <memory>
      15             : #include <string>
      16             : 
      17             : #include "webrtc/base/platform_file.h"
      18             : #include "webrtc/call/audio_receive_stream.h"
      19             : #include "webrtc/call/audio_send_stream.h"
      20             : #include "webrtc/video_receive_stream.h"
      21             : #include "webrtc/video_send_stream.h"
      22             : 
      23             : namespace webrtc {
      24             : 
      25             : // Forward declaration of storage class that is automatically generated from
      26             : // the protobuf file.
      27             : namespace rtclog {
      28             : class EventStream;
      29             : }  // namespace rtclog
      30             : 
      31             : class Clock;
      32             : class RtcEventLogImpl;
      33             : 
      34             : enum class MediaType;
      35             : 
      36             : enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
      37             : 
      38           0 : class RtcEventLog {
      39             :  public:
      40           0 :   virtual ~RtcEventLog() {}
      41             : 
      42             :   // Factory method to create an RtcEventLog object.
      43             :   static std::unique_ptr<RtcEventLog> Create();
      44             :   // TODO(nisse): webrtc::Clock is deprecated. Delete this method and
      45             :   // above forward declaration of Clock when
      46             :   // webrtc/system_wrappers/include/clock.h is deleted.
      47             :   static std::unique_ptr<RtcEventLog> Create(const Clock* clock) {
      48             :     return Create();
      49             :   }
      50             : 
      51             :   // Create an RtcEventLog object that does nothing.
      52             :   static std::unique_ptr<RtcEventLog> CreateNull();
      53             : 
      54             :   // Starts logging a maximum of max_size_bytes bytes to the specified file.
      55             :   // If the file already exists it will be overwritten.
      56             :   // If max_size_bytes <= 0, logging will be active until StopLogging is called.
      57             :   // The function has no effect and returns false if we can't start a new log
      58             :   // e.g. because we are already logging or the file cannot be opened.
      59             :   virtual bool StartLogging(const std::string& file_name,
      60             :                             int64_t max_size_bytes) = 0;
      61             : 
      62             :   // Same as above. The RtcEventLog takes ownership of the file if the call
      63             :   // is successful, i.e. if it returns true.
      64             :   virtual bool StartLogging(rtc::PlatformFile platform_file,
      65             :                             int64_t max_size_bytes) = 0;
      66             : 
      67             :   // Deprecated. Pass an explicit file size limit.
      68             :   bool StartLogging(const std::string& file_name) {
      69             :     return StartLogging(file_name, 10000000);
      70             :   }
      71             : 
      72             :   // Deprecated. Pass an explicit file size limit.
      73             :   bool StartLogging(rtc::PlatformFile platform_file) {
      74             :     return StartLogging(platform_file, 10000000);
      75             :   }
      76             : 
      77             :   // Stops logging to file and waits until the thread has finished.
      78             :   virtual void StopLogging() = 0;
      79             : 
      80             :   // Logs configuration information for webrtc::VideoReceiveStream.
      81             :   virtual void LogVideoReceiveStreamConfig(
      82             :       const webrtc::VideoReceiveStream::Config& config) = 0;
      83             : 
      84             :   // Logs configuration information for webrtc::VideoSendStream.
      85             :   virtual void LogVideoSendStreamConfig(
      86             :       const webrtc::VideoSendStream::Config& config) = 0;
      87             : 
      88             :   // Logs configuration information for webrtc::AudioReceiveStream.
      89             :   virtual void LogAudioReceiveStreamConfig(
      90             :       const webrtc::AudioReceiveStream::Config& config) = 0;
      91             : 
      92             :   // Logs configuration information for webrtc::AudioSendStream.
      93             :   virtual void LogAudioSendStreamConfig(
      94             :       const webrtc::AudioSendStream::Config& config) = 0;
      95             : 
      96             :   // Logs the header of an incoming or outgoing RTP packet. packet_length
      97             :   // is the total length of the packet, including both header and payload.
      98             :   virtual void LogRtpHeader(PacketDirection direction,
      99             :                             MediaType media_type,
     100             :                             const uint8_t* header,
     101             :                             size_t packet_length) = 0;
     102             : 
     103             :   // Logs an incoming or outgoing RTCP packet.
     104             :   virtual void LogRtcpPacket(PacketDirection direction,
     105             :                              MediaType media_type,
     106             :                              const uint8_t* packet,
     107             :                              size_t length) = 0;
     108             : 
     109             :   // Logs an audio playout event.
     110             :   virtual void LogAudioPlayout(uint32_t ssrc) = 0;
     111             : 
     112             :   // Logs a bitrate update from the bandwidth estimator based on packet loss.
     113             :   virtual void LogBwePacketLossEvent(int32_t bitrate,
     114             :                                      uint8_t fraction_loss,
     115             :                                      int32_t total_packets) = 0;
     116             : 
     117             :   // Reads an RtcEventLog file and returns true when reading was successful.
     118             :   // The result is stored in the given EventStream object.
     119             :   // The order of the events in the EventStream is implementation defined.
     120             :   // The current implementation writes a LOG_START event, then the old
     121             :   // configurations, then the remaining events in timestamp order and finally
     122             :   // a LOG_END event. However, this might change without further notice.
     123             :   // TODO(terelius): Change result type to a vector?
     124             :   static bool ParseRtcEventLog(const std::string& file_name,
     125             :                                rtclog::EventStream* result);
     126             : };
     127             : 
     128             : // No-op implementation is used if flag is not set, or in tests.
     129           0 : class RtcEventLogNullImpl final : public RtcEventLog {
     130             :  public:
     131           0 :   bool StartLogging(const std::string& file_name,
     132             :                     int64_t max_size_bytes) override {
     133           0 :     return false;
     134             :   }
     135             :   bool StartLogging(rtc::PlatformFile platform_file,
     136             :                     int64_t max_size_bytes) override;
     137           0 :   void StopLogging() override {}
     138           0 :   void LogVideoReceiveStreamConfig(
     139           0 :       const VideoReceiveStream::Config& config) override {}
     140           0 :   void LogVideoSendStreamConfig(
     141           0 :       const VideoSendStream::Config& config) override {}
     142           0 :   void LogAudioReceiveStreamConfig(
     143           0 :       const AudioReceiveStream::Config& config) override {}
     144           0 :   void LogAudioSendStreamConfig(
     145           0 :       const AudioSendStream::Config& config) override {}
     146           0 :   void LogRtpHeader(PacketDirection direction,
     147             :                     MediaType media_type,
     148             :                     const uint8_t* header,
     149           0 :                     size_t packet_length) override {}
     150           0 :   void LogRtcpPacket(PacketDirection direction,
     151             :                      MediaType media_type,
     152             :                      const uint8_t* packet,
     153           0 :                      size_t length) override {}
     154           0 :   void LogAudioPlayout(uint32_t ssrc) override {}
     155           0 :   void LogBwePacketLossEvent(int32_t bitrate,
     156             :                              uint8_t fraction_loss,
     157           0 :                              int32_t total_packets) override {}
     158             : };
     159             : 
     160             : }  // namespace webrtc
     161             : 
     162             : #endif  // WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_

Generated by: LCOV version 1.13