2016-05-13 00:42:59 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 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_PARSER_H_
|
|
|
|
|
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_
|
2016-05-13 00:42:59 -07:00
|
|
|
|
2017-06-12 01:02:46 -07:00
|
|
|
#include <map>
|
2016-05-13 00:42:59 -07:00
|
|
|
#include <string>
|
2017-06-12 01:02:46 -07:00
|
|
|
#include <utility> // pair
|
2016-05-13 00:42:59 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/video_receive_stream.h"
|
|
|
|
|
#include "call/video_send_stream.h"
|
2017-10-05 12:47:06 +00:00
|
|
|
#include "logging/rtc_event_log/events/rtc_event_probe_result_failure.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log.h"
|
2017-09-21 10:25:29 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_stream_config.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/byte_io.h"
|
|
|
|
|
#include "rtc_base/ignore_wundef.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
|
|
|
|
|
// Files generated at build-time by the protobuf compiler.
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_PUSH_IGNORING_WUNDEF()
|
2016-05-13 00:42:59 -07:00
|
|
|
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
|
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
|
|
|
#include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
#else
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log.pb.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
#endif
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_POP_IGNORING_WUNDEF()
|
2016-05-13 00:42:59 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-10-05 12:47:06 +00:00
|
|
|
enum class BandwidthUsage;
|
2016-05-13 00:42:59 -07:00
|
|
|
enum class MediaType;
|
|
|
|
|
|
2017-10-05 12:47:06 +00:00
|
|
|
struct AudioEncoderRuntimeConfig;
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
class ParsedRtcEventLog {
|
|
|
|
|
friend class RtcEventLogTestHelper;
|
|
|
|
|
|
|
|
|
|
public:
|
2017-03-29 16:28:53 +02:00
|
|
|
struct BweProbeClusterCreatedEvent {
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
uint32_t id;
|
|
|
|
|
uint64_t bitrate_bps;
|
|
|
|
|
uint32_t min_packets;
|
|
|
|
|
uint32_t min_bytes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct BweProbeResultEvent {
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
uint32_t id;
|
|
|
|
|
rtc::Optional<uint64_t> bitrate_bps;
|
|
|
|
|
rtc::Optional<ProbeFailureReason> failure_reason;
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-11 01:50:23 -07:00
|
|
|
struct BweDelayBasedUpdate {
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
int32_t bitrate_bps;
|
|
|
|
|
BandwidthUsage detector_state;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-05 13:19:45 +01:00
|
|
|
struct AlrStateEvent {
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
bool in_alr;
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
enum EventType {
|
|
|
|
|
UNKNOWN_EVENT = 0,
|
|
|
|
|
LOG_START = 1,
|
|
|
|
|
LOG_END = 2,
|
|
|
|
|
RTP_EVENT = 3,
|
|
|
|
|
RTCP_EVENT = 4,
|
|
|
|
|
AUDIO_PLAYOUT_EVENT = 5,
|
2017-02-20 05:14:41 -08:00
|
|
|
LOSS_BASED_BWE_UPDATE = 6,
|
|
|
|
|
DELAY_BASED_BWE_UPDATE = 7,
|
2016-05-13 00:42:59 -07:00
|
|
|
VIDEO_RECEIVER_CONFIG_EVENT = 8,
|
|
|
|
|
VIDEO_SENDER_CONFIG_EVENT = 9,
|
|
|
|
|
AUDIO_RECEIVER_CONFIG_EVENT = 10,
|
2017-01-24 04:54:59 -08:00
|
|
|
AUDIO_SENDER_CONFIG_EVENT = 11,
|
2017-02-27 02:18:46 -08:00
|
|
|
AUDIO_NETWORK_ADAPTATION_EVENT = 16,
|
|
|
|
|
BWE_PROBE_CLUSTER_CREATED_EVENT = 17,
|
2017-12-05 13:19:45 +01:00
|
|
|
BWE_PROBE_RESULT_EVENT = 18,
|
2018-01-31 09:38:28 +00:00
|
|
|
ALR_STATE_EVENT = 19
|
2016-05-13 00:42:59 -07:00
|
|
|
};
|
|
|
|
|
|
2017-05-30 03:52:10 -07:00
|
|
|
enum class MediaType { ANY, AUDIO, VIDEO, DATA };
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
// Reads an RtcEventLog file and returns true if parsing was successful.
|
|
|
|
|
bool ParseFile(const std::string& file_name);
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
// Reads an RtcEventLog from a string and returns true if successful.
|
|
|
|
|
bool ParseString(const std::string& s);
|
|
|
|
|
|
|
|
|
|
// Reads an RtcEventLog from an istream and returns true if successful.
|
|
|
|
|
bool ParseStream(std::istream& stream);
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
// Returns the number of events in an EventStream.
|
|
|
|
|
size_t GetNumberOfEvents() const;
|
|
|
|
|
|
|
|
|
|
// Reads the arrival timestamp (in microseconds) from a rtclog::Event.
|
|
|
|
|
int64_t GetTimestamp(size_t index) const;
|
|
|
|
|
|
|
|
|
|
// Reads the event type of the rtclog::Event at |index|.
|
|
|
|
|
EventType GetEventType(size_t index) const;
|
|
|
|
|
|
2017-05-30 03:52:10 -07:00
|
|
|
// Reads the header, direction, header length and packet length from the RTP
|
|
|
|
|
// event at |index|, and stores the values in the corresponding output
|
|
|
|
|
// parameters. Each output parameter can be set to nullptr if that value
|
|
|
|
|
// isn't needed.
|
2016-05-13 00:42:59 -07:00
|
|
|
// NB: The header must have space for at least IP_PACKET_SIZE bytes.
|
2017-06-12 01:02:46 -07:00
|
|
|
// Returns: a pointer to a header extensions map acquired from parsing
|
|
|
|
|
// corresponding Audio/Video Sender/Receiver config events.
|
|
|
|
|
// Warning: if the same SSRC is reused by both video and audio streams during
|
|
|
|
|
// call, extensions maps may be incorrect (the last one would be returned).
|
|
|
|
|
webrtc::RtpHeaderExtensionMap* GetRtpHeader(size_t index,
|
|
|
|
|
PacketDirection* incoming,
|
|
|
|
|
uint8_t* header,
|
|
|
|
|
size_t* header_length,
|
2017-10-03 15:01:03 +02:00
|
|
|
size_t* total_length,
|
|
|
|
|
int* probe_cluster_id) const;
|
2016-05-13 00:42:59 -07:00
|
|
|
|
2017-05-30 03:52:10 -07:00
|
|
|
// Reads packet, direction and packet length from the RTCP event at |index|,
|
|
|
|
|
// and stores the values in the corresponding output parameters.
|
2017-02-17 03:38:28 -08:00
|
|
|
// Each output parameter can be set to nullptr if that value isn't needed.
|
2016-05-13 00:42:59 -07:00
|
|
|
// NB: The packet must have space for at least IP_PACKET_SIZE bytes.
|
|
|
|
|
void GetRtcpPacket(size_t index,
|
|
|
|
|
PacketDirection* incoming,
|
|
|
|
|
uint8_t* packet,
|
|
|
|
|
size_t* length) const;
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
// Reads a video receive config event to a StreamConfig struct.
|
2016-05-13 00:42:59 -07:00
|
|
|
// Only the fields that are stored in the protobuf will be written.
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig GetVideoReceiveConfig(size_t index) const;
|
2016-05-13 00:42:59 -07:00
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
// Reads a video send config event to a StreamConfig struct. If the proto
|
|
|
|
|
// contains multiple SSRCs and RTX SSRCs (this used to be the case for
|
|
|
|
|
// simulcast streams) then we return one StreamConfig per SSRC,RTX_SSRC pair.
|
2016-05-13 00:42:59 -07:00
|
|
|
// Only the fields that are stored in the protobuf will be written.
|
2017-05-31 02:03:16 -07:00
|
|
|
std::vector<rtclog::StreamConfig> GetVideoSendConfig(size_t index) const;
|
2016-10-10 05:12:51 -07:00
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
// Reads a audio receive config event to a StreamConfig struct.
|
2016-10-10 05:12:51 -07:00
|
|
|
// Only the fields that are stored in the protobuf will be written.
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig GetAudioReceiveConfig(size_t index) const;
|
2016-10-10 05:12:51 -07:00
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
// Reads a config event to a StreamConfig struct.
|
2016-10-10 05:12:51 -07:00
|
|
|
// Only the fields that are stored in the protobuf will be written.
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig GetAudioSendConfig(size_t index) const;
|
2016-05-13 00:42:59 -07:00
|
|
|
|
|
|
|
|
// Reads the SSRC from the audio playout event at |index|. The SSRC is stored
|
|
|
|
|
// in the output parameter ssrc. The output parameter can be set to nullptr
|
|
|
|
|
// and in that case the function only asserts that the event is well formed.
|
|
|
|
|
void GetAudioPlayout(size_t index, uint32_t* ssrc) const;
|
|
|
|
|
|
|
|
|
|
// Reads bitrate, fraction loss (as defined in RFC 1889) and total number of
|
2017-02-17 03:38:28 -08:00
|
|
|
// expected packets from the loss based BWE event at |index| and stores the
|
|
|
|
|
// values in
|
|
|
|
|
// the corresponding output parameters. Each output parameter can be set to
|
|
|
|
|
// nullptr if that
|
|
|
|
|
// value isn't needed.
|
2017-02-20 05:14:41 -08:00
|
|
|
void GetLossBasedBweUpdate(size_t index,
|
|
|
|
|
int32_t* bitrate_bps,
|
2016-05-13 00:42:59 -07:00
|
|
|
uint8_t* fraction_loss,
|
|
|
|
|
int32_t* total_packets) const;
|
|
|
|
|
|
2017-02-17 03:38:28 -08:00
|
|
|
// Reads bitrate and detector_state from the delay based BWE event at |index|
|
|
|
|
|
// and stores the values in the corresponding output parameters. Each output
|
|
|
|
|
// parameter can be set to nullptr if that
|
|
|
|
|
// value isn't needed.
|
2017-04-11 01:50:23 -07:00
|
|
|
BweDelayBasedUpdate GetDelayBasedBweUpdate(size_t index) const;
|
2017-02-17 03:38:28 -08:00
|
|
|
|
2017-01-24 04:54:59 -08:00
|
|
|
// Reads a audio network adaptation event to a (non-NULL)
|
2017-04-06 05:59:10 -07:00
|
|
|
// AudioEncoderRuntimeConfig struct. Only the fields that are
|
2017-01-24 04:54:59 -08:00
|
|
|
// stored in the protobuf will be written.
|
2017-04-06 05:59:10 -07:00
|
|
|
void GetAudioNetworkAdaptation(size_t index,
|
|
|
|
|
AudioEncoderRuntimeConfig* config) const;
|
2017-01-24 04:54:59 -08:00
|
|
|
|
2017-05-30 03:52:10 -07:00
|
|
|
BweProbeClusterCreatedEvent GetBweProbeClusterCreated(size_t index) const;
|
2017-03-29 16:28:53 +02:00
|
|
|
|
2017-05-30 03:52:10 -07:00
|
|
|
BweProbeResultEvent GetBweProbeResult(size_t index) const;
|
|
|
|
|
|
|
|
|
|
MediaType GetMediaType(uint32_t ssrc, PacketDirection direction) const;
|
2017-03-29 16:28:53 +02:00
|
|
|
|
2017-12-05 13:19:45 +01:00
|
|
|
AlrStateEvent GetAlrState(size_t index) const;
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
private:
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig GetVideoReceiveConfig(const rtclog::Event& event) const;
|
|
|
|
|
std::vector<rtclog::StreamConfig> GetVideoSendConfig(
|
|
|
|
|
const rtclog::Event& event) const;
|
|
|
|
|
rtclog::StreamConfig GetAudioReceiveConfig(const rtclog::Event& event) const;
|
|
|
|
|
rtclog::StreamConfig GetAudioSendConfig(const rtclog::Event& event) const;
|
2017-05-30 03:52:10 -07:00
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
std::vector<rtclog::Event> events_;
|
2017-05-30 03:52:10 -07:00
|
|
|
|
|
|
|
|
struct Stream {
|
|
|
|
|
Stream(uint32_t ssrc,
|
|
|
|
|
MediaType media_type,
|
2017-06-12 01:02:46 -07:00
|
|
|
webrtc::PacketDirection direction,
|
|
|
|
|
webrtc::RtpHeaderExtensionMap map)
|
|
|
|
|
: ssrc(ssrc),
|
|
|
|
|
media_type(media_type),
|
|
|
|
|
direction(direction),
|
|
|
|
|
rtp_extensions_map(map) {}
|
2017-05-30 03:52:10 -07:00
|
|
|
uint32_t ssrc;
|
|
|
|
|
MediaType media_type;
|
|
|
|
|
webrtc::PacketDirection direction;
|
2017-06-12 01:02:46 -07:00
|
|
|
webrtc::RtpHeaderExtensionMap rtp_extensions_map;
|
2017-05-30 03:52:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// All configured streams found in the event log.
|
|
|
|
|
std::vector<Stream> streams_;
|
2017-06-12 01:02:46 -07:00
|
|
|
|
|
|
|
|
// To find configured extensions map for given stream, what are needed to
|
|
|
|
|
// parse a header.
|
|
|
|
|
typedef std::pair<uint32_t, webrtc::PacketDirection> StreamId;
|
|
|
|
|
std::map<StreamId, webrtc::RtpHeaderExtensionMap*> rtp_extensions_maps_;
|
2016-05-13 00:42:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_
|