Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: webrtc/call/flexfec_receive_stream_unittest.cc

Issue 2589393002: Revert of Parse FlexFEC RTP headers in Call and add integration with BWE. (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/flexfec_receive_stream_impl.cc ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
12 #include "webrtc/base/basictypes.h" 11 #include "webrtc/base/basictypes.h"
13 #include "webrtc/call/flexfec_receive_stream_impl.h" 12 #include "webrtc/call/flexfec_receive_stream_impl.h"
14 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" 13 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h"
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
17 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" 15 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h"
18 #include "webrtc/test/gmock.h" 16 #include "webrtc/test/gmock.h"
19 #include "webrtc/test/gtest.h" 17 #include "webrtc/test/gtest.h"
20 18
21 namespace webrtc { 19 namespace webrtc {
22 20
23 namespace {
24
25 RtpPacketReceived ParsePacket(rtc::ArrayView<const uint8_t> packet) {
26 RtpPacketReceived parsed_packet(nullptr);
27 EXPECT_TRUE(parsed_packet.Parse(packet));
28 return parsed_packet;
29 }
30
31 } // namespace
32
33 TEST(FlexfecReceiveStreamTest, ConstructDestruct) { 21 TEST(FlexfecReceiveStreamTest, ConstructDestruct) {
34 FlexfecReceiveStream::Config config; 22 FlexfecReceiveStream::Config config;
35 config.payload_type = 118; 23 config.payload_type = 118;
36 config.remote_ssrc = 424223; 24 config.remote_ssrc = 424223;
37 config.protected_media_ssrcs = {912512}; 25 config.protected_media_ssrcs = {912512};
38 MockRecoveredPacketReceiver recovered_packet_receiver; 26 MockRecoveredPacketReceiver callback;
39 27
40 FlexfecReceiveStreamImpl receive_stream(config, &recovered_packet_receiver); 28 FlexfecReceiveStreamImpl receive_stream(config, &callback);
41 } 29 }
42 30
43 TEST(FlexfecReceiveStreamTest, StartStop) { 31 TEST(FlexfecReceiveStreamTest, StartStop) {
44 FlexfecReceiveStream::Config config; 32 FlexfecReceiveStream::Config config;
45 config.payload_type = 118; 33 config.payload_type = 118;
46 config.remote_ssrc = 1652392; 34 config.remote_ssrc = 1652392;
47 config.protected_media_ssrcs = {23300443}; 35 config.protected_media_ssrcs = {23300443};
48 MockRecoveredPacketReceiver recovered_packet_receiver; 36 MockRecoveredPacketReceiver callback;
49 FlexfecReceiveStreamImpl receive_stream(config, &recovered_packet_receiver); 37 FlexfecReceiveStreamImpl receive_stream(config, &callback);
50 38
51 receive_stream.Start(); 39 receive_stream.Start();
52 receive_stream.Stop(); 40 receive_stream.Stop();
53 } 41 }
54 42
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 FlexfecReceiveStreamImpl 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
55 // Create a FlexFEC packet that protects a single media packet and ensure 57 // Create a FlexFEC packet that protects a single media packet and ensure
56 // that the callback is called. Correctness of recovery is checked in the 58 // that the callback is called. Correctness of recovery is checked in the
57 // FlexfecReceiver unit tests. 59 // FlexfecReceiver unit tests.
58 TEST(FlexfecReceiveStreamTest, RecoversPacketWhenStarted) { 60 TEST(FlexfecReceiveStreamTest, RecoversPacketWhenStarted) {
59 constexpr uint8_t kFlexfecPlType = 118; 61 constexpr uint8_t kFlexfecPlType = 118;
60 constexpr uint8_t kFlexfecSeqNum[] = {0x00, 0x01}; 62 constexpr uint8_t kFlexfecSeqNum[] = {0x00, 0x01};
61 constexpr uint8_t kFlexfecTs[] = {0x00, 0x11, 0x22, 0x33}; 63 constexpr uint8_t kFlexfecTs[] = {0x00, 0x11, 0x22, 0x33};
62 constexpr uint8_t kFlexfecSsrc[] = {0x00, 0x00, 0x00, 0x01}; 64 constexpr uint8_t kFlexfecSsrc[] = {0x00, 0x00, 0x00, 0x01};
63 constexpr uint8_t kMediaPlType = 107; 65 constexpr uint8_t kMediaPlType = 107;
64 constexpr uint8_t kMediaSeqNum[] = {0x00, 0x02}; 66 constexpr uint8_t kMediaSeqNum[] = {0x00, 0x02};
(...skipping 17 matching lines...) Expand all
82 kFlexfecSsrc[0], kFlexfecSsrc[1], kFlexfecSsrc[2], kFlexfecSsrc[3], 84 kFlexfecSsrc[0], kFlexfecSsrc[1], kFlexfecSsrc[2], kFlexfecSsrc[3],
83 // FlexFEC header. 85 // FlexFEC header.
84 0x00, kMediaPlType, kPayloadLength[0], kPayloadLength[1], 86 0x00, kMediaPlType, kPayloadLength[0], kPayloadLength[1],
85 kMediaTs[0], kMediaTs[1], kMediaTs[2], kMediaTs[3], 87 kMediaTs[0], kMediaTs[1], kMediaTs[2], kMediaTs[3],
86 kSsrcCount, kReservedBits, kReservedBits, kReservedBits, 88 kSsrcCount, kReservedBits, kReservedBits, kReservedBits,
87 kMediaSsrc[0], kMediaSsrc[1], kMediaSsrc[2], kMediaSsrc[3], 89 kMediaSsrc[0], kMediaSsrc[1], kMediaSsrc[2], kMediaSsrc[3],
88 kMediaSeqNum[0], kMediaSeqNum[1], kFlexfecPktMask[0], kFlexfecPktMask[1], 90 kMediaSeqNum[0], kMediaSeqNum[1], kFlexfecPktMask[0], kFlexfecPktMask[1],
89 // FEC payload. 91 // FEC payload.
90 kPayloadBits, kPayloadBits, kPayloadBits, kPayloadBits}; 92 kPayloadBits, kPayloadBits, kPayloadBits, kPayloadBits};
91 // clang-format on 93 // clang-format on
94 constexpr size_t kFlexfecPacketLength = sizeof(kFlexfecPacket);
92 95
93 FlexfecReceiveStream::Config config; 96 FlexfecReceiveStream::Config config;
94 config.payload_type = kFlexfecPlType; 97 config.payload_type = kFlexfecPlType;
95 config.remote_ssrc = ByteReader<uint32_t>::ReadBigEndian(kFlexfecSsrc); 98 config.remote_ssrc = ByteReader<uint32_t>::ReadBigEndian(kFlexfecSsrc);
96 config.protected_media_ssrcs = { 99 config.protected_media_ssrcs = {
97 ByteReader<uint32_t>::ReadBigEndian(kMediaSsrc)}; 100 ByteReader<uint32_t>::ReadBigEndian(kMediaSsrc)};
98 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver; 101 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver;
99 FlexfecReceiveStreamImpl receive_stream(config, &recovered_packet_receiver); 102 FlexfecReceiveStreamImpl receive_stream(config, &recovered_packet_receiver);
100 103
101 // Do not call back before being started. 104 // Do not call back before being started.
102 receive_stream.AddAndProcessReceivedPacket(ParsePacket(kFlexfecPacket)); 105 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket,
106 kFlexfecPacketLength);
103 107
104 // Call back after being started. 108 // Call back after being started.
105 receive_stream.Start(); 109 receive_stream.Start();
106 EXPECT_CALL( 110 EXPECT_CALL(
107 recovered_packet_receiver, 111 recovered_packet_receiver,
108 OnRecoveredPacket(::testing::_, kRtpHeaderSize + kPayloadLength[1])); 112 OnRecoveredPacket(::testing::_, kRtpHeaderSize + kPayloadLength[1]));
109 receive_stream.AddAndProcessReceivedPacket(ParsePacket(kFlexfecPacket)); 113 receive_stream.AddAndProcessReceivedPacket(kFlexfecPacket,
114 kFlexfecPacketLength);
110 } 115 }
111 116
112 } // namespace webrtc 117 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/flexfec_receive_stream_impl.cc ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698