| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include <memory> | |
| 12 | |
| 13 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | |
| 14 #include "webrtc/test/call_test.h" | |
| 15 #include "webrtc/test/gtest.h" | |
| 16 #include "webrtc/test/null_transport.h" | |
| 17 | |
| 18 namespace webrtc { | |
| 19 | |
| 20 class PacketInjectionTest : public test::CallTest { | |
| 21 protected: | |
| 22 enum class CodecType { | |
| 23 kVp8, | |
| 24 kH264, | |
| 25 }; | |
| 26 | |
| 27 PacketInjectionTest() : rtp_header_parser_(RtpHeaderParser::Create()) {} | |
| 28 | |
| 29 void InjectIncorrectPacket(CodecType codec_type, | |
| 30 uint8_t packet_type, | |
| 31 const uint8_t* packet, | |
| 32 size_t length); | |
| 33 | |
| 34 std::unique_ptr<RtpHeaderParser> rtp_header_parser_; | |
| 35 }; | |
| 36 | |
| 37 void PacketInjectionTest::InjectIncorrectPacket(CodecType codec_type, | |
| 38 uint8_t payload_type, | |
| 39 const uint8_t* packet, | |
| 40 size_t length) { | |
| 41 CreateSenderCall(Call::Config(&event_log_)); | |
| 42 CreateReceiverCall(Call::Config(&event_log_)); | |
| 43 | |
| 44 test::NullTransport null_transport; | |
| 45 CreateSendConfig(1, 0, 0, &null_transport); | |
| 46 CreateMatchingReceiveConfigs(&null_transport); | |
| 47 video_receive_configs_[0].decoders[0].payload_type = payload_type; | |
| 48 switch (codec_type) { | |
| 49 case CodecType::kVp8: | |
| 50 video_receive_configs_[0].decoders[0].payload_name = "VP8"; | |
| 51 break; | |
| 52 case CodecType::kH264: | |
| 53 video_receive_configs_[0].decoders[0].payload_name = "H264"; | |
| 54 break; | |
| 55 } | |
| 56 CreateVideoStreams(); | |
| 57 | |
| 58 RTPHeader header; | |
| 59 EXPECT_TRUE(rtp_header_parser_->Parse(packet, length, &header)); | |
| 60 EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc) | |
| 61 << "Packet should have configured SSRC to not be dropped early."; | |
| 62 EXPECT_EQ(payload_type, header.payloadType); | |
| 63 Start(); | |
| 64 EXPECT_EQ(PacketReceiver::DELIVERY_PACKET_ERROR, | |
| 65 receiver_call_->Receiver()->DeliverPacket(MediaType::VIDEO, packet, | |
| 66 length, PacketTime())); | |
| 67 Stop(); | |
| 68 | |
| 69 DestroyStreams(); | |
| 70 } | |
| 71 | |
| 72 TEST_F(PacketInjectionTest, StapAPacketWithTruncatedNalUnits) { | |
| 73 const uint8_t kPacket[] = {0x80, | |
| 74 0xE5, | |
| 75 0xE6, | |
| 76 0x0, | |
| 77 0x0, | |
| 78 0xED, | |
| 79 0x23, | |
| 80 0x4, | |
| 81 0x00, | |
| 82 0xC0, | |
| 83 0xFF, | |
| 84 0xED, | |
| 85 0x58, | |
| 86 0xCB, | |
| 87 0xED, | |
| 88 0xDF}; | |
| 89 | |
| 90 InjectIncorrectPacket(CodecType::kH264, 101, kPacket, sizeof(kPacket)); | |
| 91 } | |
| 92 | |
| 93 } // namespace webrtc | |
| OLD | NEW |