2015-07-30 12:45:18 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
Moved RtcEventLog files from call/ to logging/
The RtcEventLog headers need to be accessible from any place which needs
logging, and the implementation needs access to data structures that are
logged.
After a discussion in the code review, we all agreed to move the RtcEventLog implementation into its own top level directory - which I called "logging/" in expectation that other types of logging may have similar requirements. The directory contains two main build targets - "rtc_event_log_api", which is just rtc_event_log.h, that has no external dependencies and can be used from anywhere, and "rtc_event_log_impl" which contains the rest of the implementation and has many dependencies (more in the future).
The "api" target can be referenced from anywhere, while the "impl" target is only needed at the place of instantiation (currently Call, soon to be moved to PeerConnection by https://codereview.webrtc.org/2353033005/).
This change allows using RtcEventLog in the p2p/ directory, so that we
can log STUN pings and ICE state transitions.
BUG=webrtc:6393
R=kjellander@webrtc.org, kwiberg@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org
Review URL: https://codereview.webrtc.org/2380683005 .
Cr-Commit-Position: refs/heads/master@{#14485}
2016-10-03 18:31:22 -07:00
|
|
|
#ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
|
|
|
|
#define WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-03-12 06:10:44 -08:00
|
|
|
#include <memory>
|
2015-07-30 12:45:18 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
2015-10-16 02:22:18 -07:00
|
|
|
#include "webrtc/base/platform_file.h"
|
2016-12-07 04:52:58 -08:00
|
|
|
#include "webrtc/call/audio_receive_stream.h"
|
|
|
|
|
#include "webrtc/call/audio_send_stream.h"
|
2015-07-30 12:45:18 +02:00
|
|
|
#include "webrtc/video_receive_stream.h"
|
|
|
|
|
#include "webrtc/video_send_stream.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Forward declaration of storage class that is automatically generated from
|
|
|
|
|
// the protobuf file.
|
|
|
|
|
namespace rtclog {
|
|
|
|
|
class EventStream;
|
|
|
|
|
} // namespace rtclog
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
class Clock;
|
2015-07-30 12:45:18 +02:00
|
|
|
class RtcEventLogImpl;
|
|
|
|
|
|
|
|
|
|
enum class MediaType;
|
|
|
|
|
|
2016-01-21 05:42:04 -08:00
|
|
|
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
class RtcEventLog {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RtcEventLog() {}
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Factory method to create an RtcEventLog object.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> Create(const Clock* clock);
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-07-04 07:06:55 -07:00
|
|
|
// Create an RtcEventLog object that does nothing.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> CreateNull();
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Starts logging a maximum of max_size_bytes bytes to the specified file.
|
2015-07-30 12:45:18 +02:00
|
|
|
// If the file already exists it will be overwritten.
|
2016-04-22 12:40:37 -07:00
|
|
|
// If max_size_bytes <= 0, logging will be active until StopLogging is called.
|
|
|
|
|
// The function has no effect and returns false if we can't start a new log
|
|
|
|
|
// e.g. because we are already logging or the file cannot be opened.
|
|
|
|
|
virtual bool StartLogging(const std::string& file_name,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
|
|
|
|
|
|
|
|
|
// Same as above. The RtcEventLog takes ownership of the file if the call
|
|
|
|
|
// is successful, i.e. if it returns true.
|
|
|
|
|
virtual bool StartLogging(rtc::PlatformFile platform_file,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
|
|
|
|
|
|
|
|
|
// Deprecated. Pass an explicit file size limit.
|
|
|
|
|
bool StartLogging(const std::string& file_name) {
|
|
|
|
|
return StartLogging(file_name, 10000000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deprecated. Pass an explicit file size limit.
|
|
|
|
|
bool StartLogging(rtc::PlatformFile platform_file) {
|
|
|
|
|
return StartLogging(platform_file, 10000000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stops logging to file and waits until the thread has finished.
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual void StopLogging() = 0;
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Logs configuration information for webrtc::VideoReceiveStream.
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual void LogVideoReceiveStreamConfig(
|
|
|
|
|
const webrtc::VideoReceiveStream::Config& config) = 0;
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Logs configuration information for webrtc::VideoSendStream.
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual void LogVideoSendStreamConfig(
|
|
|
|
|
const webrtc::VideoSendStream::Config& config) = 0;
|
|
|
|
|
|
2016-10-10 05:12:51 -07:00
|
|
|
// Logs configuration information for webrtc::AudioReceiveStream.
|
|
|
|
|
virtual void LogAudioReceiveStreamConfig(
|
|
|
|
|
const webrtc::AudioReceiveStream::Config& config) = 0;
|
|
|
|
|
|
|
|
|
|
// Logs configuration information for webrtc::AudioSendStream.
|
|
|
|
|
virtual void LogAudioSendStreamConfig(
|
|
|
|
|
const webrtc::AudioSendStream::Config& config) = 0;
|
|
|
|
|
|
2015-09-04 03:39:42 -07:00
|
|
|
// Logs the header of an incoming or outgoing RTP packet. packet_length
|
|
|
|
|
// is the total length of the packet, including both header and payload.
|
2016-01-21 05:42:04 -08:00
|
|
|
virtual void LogRtpHeader(PacketDirection direction,
|
2015-07-30 12:45:18 +02:00
|
|
|
MediaType media_type,
|
|
|
|
|
const uint8_t* header,
|
2015-09-04 03:39:42 -07:00
|
|
|
size_t packet_length) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
|
|
|
|
// Logs an incoming or outgoing RTCP packet.
|
2016-01-21 05:42:04 -08:00
|
|
|
virtual void LogRtcpPacket(PacketDirection direction,
|
2015-07-30 12:45:18 +02:00
|
|
|
MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) = 0;
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Logs an audio playout event.
|
2015-09-17 16:30:16 +02:00
|
|
|
virtual void LogAudioPlayout(uint32_t ssrc) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2015-11-05 12:02:15 -08:00
|
|
|
// Logs a bitrate update from the bandwidth estimator based on packet loss.
|
|
|
|
|
virtual void LogBwePacketLossEvent(int32_t bitrate,
|
|
|
|
|
uint8_t fraction_loss,
|
|
|
|
|
int32_t total_packets) = 0;
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
// Reads an RtcEventLog file and returns true when reading was successful.
|
|
|
|
|
// The result is stored in the given EventStream object.
|
2016-04-22 12:40:37 -07:00
|
|
|
// The order of the events in the EventStream is implementation defined.
|
|
|
|
|
// The current implementation writes a LOG_START event, then the old
|
|
|
|
|
// configurations, then the remaining events in timestamp order and finally
|
|
|
|
|
// a LOG_END event. However, this might change without further notice.
|
|
|
|
|
// TODO(terelius): Change result type to a vector?
|
2015-07-30 12:45:18 +02:00
|
|
|
static bool ParseRtcEventLog(const std::string& file_name,
|
|
|
|
|
rtclog::EventStream* result);
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-29 14:48:54 +02:00
|
|
|
// No-op implementation is used if flag is not set, or in tests.
|
|
|
|
|
class RtcEventLogNullImpl final : public RtcEventLog {
|
|
|
|
|
public:
|
|
|
|
|
bool StartLogging(const std::string& file_name,
|
|
|
|
|
int64_t max_size_bytes) override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool StartLogging(rtc::PlatformFile platform_file,
|
|
|
|
|
int64_t max_size_bytes) override;
|
|
|
|
|
void StopLogging() override {}
|
|
|
|
|
void LogVideoReceiveStreamConfig(
|
|
|
|
|
const VideoReceiveStream::Config& config) override {}
|
|
|
|
|
void LogVideoSendStreamConfig(
|
|
|
|
|
const VideoSendStream::Config& config) override {}
|
2016-10-10 05:12:51 -07:00
|
|
|
void LogAudioReceiveStreamConfig(
|
|
|
|
|
const AudioReceiveStream::Config& config) override {}
|
|
|
|
|
void LogAudioSendStreamConfig(
|
|
|
|
|
const AudioSendStream::Config& config) override {}
|
2016-07-29 14:48:54 +02:00
|
|
|
void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
MediaType media_type,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length) override {}
|
|
|
|
|
void LogRtcpPacket(PacketDirection direction,
|
|
|
|
|
MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) override {}
|
|
|
|
|
void LogAudioPlayout(uint32_t ssrc) override {}
|
|
|
|
|
void LogBwePacketLossEvent(int32_t bitrate,
|
|
|
|
|
uint8_t fraction_loss,
|
|
|
|
|
int32_t total_packets) override {}
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
Moved RtcEventLog files from call/ to logging/
The RtcEventLog headers need to be accessible from any place which needs
logging, and the implementation needs access to data structures that are
logged.
After a discussion in the code review, we all agreed to move the RtcEventLog implementation into its own top level directory - which I called "logging/" in expectation that other types of logging may have similar requirements. The directory contains two main build targets - "rtc_event_log_api", which is just rtc_event_log.h, that has no external dependencies and can be used from anywhere, and "rtc_event_log_impl" which contains the rest of the implementation and has many dependencies (more in the future).
The "api" target can be referenced from anywhere, while the "impl" target is only needed at the place of instantiation (currently Call, soon to be moved to PeerConnection by https://codereview.webrtc.org/2353033005/).
This change allows using RtcEventLog in the p2p/ directory, so that we
can log STUN pings and ICE state transitions.
BUG=webrtc:6393
R=kjellander@webrtc.org, kwiberg@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org
Review URL: https://codereview.webrtc.org/2380683005 .
Cr-Commit-Position: refs/heads/master@{#14485}
2016-10-03 18:31:22 -07:00
|
|
|
#endif // WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|