mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Publish rtc event log api and default factory for it in api/
Bug: webrtc:10206 Change-Id: I34194ddb6fd2b0a3d7c553fadc9ddc1ea9740da0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137500 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28023}
This commit is contained in:
parent
23aff9b737
commit
b32f2c7f57
29 changed files with 512 additions and 304 deletions
|
@ -151,6 +151,7 @@ rtc_static_library("libjingle_peerconnection_api") {
|
||||||
":scoped_refptr",
|
":scoped_refptr",
|
||||||
"audio:audio_mixer_api",
|
"audio:audio_mixer_api",
|
||||||
"audio_codecs:audio_codecs_api",
|
"audio_codecs:audio_codecs_api",
|
||||||
|
"rtc_event_log",
|
||||||
"task_queue",
|
"task_queue",
|
||||||
"transport:bitrate_settings",
|
"transport:bitrate_settings",
|
||||||
"transport:network_control",
|
"transport:network_control",
|
||||||
|
@ -167,7 +168,6 @@ rtc_static_library("libjingle_peerconnection_api") {
|
||||||
# targets like pnacl. API should not depend on anything outside of this
|
# targets like pnacl. API should not depend on anything outside of this
|
||||||
# file, really. All these should arguably go away in time.
|
# file, really. All these should arguably go away in time.
|
||||||
"..:webrtc_common",
|
"..:webrtc_common",
|
||||||
"../logging:rtc_event_log_api",
|
|
||||||
"../media:rtc_media_config",
|
"../media:rtc_media_config",
|
||||||
"../modules/audio_processing:audio_processing_statistics",
|
"../modules/audio_processing:audio_processing_statistics",
|
||||||
"../rtc_base",
|
"../rtc_base",
|
||||||
|
@ -361,10 +361,10 @@ rtc_source_set("rtc_event_log_output_file") {
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":libjingle_logging_api",
|
":libjingle_logging_api",
|
||||||
"../logging:rtc_event_log_api",
|
|
||||||
"../rtc_base:checks",
|
"../rtc_base:checks",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"../rtc_base/system:file_wrapper",
|
"../rtc_base/system:file_wrapper",
|
||||||
|
"rtc_event_log",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
api/DEPS
1
api/DEPS
|
@ -117,7 +117,6 @@ specific_include_rules = {
|
||||||
],
|
],
|
||||||
|
|
||||||
"peer_connection_interface\.h": [
|
"peer_connection_interface\.h": [
|
||||||
"+logging/rtc_event_log/rtc_event_log_factory_interface.h",
|
|
||||||
"+media/base/media_config.h",
|
"+media/base/media_config.h",
|
||||||
"+media/base/media_engine.h",
|
"+media/base/media_engine.h",
|
||||||
"+p2p/base/port_allocator.h",
|
"+p2p/base/port_allocator.h",
|
||||||
|
|
|
@ -85,6 +85,7 @@
|
||||||
#include "api/media_transport_interface.h"
|
#include "api/media_transport_interface.h"
|
||||||
#include "api/network_state_predictor.h"
|
#include "api/network_state_predictor.h"
|
||||||
#include "api/rtc_error.h"
|
#include "api/rtc_error.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||||
#include "api/rtc_event_log_output.h"
|
#include "api/rtc_event_log_output.h"
|
||||||
#include "api/rtp_receiver_interface.h"
|
#include "api/rtp_receiver_interface.h"
|
||||||
#include "api/rtp_sender_interface.h"
|
#include "api/rtp_sender_interface.h"
|
||||||
|
@ -96,7 +97,6 @@
|
||||||
#include "api/transport/bitrate_settings.h"
|
#include "api/transport/bitrate_settings.h"
|
||||||
#include "api/transport/network_control.h"
|
#include "api/transport/network_control.h"
|
||||||
#include "api/turn_customizer.h"
|
#include "api/turn_customizer.h"
|
||||||
#include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
|
||||||
#include "media/base/media_config.h"
|
#include "media/base/media_config.h"
|
||||||
// TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
|
// TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
|
||||||
// inject a PacketSocketFactory and/or NetworkManager, and not expose
|
// inject a PacketSocketFactory and/or NetworkManager, and not expose
|
||||||
|
|
49
api/rtc_event_log/BUILD.gn
Normal file
49
api/rtc_event_log/BUILD.gn
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# Copyright (c) 2019 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.
|
||||||
|
|
||||||
|
import("../../webrtc.gni")
|
||||||
|
|
||||||
|
rtc_source_set("rtc_event_log") {
|
||||||
|
visibility = [ "*" ]
|
||||||
|
sources = [
|
||||||
|
"rtc_event.cc",
|
||||||
|
"rtc_event.h",
|
||||||
|
"rtc_event_log.cc",
|
||||||
|
"rtc_event_log.h",
|
||||||
|
"rtc_event_log_factory_interface.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"..:libjingle_logging_api",
|
||||||
|
"../../rtc_base:checks",
|
||||||
|
"../../rtc_base:deprecation",
|
||||||
|
"../../rtc_base:timeutils",
|
||||||
|
"../task_queue",
|
||||||
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_source_set("rtc_event_log_factory") {
|
||||||
|
visibility = [ "*" ]
|
||||||
|
sources = [
|
||||||
|
"rtc_event_log_factory.cc",
|
||||||
|
"rtc_event_log_factory.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":rtc_event_log",
|
||||||
|
"../../rtc_base:checks",
|
||||||
|
"../task_queue",
|
||||||
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (rtc_enable_protobuf) {
|
||||||
|
defines = [ "ENABLE_RTC_EVENT_LOG" ]
|
||||||
|
deps += [ "../../logging:rtc_event_log_impl" ]
|
||||||
|
}
|
||||||
|
}
|
19
api/rtc_event_log/rtc_event.cc
Normal file
19
api/rtc_event_log/rtc_event.cc
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "api/rtc_event_log/rtc_event.h"
|
||||||
|
|
||||||
|
#include "rtc_base/time_utils.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
RtcEvent::RtcEvent() : timestamp_us_(rtc::TimeMicros()) {}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
75
api/rtc_event_log/rtc_event.h
Normal file
75
api/rtc_event_log/rtc_event.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef API_RTC_EVENT_LOG_RTC_EVENT_H_
|
||||||
|
#define API_RTC_EVENT_LOG_RTC_EVENT_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
// This class allows us to store unencoded RTC events. Subclasses of this class
|
||||||
|
// store the actual information. This allows us to keep all unencoded events,
|
||||||
|
// even when their type and associated information differ, in the same buffer.
|
||||||
|
// Additionally, it prevents dependency leaking - a module that only logs
|
||||||
|
// events of type RtcEvent_A doesn't need to know about anything associated
|
||||||
|
// with events of type RtcEvent_B.
|
||||||
|
class RtcEvent {
|
||||||
|
public:
|
||||||
|
// Subclasses of this class have to associate themselves with a unique value
|
||||||
|
// of Type. This leaks the information of existing subclasses into the
|
||||||
|
// superclass, but the *actual* information - rtclog::StreamConfig, etc. -
|
||||||
|
// is kept separate.
|
||||||
|
enum class Type {
|
||||||
|
AlrStateEvent,
|
||||||
|
RouteChangeEvent,
|
||||||
|
AudioNetworkAdaptation,
|
||||||
|
AudioPlayout,
|
||||||
|
AudioReceiveStreamConfig,
|
||||||
|
AudioSendStreamConfig,
|
||||||
|
BweUpdateDelayBased,
|
||||||
|
BweUpdateLossBased,
|
||||||
|
DtlsTransportState,
|
||||||
|
DtlsWritableState,
|
||||||
|
IceCandidatePairConfig,
|
||||||
|
IceCandidatePairEvent,
|
||||||
|
ProbeClusterCreated,
|
||||||
|
ProbeResultFailure,
|
||||||
|
ProbeResultSuccess,
|
||||||
|
RtcpPacketIncoming,
|
||||||
|
RtcpPacketOutgoing,
|
||||||
|
RtpPacketIncoming,
|
||||||
|
RtpPacketOutgoing,
|
||||||
|
VideoReceiveStreamConfig,
|
||||||
|
VideoSendStreamConfig,
|
||||||
|
GenericPacketSent,
|
||||||
|
GenericPacketReceived,
|
||||||
|
GenericAckReceived
|
||||||
|
};
|
||||||
|
|
||||||
|
RtcEvent();
|
||||||
|
virtual ~RtcEvent() = default;
|
||||||
|
|
||||||
|
virtual Type GetType() const = 0;
|
||||||
|
|
||||||
|
virtual bool IsConfigEvent() const = 0;
|
||||||
|
|
||||||
|
int64_t timestamp_ms() const { return timestamp_us_ / 1000; }
|
||||||
|
int64_t timestamp_us() const { return timestamp_us_; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit RtcEvent(int64_t timestamp_us) : timestamp_us_(timestamp_us) {}
|
||||||
|
|
||||||
|
const int64_t timestamp_us_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // API_RTC_EVENT_LOG_RTC_EVENT_H_
|
|
@ -8,19 +8,13 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
|
bool RtcEventLogNull::StartLogging(
|
||||||
return absl::make_unique<RtcEventLogNullImpl>();
|
std::unique_ptr<RtcEventLogOutput> /*output*/,
|
||||||
}
|
int64_t /*output_period_ms*/) {
|
||||||
|
|
||||||
bool RtcEventLogNullImpl::StartLogging(
|
|
||||||
std::unique_ptr<RtcEventLogOutput> output,
|
|
||||||
int64_t output_period_ms) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
76
api/rtc_event_log/rtc_event_log.h
Normal file
76
api/rtc_event_log/rtc_event_log.h
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef API_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
||||||
|
#define API_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/memory/memory.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event.h"
|
||||||
|
#include "api/rtc_event_log_output.h"
|
||||||
|
#include "api/task_queue/task_queue_factory.h"
|
||||||
|
#include "rtc_base/deprecation.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class RtcEventLog {
|
||||||
|
public:
|
||||||
|
enum : size_t { kUnlimitedOutput = 0 };
|
||||||
|
enum : int64_t { kImmediateOutput = 0 };
|
||||||
|
|
||||||
|
// TODO(eladalon): Get rid of the legacy encoding and this enum once all
|
||||||
|
// clients have migrated to the new format.
|
||||||
|
enum class EncodingType { Legacy, NewFormat };
|
||||||
|
|
||||||
|
// Factory method to create an RtcEventLog object.
|
||||||
|
// Create RtcEventLog with an RtcEventLogFactory instead.
|
||||||
|
RTC_DEPRECATED
|
||||||
|
static std::unique_ptr<RtcEventLog> Create(
|
||||||
|
EncodingType encoding_type,
|
||||||
|
TaskQueueFactory* task_queue_factory);
|
||||||
|
|
||||||
|
// Create an RtcEventLog object that does nothing.
|
||||||
|
RTC_DEPRECATED
|
||||||
|
static std::unique_ptr<RtcEventLog> CreateNull();
|
||||||
|
|
||||||
|
virtual ~RtcEventLog() = default;
|
||||||
|
|
||||||
|
// Starts logging to a given output. The output might be limited in size,
|
||||||
|
// and may close itself once it has reached the maximum size.
|
||||||
|
virtual bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
||||||
|
int64_t output_period_ms) = 0;
|
||||||
|
|
||||||
|
// Stops logging to file and waits until the file has been closed, after
|
||||||
|
// which it would be permissible to read and/or modify it.
|
||||||
|
virtual void StopLogging() = 0;
|
||||||
|
|
||||||
|
// Log an RTC event (the type of event is determined by the subclass).
|
||||||
|
virtual void Log(std::unique_ptr<RtcEvent> event) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// No-op implementation is used if flag is not set, or in tests.
|
||||||
|
class RtcEventLogNull final : public RtcEventLog {
|
||||||
|
public:
|
||||||
|
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
||||||
|
int64_t output_period_ms) override;
|
||||||
|
void StopLogging() override {}
|
||||||
|
void Log(std::unique_ptr<RtcEvent> event) override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
|
||||||
|
return absl::make_unique<RtcEventLogNull>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // API_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
44
api/rtc_event_log/rtc_event_log_factory.cc
Normal file
44
api/rtc_event_log/rtc_event_log_factory.cc
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/memory/memory.h"
|
||||||
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_RTC_EVENT_LOG
|
||||||
|
#include "logging/rtc_event_log/rtc_event_log_impl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
RtcEventLogFactory::RtcEventLogFactory(TaskQueueFactory* task_queue_factory)
|
||||||
|
: task_queue_factory_(task_queue_factory) {
|
||||||
|
RTC_DCHECK(task_queue_factory_);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
|
||||||
|
RtcEventLog::EncodingType encoding_type) {
|
||||||
|
#ifdef ENABLE_RTC_EVENT_LOG
|
||||||
|
return absl::make_unique<RtcEventLogImpl>(encoding_type, task_queue_factory_);
|
||||||
|
#else
|
||||||
|
return absl::make_unique<RtcEventLogNull>();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<RtcEventLog> RtcEventLog::Create(
|
||||||
|
RtcEventLog::EncodingType encoding_type,
|
||||||
|
TaskQueueFactory* task_queue_factory) {
|
||||||
|
return RtcEventLogFactory(task_queue_factory)
|
||||||
|
.CreateRtcEventLog(encoding_type);
|
||||||
|
}
|
||||||
|
} // namespace webrtc
|
36
api/rtc_event_log/rtc_event_log_factory.h
Normal file
36
api/rtc_event_log/rtc_event_log_factory.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
||||||
|
#define API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||||
|
#include "api/task_queue/task_queue_factory.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class RtcEventLogFactory : public RtcEventLogFactoryInterface {
|
||||||
|
public:
|
||||||
|
explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory);
|
||||||
|
~RtcEventLogFactory() override {}
|
||||||
|
|
||||||
|
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||||
|
RtcEventLog::EncodingType encoding_type) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TaskQueueFactory* const task_queue_factory_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
33
api/rtc_event_log/rtc_event_log_factory_interface.h
Normal file
33
api/rtc_event_log/rtc_event_log_factory_interface.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||||
|
#define API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
// This interface exists to allow webrtc to be optionally built without
|
||||||
|
// RtcEventLog support. A PeerConnectionFactory is constructed with an
|
||||||
|
// RtcEventLogFactoryInterface, which may or may not be null.
|
||||||
|
class RtcEventLogFactoryInterface {
|
||||||
|
public:
|
||||||
|
virtual ~RtcEventLogFactoryInterface() = default;
|
||||||
|
|
||||||
|
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||||
|
RtcEventLog::EncodingType encoding_type) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // API_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
|
@ -11,8 +11,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
#include "api/rtc_event_log_output_file.h"
|
#include "api/rtc_event_log_output_file.h"
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
|
||||||
MediaTransportPair transport_pair(transport_thread.get());
|
MediaTransportPair transport_pair(transport_thread.get());
|
||||||
NiceMock<MockTransport> rtcp_send_transport;
|
NiceMock<MockTransport> rtcp_send_transport;
|
||||||
NiceMock<MockTransport> send_transport;
|
NiceMock<MockTransport> send_transport;
|
||||||
std::unique_ptr<RtcEventLog> null_event_log = RtcEventLog::CreateNull();
|
RtcEventLogNull null_event_log;
|
||||||
NiceMock<MockBitrateAllocator> bitrate_allocator;
|
NiceMock<MockBitrateAllocator> bitrate_allocator;
|
||||||
|
|
||||||
rtc::scoped_refptr<TestAudioDeviceModule> audio_device =
|
rtc::scoped_refptr<TestAudioDeviceModule> audio_device =
|
||||||
|
@ -114,7 +114,7 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
|
||||||
Clock::GetRealTimeClock(),
|
Clock::GetRealTimeClock(),
|
||||||
/*receiver_controller=*/nullptr,
|
/*receiver_controller=*/nullptr,
|
||||||
/*packet_router=*/nullptr, receive_process_thread.get(), receive_config,
|
/*packet_router=*/nullptr, receive_process_thread.get(), receive_config,
|
||||||
audio_state, null_event_log.get());
|
audio_state, &null_event_log);
|
||||||
|
|
||||||
// TODO(nisse): Update AudioSendStream to not require send_transport when a
|
// TODO(nisse): Update AudioSendStream to not require send_transport when a
|
||||||
// MediaTransport is provided.
|
// MediaTransport is provided.
|
||||||
|
@ -128,13 +128,13 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
|
||||||
std::unique_ptr<TaskQueueFactory> task_queue_factory =
|
std::unique_ptr<TaskQueueFactory> task_queue_factory =
|
||||||
CreateDefaultTaskQueueFactory();
|
CreateDefaultTaskQueueFactory();
|
||||||
RtpTransportControllerSend rtp_transport(
|
RtpTransportControllerSend rtp_transport(
|
||||||
Clock::GetRealTimeClock(), null_event_log.get(), nullptr, nullptr,
|
Clock::GetRealTimeClock(), &null_event_log, nullptr, nullptr,
|
||||||
BitrateConstraints(), ProcessThread::Create("Pacer"),
|
BitrateConstraints(), ProcessThread::Create("Pacer"),
|
||||||
task_queue_factory.get());
|
task_queue_factory.get());
|
||||||
webrtc::internal::AudioSendStream send_stream(
|
webrtc::internal::AudioSendStream send_stream(
|
||||||
Clock::GetRealTimeClock(), send_config, audio_state,
|
Clock::GetRealTimeClock(), send_config, audio_state,
|
||||||
task_queue_factory.get(), send_process_thread.get(), &rtp_transport,
|
task_queue_factory.get(), send_process_thread.get(), &rtp_transport,
|
||||||
&bitrate_allocator, null_event_log.get(),
|
&bitrate_allocator, &null_event_log,
|
||||||
/*rtcp_rtt_stats=*/nullptr, absl::optional<RtpState>());
|
/*rtcp_rtt_stats=*/nullptr, absl::optional<RtpState>());
|
||||||
|
|
||||||
audio_device->Init(); // Starts thread.
|
audio_device->Init(); // Starts thread.
|
||||||
|
|
|
@ -31,7 +31,6 @@ rtc_source_set("rtc_event_log_api") {
|
||||||
sources = [
|
sources = [
|
||||||
"rtc_event_log/encoder/rtc_event_log_encoder.h",
|
"rtc_event_log/encoder/rtc_event_log_encoder.h",
|
||||||
"rtc_event_log/events/rtc_event.h",
|
"rtc_event_log/events/rtc_event.h",
|
||||||
"rtc_event_log/rtc_event_log.cc",
|
|
||||||
"rtc_event_log/rtc_event_log.h",
|
"rtc_event_log/rtc_event_log.h",
|
||||||
"rtc_event_log/rtc_event_log_factory_interface.h",
|
"rtc_event_log/rtc_event_log_factory_interface.h",
|
||||||
]
|
]
|
||||||
|
@ -39,6 +38,7 @@ rtc_source_set("rtc_event_log_api") {
|
||||||
deps = [
|
deps = [
|
||||||
"../api:libjingle_logging_api",
|
"../api:libjingle_logging_api",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
|
"../api/rtc_event_log",
|
||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"//third_party/abseil-cpp/absl/memory",
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
|
@ -129,7 +129,9 @@ rtc_source_set("rtc_event_generic_packet_events") {
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":rtc_event_log_api",
|
":rtc_event_log_api",
|
||||||
|
"../rtc_base:timeutils",
|
||||||
"//third_party/abseil-cpp/absl/memory",
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,24 +241,20 @@ rtc_source_set("rtc_event_log_impl_output") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_static_library("rtc_event_log_impl_base") {
|
if (rtc_enable_protobuf) {
|
||||||
# TODO(terelius): Should this really be visible? Currently used to instantiate
|
rtc_source_set("rtc_event_log_impl") {
|
||||||
# the default event log factory.
|
visibility = [ "../api/rtc_event_log:rtc_event_log_factory" ]
|
||||||
visibility = [ "*" ]
|
|
||||||
sources = [
|
sources = [
|
||||||
"rtc_event_log/rtc_event_log_factory.cc",
|
|
||||||
"rtc_event_log/rtc_event_log_factory.h",
|
|
||||||
"rtc_event_log/rtc_event_log_impl.cc",
|
"rtc_event_log/rtc_event_log_impl.cc",
|
||||||
|
"rtc_event_log/rtc_event_log_impl.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
defines = []
|
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":ice_log",
|
":ice_log",
|
||||||
":rtc_event_log_api",
|
":rtc_event_log_api",
|
||||||
|
":rtc_event_log_impl_encoder",
|
||||||
"../api:libjingle_logging_api",
|
"../api:libjingle_logging_api",
|
||||||
|
"../api/rtc_event_log",
|
||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
"../api/task_queue:global_task_queue_factory",
|
|
||||||
"../rtc_base:checks",
|
"../rtc_base:checks",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"../rtc_base:rtc_task_queue",
|
"../rtc_base:rtc_task_queue",
|
||||||
|
@ -265,13 +263,26 @@ rtc_static_library("rtc_event_log_impl_base") {
|
||||||
"//third_party/abseil-cpp/absl/memory",
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
"//third_party/abseil-cpp/absl/types:optional",
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (rtc_enable_protobuf) {
|
|
||||||
defines += [ "ENABLE_RTC_EVENT_LOG" ]
|
|
||||||
deps += [ ":rtc_event_log_impl_encoder" ]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_static_library("rtc_event_log_impl_base") {
|
||||||
|
# TODO(bugs.webrtc.org/10206): Remove this target when all users switch to
|
||||||
|
# using target api/rtc_event_log:rtc_event_log_factory directly.
|
||||||
|
visibility = [ "*" ]
|
||||||
|
sources = [
|
||||||
|
"rtc_event_log/rtc_event_log_factory.cc",
|
||||||
|
"rtc_event_log/rtc_event_log_factory.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"../api/rtc_event_log",
|
||||||
|
"../api/rtc_event_log:rtc_event_log_factory",
|
||||||
|
"../api/task_queue:global_task_queue_factory",
|
||||||
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
rtc_source_set("fake_rtc_event_log") {
|
rtc_source_set("fake_rtc_event_log") {
|
||||||
testonly = true
|
testonly = true
|
||||||
sources = [
|
sources = [
|
||||||
|
|
|
@ -11,67 +11,9 @@
|
||||||
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
||||||
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
||||||
|
|
||||||
#include <memory>
|
// TODO(bugs.webrtc.org/10206): For backwards compatibility; Delete as soon as
|
||||||
|
// dependencies are updated.
|
||||||
|
|
||||||
#include "rtc_base/time_utils.h"
|
#include "api/rtc_event_log/rtc_event.h"
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
// This class allows us to store unencoded RTC events. Subclasses of this class
|
|
||||||
// store the actual information. This allows us to keep all unencoded events,
|
|
||||||
// even when their type and associated information differ, in the same buffer.
|
|
||||||
// Additionally, it prevents dependency leaking - a module that only logs
|
|
||||||
// events of type RtcEvent_A doesn't need to know about anything associated
|
|
||||||
// with events of type RtcEvent_B.
|
|
||||||
class RtcEvent {
|
|
||||||
public:
|
|
||||||
// Subclasses of this class have to associate themselves with a unique value
|
|
||||||
// of Type. This leaks the information of existing subclasses into the
|
|
||||||
// superclass, but the *actual* information - rtclog::StreamConfig, etc. -
|
|
||||||
// is kept separate.
|
|
||||||
enum class Type {
|
|
||||||
AlrStateEvent,
|
|
||||||
RouteChangeEvent,
|
|
||||||
AudioNetworkAdaptation,
|
|
||||||
AudioPlayout,
|
|
||||||
AudioReceiveStreamConfig,
|
|
||||||
AudioSendStreamConfig,
|
|
||||||
BweUpdateDelayBased,
|
|
||||||
BweUpdateLossBased,
|
|
||||||
DtlsTransportState,
|
|
||||||
DtlsWritableState,
|
|
||||||
IceCandidatePairConfig,
|
|
||||||
IceCandidatePairEvent,
|
|
||||||
ProbeClusterCreated,
|
|
||||||
ProbeResultFailure,
|
|
||||||
ProbeResultSuccess,
|
|
||||||
RtcpPacketIncoming,
|
|
||||||
RtcpPacketOutgoing,
|
|
||||||
RtpPacketIncoming,
|
|
||||||
RtpPacketOutgoing,
|
|
||||||
VideoReceiveStreamConfig,
|
|
||||||
VideoSendStreamConfig,
|
|
||||||
GenericPacketSent,
|
|
||||||
GenericPacketReceived,
|
|
||||||
GenericAckReceived
|
|
||||||
};
|
|
||||||
|
|
||||||
RtcEvent() : timestamp_us_(rtc::TimeMicros()) {}
|
|
||||||
virtual ~RtcEvent() = default;
|
|
||||||
|
|
||||||
virtual Type GetType() const = 0;
|
|
||||||
|
|
||||||
virtual bool IsConfigEvent() const = 0;
|
|
||||||
|
|
||||||
int64_t timestamp_ms() const { return timestamp_us_ / 1000; }
|
|
||||||
int64_t timestamp_us() const { return timestamp_us_; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit RtcEvent(int64_t timestamp_us) : timestamp_us_(timestamp_us) {}
|
|
||||||
|
|
||||||
const int64_t timestamp_us_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
#endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "rtc_base/time_utils.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
struct AckedPacket {
|
struct AckedPacket {
|
||||||
|
|
|
@ -11,59 +11,13 @@
|
||||||
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
||||||
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
// TODO(bugs.webrtc.org/10206): For backwards compatibility; Delete as soon as
|
||||||
#include <memory>
|
// dependencies are updated.
|
||||||
|
|
||||||
#include "api/rtc_event_log_output.h"
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
#include "api/task_queue/task_queue_factory.h"
|
|
||||||
#include "logging/rtc_event_log/events/rtc_event.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
using RtcEventLogNullImpl = ::webrtc::RtcEventLogNull;
|
||||||
// TODO(terelius): Move this to the parser.
|
|
||||||
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
|
||||||
|
|
||||||
class RtcEventLog {
|
|
||||||
public:
|
|
||||||
enum : size_t { kUnlimitedOutput = 0 };
|
|
||||||
enum : int64_t { kImmediateOutput = 0 };
|
|
||||||
|
|
||||||
// TODO(eladalon): Get rid of the legacy encoding and this enum once all
|
|
||||||
// clients have migrated to the new format.
|
|
||||||
enum class EncodingType { Legacy, NewFormat };
|
|
||||||
|
|
||||||
virtual ~RtcEventLog() {}
|
|
||||||
|
|
||||||
// Factory method to create an RtcEventLog object.
|
|
||||||
static std::unique_ptr<RtcEventLog> Create(
|
|
||||||
EncodingType encoding_type,
|
|
||||||
TaskQueueFactory* task_queue_factory);
|
|
||||||
|
|
||||||
// Create an RtcEventLog object that does nothing.
|
|
||||||
static std::unique_ptr<RtcEventLog> CreateNull();
|
|
||||||
|
|
||||||
// Starts logging to a given output. The output might be limited in size,
|
|
||||||
// and may close itself once it has reached the maximum size.
|
|
||||||
virtual bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
|
||||||
int64_t output_period_ms) = 0;
|
|
||||||
|
|
||||||
// Stops logging to file and waits until the file has been closed, after
|
|
||||||
// which it would be permissible to read and/or modify it.
|
|
||||||
virtual void StopLogging() = 0;
|
|
||||||
|
|
||||||
// Log an RTC event (the type of event is determined by the subclass).
|
|
||||||
virtual void Log(std::unique_ptr<RtcEvent> event) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// No-op implementation is used if flag is not set, or in tests.
|
|
||||||
class RtcEventLogNullImpl : public RtcEventLog {
|
|
||||||
public:
|
|
||||||
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
|
||||||
int64_t output_period_ms) override;
|
|
||||||
void StopLogging() override {}
|
|
||||||
void Log(std::unique_ptr<RtcEvent> event) override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
||||||
|
|
|
@ -10,25 +10,11 @@
|
||||||
|
|
||||||
#include "logging/rtc_event_log/rtc_event_log_factory.h"
|
#include "logging/rtc_event_log/rtc_event_log_factory.h"
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "api/task_queue/global_task_queue_factory.h"
|
#include "api/task_queue/global_task_queue_factory.h"
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
|
||||||
#include "rtc_base/checks.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
RtcEventLogFactory::RtcEventLogFactory(TaskQueueFactory* task_queue_factory)
|
|
||||||
: task_queue_factory_(task_queue_factory) {
|
|
||||||
RTC_DCHECK(task_queue_factory_);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
|
|
||||||
RtcEventLog::EncodingType encoding_type) {
|
|
||||||
return RtcEventLog::Create(encoding_type, task_queue_factory_);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory() {
|
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory() {
|
||||||
return absl::make_unique<RtcEventLogFactory>(&GlobalTaskQueueFactory());
|
return absl::make_unique<RtcEventLogFactory>(&GlobalTaskQueueFactory());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,24 +13,11 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/task_queue/task_queue_factory.h"
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||||
#include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class RtcEventLogFactory : public RtcEventLogFactoryInterface {
|
|
||||||
public:
|
|
||||||
explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory);
|
|
||||||
~RtcEventLogFactory() override {}
|
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
|
||||||
RtcEventLog::EncodingType encoding_type) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
TaskQueueFactory* const task_queue_factory_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(bugs.webrtc.org/10284): Stop using the RtcEventLogFactory factory.
|
// TODO(bugs.webrtc.org/10284): Stop using the RtcEventLogFactory factory.
|
||||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
|
@ -11,23 +11,8 @@
|
||||||
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||||
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||||
|
|
||||||
#include <memory>
|
// TODO(bugs.webrtc.org/10206): For backwards compatibility; Delete as soon as
|
||||||
|
// dependencies are updated.
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
// This interface exists to allow webrtc to be optionally built without
|
|
||||||
// RtcEventLog support. A PeerConnectionFactory is constructed with an
|
|
||||||
// RtcEventLogFactoryInterface, which may or may not be null.
|
|
||||||
class RtcEventLogFactoryInterface {
|
|
||||||
public:
|
|
||||||
virtual ~RtcEventLogFactoryInterface() {}
|
|
||||||
|
|
||||||
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
|
||||||
RtcEventLog::EncodingType encoding_type) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||||
|
|
|
@ -8,18 +8,15 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
#include "logging/rtc_event_log/rtc_event_log_impl.h"
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/rtc_event_log_output.h"
|
|
||||||
#include "api/task_queue/queued_task.h"
|
#include "api/task_queue/queued_task.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h"
|
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h"
|
||||||
|
@ -30,15 +27,9 @@
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/numerics/safe_conversions.h"
|
#include "rtc_base/numerics/safe_conversions.h"
|
||||||
#include "rtc_base/numerics/safe_minmax.h"
|
#include "rtc_base/numerics/safe_minmax.h"
|
||||||
#include "rtc_base/synchronization/sequence_checker.h"
|
|
||||||
#include "rtc_base/task_queue.h"
|
|
||||||
#include "rtc_base/thread_annotations.h"
|
|
||||||
#include "rtc_base/time_utils.h"
|
#include "rtc_base/time_utils.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
#ifdef ENABLE_RTC_EVENT_LOG
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr size_t kMaxEventsInHistory = 10000;
|
constexpr size_t kMaxEventsInHistory = 10000;
|
||||||
// The config-history is supposed to be unbounded, but needs to have some bound
|
// The config-history is supposed to be unbounded, but needs to have some bound
|
||||||
|
@ -81,77 +72,20 @@ std::unique_ptr<RtcEventLogEncoder> CreateEncoder(
|
||||||
return std::unique_ptr<RtcEventLogEncoder>(nullptr);
|
return std::unique_ptr<RtcEventLogEncoder>(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
class RtcEventLogImpl final : public RtcEventLog {
|
RtcEventLogImpl::RtcEventLogImpl(RtcEventLog::EncodingType encoding_type,
|
||||||
public:
|
TaskQueueFactory* task_queue_factory)
|
||||||
RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> event_encoder,
|
|
||||||
std::unique_ptr<rtc::TaskQueue> task_queue);
|
|
||||||
|
|
||||||
~RtcEventLogImpl() override;
|
|
||||||
|
|
||||||
// TODO(eladalon): We should change these name to reflect that what we're
|
|
||||||
// actually starting/stopping is the output of the log, not the log itself.
|
|
||||||
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
|
||||||
int64_t output_period_ms) override;
|
|
||||||
void StopLogging() override;
|
|
||||||
|
|
||||||
void Log(std::unique_ptr<RtcEvent> event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void LogToMemory(std::unique_ptr<RtcEvent> event) RTC_RUN_ON(task_queue_);
|
|
||||||
void LogEventsFromMemoryToOutput() RTC_RUN_ON(task_queue_);
|
|
||||||
|
|
||||||
void StopOutput() RTC_RUN_ON(task_queue_);
|
|
||||||
|
|
||||||
void WriteConfigsAndHistoryToOutput(const std::string& encoded_configs,
|
|
||||||
const std::string& encoded_history)
|
|
||||||
RTC_RUN_ON(task_queue_);
|
|
||||||
void WriteToOutput(const std::string& output_string) RTC_RUN_ON(task_queue_);
|
|
||||||
|
|
||||||
void StopLoggingInternal() RTC_RUN_ON(task_queue_);
|
|
||||||
|
|
||||||
void ScheduleOutput() RTC_RUN_ON(task_queue_);
|
|
||||||
|
|
||||||
// History containing all past configuration events.
|
|
||||||
std::deque<std::unique_ptr<RtcEvent>> config_history_
|
|
||||||
RTC_GUARDED_BY(*task_queue_);
|
|
||||||
|
|
||||||
// History containing the most recent (non-configuration) events (~10s).
|
|
||||||
std::deque<std::unique_ptr<RtcEvent>> history_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
|
|
||||||
size_t max_size_bytes_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
size_t written_bytes_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLogEncoder> event_encoder_
|
|
||||||
RTC_GUARDED_BY(*task_queue_);
|
|
||||||
std::unique_ptr<RtcEventLogOutput> event_output_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
|
|
||||||
size_t num_config_events_written_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
absl::optional<int64_t> output_period_ms_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
int64_t last_output_ms_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
bool output_scheduled_ RTC_GUARDED_BY(*task_queue_);
|
|
||||||
|
|
||||||
// Since we are posting tasks bound to |this|, it is critical that the event
|
|
||||||
// log and it's members outlive the |task_queue_|. Keep the "task_queue_|
|
|
||||||
// last to ensure it destructs first, or else tasks living on the queue might
|
|
||||||
// access other members after they've been torn down.
|
|
||||||
std::unique_ptr<rtc::TaskQueue> task_queue_;
|
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogImpl);
|
|
||||||
};
|
|
||||||
|
|
||||||
RtcEventLogImpl::RtcEventLogImpl(
|
|
||||||
std::unique_ptr<RtcEventLogEncoder> event_encoder,
|
|
||||||
std::unique_ptr<rtc::TaskQueue> task_queue)
|
|
||||||
: max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()),
|
: max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()),
|
||||||
written_bytes_(0),
|
written_bytes_(0),
|
||||||
event_encoder_(std::move(event_encoder)),
|
event_encoder_(CreateEncoder(encoding_type)),
|
||||||
num_config_events_written_(0),
|
num_config_events_written_(0),
|
||||||
last_output_ms_(rtc::TimeMillis()),
|
last_output_ms_(rtc::TimeMillis()),
|
||||||
output_scheduled_(false),
|
output_scheduled_(false),
|
||||||
task_queue_(std::move(task_queue)) {
|
task_queue_(
|
||||||
RTC_DCHECK(task_queue_);
|
absl::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue(
|
||||||
}
|
"rtc_event_log",
|
||||||
|
TaskQueueFactory::Priority::NORMAL))) {}
|
||||||
|
|
||||||
RtcEventLogImpl::~RtcEventLogImpl() {
|
RtcEventLogImpl::~RtcEventLogImpl() {
|
||||||
// If we're logging to the output, this will stop that. Blocking function.
|
// If we're logging to the output, this will stop that. Blocking function.
|
||||||
|
@ -361,22 +295,4 @@ void RtcEventLogImpl::WriteToOutput(const std::string& output_string) {
|
||||||
written_bytes_ += output_string.size();
|
written_bytes_ += output_string.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // ENABLE_RTC_EVENT_LOG
|
|
||||||
|
|
||||||
// RtcEventLog member functions.
|
|
||||||
std::unique_ptr<RtcEventLog> RtcEventLog::Create(
|
|
||||||
RtcEventLog::EncodingType encoding_type,
|
|
||||||
TaskQueueFactory* task_queue_factory) {
|
|
||||||
#ifdef ENABLE_RTC_EVENT_LOG
|
|
||||||
return absl::make_unique<RtcEventLogImpl>(
|
|
||||||
CreateEncoder(encoding_type),
|
|
||||||
absl::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue(
|
|
||||||
"rtc_event_log", TaskQueueFactory::Priority::NORMAL)));
|
|
||||||
#else
|
|
||||||
return CreateNull();
|
|
||||||
#endif // ENABLE_RTC_EVENT_LOG
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
92
logging/rtc_event_log/rtc_event_log_impl.h
Normal file
92
logging/rtc_event_log/rtc_event_log_impl.h
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_IMPL_H_
|
||||||
|
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_IMPL_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <deque>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
|
#include "api/rtc_event_log_output.h"
|
||||||
|
#include "api/task_queue/task_queue_factory.h"
|
||||||
|
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h"
|
||||||
|
#include "rtc_base/synchronization/sequence_checker.h"
|
||||||
|
#include "rtc_base/task_queue.h"
|
||||||
|
#include "rtc_base/thread_annotations.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class RtcEventLogImpl final : public RtcEventLog {
|
||||||
|
public:
|
||||||
|
RtcEventLogImpl(EncodingType encoding_type,
|
||||||
|
TaskQueueFactory* task_queue_factory);
|
||||||
|
RtcEventLogImpl(const RtcEventLogImpl&) = delete;
|
||||||
|
RtcEventLogImpl& operator=(const RtcEventLogImpl&) = delete;
|
||||||
|
|
||||||
|
~RtcEventLogImpl() override;
|
||||||
|
|
||||||
|
// TODO(eladalon): We should change these name to reflect that what we're
|
||||||
|
// actually starting/stopping is the output of the log, not the log itself.
|
||||||
|
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
|
||||||
|
int64_t output_period_ms) override;
|
||||||
|
void StopLogging() override;
|
||||||
|
|
||||||
|
void Log(std::unique_ptr<RtcEvent> event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LogToMemory(std::unique_ptr<RtcEvent> event) RTC_RUN_ON(task_queue_);
|
||||||
|
void LogEventsFromMemoryToOutput() RTC_RUN_ON(task_queue_);
|
||||||
|
|
||||||
|
void StopOutput() RTC_RUN_ON(task_queue_);
|
||||||
|
|
||||||
|
void WriteConfigsAndHistoryToOutput(const std::string& encoded_configs,
|
||||||
|
const std::string& encoded_history)
|
||||||
|
RTC_RUN_ON(task_queue_);
|
||||||
|
void WriteToOutput(const std::string& output_string) RTC_RUN_ON(task_queue_);
|
||||||
|
|
||||||
|
void StopLoggingInternal() RTC_RUN_ON(task_queue_);
|
||||||
|
|
||||||
|
void ScheduleOutput() RTC_RUN_ON(task_queue_);
|
||||||
|
|
||||||
|
// History containing all past configuration events.
|
||||||
|
std::deque<std::unique_ptr<RtcEvent>> config_history_
|
||||||
|
RTC_GUARDED_BY(*task_queue_);
|
||||||
|
|
||||||
|
// History containing the most recent (non-configuration) events (~10s).
|
||||||
|
std::deque<std::unique_ptr<RtcEvent>> history_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
|
||||||
|
size_t max_size_bytes_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
size_t written_bytes_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
|
||||||
|
std::unique_ptr<RtcEventLogEncoder> event_encoder_
|
||||||
|
RTC_GUARDED_BY(*task_queue_);
|
||||||
|
std::unique_ptr<RtcEventLogOutput> event_output_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
|
||||||
|
size_t num_config_events_written_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
absl::optional<int64_t> output_period_ms_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
int64_t last_output_ms_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
bool output_scheduled_ RTC_GUARDED_BY(*task_queue_);
|
||||||
|
|
||||||
|
// Since we are posting tasks bound to |this|, it is critical that the event
|
||||||
|
// log and its members outlive |task_queue_|. Keep the |task_queue_|
|
||||||
|
// last to ensure it destructs first, or else tasks living on the queue might
|
||||||
|
// access other members after they've been torn down.
|
||||||
|
std::unique_ptr<rtc::TaskQueue> task_queue_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_IMPL_H_
|
|
@ -39,6 +39,8 @@ RTC_POP_IGNORING_WUNDEF()
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PacketView;
|
class PacketView;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ namespace test {
|
||||||
CallTest::CallTest()
|
CallTest::CallTest()
|
||||||
: clock_(Clock::GetRealTimeClock()),
|
: clock_(Clock::GetRealTimeClock()),
|
||||||
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
||||||
send_event_log_(RtcEventLog::CreateNull()),
|
send_event_log_(absl::make_unique<RtcEventLogNull>()),
|
||||||
recv_event_log_(RtcEventLog::CreateNull()),
|
recv_event_log_(absl::make_unique<RtcEventLogNull>()),
|
||||||
audio_send_config_(/*send_transport=*/nullptr, MediaTransportConfig()),
|
audio_send_config_(/*send_transport=*/nullptr, MediaTransportConfig()),
|
||||||
audio_send_stream_(nullptr),
|
audio_send_stream_(nullptr),
|
||||||
frame_generator_capturer_(nullptr),
|
frame_generator_capturer_(nullptr),
|
||||||
|
|
|
@ -87,6 +87,8 @@ if (rtc_include_tests) {
|
||||||
"../../api:transport_api",
|
"../../api:transport_api",
|
||||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||||
"../../api/audio_codecs:builtin_audio_encoder_factory",
|
"../../api/audio_codecs:builtin_audio_encoder_factory",
|
||||||
|
"../../api/rtc_event_log",
|
||||||
|
"../../api/rtc_event_log:rtc_event_log_factory",
|
||||||
"../../api/test/video:function_video_factory",
|
"../../api/test/video:function_video_factory",
|
||||||
"../../api/transport:network_control",
|
"../../api/transport:network_control",
|
||||||
"../../api/units:data_rate",
|
"../../api/units:data_rate",
|
||||||
|
@ -105,7 +107,6 @@ if (rtc_include_tests) {
|
||||||
"../../call:video_stream_api",
|
"../../call:video_stream_api",
|
||||||
"../../common_video",
|
"../../common_video",
|
||||||
"../../logging:rtc_event_log_api",
|
"../../logging:rtc_event_log_api",
|
||||||
"../../logging:rtc_event_log_impl_base",
|
|
||||||
"../../media:rtc_audio_video",
|
"../../media:rtc_audio_video",
|
||||||
"../../media:rtc_internal_video_codecs",
|
"../../media:rtc_internal_video_codecs",
|
||||||
"../../media:rtc_media_base",
|
"../../media:rtc_media_base",
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
#include "modules/audio_mixer/audio_mixer_impl.h"
|
#include "modules/audio_mixer/audio_mixer_impl.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -74,10 +76,10 @@ std::unique_ptr<RtcEventLog> CreateEventLog(
|
||||||
TaskQueueFactory* task_queue_factory,
|
TaskQueueFactory* task_queue_factory,
|
||||||
LogWriterFactoryInterface* log_writer_factory) {
|
LogWriterFactoryInterface* log_writer_factory) {
|
||||||
if (!log_writer_factory) {
|
if (!log_writer_factory) {
|
||||||
return RtcEventLog::CreateNull();
|
return absl::make_unique<RtcEventLogNull>();
|
||||||
}
|
}
|
||||||
auto event_log = RtcEventLog::Create(RtcEventLog::EncodingType::NewFormat,
|
auto event_log = RtcEventLogFactory(task_queue_factory)
|
||||||
task_queue_factory);
|
.CreateRtcEventLog(RtcEventLog::EncodingType::NewFormat);
|
||||||
bool success = event_log->StartLogging(log_writer_factory->Create(".rtc.dat"),
|
bool success = event_log->StartLogging(log_writer_factory->Create(".rtc.dat"),
|
||||||
kEventLogOutputIntervalMs);
|
kEventLogOutputIntervalMs);
|
||||||
RTC_CHECK(success);
|
RTC_CHECK(success);
|
||||||
|
|
|
@ -15,7 +15,9 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
|
|
||||||
|
@ -39,10 +41,10 @@ std::unique_ptr<RtcEventLog> CreateEventLog(
|
||||||
TaskQueueFactory* task_queue_factory,
|
TaskQueueFactory* task_queue_factory,
|
||||||
LogWriterFactoryInterface* log_writer_factory) {
|
LogWriterFactoryInterface* log_writer_factory) {
|
||||||
if (!log_writer_factory) {
|
if (!log_writer_factory) {
|
||||||
return RtcEventLog::CreateNull();
|
return absl::make_unique<RtcEventLogNull>();
|
||||||
}
|
}
|
||||||
auto event_log = RtcEventLog::Create(RtcEventLog::EncodingType::NewFormat,
|
auto event_log = RtcEventLogFactory(task_queue_factory)
|
||||||
task_queue_factory);
|
.CreateRtcEventLog(RtcEventLog::EncodingType::NewFormat);
|
||||||
bool success = event_log->StartLogging(log_writer_factory->Create(".rtc.dat"),
|
bool success = event_log->StartLogging(log_writer_factory->Create(".rtc.dat"),
|
||||||
kEventLogOutputIntervalMs);
|
kEventLogOutputIntervalMs);
|
||||||
RTC_CHECK(success);
|
RTC_CHECK(success);
|
||||||
|
|
|
@ -1222,8 +1222,8 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) {
|
||||||
RtcEventLog::kImmediateOutput);
|
RtcEventLog::kImmediateOutput);
|
||||||
RTC_DCHECK(event_log_started);
|
RTC_DCHECK(event_log_started);
|
||||||
} else {
|
} else {
|
||||||
send_event_log_ = RtcEventLog::CreateNull();
|
send_event_log_ = absl::make_unique<RtcEventLogNull>();
|
||||||
recv_event_log_ = RtcEventLog::CreateNull();
|
recv_event_log_ = absl::make_unique<RtcEventLogNull>();
|
||||||
}
|
}
|
||||||
|
|
||||||
task_queue_.SendTask([this, ¶ms, &send_transport, &recv_transport]() {
|
task_queue_.SendTask([this, ¶ms, &send_transport, &recv_transport]() {
|
||||||
|
@ -1443,8 +1443,8 @@ void VideoQualityTest::RunWithRenderers(const Params& params) {
|
||||||
/*output_period_ms=*/5000);
|
/*output_period_ms=*/5000);
|
||||||
RTC_DCHECK(event_log_started);
|
RTC_DCHECK(event_log_started);
|
||||||
} else {
|
} else {
|
||||||
send_event_log_ = RtcEventLog::CreateNull();
|
send_event_log_ = absl::make_unique<RtcEventLogNull>();
|
||||||
recv_event_log_ = RtcEventLog::CreateNull();
|
recv_event_log_ = absl::make_unique<RtcEventLogNull>();
|
||||||
}
|
}
|
||||||
|
|
||||||
task_queue_.SendTask([&]() {
|
task_queue_.SendTask([&]() {
|
||||||
|
|
Loading…
Reference in a new issue