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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
|
|
|
|
#define 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>
|
2017-11-20 17:38:14 +01:00
|
|
|
#include <utility>
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2017-10-06 13:07:32 +02:00
|
|
|
#include "api/rtceventlogoutput.h"
|
2017-10-05 12:47:06 +00:00
|
|
|
#include "logging/rtc_event_log/events/rtc_event.h"
|
2015-07-30 12:45:18 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-10-05 12:25:18 +00:00
|
|
|
class Clock;
|
2017-10-05 12:47:06 +00:00
|
|
|
|
2016-01-21 05:42:04 -08:00
|
|
|
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
class RtcEventLog {
|
|
|
|
|
public:
|
2017-10-04 13:18:26 +02:00
|
|
|
enum : size_t { kUnlimitedOutput = 0 };
|
2017-11-20 17:38:14 +01:00
|
|
|
enum : int64_t { kImmediateOutput = 0 };
|
2017-10-04 13:18:26 +02:00
|
|
|
|
2017-10-03 16:11:34 +02:00
|
|
|
// TODO(eladalon): Two stages are upcoming.
|
|
|
|
|
// 1. Extend this to actually support the new encoding.
|
|
|
|
|
// 2. Get rid of the legacy encoding, allowing us to get rid of this enum.
|
|
|
|
|
enum class EncodingType { Legacy };
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual ~RtcEventLog() {}
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Factory method to create an RtcEventLog object.
|
2017-10-05 12:47:06 +00:00
|
|
|
static std::unique_ptr<RtcEventLog> Create(EncodingType encoding_type);
|
2016-12-20 05:03:58 -08:00
|
|
|
// TODO(nisse): webrtc::Clock is deprecated. Delete this method and
|
|
|
|
|
// above forward declaration of Clock when
|
2017-10-03 16:11:34 +02:00
|
|
|
// webrtc/system_wrappers/include/clock.h is deleted.
|
2017-10-05 12:47:06 +00:00
|
|
|
static std::unique_ptr<RtcEventLog> Create(const Clock* clock,
|
|
|
|
|
EncodingType encoding_type) {
|
2017-10-03 16:11:34 +02:00
|
|
|
return Create(encoding_type);
|
2016-12-20 05:03:58 -08:00
|
|
|
}
|
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();
|
|
|
|
|
|
2017-10-04 13:18:26 +02:00
|
|
|
// Starts logging to a given output. The output might be limited in size,
|
|
|
|
|
// and may close itself once it has reached the maximum size.
|
2017-11-20 17:38:14 +01:00
|
|
|
virtual bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
|
|
|
|
int64_t output_period_ms) = 0;
|
2017-10-04 13:18:26 +02:00
|
|
|
|
2017-09-06 05:18:15 -07:00
|
|
|
// Stops logging to file and waits until the file has been closed, after
|
|
|
|
|
// which it would be permissible to read and/or modify it.
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual void StopLogging() = 0;
|
|
|
|
|
|
2017-10-03 16:11:34 +02:00
|
|
|
// Log an RTC event (the type of event is determined by the subclass).
|
|
|
|
|
virtual void Log(std::unique_ptr<RtcEvent> event) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
};
|
|
|
|
|
|
2016-07-29 14:48:54 +02:00
|
|
|
// No-op implementation is used if flag is not set, or in tests.
|
2017-05-29 02:46:05 -07:00
|
|
|
class RtcEventLogNullImpl : public RtcEventLog {
|
2016-07-29 14:48:54 +02:00
|
|
|
public:
|
2017-11-20 17:38:14 +01:00
|
|
|
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
|
|
|
|
int64_t output_period_ms) override {
|
2017-10-04 13:18:26 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-07-29 14:48:54 +02:00
|
|
|
void StopLogging() override {}
|
2017-10-03 16:11:34 +02:00
|
|
|
void Log(std::unique_ptr<RtcEvent> event) override {}
|
2016-07-29 14:48:54 +02:00
|
|
|
};
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|