Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 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 "webrtc/base/basictypes.h" | |
| 12 #include "webrtc/call/flexfec_receive_stream.h" | |
| 13 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | |
| 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" | |
| 16 #include "webrtc/test/gmock.h" | |
| 17 #include "webrtc/test/gtest.h" | |
| 18 | |
| 19 namespace webrtc { | |
| 20 | |
| 21 TEST(FlexfecReceiveStreamTest, ConfigToString) { | |
| 22 FlexfecReceiveStream::Config config; | |
| 23 config.flexfec_payload_type = 118; | |
| 24 config.flexfec_ssrc = 12545412; | |
| 25 config.protected_media_ssrc = 89372; | |
| 26 | |
| 27 EXPECT_EQ( | |
| 28 "{flexfec_payload_type: 118, " | |
| 29 "flexfec_ssrc: 12545412, " | |
| 30 "protected_media_ssrc: 89372}", | |
| 31 config.ToString()); | |
|
philipel
2016/10/18 10:43:34
Is the format of the string representation of the
brandtr
2016/10/18 14:31:18
Nope, this is purely for human consumption.
Since
philipel
2016/10/19 09:10:50
I think you should remove this test, or if you wan
brandtr
2016/10/19 09:31:24
Ok, thanks for the explanation. Removing the test.
| |
| 32 } | |
| 33 | |
| 34 TEST(FlexfecReceiveStreamTest, ConstructDestruct) { | |
| 35 FlexfecReceiveStream::Config config; | |
| 36 config.flexfec_payload_type = 118; | |
| 37 config.flexfec_ssrc = 424223; | |
| 38 config.protected_media_ssrc = 912512; | |
| 39 MockRecoveredPacketReceiver callback; | |
| 40 | |
| 41 internal::FlexfecReceiveStream receive_stream(config, &callback); | |
| 42 } | |
| 43 | |
| 44 TEST(FlexfecReceiveStreamTest, StartStop) { | |
| 45 FlexfecReceiveStream::Config config; | |
| 46 config.flexfec_payload_type = 118; | |
| 47 config.flexfec_ssrc = 1652392; | |
| 48 config.protected_media_ssrc = 23300443; | |
| 49 MockRecoveredPacketReceiver callback; | |
| 50 internal::FlexfecReceiveStream receive_stream(config, &callback); | |
| 51 | |
| 52 receive_stream.Start(); | |
| 53 receive_stream.Stop(); | |
| 54 } | |
| 55 | |
| 56 // Create a FlexFEC packet that protects a single media packet and ensure | |
| 57 // that the callback is called. Correctness of recovery is checked in the | |
| 58 // FlexfecReceiver unit tests. | |
| 59 TEST(FlexfecReceiveStreamTest, RecoversPacketWhenStarted) { | |
|
stefan-webrtc
2016/10/17 17:56:04
Useful test!
| |
| 60 constexpr uint8_t kFlexfecPlType = 118; | |
| 61 constexpr uint8_t kFlexfecSeqNum[] = {0x00, 0x01}; | |
| 62 constexpr uint8_t kFlexfecTs[] = {0x00, 0x11, 0x22, 0x33}; | |
| 63 constexpr uint8_t kFlexfecSsrc[] = {0x00, 0x00, 0x00, 0x01}; | |
| 64 constexpr uint8_t kMediaPlType = 107; | |
| 65 constexpr uint8_t kMediaSeqNum[] = {0x00, 0x02}; | |
| 66 constexpr uint8_t kMediaTs[] = {0xaa, 0xbb, 0xcc, 0xdd}; | |
| 67 constexpr uint8_t kMediaSsrc[] = {0x00, 0x00, 0x00, 0x02}; | |
| 68 | |
| 69 // This packet mask protects a single media packet, i.e., the FlexFEC payload | |
| 70 // is a copy of that media packet. When inserted in the FlexFEC pipeline, | |
| 71 // it will thus trivially recover the lost media packet. | |
| 72 constexpr uint8_t kKBit0 = 1 << 7; | |
| 73 constexpr uint8_t kFlexfecPktMask[] = {kKBit0 | 0x00, 0x01}; | |
| 74 constexpr uint8_t kPayloadLength[] = {0x00, 0x04}; | |
| 75 constexpr uint8_t kSsrcCount = 1; | |
| 76 constexpr uint8_t kReservedBits = 0x00; | |
| 77 constexpr uint8_t kPayloadBits = 0x00; | |
| 78 // clang-format off | |
| 79 constexpr uint8_t kFlexfecPacket[] = { | |
| 80 // RTP header. | |
| 81 0x80, kFlexfecPlType, kFlexfecSeqNum[0], kFlexfecSeqNum[1], | |
| 82 kFlexfecTs[0], kFlexfecTs[1], kFlexfecTs[2], kFlexfecTs[3], | |
| 83 kFlexfecSsrc[0], kFlexfecSsrc[1], kFlexfecSsrc[2], kFlexfecSsrc[3], | |
| 84 // FlexFEC header. | |
| 85 0x00, kMediaPlType, kPayloadLength[0], kPayloadLength[1], | |
| 86 kMediaTs[0], kMediaTs[1], kMediaTs[2], kMediaTs[3], | |
| 87 kSsrcCount, kReservedBits, kReservedBits, kReservedBits, | |
| 88 kMediaSsrc[0], kMediaSsrc[1], kMediaSsrc[2], kMediaSsrc[3], | |
| 89 kMediaSeqNum[0], kMediaSeqNum[1], kFlexfecPktMask[0], kFlexfecPktMask[1], | |
| 90 // FEC payload. | |
| 91 kPayloadBits, kPayloadBits, kPayloadBits, kPayloadBits}; | |
| 92 // clang-format on | |
| 93 constexpr size_t kFlexfecPacketLength = sizeof(kFlexfecPacket); | |
| 94 | |
| 95 FlexfecReceiveStream::Config config; | |
| 96 config.flexfec_payload_type = kFlexfecPlType; | |
| 97 config.flexfec_ssrc = ByteReader<uint32_t>::ReadBigEndian(kFlexfecSsrc); | |
| 98 config.protected_media_ssrc = ByteReader<uint32_t>::ReadBigEndian(kMediaSsrc); | |
| 99 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver; | |
| 100 internal::FlexfecReceiveStream receive_stream(config, | |
| 101 &recovered_packet_receiver); | |
| 102 | |
| 103 // Do not call back before being started. | |
| 104 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket, | |
| 105 kFlexfecPacketLength); | |
| 106 | |
| 107 // Call back after being started. | |
| 108 receive_stream.Start(); | |
| 109 EXPECT_CALL( | |
| 110 recovered_packet_receiver, | |
| 111 OnRecoveredPacket(::testing::_, kRtpHeaderSize + kPayloadLength[1])); | |
| 112 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket, | |
| 113 kFlexfecPacketLength); | |
| 114 } | |
| 115 | |
| 116 } // namespace webrtc | |
| OLD | NEW |