Add NetEqInput::PacketData::ToString method

This new method prints information about the packet.

BUG=webrtc:7467

Review-Url: https://codereview.webrtc.org/2844283002
Cr-Commit-Position: refs/heads/master@{#17922}
This commit is contained in:
henrik.lundin
2017-04-28 01:35:53 -07:00
committed by Commit bot
parent b637a94b63
commit 7a38fd2628
4 changed files with 37 additions and 5 deletions

View File

@ -1111,6 +1111,7 @@ rtc_source_set("neteq_tools_minimal") {
"neteq/tools/audio_sink.h", "neteq/tools/audio_sink.h",
"neteq/tools/encode_neteq_input.cc", "neteq/tools/encode_neteq_input.cc",
"neteq/tools/encode_neteq_input.h", "neteq/tools/encode_neteq_input.h",
"neteq/tools/neteq_input.cc",
"neteq/tools/neteq_input.h", "neteq/tools/neteq_input.h",
"neteq/tools/neteq_test.cc", "neteq/tools/neteq_test.cc",
"neteq/tools/neteq_test.h", "neteq/tools/neteq_test.h",

View File

@ -0,0 +1,32 @@
/*
* 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.
*/
#include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h"
#include <sstream>
namespace webrtc {
namespace test {
std::string NetEqInput::PacketData::ToString() const {
std::stringstream ss;
ss << "{"
<< "time_ms: " << static_cast<int64_t>(time_ms) << ", "
<< "header: {"
<< "pt: " << static_cast<int>(header.payloadType) << ", "
<< "sn: " << header.sequenceNumber << ", "
<< "ts: " << header.timestamp << ", "
<< "ssrc: " << header.ssrc << "}, "
<< "payload bytes: " << payload.size() << "}";
return ss.str();
}
} // namespace test
} // namespace webrtc

View File

@ -13,6 +13,7 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <string>
#include "webrtc/base/buffer.h" #include "webrtc/base/buffer.h"
#include "webrtc/base/optional.h" #include "webrtc/base/optional.h"
@ -27,6 +28,8 @@ namespace test {
class NetEqInput { class NetEqInput {
public: public:
struct PacketData { struct PacketData {
std::string ToString() const;
RTPHeader header; RTPHeader header;
rtc::Buffer payload; rtc::Buffer payload;
double time_ms; double time_ms;

View File

@ -26,12 +26,8 @@ void DefaultNetEqTestErrorCallback::OnInsertPacketError(
<< std::endl; << std::endl;
} else { } else {
std::cerr << "InsertPacket returned error code " << error_code << std::endl; std::cerr << "InsertPacket returned error code " << error_code << std::endl;
std::cerr << "Header data:" << std::endl;
std::cerr << " PT = " << static_cast<int>(packet.header.payloadType)
<< std::endl;
std::cerr << " SN = " << packet.header.sequenceNumber << std::endl;
std::cerr << " TS = " << packet.header.timestamp << std::endl;
} }
std::cerr << "Packet data: " << packet.ToString() << std::endl;
FATAL(); FATAL();
} }