| 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(_, _, _, _, _, _, _, _)) | 116 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); |
| 117 .Times(0); | |
| 118 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 117 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); |
| 119 | 118 |
| 120 CodecSpecificInfo codec_info_2; | 119 CodecSpecificInfo codec_info_2; |
| 121 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); | 120 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); |
| 122 codec_info_2.codecType = kVideoCodecVP8; | 121 codec_info_2.codecType = kVideoCodecVP8; |
| 123 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 122 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; |
| 124 | 123 |
| 125 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, | 124 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, |
| 126 encoded_image._timeStamp, | 125 encoded_image._timeStamp, |
| 127 encoded_image.capture_time_ms_, &payload, | 126 encoded_image.capture_time_ms_, &payload, |
| 128 encoded_image._length, nullptr, _)) | 127 encoded_image._length, nullptr, _, _)) |
| 129 .Times(1); | 128 .Times(1); |
| 130 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 129 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
| 131 .Times(0); | 130 .Times(0); |
| 132 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 131 EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
| 133 | 132 |
| 134 // Inactive. | 133 // Inactive. |
| 135 payload_router.set_active(false); | 134 payload_router.set_active(false); |
| 136 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 135 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
| 137 .Times(0); | 136 .Times(0); |
| 138 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) | 137 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
| 139 .Times(0); | 138 .Times(0); |
| 140 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 139 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); |
| 141 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 140 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
| 142 | 141 |
| 143 // Invalid simulcast index. | 142 // Invalid simulcast index. |
| 144 streams.pop_back(); // Remove a stream. | 143 streams.pop_back(); // Remove a stream. |
| 145 payload_router.SetSendStreams(streams); | 144 payload_router.SetSendStreams(streams); |
| 146 payload_router.set_active(true); | 145 payload_router.set_active(true); |
| 147 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 146 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
| 148 .Times(0); | 147 .Times(0); |
| 149 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) | 148 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) |
| 150 .Times(0); | 149 .Times(0); |
| 151 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 150 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; |
| 152 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 151 EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); |
| 153 } | 152 } |
| 154 | 153 |
| 155 TEST(PayloadRouterTest, MaxPayloadLength) { | 154 TEST(PayloadRouterTest, MaxPayloadLength) { |
| 156 // Without any limitations from the modules, verify we get the max payload | 155 // Without any limitations from the modules, verify we get the max payload |
| 157 // length for IP/UDP/SRTP with a MTU of 150 bytes. | 156 // length for IP/UDP/SRTP with a MTU of 150 bytes. |
| 158 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 157 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
| 159 NiceMock<MockRtpRtcp> rtp_1; | 158 NiceMock<MockRtpRtcp> rtp_1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 180 const size_t kTestMinPayloadLength = 1001; | 179 const size_t kTestMinPayloadLength = 1001; |
| 181 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 180 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
| 182 .Times(1) | 181 .Times(1) |
| 183 .WillOnce(Return(kTestMinPayloadLength + 10)); | 182 .WillOnce(Return(kTestMinPayloadLength + 10)); |
| 184 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 183 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
| 185 .Times(1) | 184 .Times(1) |
| 186 .WillOnce(Return(kTestMinPayloadLength)); | 185 .WillOnce(Return(kTestMinPayloadLength)); |
| 187 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); | 186 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); |
| 188 } | 187 } |
| 189 } // namespace webrtc | 188 } // namespace webrtc |
| OLD | NEW |