OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/base/array_view.h" | |
11 #include "webrtc/base/basictypes.h" | 12 #include "webrtc/base/basictypes.h" |
12 #include "webrtc/call/flexfec_receive_stream.h" | 13 #include "webrtc/call/flexfec_receive_stream.h" |
13 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | 14 #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/source/byte_io.h" |
16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
15 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" | 17 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" |
16 #include "webrtc/test/gmock.h" | 18 #include "webrtc/test/gmock.h" |
17 #include "webrtc/test/gtest.h" | 19 #include "webrtc/test/gtest.h" |
18 | 20 |
19 namespace webrtc { | 21 namespace webrtc { |
20 | 22 |
23 namespace { | |
24 | |
25 using ::testing::_; | |
26 using ::testing::Return; | |
27 | |
28 RtpPacketReceived ParsePacket(rtc::ArrayView<const uint8_t> packet) { | |
29 RtpPacketReceived parsed_packet(nullptr); | |
30 EXPECT_TRUE(parsed_packet.Parse(packet)); | |
31 return parsed_packet; | |
32 } | |
33 | |
34 } // namespace | |
35 | |
21 TEST(FlexfecReceiveStreamTest, ConstructDestruct) { | 36 TEST(FlexfecReceiveStreamTest, ConstructDestruct) { |
22 FlexfecReceiveStream::Config config; | 37 FlexfecReceiveStream::Config config; |
23 config.payload_type = 118; | 38 config.payload_type = 118; |
24 config.remote_ssrc = 424223; | 39 config.remote_ssrc = 424223; |
25 config.protected_media_ssrcs = {912512}; | 40 config.protected_media_ssrcs = {912512}; |
26 MockRecoveredPacketReceiver callback; | 41 MockRecoveredPacketReceiver recovered_packet_receiver; |
27 | 42 |
28 internal::FlexfecReceiveStream receive_stream(config, &callback); | 43 internal::FlexfecReceiveStream receive_stream(config, |
44 &recovered_packet_receiver); | |
29 } | 45 } |
30 | 46 |
31 TEST(FlexfecReceiveStreamTest, StartStop) { | 47 TEST(FlexfecReceiveStreamTest, StartStop) { |
32 FlexfecReceiveStream::Config config; | 48 FlexfecReceiveStream::Config config; |
33 config.payload_type = 118; | 49 config.payload_type = 118; |
34 config.remote_ssrc = 1652392; | 50 config.remote_ssrc = 1652392; |
35 config.protected_media_ssrcs = {23300443}; | 51 config.protected_media_ssrcs = {23300443}; |
36 MockRecoveredPacketReceiver callback; | 52 MockRecoveredPacketReceiver recovered_packet_receiver; |
37 internal::FlexfecReceiveStream receive_stream(config, &callback); | 53 internal::FlexfecReceiveStream receive_stream(config, |
54 &recovered_packet_receiver); | |
38 | 55 |
39 receive_stream.Start(); | 56 receive_stream.Start(); |
40 receive_stream.Stop(); | 57 receive_stream.Stop(); |
41 } | 58 } |
42 | 59 |
43 TEST(FlexfecReceiveStreamTest, DoesNotProcessPacketWhenNoMediaSsrcGiven) { | |
44 FlexfecReceiveStream::Config config; | |
45 config.payload_type = 118; | |
46 config.remote_ssrc = 424223; | |
47 config.protected_media_ssrcs = {}; | |
48 MockRecoveredPacketReceiver callback; | |
49 internal::FlexfecReceiveStream receive_stream(config, &callback); | |
50 const uint8_t packet[] = {0x00, 0x11, 0x22, 0x33}; | |
51 const size_t packet_length = sizeof(packet); | |
52 | |
53 EXPECT_FALSE( | |
54 receive_stream.AddAndProcessReceivedPacket(packet, packet_length)); | |
55 } | |
56 | |
57 // Create a FlexFEC packet that protects a single media packet and ensure | 60 // Create a FlexFEC packet that protects a single media packet and ensure |
58 // that the callback is called. Correctness of recovery is checked in the | 61 // that the callback is called. Correctness of recovery is checked in the |
59 // FlexfecReceiver unit tests. | 62 // FlexfecReceiver unit tests. |
60 TEST(FlexfecReceiveStreamTest, RecoversPacketWhenStarted) { | 63 TEST(FlexfecReceiveStreamTest, RecoversPacketWhenStarted) { |
61 constexpr uint8_t kFlexfecPlType = 118; | 64 constexpr uint8_t kFlexfecPlType = 118; |
62 constexpr uint8_t kFlexfecSeqNum[] = {0x00, 0x01}; | 65 constexpr uint8_t kFlexfecSeqNum[] = {0x00, 0x01}; |
63 constexpr uint8_t kFlexfecTs[] = {0x00, 0x11, 0x22, 0x33}; | 66 constexpr uint8_t kFlexfecTs[] = {0x00, 0x11, 0x22, 0x33}; |
64 constexpr uint8_t kFlexfecSsrc[] = {0x00, 0x00, 0x00, 0x01}; | 67 constexpr uint8_t kFlexfecSsrc[] = {0x00, 0x00, 0x00, 0x01}; |
65 constexpr uint8_t kMediaPlType = 107; | 68 constexpr uint8_t kMediaPlType = 107; |
66 constexpr uint8_t kMediaSeqNum[] = {0x00, 0x02}; | 69 constexpr uint8_t kMediaSeqNum[] = {0x00, 0x02}; |
(...skipping 29 matching lines...) Expand all Loading... | |
96 FlexfecReceiveStream::Config config; | 99 FlexfecReceiveStream::Config config; |
97 config.payload_type = kFlexfecPlType; | 100 config.payload_type = kFlexfecPlType; |
98 config.remote_ssrc = ByteReader<uint32_t>::ReadBigEndian(kFlexfecSsrc); | 101 config.remote_ssrc = ByteReader<uint32_t>::ReadBigEndian(kFlexfecSsrc); |
99 config.protected_media_ssrcs = { | 102 config.protected_media_ssrcs = { |
100 ByteReader<uint32_t>::ReadBigEndian(kMediaSsrc)}; | 103 ByteReader<uint32_t>::ReadBigEndian(kMediaSsrc)}; |
101 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver; | 104 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver; |
102 internal::FlexfecReceiveStream receive_stream(config, | 105 internal::FlexfecReceiveStream receive_stream(config, |
103 &recovered_packet_receiver); | 106 &recovered_packet_receiver); |
104 | 107 |
105 // Do not call back before being started. | 108 // Do not call back before being started. |
106 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket, | 109 receive_stream.AddAndProcessReceivedPacket(ParsePacket( |
107 kFlexfecPacketLength); | 110 rtc::ArrayView<const uint8_t>(kFlexfecPacket, kFlexfecPacketLength))); |
danilchap
2016/12/14 13:39:02
just ParsePacket(kFlexfecPacket)
ArrayView would d
brandtr
2016/12/14 14:08:31
Nice!
| |
108 | 111 |
109 // Call back after being started. | 112 // Call back after being started. |
110 receive_stream.Start(); | 113 receive_stream.Start(); |
111 EXPECT_CALL( | 114 EXPECT_CALL(recovered_packet_receiver, |
112 recovered_packet_receiver, | 115 OnRecoveredPacket(_, kRtpHeaderSize + kPayloadLength[1])); |
113 OnRecoveredPacket(::testing::_, kRtpHeaderSize + kPayloadLength[1])); | 116 receive_stream.AddAndProcessReceivedPacket(ParsePacket( |
danilchap
2016/12/14 13:39:02
ditto
brandtr
2016/12/14 14:08:31
Done.
| |
114 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket, | 117 rtc::ArrayView<const uint8_t>(kFlexfecPacket, kFlexfecPacketLength))); |
115 kFlexfecPacketLength); | |
116 } | 118 } |
117 | 119 |
118 } // namespace webrtc | 120 } // namespace webrtc |
OLD | NEW |