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.
|
|
|
|
|
*/
|
|
|
|
|
|
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 "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
|
Reland of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #1 id:1 of https://codereview.webrtc.org/2649323010/ )
Reason for revert:
Downstream project relied on changed struct.
Transition made possible by https://codereview.webrtc.org/2655243006/.
Original issue's description:
> Revert of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #7 id:160001 of https://codereview.webrtc.org/2646073004/ )
>
> Reason for revert:
> Breaks internal downstream project.
>
> Original issue's description:
> > Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters.
> >
> > Prior to this CL, received RTX (associated) payload types were only configured
> > when WebRtcVideoChannel2::AddRecvStream was called. In the same method, the RTX
> > SSRC was set up.
> >
> > After this CL, the RTX (associated) payload types are set in
> > WebRtcVideoChannel2::SetRecvParameters, which is the appropriate place to set
> > them. The RTX SSRC is still set in WebRtcVideoChannel2::AddRecvStream, since
> > that is the code path that sets other SSRCs.
> >
> > As part of this fix, the VideoReceiveStream::Config::Rtp struct is changed.
> > We remove the possibility for each video payload type to have an associated
> > specific RTX SSRC. Although the config previously allowed for this, all payload
> > types always had the same RTX SSRC set, and the underlying RtpPayloadRegistry
> > did not support multiple SSRCs. This change to the config struct should thus not
> > have any functional impact. The change does however affect the RtcEventLog, since
> > that is used for storing the VideoReceiveStream::Configs. For simplicity,
> > this CL does not change the event log proto definitions, instead duplicating
> > the serialized RTX SSRCs such that they fit in the existing proto definition.
> >
> > BUG=webrtc:7011
> >
> > Review-Url: https://codereview.webrtc.org/2646073004
> > Cr-Commit-Position: refs/heads/master@{#16302}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fe2bef39cd2a5c891a49f7320514fb04324dc66c
>
> TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,brandtr@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7011
>
> Review-Url: https://codereview.webrtc.org/2649323010
> Cr-Commit-Position: refs/heads/master@{#16307}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e4974953ce0d03a60fae7659b199a6a62a79fa30
TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
# NOTREECHECKS=true
# NOTRY=true
BUG=webrtc:7011
Review-Url: https://codereview.webrtc.org/2654163006
Cr-Commit-Position: refs/heads/master@{#16322}
2017-01-27 04:53:07 -08:00
|
|
|
#include <stdint.h>
|
2016-05-13 00:42:59 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
|
Reland of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #1 id:1 of https://codereview.webrtc.org/2649323010/ )
Reason for revert:
Downstream project relied on changed struct.
Transition made possible by https://codereview.webrtc.org/2655243006/.
Original issue's description:
> Revert of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #7 id:160001 of https://codereview.webrtc.org/2646073004/ )
>
> Reason for revert:
> Breaks internal downstream project.
>
> Original issue's description:
> > Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters.
> >
> > Prior to this CL, received RTX (associated) payload types were only configured
> > when WebRtcVideoChannel2::AddRecvStream was called. In the same method, the RTX
> > SSRC was set up.
> >
> > After this CL, the RTX (associated) payload types are set in
> > WebRtcVideoChannel2::SetRecvParameters, which is the appropriate place to set
> > them. The RTX SSRC is still set in WebRtcVideoChannel2::AddRecvStream, since
> > that is the code path that sets other SSRCs.
> >
> > As part of this fix, the VideoReceiveStream::Config::Rtp struct is changed.
> > We remove the possibility for each video payload type to have an associated
> > specific RTX SSRC. Although the config previously allowed for this, all payload
> > types always had the same RTX SSRC set, and the underlying RtpPayloadRegistry
> > did not support multiple SSRCs. This change to the config struct should thus not
> > have any functional impact. The change does however affect the RtcEventLog, since
> > that is used for storing the VideoReceiveStream::Configs. For simplicity,
> > this CL does not change the event log proto definitions, instead duplicating
> > the serialized RTX SSRCs such that they fit in the existing proto definition.
> >
> > BUG=webrtc:7011
> >
> > Review-Url: https://codereview.webrtc.org/2646073004
> > Cr-Commit-Position: refs/heads/master@{#16302}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fe2bef39cd2a5c891a49f7320514fb04324dc66c
>
> TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,brandtr@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7011
>
> Review-Url: https://codereview.webrtc.org/2649323010
> Cr-Commit-Position: refs/heads/master@{#16307}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e4974953ce0d03a60fae7659b199a6a62a79fa30
TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
# NOTREECHECKS=true
# NOTRY=true
BUG=webrtc:7011
Review-Url: https://codereview.webrtc.org/2654163006
Cr-Commit-Position: refs/heads/master@{#16322}
2017-01-27 04:53:07 -08:00
|
|
|
#include <algorithm>
|
2016-05-13 00:42:59 -07:00
|
|
|
#include <fstream>
|
2016-08-22 11:35:47 -07:00
|
|
|
#include <istream>
|
2017-05-22 03:26:49 -07:00
|
|
|
#include <map>
|
2016-08-22 11:35:47 -07:00
|
|
|
#include <utility>
|
2016-05-13 00:42:59 -07:00
|
|
|
|
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 "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
2017-04-06 05:59:10 -07:00
|
|
|
#include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
|
2017-04-11 00:49:44 -07:00
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/checks.h"
|
|
|
|
|
#include "webrtc/rtc_base/logging.h"
|
|
|
|
|
#include "webrtc/rtc_base/protobuf_utils.h"
|
2016-05-13 00:42:59 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
RtcpMode GetRuntimeRtcpMode(rtclog::VideoReceiveConfig::RtcpMode rtcp_mode) {
|
|
|
|
|
switch (rtcp_mode) {
|
|
|
|
|
case rtclog::VideoReceiveConfig::RTCP_COMPOUND:
|
|
|
|
|
return RtcpMode::kCompound;
|
|
|
|
|
case rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE:
|
|
|
|
|
return RtcpMode::kReducedSize;
|
|
|
|
|
}
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
return RtcpMode::kOff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParsedRtcEventLog::EventType GetRuntimeEventType(
|
|
|
|
|
rtclog::Event::EventType event_type) {
|
|
|
|
|
switch (event_type) {
|
|
|
|
|
case rtclog::Event::UNKNOWN_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::UNKNOWN_EVENT;
|
|
|
|
|
case rtclog::Event::LOG_START:
|
|
|
|
|
return ParsedRtcEventLog::EventType::LOG_START;
|
|
|
|
|
case rtclog::Event::LOG_END:
|
|
|
|
|
return ParsedRtcEventLog::EventType::LOG_END;
|
|
|
|
|
case rtclog::Event::RTP_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::RTP_EVENT;
|
|
|
|
|
case rtclog::Event::RTCP_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::RTCP_EVENT;
|
|
|
|
|
case rtclog::Event::AUDIO_PLAYOUT_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::AUDIO_PLAYOUT_EVENT;
|
2017-02-20 05:14:41 -08:00
|
|
|
case rtclog::Event::LOSS_BASED_BWE_UPDATE:
|
|
|
|
|
return ParsedRtcEventLog::EventType::LOSS_BASED_BWE_UPDATE;
|
|
|
|
|
case rtclog::Event::DELAY_BASED_BWE_UPDATE:
|
|
|
|
|
return ParsedRtcEventLog::EventType::DELAY_BASED_BWE_UPDATE;
|
2016-05-13 00:42:59 -07:00
|
|
|
case rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::VIDEO_RECEIVER_CONFIG_EVENT;
|
|
|
|
|
case rtclog::Event::VIDEO_SENDER_CONFIG_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::VIDEO_SENDER_CONFIG_EVENT;
|
|
|
|
|
case rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::AUDIO_RECEIVER_CONFIG_EVENT;
|
|
|
|
|
case rtclog::Event::AUDIO_SENDER_CONFIG_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::AUDIO_SENDER_CONFIG_EVENT;
|
2017-01-24 04:54:59 -08:00
|
|
|
case rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::AUDIO_NETWORK_ADAPTATION_EVENT;
|
2017-02-27 02:18:46 -08:00
|
|
|
case rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::BWE_PROBE_CLUSTER_CREATED_EVENT;
|
|
|
|
|
case rtclog::Event::BWE_PROBE_RESULT_EVENT:
|
|
|
|
|
return ParsedRtcEventLog::EventType::BWE_PROBE_RESULT_EVENT;
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
return ParsedRtcEventLog::EventType::UNKNOWN_EVENT;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 03:38:28 -08:00
|
|
|
BandwidthUsage GetRuntimeDetectorState(
|
2017-02-20 05:14:41 -08:00
|
|
|
rtclog::DelayBasedBweUpdate::DetectorState detector_state) {
|
2017-02-17 03:38:28 -08:00
|
|
|
switch (detector_state) {
|
2017-02-20 05:14:41 -08:00
|
|
|
case rtclog::DelayBasedBweUpdate::BWE_NORMAL:
|
2017-04-11 00:49:44 -07:00
|
|
|
return BandwidthUsage::kBwNormal;
|
2017-02-20 05:14:41 -08:00
|
|
|
case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING:
|
2017-04-11 00:49:44 -07:00
|
|
|
return BandwidthUsage::kBwUnderusing;
|
2017-02-20 05:14:41 -08:00
|
|
|
case rtclog::DelayBasedBweUpdate::BWE_OVERUSING:
|
2017-04-11 00:49:44 -07:00
|
|
|
return BandwidthUsage::kBwOverusing;
|
2017-02-17 03:38:28 -08:00
|
|
|
}
|
|
|
|
|
RTC_NOTREACHED();
|
2017-04-11 00:49:44 -07:00
|
|
|
return BandwidthUsage::kBwNormal;
|
2017-02-17 03:38:28 -08:00
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
std::pair<uint64_t, bool> ParseVarInt(std::istream& stream) {
|
|
|
|
|
uint64_t varint = 0;
|
|
|
|
|
for (size_t bytes_read = 0; bytes_read < 10; ++bytes_read) {
|
2016-05-13 00:42:59 -07:00
|
|
|
// The most significant bit of each byte is 0 if it is the last byte in
|
|
|
|
|
// the varint and 1 otherwise. Thus, we take the 7 least significant bits
|
|
|
|
|
// of each byte and shift them 7 bits for each byte read previously to get
|
|
|
|
|
// the (unsigned) integer.
|
2016-08-22 11:35:47 -07:00
|
|
|
int byte = stream.get();
|
|
|
|
|
if (stream.eof()) {
|
|
|
|
|
return std::make_pair(varint, false);
|
|
|
|
|
}
|
2017-08-09 17:22:01 -07:00
|
|
|
RTC_DCHECK_GE(byte, 0);
|
|
|
|
|
RTC_DCHECK_LE(byte, 255);
|
2016-08-22 11:35:47 -07:00
|
|
|
varint |= static_cast<uint64_t>(byte & 0x7F) << (7 * bytes_read);
|
2016-05-13 00:42:59 -07:00
|
|
|
if ((byte & 0x80) == 0) {
|
2016-08-22 11:35:47 -07:00
|
|
|
return std::make_pair(varint, true);
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
}
|
2016-08-22 11:35:47 -07:00
|
|
|
return std::make_pair(varint, false);
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
2016-10-10 05:12:51 -07:00
|
|
|
void GetHeaderExtensions(
|
|
|
|
|
std::vector<RtpExtension>* header_extensions,
|
2017-04-07 00:59:12 -07:00
|
|
|
const RepeatedPtrField<rtclog::RtpHeaderExtension>&
|
|
|
|
|
proto_header_extensions) {
|
2016-10-10 05:12:51 -07:00
|
|
|
header_extensions->clear();
|
|
|
|
|
for (auto& p : proto_header_extensions) {
|
|
|
|
|
RTC_CHECK(p.has_name());
|
|
|
|
|
RTC_CHECK(p.has_id());
|
|
|
|
|
const std::string& name = p.name();
|
|
|
|
|
int id = p.id();
|
|
|
|
|
header_extensions->push_back(RtpExtension(name, id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
bool ParsedRtcEventLog::ParseFile(const std::string& filename) {
|
2016-08-22 11:35:47 -07:00
|
|
|
std::ifstream file(filename, std::ios_base::in | std::ios_base::binary);
|
|
|
|
|
if (!file.good() || !file.is_open()) {
|
2016-05-13 00:42:59 -07:00
|
|
|
LOG(LS_WARNING) << "Could not open file for reading.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
return ParseStream(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ParsedRtcEventLog::ParseString(const std::string& s) {
|
|
|
|
|
std::istringstream stream(s, std::ios_base::in | std::ios_base::binary);
|
|
|
|
|
return ParseStream(stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ParsedRtcEventLog::ParseStream(std::istream& stream) {
|
|
|
|
|
events_.clear();
|
|
|
|
|
const size_t kMaxEventSize = (1u << 16) - 1;
|
2016-09-02 13:22:26 -07:00
|
|
|
std::vector<char> tmp_buffer(kMaxEventSize);
|
2016-08-22 11:35:47 -07:00
|
|
|
uint64_t tag;
|
|
|
|
|
uint64_t message_length;
|
|
|
|
|
bool success;
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK(stream.good());
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
while (1) {
|
2016-08-22 11:35:47 -07:00
|
|
|
// Check whether we have reached end of file.
|
|
|
|
|
stream.peek();
|
|
|
|
|
if (stream.eof()) {
|
2017-06-12 01:02:46 -07:00
|
|
|
// Process all extensions maps for faster look-up later.
|
|
|
|
|
for (auto& event_stream : streams_) {
|
|
|
|
|
rtp_extensions_maps_[StreamId(event_stream.ssrc,
|
|
|
|
|
event_stream.direction)] =
|
|
|
|
|
&event_stream.rtp_extensions_map;
|
|
|
|
|
}
|
2016-08-22 11:35:47 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read the next message tag. The tag number is defined as
|
2016-05-13 00:42:59 -07:00
|
|
|
// (fieldnumber << 3) | wire_type. In our case, the field number is
|
2017-05-30 03:52:10 -07:00
|
|
|
// supposed to be 1 and the wire type for an
|
|
|
|
|
// length-delimited field is 2.
|
2016-05-13 00:42:59 -07:00
|
|
|
const uint64_t kExpectedTag = (1 << 3) | 2;
|
2016-08-22 11:35:47 -07:00
|
|
|
std::tie(tag, success) = ParseVarInt(stream);
|
|
|
|
|
if (!success) {
|
2016-05-13 00:42:59 -07:00
|
|
|
LOG(LS_WARNING) << "Missing field tag from beginning of protobuf event.";
|
|
|
|
|
return false;
|
2016-08-22 11:35:47 -07:00
|
|
|
} else if (tag != kExpectedTag) {
|
|
|
|
|
LOG(LS_WARNING) << "Unexpected field tag at beginning of protobuf event.";
|
|
|
|
|
return false;
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
// Read the length field.
|
|
|
|
|
std::tie(message_length, success) = ParseVarInt(stream);
|
|
|
|
|
if (!success) {
|
2016-05-13 00:42:59 -07:00
|
|
|
LOG(LS_WARNING) << "Missing message length after protobuf field tag.";
|
|
|
|
|
return false;
|
|
|
|
|
} else if (message_length > kMaxEventSize) {
|
|
|
|
|
LOG(LS_WARNING) << "Protobuf message length is too large.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
// Read the next protobuf event to a temporary char buffer.
|
2016-09-02 13:22:26 -07:00
|
|
|
stream.read(tmp_buffer.data(), message_length);
|
2016-08-22 11:35:47 -07:00
|
|
|
if (stream.gcount() != static_cast<int>(message_length)) {
|
2016-05-13 00:42:59 -07:00
|
|
|
LOG(LS_WARNING) << "Failed to read protobuf message from file.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
// Parse the protobuf event from the buffer.
|
2016-05-13 00:42:59 -07:00
|
|
|
rtclog::Event event;
|
2016-09-02 13:22:26 -07:00
|
|
|
if (!event.ParseFromArray(tmp_buffer.data(), message_length)) {
|
2016-05-13 00:42:59 -07:00
|
|
|
LOG(LS_WARNING) << "Failed to parse protobuf message.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-05-30 03:52:10 -07:00
|
|
|
|
|
|
|
|
EventType type = GetRuntimeEventType(event.type());
|
|
|
|
|
switch (type) {
|
|
|
|
|
case VIDEO_RECEIVER_CONFIG_EVENT: {
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig config = GetVideoReceiveConfig(event);
|
2017-05-30 03:52:10 -07:00
|
|
|
streams_.emplace_back(config.remote_ssrc, MediaType::VIDEO,
|
2017-06-12 01:02:46 -07:00
|
|
|
kIncomingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(config.rtp_extensions));
|
2017-05-30 03:52:10 -07:00
|
|
|
streams_.emplace_back(config.local_ssrc, MediaType::VIDEO,
|
2017-06-12 01:02:46 -07:00
|
|
|
kOutgoingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(config.rtp_extensions));
|
2017-05-30 03:52:10 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case VIDEO_SENDER_CONFIG_EVENT: {
|
2017-05-31 02:03:16 -07:00
|
|
|
std::vector<rtclog::StreamConfig> configs = GetVideoSendConfig(event);
|
|
|
|
|
for (size_t i = 0; i < configs.size(); i++) {
|
2017-06-12 01:02:46 -07:00
|
|
|
streams_.emplace_back(
|
|
|
|
|
configs[i].local_ssrc, MediaType::VIDEO, kOutgoingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(configs[i].rtp_extensions));
|
2017-05-31 02:03:16 -07:00
|
|
|
|
2017-06-12 01:02:46 -07:00
|
|
|
streams_.emplace_back(
|
|
|
|
|
configs[i].rtx_ssrc, MediaType::VIDEO, kOutgoingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(configs[i].rtp_extensions));
|
2017-05-31 02:03:16 -07:00
|
|
|
}
|
2017-05-30 03:52:10 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case AUDIO_RECEIVER_CONFIG_EVENT: {
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig config = GetAudioReceiveConfig(event);
|
2017-05-30 03:52:10 -07:00
|
|
|
streams_.emplace_back(config.remote_ssrc, MediaType::AUDIO,
|
2017-06-12 01:02:46 -07:00
|
|
|
kIncomingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(config.rtp_extensions));
|
2017-05-30 03:52:10 -07:00
|
|
|
streams_.emplace_back(config.local_ssrc, MediaType::AUDIO,
|
2017-06-12 01:02:46 -07:00
|
|
|
kOutgoingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(config.rtp_extensions));
|
2017-05-30 03:52:10 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case AUDIO_SENDER_CONFIG_EVENT: {
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig config = GetAudioSendConfig(event);
|
2017-05-30 03:52:10 -07:00
|
|
|
streams_.emplace_back(config.local_ssrc, MediaType::AUDIO,
|
2017-06-12 01:02:46 -07:00
|
|
|
kOutgoingPacket,
|
|
|
|
|
RtpHeaderExtensionMap(config.rtp_extensions));
|
2017-05-30 03:52:10 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:35:47 -07:00
|
|
|
events_.push_back(event);
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t ParsedRtcEventLog::GetNumberOfEvents() const {
|
2016-08-22 11:35:47 -07:00
|
|
|
return events_.size();
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t ParsedRtcEventLog::GetTimestamp(size_t index) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_timestamp_us());
|
|
|
|
|
return event.timestamp_us();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParsedRtcEventLog::EventType ParsedRtcEventLog::GetEventType(
|
|
|
|
|
size_t index) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
return GetRuntimeEventType(event.type());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The header must have space for at least IP_PACKET_SIZE bytes.
|
2017-06-12 01:02:46 -07:00
|
|
|
webrtc::RtpHeaderExtensionMap* ParsedRtcEventLog::GetRtpHeader(
|
|
|
|
|
size_t index,
|
|
|
|
|
PacketDirection* incoming,
|
|
|
|
|
uint8_t* header,
|
|
|
|
|
size_t* header_length,
|
|
|
|
|
size_t* total_length) const {
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::RTP_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_rtp_packet());
|
|
|
|
|
const rtclog::RtpPacket& rtp_packet = event.rtp_packet();
|
|
|
|
|
// Get direction of packet.
|
|
|
|
|
RTC_CHECK(rtp_packet.has_incoming());
|
|
|
|
|
if (incoming != nullptr) {
|
|
|
|
|
*incoming = rtp_packet.incoming() ? kIncomingPacket : kOutgoingPacket;
|
|
|
|
|
}
|
|
|
|
|
// Get packet length.
|
|
|
|
|
RTC_CHECK(rtp_packet.has_packet_length());
|
|
|
|
|
if (total_length != nullptr) {
|
|
|
|
|
*total_length = rtp_packet.packet_length();
|
|
|
|
|
}
|
|
|
|
|
// Get header length.
|
|
|
|
|
RTC_CHECK(rtp_packet.has_header());
|
|
|
|
|
if (header_length != nullptr) {
|
|
|
|
|
*header_length = rtp_packet.header().size();
|
|
|
|
|
}
|
|
|
|
|
// Get header contents.
|
|
|
|
|
if (header != nullptr) {
|
|
|
|
|
const size_t kMinRtpHeaderSize = 12;
|
|
|
|
|
RTC_CHECK_GE(rtp_packet.header().size(), kMinRtpHeaderSize);
|
|
|
|
|
RTC_CHECK_LE(rtp_packet.header().size(),
|
|
|
|
|
static_cast<size_t>(IP_PACKET_SIZE));
|
|
|
|
|
memcpy(header, rtp_packet.header().data(), rtp_packet.header().size());
|
2017-06-12 01:02:46 -07:00
|
|
|
uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(header + 8);
|
|
|
|
|
StreamId stream_id(
|
|
|
|
|
ssrc, rtp_packet.incoming() ? kIncomingPacket : kOutgoingPacket);
|
|
|
|
|
auto it = rtp_extensions_maps_.find(stream_id);
|
|
|
|
|
if (it != rtp_extensions_maps_.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
2017-06-12 01:02:46 -07:00
|
|
|
return nullptr;
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The packet must have space for at least IP_PACKET_SIZE bytes.
|
|
|
|
|
void ParsedRtcEventLog::GetRtcpPacket(size_t index,
|
|
|
|
|
PacketDirection* incoming,
|
|
|
|
|
uint8_t* packet,
|
|
|
|
|
size_t* length) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::RTCP_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_rtcp_packet());
|
|
|
|
|
const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet();
|
|
|
|
|
// Get direction of packet.
|
|
|
|
|
RTC_CHECK(rtcp_packet.has_incoming());
|
|
|
|
|
if (incoming != nullptr) {
|
|
|
|
|
*incoming = rtcp_packet.incoming() ? kIncomingPacket : kOutgoingPacket;
|
|
|
|
|
}
|
|
|
|
|
// Get packet length.
|
|
|
|
|
RTC_CHECK(rtcp_packet.has_packet_data());
|
|
|
|
|
if (length != nullptr) {
|
|
|
|
|
*length = rtcp_packet.packet_data().size();
|
|
|
|
|
}
|
|
|
|
|
// Get packet contents.
|
|
|
|
|
if (packet != nullptr) {
|
|
|
|
|
RTC_CHECK_LE(rtcp_packet.packet_data().size(),
|
|
|
|
|
static_cast<unsigned>(IP_PACKET_SIZE));
|
|
|
|
|
memcpy(packet, rtcp_packet.packet_data().data(),
|
|
|
|
|
rtcp_packet.packet_data().size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetVideoReceiveConfig(
|
|
|
|
|
size_t index) const {
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2017-05-31 02:03:16 -07:00
|
|
|
return GetVideoReceiveConfig(events_[index]);
|
2017-05-30 03:52:10 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetVideoReceiveConfig(
|
|
|
|
|
const rtclog::Event& event) const {
|
|
|
|
|
rtclog::StreamConfig config;
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_video_receiver_config());
|
|
|
|
|
const rtclog::VideoReceiveConfig& receiver_config =
|
|
|
|
|
event.video_receiver_config();
|
|
|
|
|
// Get SSRCs.
|
|
|
|
|
RTC_CHECK(receiver_config.has_remote_ssrc());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.remote_ssrc = receiver_config.remote_ssrc();
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(receiver_config.has_local_ssrc());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.local_ssrc = receiver_config.local_ssrc();
|
|
|
|
|
config.rtx_ssrc = 0;
|
2016-05-13 00:42:59 -07:00
|
|
|
// Get RTCP settings.
|
|
|
|
|
RTC_CHECK(receiver_config.has_rtcp_mode());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.rtcp_mode = GetRuntimeRtcpMode(receiver_config.rtcp_mode());
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(receiver_config.has_remb());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.remb = receiver_config.remb();
|
2017-05-22 03:26:49 -07:00
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
// Get RTX map.
|
2017-05-22 03:26:49 -07:00
|
|
|
std::map<uint32_t, const rtclog::RtxConfig> rtx_map;
|
2016-05-13 00:42:59 -07:00
|
|
|
for (int i = 0; i < receiver_config.rtx_map_size(); i++) {
|
|
|
|
|
const rtclog::RtxMap& map = receiver_config.rtx_map(i);
|
|
|
|
|
RTC_CHECK(map.has_payload_type());
|
|
|
|
|
RTC_CHECK(map.has_config());
|
|
|
|
|
RTC_CHECK(map.config().has_rtx_ssrc());
|
|
|
|
|
RTC_CHECK(map.config().has_rtx_payload_type());
|
2017-05-22 03:26:49 -07:00
|
|
|
rtx_map.insert(std::make_pair(map.payload_type(), map.config()));
|
Reland of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #1 id:1 of https://codereview.webrtc.org/2649323010/ )
Reason for revert:
Downstream project relied on changed struct.
Transition made possible by https://codereview.webrtc.org/2655243006/.
Original issue's description:
> Revert of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #7 id:160001 of https://codereview.webrtc.org/2646073004/ )
>
> Reason for revert:
> Breaks internal downstream project.
>
> Original issue's description:
> > Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters.
> >
> > Prior to this CL, received RTX (associated) payload types were only configured
> > when WebRtcVideoChannel2::AddRecvStream was called. In the same method, the RTX
> > SSRC was set up.
> >
> > After this CL, the RTX (associated) payload types are set in
> > WebRtcVideoChannel2::SetRecvParameters, which is the appropriate place to set
> > them. The RTX SSRC is still set in WebRtcVideoChannel2::AddRecvStream, since
> > that is the code path that sets other SSRCs.
> >
> > As part of this fix, the VideoReceiveStream::Config::Rtp struct is changed.
> > We remove the possibility for each video payload type to have an associated
> > specific RTX SSRC. Although the config previously allowed for this, all payload
> > types always had the same RTX SSRC set, and the underlying RtpPayloadRegistry
> > did not support multiple SSRCs. This change to the config struct should thus not
> > have any functional impact. The change does however affect the RtcEventLog, since
> > that is used for storing the VideoReceiveStream::Configs. For simplicity,
> > this CL does not change the event log proto definitions, instead duplicating
> > the serialized RTX SSRCs such that they fit in the existing proto definition.
> >
> > BUG=webrtc:7011
> >
> > Review-Url: https://codereview.webrtc.org/2646073004
> > Cr-Commit-Position: refs/heads/master@{#16302}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fe2bef39cd2a5c891a49f7320514fb04324dc66c
>
> TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,brandtr@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7011
>
> Review-Url: https://codereview.webrtc.org/2649323010
> Cr-Commit-Position: refs/heads/master@{#16307}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e4974953ce0d03a60fae7659b199a6a62a79fa30
TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
# NOTREECHECKS=true
# NOTRY=true
BUG=webrtc:7011
Review-Url: https://codereview.webrtc.org/2654163006
Cr-Commit-Position: refs/heads/master@{#16322}
2017-01-27 04:53:07 -08:00
|
|
|
}
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
// Get header extensions.
|
2017-05-31 02:03:16 -07:00
|
|
|
GetHeaderExtensions(&config.rtp_extensions,
|
2016-10-10 05:12:51 -07:00
|
|
|
receiver_config.header_extensions());
|
2016-05-13 00:42:59 -07:00
|
|
|
// Get decoders.
|
2017-05-31 02:03:16 -07:00
|
|
|
config.codecs.clear();
|
2016-05-13 00:42:59 -07:00
|
|
|
for (int i = 0; i < receiver_config.decoders_size(); i++) {
|
|
|
|
|
RTC_CHECK(receiver_config.decoders(i).has_name());
|
|
|
|
|
RTC_CHECK(receiver_config.decoders(i).has_payload_type());
|
2017-05-22 03:26:49 -07:00
|
|
|
int rtx_payload_type = 0;
|
|
|
|
|
auto rtx_it = rtx_map.find(receiver_config.decoders(i).payload_type());
|
|
|
|
|
if (rtx_it != rtx_map.end()) {
|
|
|
|
|
rtx_payload_type = rtx_it->second.rtx_payload_type();
|
2017-05-31 02:03:16 -07:00
|
|
|
if (config.rtx_ssrc != 0 &&
|
|
|
|
|
config.rtx_ssrc != rtx_it->second.rtx_ssrc()) {
|
2017-05-22 03:26:49 -07:00
|
|
|
LOG(LS_WARNING)
|
|
|
|
|
<< "RtcEventLog protobuf contained different SSRCs for "
|
|
|
|
|
"different received RTX payload types. Will only use "
|
|
|
|
|
"rtx_ssrc = "
|
2017-05-31 02:03:16 -07:00
|
|
|
<< config.rtx_ssrc << ".";
|
2017-05-22 03:26:49 -07:00
|
|
|
} else {
|
2017-05-31 02:03:16 -07:00
|
|
|
config.rtx_ssrc = rtx_it->second.rtx_ssrc();
|
2017-05-22 03:26:49 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
config.codecs.emplace_back(receiver_config.decoders(i).name(),
|
|
|
|
|
receiver_config.decoders(i).payload_type(),
|
|
|
|
|
rtx_payload_type);
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
return config;
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
std::vector<rtclog::StreamConfig> ParsedRtcEventLog::GetVideoSendConfig(
|
|
|
|
|
size_t index) const {
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2017-05-31 02:03:16 -07:00
|
|
|
return GetVideoSendConfig(events_[index]);
|
2017-05-30 03:52:10 -07:00
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
|
|
|
|
|
std::vector<rtclog::StreamConfig> ParsedRtcEventLog::GetVideoSendConfig(
|
|
|
|
|
const rtclog::Event& event) const {
|
|
|
|
|
std::vector<rtclog::StreamConfig> configs;
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::VIDEO_SENDER_CONFIG_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_video_sender_config());
|
|
|
|
|
const rtclog::VideoSendConfig& sender_config = event.video_sender_config();
|
2017-05-31 02:03:16 -07:00
|
|
|
if (sender_config.rtx_ssrcs_size() > 0 &&
|
|
|
|
|
sender_config.ssrcs_size() != sender_config.rtx_ssrcs_size()) {
|
|
|
|
|
LOG(WARNING) << "VideoSendConfig is configured for RTX but the number of "
|
|
|
|
|
"SSRCs doesn't match the number of RTX SSRCs.";
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
configs.resize(sender_config.ssrcs_size());
|
|
|
|
|
for (int i = 0; i < sender_config.ssrcs_size(); i++) {
|
|
|
|
|
// Get SSRCs.
|
|
|
|
|
configs[i].local_ssrc = sender_config.ssrcs(i);
|
|
|
|
|
if (sender_config.rtx_ssrcs_size() > 0 &&
|
|
|
|
|
i < sender_config.rtx_ssrcs_size()) {
|
|
|
|
|
RTC_CHECK(sender_config.has_rtx_payload_type());
|
|
|
|
|
configs[i].rtx_ssrc = sender_config.rtx_ssrcs(i);
|
2017-05-22 04:08:28 -07:00
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
// Get header extensions.
|
|
|
|
|
GetHeaderExtensions(&configs[i].rtp_extensions,
|
|
|
|
|
sender_config.header_extensions());
|
|
|
|
|
|
|
|
|
|
// Get the codec.
|
|
|
|
|
RTC_CHECK(sender_config.has_encoder());
|
|
|
|
|
RTC_CHECK(sender_config.encoder().has_name());
|
|
|
|
|
RTC_CHECK(sender_config.encoder().has_payload_type());
|
|
|
|
|
configs[i].codecs.emplace_back(
|
|
|
|
|
sender_config.encoder().name(), sender_config.encoder().payload_type(),
|
|
|
|
|
sender_config.has_rtx_payload_type() ? sender_config.rtx_payload_type()
|
|
|
|
|
: 0);
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
2017-05-31 02:03:16 -07:00
|
|
|
return configs;
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetAudioReceiveConfig(
|
|
|
|
|
size_t index) const {
|
2016-10-10 05:12:51 -07:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2017-05-31 02:03:16 -07:00
|
|
|
return GetAudioReceiveConfig(events_[index]);
|
2017-05-30 03:52:10 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetAudioReceiveConfig(
|
|
|
|
|
const rtclog::Event& event) const {
|
|
|
|
|
rtclog::StreamConfig config;
|
2016-10-10 05:12:51 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_audio_receiver_config());
|
|
|
|
|
const rtclog::AudioReceiveConfig& receiver_config =
|
|
|
|
|
event.audio_receiver_config();
|
|
|
|
|
// Get SSRCs.
|
|
|
|
|
RTC_CHECK(receiver_config.has_remote_ssrc());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.remote_ssrc = receiver_config.remote_ssrc();
|
2016-10-10 05:12:51 -07:00
|
|
|
RTC_CHECK(receiver_config.has_local_ssrc());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.local_ssrc = receiver_config.local_ssrc();
|
2016-10-10 05:12:51 -07:00
|
|
|
// Get header extensions.
|
2017-05-31 02:03:16 -07:00
|
|
|
GetHeaderExtensions(&config.rtp_extensions,
|
2016-10-10 05:12:51 -07:00
|
|
|
receiver_config.header_extensions());
|
2017-05-31 02:03:16 -07:00
|
|
|
return config;
|
2016-10-10 05:12:51 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetAudioSendConfig(size_t index) const {
|
2016-10-10 05:12:51 -07:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2017-05-31 02:03:16 -07:00
|
|
|
return GetAudioSendConfig(events_[index]);
|
2017-05-30 03:52:10 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-31 02:03:16 -07:00
|
|
|
rtclog::StreamConfig ParsedRtcEventLog::GetAudioSendConfig(
|
|
|
|
|
const rtclog::Event& event) const {
|
|
|
|
|
rtclog::StreamConfig config;
|
2016-10-10 05:12:51 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_SENDER_CONFIG_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_audio_sender_config());
|
|
|
|
|
const rtclog::AudioSendConfig& sender_config = event.audio_sender_config();
|
|
|
|
|
// Get SSRCs.
|
|
|
|
|
RTC_CHECK(sender_config.has_ssrc());
|
2017-05-31 02:03:16 -07:00
|
|
|
config.local_ssrc = sender_config.ssrc();
|
2016-10-10 05:12:51 -07:00
|
|
|
// Get header extensions.
|
2017-05-31 02:03:16 -07:00
|
|
|
GetHeaderExtensions(&config.rtp_extensions,
|
2016-10-10 05:12:51 -07:00
|
|
|
sender_config.header_extensions());
|
2017-05-31 02:03:16 -07:00
|
|
|
return config;
|
2016-10-10 05:12:51 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-13 00:42:59 -07:00
|
|
|
void ParsedRtcEventLog::GetAudioPlayout(size_t index, uint32_t* ssrc) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_PLAYOUT_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_audio_playout_event());
|
|
|
|
|
const rtclog::AudioPlayoutEvent& loss_event = event.audio_playout_event();
|
|
|
|
|
RTC_CHECK(loss_event.has_local_ssrc());
|
|
|
|
|
if (ssrc != nullptr) {
|
|
|
|
|
*ssrc = loss_event.local_ssrc();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-20 05:14:41 -08:00
|
|
|
void ParsedRtcEventLog::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 {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
2016-08-22 11:35:47 -07:00
|
|
|
const rtclog::Event& event = events_[index];
|
2016-05-13 00:42:59 -07:00
|
|
|
RTC_CHECK(event.has_type());
|
2017-02-20 05:14:41 -08:00
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::LOSS_BASED_BWE_UPDATE);
|
|
|
|
|
RTC_CHECK(event.has_loss_based_bwe_update());
|
|
|
|
|
const rtclog::LossBasedBweUpdate& loss_event = event.loss_based_bwe_update();
|
|
|
|
|
RTC_CHECK(loss_event.has_bitrate_bps());
|
|
|
|
|
if (bitrate_bps != nullptr) {
|
|
|
|
|
*bitrate_bps = loss_event.bitrate_bps();
|
2016-05-13 00:42:59 -07:00
|
|
|
}
|
|
|
|
|
RTC_CHECK(loss_event.has_fraction_loss());
|
|
|
|
|
if (fraction_loss != nullptr) {
|
|
|
|
|
*fraction_loss = loss_event.fraction_loss();
|
|
|
|
|
}
|
|
|
|
|
RTC_CHECK(loss_event.has_total_packets());
|
|
|
|
|
if (total_packets != nullptr) {
|
|
|
|
|
*total_packets = loss_event.total_packets();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-11 01:50:23 -07:00
|
|
|
ParsedRtcEventLog::BweDelayBasedUpdate
|
|
|
|
|
ParsedRtcEventLog::GetDelayBasedBweUpdate(size_t index) const {
|
2017-02-17 03:38:28 -08:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
|
|
|
|
const rtclog::Event& event = events_[index];
|
|
|
|
|
RTC_CHECK(event.has_type());
|
2017-02-20 05:14:41 -08:00
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::DELAY_BASED_BWE_UPDATE);
|
|
|
|
|
RTC_CHECK(event.has_delay_based_bwe_update());
|
|
|
|
|
const rtclog::DelayBasedBweUpdate& delay_event =
|
|
|
|
|
event.delay_based_bwe_update();
|
2017-04-11 01:50:23 -07:00
|
|
|
|
|
|
|
|
BweDelayBasedUpdate res;
|
|
|
|
|
res.timestamp = GetTimestamp(index);
|
2017-02-20 05:14:41 -08:00
|
|
|
RTC_CHECK(delay_event.has_bitrate_bps());
|
2017-04-11 01:50:23 -07:00
|
|
|
res.bitrate_bps = delay_event.bitrate_bps();
|
2017-02-17 03:38:28 -08:00
|
|
|
RTC_CHECK(delay_event.has_detector_state());
|
2017-04-11 01:50:23 -07:00
|
|
|
res.detector_state = GetRuntimeDetectorState(delay_event.detector_state());
|
|
|
|
|
return res;
|
2017-02-17 03:38:28 -08:00
|
|
|
}
|
|
|
|
|
|
2017-01-24 04:54:59 -08:00
|
|
|
void ParsedRtcEventLog::GetAudioNetworkAdaptation(
|
|
|
|
|
size_t index,
|
2017-04-06 05:59:10 -07:00
|
|
|
AudioEncoderRuntimeConfig* config) const {
|
2017-01-24 04:54:59 -08:00
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
|
|
|
|
const rtclog::Event& event = events_[index];
|
|
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_audio_network_adaptation());
|
|
|
|
|
const rtclog::AudioNetworkAdaptation& ana_event =
|
|
|
|
|
event.audio_network_adaptation();
|
|
|
|
|
if (ana_event.has_bitrate_bps())
|
|
|
|
|
config->bitrate_bps = rtc::Optional<int>(ana_event.bitrate_bps());
|
|
|
|
|
if (ana_event.has_enable_fec())
|
|
|
|
|
config->enable_fec = rtc::Optional<bool>(ana_event.enable_fec());
|
|
|
|
|
if (ana_event.has_enable_dtx())
|
|
|
|
|
config->enable_dtx = rtc::Optional<bool>(ana_event.enable_dtx());
|
|
|
|
|
if (ana_event.has_frame_length_ms())
|
|
|
|
|
config->frame_length_ms = rtc::Optional<int>(ana_event.frame_length_ms());
|
|
|
|
|
if (ana_event.has_num_channels())
|
|
|
|
|
config->num_channels = rtc::Optional<size_t>(ana_event.num_channels());
|
|
|
|
|
if (ana_event.has_uplink_packet_loss_fraction())
|
|
|
|
|
config->uplink_packet_loss_fraction =
|
|
|
|
|
rtc::Optional<float>(ana_event.uplink_packet_loss_fraction());
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 16:28:53 +02:00
|
|
|
ParsedRtcEventLog::BweProbeClusterCreatedEvent
|
|
|
|
|
ParsedRtcEventLog::GetBweProbeClusterCreated(size_t index) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
|
|
|
|
const rtclog::Event& event = events_[index];
|
|
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_probe_cluster());
|
|
|
|
|
const rtclog::BweProbeCluster& pcc_event = event.probe_cluster();
|
|
|
|
|
BweProbeClusterCreatedEvent res;
|
|
|
|
|
res.timestamp = GetTimestamp(index);
|
|
|
|
|
RTC_CHECK(pcc_event.has_id());
|
|
|
|
|
res.id = pcc_event.id();
|
|
|
|
|
RTC_CHECK(pcc_event.has_bitrate_bps());
|
|
|
|
|
res.bitrate_bps = pcc_event.bitrate_bps();
|
|
|
|
|
RTC_CHECK(pcc_event.has_min_packets());
|
|
|
|
|
res.min_packets = pcc_event.min_packets();
|
|
|
|
|
RTC_CHECK(pcc_event.has_min_bytes());
|
|
|
|
|
res.min_bytes = pcc_event.min_bytes();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParsedRtcEventLog::BweProbeResultEvent ParsedRtcEventLog::GetBweProbeResult(
|
|
|
|
|
size_t index) const {
|
|
|
|
|
RTC_CHECK_LT(index, GetNumberOfEvents());
|
|
|
|
|
const rtclog::Event& event = events_[index];
|
|
|
|
|
RTC_CHECK(event.has_type());
|
|
|
|
|
RTC_CHECK_EQ(event.type(), rtclog::Event::BWE_PROBE_RESULT_EVENT);
|
|
|
|
|
RTC_CHECK(event.has_probe_result());
|
|
|
|
|
const rtclog::BweProbeResult& pr_event = event.probe_result();
|
|
|
|
|
BweProbeResultEvent res;
|
|
|
|
|
res.timestamp = GetTimestamp(index);
|
|
|
|
|
RTC_CHECK(pr_event.has_id());
|
|
|
|
|
res.id = pr_event.id();
|
|
|
|
|
|
|
|
|
|
RTC_CHECK(pr_event.has_result());
|
|
|
|
|
if (pr_event.result() == rtclog::BweProbeResult::SUCCESS) {
|
|
|
|
|
RTC_CHECK(pr_event.has_bitrate_bps());
|
|
|
|
|
res.bitrate_bps = rtc::Optional<uint64_t>(pr_event.bitrate_bps());
|
|
|
|
|
} else if (pr_event.result() ==
|
|
|
|
|
rtclog::BweProbeResult::INVALID_SEND_RECEIVE_INTERVAL) {
|
|
|
|
|
res.failure_reason =
|
|
|
|
|
rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveInterval);
|
|
|
|
|
} else if (pr_event.result() ==
|
|
|
|
|
rtclog::BweProbeResult::INVALID_SEND_RECEIVE_RATIO) {
|
|
|
|
|
res.failure_reason =
|
|
|
|
|
rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveRatio);
|
|
|
|
|
} else if (pr_event.result() == rtclog::BweProbeResult::TIMEOUT) {
|
|
|
|
|
res.failure_reason = rtc::Optional<ProbeFailureReason>(kTimeout);
|
|
|
|
|
} else {
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2017-05-30 03:52:10 -07:00
|
|
|
|
|
|
|
|
// Returns the MediaType for registered SSRCs. Search from the end to use last
|
|
|
|
|
// registered types first.
|
|
|
|
|
ParsedRtcEventLog::MediaType ParsedRtcEventLog::GetMediaType(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
PacketDirection direction) const {
|
|
|
|
|
for (auto rit = streams_.rbegin(); rit != streams_.rend(); ++rit) {
|
|
|
|
|
if (rit->ssrc == ssrc && rit->direction == direction)
|
|
|
|
|
return rit->media_type;
|
|
|
|
|
}
|
|
|
|
|
return MediaType::ANY;
|
|
|
|
|
}
|
2016-05-13 00:42:59 -07:00
|
|
|
} // namespace webrtc
|