webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc
Björn Terelius ff61273c01 Revert "Create new API for RtcEventLogParser."
This reverts commit 9e336ec0b8.

Reason for revert: Code can accidentally include the deprecated parser but link with the new one, or vice versa. Reverting to fix naming.

Original change's description:
> Create new API for RtcEventLogParser.
> 
> The new API stores events gathered by event type. For example, it is
> possible to ask fo a list of all incoming RTCP messages or all audio
> playout events.
> 
> The new API is experimental and may change over next few weeks. Once
> it has stabilized and all unit tests and existing tools have been
> ported to the new API, the old one will be removed.
> 
> This CL also updates the event_log_visualizer tool to use the new
> parser API. This is not a funcional change except for:
> - Incoming and outgoing audio level are now drawn in two separate plots.
> - Incoming and outgoing timstamps are now drawn in two separate plots.
> - RTCP count is no longer split into Video and Audio. It also counts
>   all RTCP packets rather than only specific message types.
> - Slight timing difference in sendside BWE simulation due to only
>   iterating over transport feedbacks and not over all RTCP packets.
>   This timing changes are not visible in the plots.
> 
> 
> Media type for RTCP messages might not be identified correctly by
> rtc_event_log2text anymore. On the other hand, assigning a specific
> media type to an RTCP packet was a bit hacky to begin with.
> 
> Bug: webrtc:8111
> Change-Id: I8e7168302beb69b2e163a097a2a142b86dd4a26b
> Reviewed-on: https://webrtc-review.googlesource.com/60865
> Reviewed-by: Minyue Li <minyue@webrtc.org>
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Björn Terelius <terelius@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23015}

TBR=terelius@webrtc.org,srte@webrtc.org,minyue@webrtc.org

Change-Id: Ib4bbcf0563423675a3cc1dce59ebf665e0c5dae9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8111
Reviewed-on: https://webrtc-review.googlesource.com/72500
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23026}
2018-04-25 14:23:14 +00:00

108 lines
3.7 KiB
C++

/*
* 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.
*/
#include "modules/audio_coding/neteq/tools/rtc_event_log_source.h"
#include <assert.h>
#include <string.h>
#include <iostream>
#include <limits>
#include "modules/audio_coding/neteq/tools/packet.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace test {
RtcEventLogSource* RtcEventLogSource::Create(const std::string& file_name) {
RtcEventLogSource* source = new RtcEventLogSource();
RTC_CHECK(source->OpenFile(file_name));
return source;
}
RtcEventLogSource::~RtcEventLogSource() {}
bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type,
uint8_t id) {
RTC_CHECK(parser_.get());
return parser_->RegisterRtpHeaderExtension(type, id);
}
std::unique_ptr<Packet> RtcEventLogSource::NextPacket() {
for (; rtp_packet_index_ < parsed_stream_.GetNumberOfEvents();
rtp_packet_index_++) {
if (parsed_stream_.GetEventType(rtp_packet_index_) ==
ParsedRtcEventLog::RTP_EVENT) {
PacketDirection direction;
size_t header_length;
size_t packet_length;
uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_);
parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, nullptr,
&header_length, &packet_length, nullptr);
if (direction != kIncomingPacket) {
continue;
}
uint8_t* packet_header = new uint8_t[header_length];
parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, packet_header,
nullptr, nullptr, nullptr);
std::unique_ptr<Packet> packet(
new Packet(packet_header, header_length, packet_length,
static_cast<double>(timestamp_us) / 1000, *parser_.get()));
if (!packet->valid_header()) {
std::cout << "Warning: Packet with index " << rtp_packet_index_
<< " has an invalid header and will be ignored." << std::endl;
continue;
}
if (parsed_stream_.GetMediaType(packet->header().ssrc, direction) !=
webrtc::ParsedRtcEventLog::MediaType::AUDIO) {
continue;
}
// Check if the packet should not be filtered out.
if (!filter_.test(packet->header().payloadType) &&
!(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) {
++rtp_packet_index_;
return packet;
}
}
}
return nullptr;
}
int64_t RtcEventLogSource::NextAudioOutputEventMs() {
while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) {
if (parsed_stream_.GetEventType(audio_output_index_) ==
ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT) {
uint64_t timestamp_us = parsed_stream_.GetTimestamp(audio_output_index_);
// We call GetAudioPlayout only to check that the protobuf event is
// well-formed.
parsed_stream_.GetAudioPlayout(audio_output_index_, nullptr);
audio_output_index_++;
return timestamp_us / 1000;
}
audio_output_index_++;
}
return std::numeric_limits<int64_t>::max();
}
RtcEventLogSource::RtcEventLogSource()
: PacketSource(), parser_(RtpHeaderParser::Create()) {}
bool RtcEventLogSource::OpenFile(const std::string& file_name) {
return parsed_stream_.ParseFile(file_name);
}
} // namespace test
} // namespace webrtc