OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 uint8_t payload = 'a'; | 32 uint8_t payload = 'a'; |
33 int8_t payload_type = 96; | 33 int8_t payload_type = 96; |
34 EncodedImage encoded_image; | 34 EncodedImage encoded_image; |
35 encoded_image._timeStamp = 1; | 35 encoded_image._timeStamp = 1; |
36 encoded_image.capture_time_ms_ = 2; | 36 encoded_image.capture_time_ms_ = 2; |
37 encoded_image._frameType = kVideoFrameKey; | 37 encoded_image._frameType = kVideoFrameKey; |
38 encoded_image._buffer = &payload; | 38 encoded_image._buffer = &payload; |
39 encoded_image._length = 1; | 39 encoded_image._length = 1; |
40 | 40 |
41 PayloadRouter payload_router(modules, payload_type); | 41 PayloadRouter payload_router(modules, payload_type); |
42 payload_router.SetSendStreams(streams); | |
43 | 42 |
44 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 43 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
45 encoded_image._timeStamp, | 44 encoded_image._timeStamp, |
46 encoded_image.capture_time_ms_, &payload, | 45 encoded_image.capture_time_ms_, &payload, |
47 encoded_image._length, nullptr, _, _)) | 46 encoded_image._length, nullptr, _, _)) |
48 .Times(0); | 47 .Times(0); |
49 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 48 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
50 | 49 |
51 payload_router.set_active(true); | 50 payload_router.set_active(true); |
52 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 51 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
(...skipping 11 matching lines...) Expand all Loading... |
64 .Times(0); | 63 .Times(0); |
65 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 64 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
66 | 65 |
67 payload_router.set_active(true); | 66 payload_router.set_active(true); |
68 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 67 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
69 encoded_image._timeStamp, | 68 encoded_image._timeStamp, |
70 encoded_image.capture_time_ms_, &payload, | 69 encoded_image.capture_time_ms_, &payload, |
71 encoded_image._length, nullptr, _, _)) | 70 encoded_image._length, nullptr, _, _)) |
72 .Times(1); | 71 .Times(1); |
73 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 72 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
74 | |
75 streams.clear(); | |
76 payload_router.SetSendStreams(streams); | |
77 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | |
78 encoded_image._timeStamp, | |
79 encoded_image.capture_time_ms_, &payload, | |
80 encoded_image._length, nullptr, _, _)) | |
81 .Times(0); | |
82 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | |
83 } | 73 } |
84 | 74 |
85 TEST(PayloadRouterTest, SendSimulcast) { | 75 TEST(PayloadRouterTest, SendSimulcast) { |
86 NiceMock<MockRtpRtcp> rtp_1; | 76 NiceMock<MockRtpRtcp> rtp_1; |
87 NiceMock<MockRtpRtcp> rtp_2; | 77 NiceMock<MockRtpRtcp> rtp_2; |
88 std::vector<RtpRtcp*> modules; | 78 std::vector<RtpRtcp*> modules; |
89 modules.push_back(&rtp_1); | 79 modules.push_back(&rtp_1); |
90 modules.push_back(&rtp_2); | 80 modules.push_back(&rtp_2); |
91 std::vector<VideoStream> streams(2); | 81 std::vector<VideoStream> streams(2); |
92 | 82 |
93 int8_t payload_type = 96; | 83 int8_t payload_type = 96; |
94 uint8_t payload = 'a'; | 84 uint8_t payload = 'a'; |
95 EncodedImage encoded_image; | 85 EncodedImage encoded_image; |
96 encoded_image._timeStamp = 1; | 86 encoded_image._timeStamp = 1; |
97 encoded_image.capture_time_ms_ = 2; | 87 encoded_image.capture_time_ms_ = 2; |
98 encoded_image._frameType = kVideoFrameKey; | 88 encoded_image._frameType = kVideoFrameKey; |
99 encoded_image._buffer = &payload; | 89 encoded_image._buffer = &payload; |
100 encoded_image._length = 1; | 90 encoded_image._length = 1; |
101 | 91 |
102 PayloadRouter payload_router(modules, payload_type); | 92 PayloadRouter payload_router(modules, payload_type); |
103 payload_router.SetSendStreams(streams); | |
104 | 93 |
105 CodecSpecificInfo codec_info_1; | 94 CodecSpecificInfo codec_info_1; |
106 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo)); | 95 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo)); |
107 codec_info_1.codecType = kVideoCodecVP8; | 96 codec_info_1.codecType = kVideoCodecVP8; |
108 codec_info_1.codecSpecific.VP8.simulcastIdx = 0; | 97 codec_info_1.codecSpecific.VP8.simulcastIdx = 0; |
109 | 98 |
110 payload_router.set_active(true); | 99 payload_router.set_active(true); |
111 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, | 100 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, |
112 encoded_image._timeStamp, | 101 encoded_image._timeStamp, |
113 encoded_image.capture_time_ms_, &payload, | 102 encoded_image.capture_time_ms_, &payload, |
(...skipping 17 matching lines...) Expand all Loading... |
131 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 120 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
132 | 121 |
133 // Inactive. | 122 // Inactive. |
134 payload_router.set_active(false); | 123 payload_router.set_active(false); |
135 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 124 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
136 .Times(0); | 125 .Times(0); |
137 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 126 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
138 .Times(0); | 127 .Times(0); |
139 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 128 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); |
140 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 129 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
141 | |
142 // Invalid simulcast index. | |
143 streams.pop_back(); // Remove a stream. | |
144 payload_router.SetSendStreams(streams); | |
145 payload_router.set_active(true); | |
146 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | |
147 .Times(0); | |
148 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | |
149 .Times(0); | |
150 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | |
151 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | |
152 } | 130 } |
153 | 131 |
154 TEST(PayloadRouterTest, MaxPayloadLength) { | 132 TEST(PayloadRouterTest, MaxPayloadLength) { |
155 // Without any limitations from the modules, verify we get the max payload | 133 // Without any limitations from the modules, verify we get the max payload |
156 // length for IP/UDP/SRTP with a MTU of 150 bytes. | 134 // length for IP/UDP/SRTP with a MTU of 150 bytes. |
157 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 135 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
158 NiceMock<MockRtpRtcp> rtp_1; | 136 NiceMock<MockRtpRtcp> rtp_1; |
159 NiceMock<MockRtpRtcp> rtp_2; | 137 NiceMock<MockRtpRtcp> rtp_2; |
160 std::vector<RtpRtcp*> modules; | 138 std::vector<RtpRtcp*> modules; |
161 modules.push_back(&rtp_1); | 139 modules.push_back(&rtp_1); |
162 modules.push_back(&rtp_2); | 140 modules.push_back(&rtp_2); |
163 PayloadRouter payload_router(modules, 42); | 141 PayloadRouter payload_router(modules, 42); |
164 | 142 |
165 EXPECT_EQ(kDefaultMaxLength, PayloadRouter::DefaultMaxPayloadLength()); | 143 EXPECT_EQ(kDefaultMaxLength, PayloadRouter::DefaultMaxPayloadLength()); |
166 std::vector<VideoStream> streams(2); | 144 std::vector<VideoStream> streams(2); |
167 payload_router.SetSendStreams(streams); | |
168 | 145 |
169 // Modules return a higher length than the default value. | 146 // Modules return a higher length than the default value. |
170 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 147 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
171 .Times(1) | 148 .Times(1) |
172 .WillOnce(Return(kDefaultMaxLength + 10)); | 149 .WillOnce(Return(kDefaultMaxLength + 10)); |
173 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 150 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
174 .Times(1) | 151 .Times(1) |
175 .WillOnce(Return(kDefaultMaxLength + 10)); | 152 .WillOnce(Return(kDefaultMaxLength + 10)); |
176 EXPECT_EQ(kDefaultMaxLength, payload_router.MaxPayloadLength()); | 153 EXPECT_EQ(kDefaultMaxLength, payload_router.MaxPayloadLength()); |
177 | 154 |
178 // The modules return a value lower than default. | 155 // The modules return a value lower than default. |
179 const size_t kTestMinPayloadLength = 1001; | 156 const size_t kTestMinPayloadLength = 1001; |
180 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 157 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
181 .Times(1) | 158 .Times(1) |
182 .WillOnce(Return(kTestMinPayloadLength + 10)); | 159 .WillOnce(Return(kTestMinPayloadLength + 10)); |
183 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 160 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
184 .Times(1) | 161 .Times(1) |
185 .WillOnce(Return(kTestMinPayloadLength)); | 162 .WillOnce(Return(kTestMinPayloadLength)); |
186 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); | 163 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); |
187 } | 164 } |
188 } // namespace webrtc | 165 } // namespace webrtc |
OLD | NEW |