webrtc_m130/webrtc/call/packet_injection_tests.cc
Stefan Holmer 9fea80f50d Add audio streams to CallTest and a first A/V call test.
Add audio send and receive streams to CallTest and call the necessary voice engine APIs for the streams to be usable. Verifies the implementation by adding a simple test which monitors outgoing packets and checks that both audio and video is being sent with transport sequence numbers.

Audio streams are using a fake audio device with file input.

The CallTest implementation is to a big degree based on call_perf_tests.cc and should in the future replace a lot of that code.

R=pbos@webrtc.org
TBR=kjellander@webrtc.org

BUG=webrtc:5263

Review URL: https://codereview.webrtc.org/1542653002 .

Cr-Commit-Position: refs/heads/master@{#11171}
2016-01-07 16:43:31 +00:00

92 lines
3.0 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 "testing/gtest/include/gtest/gtest.h"
#include "webrtc/test/call_test.h"
#include "webrtc/test/null_transport.h"
namespace webrtc {
class PacketInjectionTest : public test::CallTest {
protected:
enum class CodecType {
kVp8,
kH264,
};
PacketInjectionTest() : rtp_header_parser_(RtpHeaderParser::Create()) {}
void InjectIncorrectPacket(CodecType codec_type,
uint8_t packet_type,
const uint8_t* packet,
size_t length);
rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_;
};
void PacketInjectionTest::InjectIncorrectPacket(CodecType codec_type,
uint8_t payload_type,
const uint8_t* packet,
size_t length) {
CreateSenderCall(Call::Config());
CreateReceiverCall(Call::Config());
test::NullTransport null_transport;
CreateSendConfig(1, 0, &null_transport);
CreateMatchingReceiveConfigs(&null_transport);
video_receive_configs_[0].decoders[0].payload_type = payload_type;
switch (codec_type) {
case CodecType::kVp8:
video_receive_configs_[0].decoders[0].payload_name = "VP8";
break;
case CodecType::kH264:
video_receive_configs_[0].decoders[0].payload_name = "H264";
break;
}
CreateVideoStreams();
RTPHeader header;
EXPECT_TRUE(rtp_header_parser_->Parse(packet, length, &header));
EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc)
<< "Packet should have configured SSRC to not be dropped early.";
EXPECT_EQ(payload_type, header.payloadType);
Start();
EXPECT_EQ(PacketReceiver::DELIVERY_PACKET_ERROR,
receiver_call_->Receiver()->DeliverPacket(MediaType::VIDEO, packet,
length, PacketTime()));
Stop();
DestroyStreams();
}
TEST_F(PacketInjectionTest, StapAPacketWithTruncatedNalUnits) {
const uint8_t kPacket[] = {0x80,
0xE5,
0xE6,
0x0,
0x0,
0xED,
0x23,
0x4,
0x00,
0xC0,
0xFF,
0xED,
0x58,
0xCB,
0xED,
0xDF};
InjectIncorrectPacket(CodecType::kH264, 101, kPacket, sizeof(kPacket));
}
} // namespace webrtc