webrtc_m130/logging/rtc_event_log/rtc_event_log_parser.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

213 lines
8.0 KiB
C
Raw Normal View History

/*
* 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.
*/
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_
#include <map>
#include <string>
#include <utility> // pair
#include <vector>
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
#include "logging/rtc_event_log/rtc_event_log.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "rtc_base/ignore_wundef.h"
// Files generated at build-time by the protobuf compiler.
RTC_PUSH_IGNORING_WUNDEF()
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
#include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
#else
#include "logging/rtc_event_log/rtc_event_log.pb.h"
#endif
RTC_POP_IGNORING_WUNDEF()
namespace webrtc {
enum class MediaType;
class ParsedRtcEventLog {
friend class RtcEventLogTestHelper;
public:
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;
};
struct BweDelayBasedUpdate {
uint64_t timestamp;
int32_t bitrate_bps;
BandwidthUsage detector_state;
};
enum EventType {
UNKNOWN_EVENT = 0,
LOG_START = 1,
LOG_END = 2,
RTP_EVENT = 3,
RTCP_EVENT = 4,
AUDIO_PLAYOUT_EVENT = 5,
LOSS_BASED_BWE_UPDATE = 6,
DELAY_BASED_BWE_UPDATE = 7,
VIDEO_RECEIVER_CONFIG_EVENT = 8,
VIDEO_SENDER_CONFIG_EVENT = 9,
AUDIO_RECEIVER_CONFIG_EVENT = 10,
AUDIO_SENDER_CONFIG_EVENT = 11,
AUDIO_NETWORK_ADAPTATION_EVENT = 16,
BWE_PROBE_CLUSTER_CREATED_EVENT = 17,
Revert of Add logging of host lookups made by TurnPort to the RtcEventLog. (patchset #11 id:200001 of https://codereview.webrtc.org/2996933003/ ) Reason for revert: Breaks Chromium build due to the changed constructor in webrtc/p2p/client/basicportallocator.h. Build (example): https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/19739. Log: FAILED: obj/remoting/protocol/protocol/port_allocator.o /b/c/goma_client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/protocol/protocol/port_allocator.o.d -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"310694-2\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCOMPONENT_BUILD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_GLIBCXX_DEBUG=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DEXPAT_RELATIVE_PATH -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DFEATURE_ENABLE_VOICEMAIL -DGTEST_RELATIVE_PATH -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DBORINGSSL_SHARED_LIBRARY -I../.. -Igen -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../third_party/libwebp/src -I../../third_party/khronos -I../../gpu -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/protobuf/src -I../../third_party/webrtc_overrides -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc_overrides -I../../third_party -I../../third_party/boringssl/src/include -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fdebug-prefix-map=/b/c/b/Linux_Builder__dbg_/src=. -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-auto-raw-pointer -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wno-header-guard -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=gnu++14 -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_jessie_amd64-sysroot -fno-exceptions -fvisibility-inlines-hidden -c ../../remoting/protocol/port_allocator.cc -o obj/remoting/protocol/protocol/port_allocator.o ../../remoting/protocol/port_allocator.cc:48:7: error: no matching constructor for initialization of 'cricket::BasicPortAllocator' : BasicPortAllocator(network_manager.get(), socket_factory.get()), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../third_party/webrtc/p2p/client/basicportallocator.h:35:12: note: candidate constructor not viable: requires single argument 'network_manager', but 2 arguments were provided explicit BasicPortAllocator(rtc::NetworkManager* network_manager); ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:30:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided class BasicPortAllocator : public PortAllocator { ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:32:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:36:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:39:3: note: candidate constructor not viable: requires 5 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ 1 error generated. Original issue's description: > Add logging host lookups made by TurnPort to the RtcEventLog. > > The following fields are logged: > - error, if there was an error. > - elapsed time in milliseconds > > BUG=webrtc:8100 > > Review-Url: https://codereview.webrtc.org/2996933003 > Cr-Commit-Position: refs/heads/master@{#19574} > Committed: https://chromium.googlesource.com/external/webrtc/+/c251cb13c08aba710ba3a12588beb4aa172c7323 TBR=terelius@webrtc.org,pthatcher@webrtc.org,jonaso@google.com,pthatcher@google.com,solenberg@webrtc.org,deadbeef@webrtc.org,jonaso@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:8100 Review-Url: https://codereview.webrtc.org/3012473002 Cr-Commit-Position: refs/heads/master@{#19578}
2017-08-29 04:49:00 -07:00
BWE_PROBE_RESULT_EVENT = 18
};
enum class MediaType { ANY, AUDIO, VIDEO, DATA };
// Reads an RtcEventLog file and returns true if parsing was successful.
bool ParseFile(const std::string& file_name);
// 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);
// 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;
// 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.
// NB: The header must have space for at least IP_PACKET_SIZE bytes.
// 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,
size_t* total_length) const;
// Reads packet, direction and packet length from the RTCP 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.
// 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;
// Reads a video receive config event to a StreamConfig struct.
// Only the fields that are stored in the protobuf will be written.
rtclog::StreamConfig GetVideoReceiveConfig(size_t index) const;
// 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.
// Only the fields that are stored in the protobuf will be written.
std::vector<rtclog::StreamConfig> GetVideoSendConfig(size_t index) const;
// Reads a audio receive config event to a StreamConfig struct.
// Only the fields that are stored in the protobuf will be written.
rtclog::StreamConfig GetAudioReceiveConfig(size_t index) const;
// Reads a config event to a StreamConfig struct.
// Only the fields that are stored in the protobuf will be written.
rtclog::StreamConfig GetAudioSendConfig(size_t index) const;
// 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
// 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.
void GetLossBasedBweUpdate(size_t index,
int32_t* bitrate_bps,
uint8_t* fraction_loss,
int32_t* total_packets) const;
// 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.
BweDelayBasedUpdate GetDelayBasedBweUpdate(size_t index) const;
// Reads a audio network adaptation event to a (non-NULL)
// AudioEncoderRuntimeConfig struct. Only the fields that are
// stored in the protobuf will be written.
void GetAudioNetworkAdaptation(size_t index,
AudioEncoderRuntimeConfig* config) const;
BweProbeClusterCreatedEvent GetBweProbeClusterCreated(size_t index) const;
BweProbeResultEvent GetBweProbeResult(size_t index) const;
MediaType GetMediaType(uint32_t ssrc, PacketDirection direction) const;
private:
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;
std::vector<rtclog::Event> events_;
struct Stream {
Stream(uint32_t ssrc,
MediaType media_type,
webrtc::PacketDirection direction,
webrtc::RtpHeaderExtensionMap map)
: ssrc(ssrc),
media_type(media_type),
direction(direction),
rtp_extensions_map(map) {}
uint32_t ssrc;
MediaType media_type;
webrtc::PacketDirection direction;
webrtc::RtpHeaderExtensionMap rtp_extensions_map;
};
// All configured streams found in the event log.
std::vector<Stream> streams_;
// 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_;
};
} // namespace webrtc
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_