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 26 matching lines...) Expand all Loading... |
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); | 42 payload_router.SetSendStreams(streams); |
43 | 43 |
44 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 44 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
45 encoded_image._timeStamp, | 45 encoded_image._timeStamp, |
46 encoded_image.capture_time_ms_, &payload, | 46 encoded_image.capture_time_ms_, &payload, |
47 encoded_image._length, nullptr, _, _)) | 47 encoded_image._length, nullptr, _)) |
48 .Times(0); | 48 .Times(0); |
49 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 49 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
50 | 50 |
51 payload_router.set_active(true); | 51 payload_router.set_active(true); |
52 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 52 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
53 encoded_image._timeStamp, | 53 encoded_image._timeStamp, |
54 encoded_image.capture_time_ms_, &payload, | 54 encoded_image.capture_time_ms_, &payload, |
55 encoded_image._length, nullptr, _, _)) | 55 encoded_image._length, nullptr, _)) |
56 .Times(1); | 56 .Times(1); |
57 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 57 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
58 | 58 |
59 payload_router.set_active(false); | 59 payload_router.set_active(false); |
60 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 60 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
61 encoded_image._timeStamp, | 61 encoded_image._timeStamp, |
62 encoded_image.capture_time_ms_, &payload, | 62 encoded_image.capture_time_ms_, &payload, |
63 encoded_image._length, nullptr, _, _)) | 63 encoded_image._length, nullptr, _)) |
64 .Times(0); | 64 .Times(0); |
65 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 65 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
66 | 66 |
67 payload_router.set_active(true); | 67 payload_router.set_active(true); |
68 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 68 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
69 encoded_image._timeStamp, | 69 encoded_image._timeStamp, |
70 encoded_image.capture_time_ms_, &payload, | 70 encoded_image.capture_time_ms_, &payload, |
71 encoded_image._length, nullptr, _, _)) | 71 encoded_image._length, nullptr, _)) |
72 .Times(1); | 72 .Times(1); |
73 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 73 EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
74 | 74 |
75 streams.clear(); | 75 streams.clear(); |
76 payload_router.SetSendStreams(streams); | 76 payload_router.SetSendStreams(streams); |
77 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 77 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, |
78 encoded_image._timeStamp, | 78 encoded_image._timeStamp, |
79 encoded_image.capture_time_ms_, &payload, | 79 encoded_image.capture_time_ms_, &payload, |
80 encoded_image._length, nullptr, _, _)) | 80 encoded_image._length, nullptr, _)) |
81 .Times(0); | 81 .Times(0); |
82 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 82 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); |
83 } | 83 } |
84 | 84 |
85 TEST(PayloadRouterTest, SendSimulcast) { | 85 TEST(PayloadRouterTest, SendSimulcast) { |
86 NiceMock<MockRtpRtcp> rtp_1; | 86 NiceMock<MockRtpRtcp> rtp_1; |
87 NiceMock<MockRtpRtcp> rtp_2; | 87 NiceMock<MockRtpRtcp> rtp_2; |
88 std::vector<RtpRtcp*> modules; | 88 std::vector<RtpRtcp*> modules; |
89 modules.push_back(&rtp_1); | 89 modules.push_back(&rtp_1); |
90 modules.push_back(&rtp_2); | 90 modules.push_back(&rtp_2); |
(...skipping 13 matching lines...) Expand all Loading... |
104 | 104 |
105 CodecSpecificInfo codec_info_1; | 105 CodecSpecificInfo codec_info_1; |
106 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo)); | 106 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo)); |
107 codec_info_1.codecType = kVideoCodecVP8; | 107 codec_info_1.codecType = kVideoCodecVP8; |
108 codec_info_1.codecSpecific.VP8.simulcastIdx = 0; | 108 codec_info_1.codecSpecific.VP8.simulcastIdx = 0; |
109 | 109 |
110 payload_router.set_active(true); | 110 payload_router.set_active(true); |
111 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, | 111 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, |
112 encoded_image._timeStamp, | 112 encoded_image._timeStamp, |
113 encoded_image.capture_time_ms_, &payload, | 113 encoded_image.capture_time_ms_, &payload, |
114 encoded_image._length, nullptr, _, _)) | 114 encoded_image._length, nullptr, _)) |
115 .Times(1); | 115 .Times(1); |
116 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); | 116 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
| 117 .Times(0); |
117 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 118 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); |
118 | 119 |
119 CodecSpecificInfo codec_info_2; | 120 CodecSpecificInfo codec_info_2; |
120 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); | 121 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); |
121 codec_info_2.codecType = kVideoCodecVP8; | 122 codec_info_2.codecType = kVideoCodecVP8; |
122 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 123 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; |
123 | 124 |
124 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, | 125 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, |
125 encoded_image._timeStamp, | 126 encoded_image._timeStamp, |
126 encoded_image.capture_time_ms_, &payload, | 127 encoded_image.capture_time_ms_, &payload, |
127 encoded_image._length, nullptr, _, _)) | 128 encoded_image._length, nullptr, _)) |
128 .Times(1); | 129 .Times(1); |
129 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 130 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
130 .Times(0); | 131 .Times(0); |
131 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 132 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
132 | 133 |
133 // Inactive. | 134 // Inactive. |
134 payload_router.set_active(false); | 135 payload_router.set_active(false); |
135 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 136 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
136 .Times(0); | 137 .Times(0); |
137 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 138 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
138 .Times(0); | 139 .Times(0); |
139 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 140 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)); | 141 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
141 | 142 |
142 // Invalid simulcast index. | 143 // Invalid simulcast index. |
143 streams.pop_back(); // Remove a stream. | 144 streams.pop_back(); // Remove a stream. |
144 payload_router.SetSendStreams(streams); | 145 payload_router.SetSendStreams(streams); |
145 payload_router.set_active(true); | 146 payload_router.set_active(true); |
146 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 147 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
147 .Times(0); | 148 .Times(0); |
148 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 149 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
149 .Times(0); | 150 .Times(0); |
150 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 151 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; |
151 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 152 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
152 } | 153 } |
153 | 154 |
154 TEST(PayloadRouterTest, MaxPayloadLength) { | 155 TEST(PayloadRouterTest, MaxPayloadLength) { |
155 // Without any limitations from the modules, verify we get the max payload | 156 // Without any limitations from the modules, verify we get the max payload |
156 // length for IP/UDP/SRTP with a MTU of 150 bytes. | 157 // length for IP/UDP/SRTP with a MTU of 150 bytes. |
157 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 158 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
158 NiceMock<MockRtpRtcp> rtp_1; | 159 NiceMock<MockRtpRtcp> rtp_1; |
(...skipping 20 matching lines...) Expand all Loading... |
179 const size_t kTestMinPayloadLength = 1001; | 180 const size_t kTestMinPayloadLength = 1001; |
180 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 181 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
181 .Times(1) | 182 .Times(1) |
182 .WillOnce(Return(kTestMinPayloadLength + 10)); | 183 .WillOnce(Return(kTestMinPayloadLength + 10)); |
183 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 184 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
184 .Times(1) | 185 .Times(1) |
185 .WillOnce(Return(kTestMinPayloadLength)); | 186 .WillOnce(Return(kTestMinPayloadLength)); |
186 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); | 187 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); |
187 } | 188 } |
188 } // namespace webrtc | 189 } // namespace webrtc |
OLD | NEW |