| 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 27 matching lines...) Expand all  Loading... | 
| 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 | 42 | 
| 43   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 43   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 44                                     encoded_image._timeStamp, | 44                                     encoded_image._timeStamp, | 
| 45                                     encoded_image.capture_time_ms_, &payload, | 45                                     encoded_image.capture_time_ms_, &payload, | 
| 46                                     encoded_image._length, nullptr, _, _)) | 46                                     encoded_image._length, nullptr, _, _)) | 
| 47       .Times(0); | 47       .Times(0); | 
| 48   EXPECT_NE( | 48   EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 
| 49       EncodedImageCallback::Result::OK, |  | 
| 50       payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); |  | 
| 51 | 49 | 
| 52   payload_router.set_active(true); | 50   payload_router.set_active(true); | 
| 53   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 51   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 54                                     encoded_image._timeStamp, | 52                                     encoded_image._timeStamp, | 
| 55                                     encoded_image.capture_time_ms_, &payload, | 53                                     encoded_image.capture_time_ms_, &payload, | 
| 56                                     encoded_image._length, nullptr, _, _)) | 54                                     encoded_image._length, nullptr, _, _)) | 
| 57       .Times(1); | 55       .Times(1); | 
| 58   EXPECT_EQ( | 56   EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 
| 59       EncodedImageCallback::Result::OK, |  | 
| 60       payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); |  | 
| 61 | 57 | 
| 62   payload_router.set_active(false); | 58   payload_router.set_active(false); | 
| 63   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 59   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 64                                     encoded_image._timeStamp, | 60                                     encoded_image._timeStamp, | 
| 65                                     encoded_image.capture_time_ms_, &payload, | 61                                     encoded_image.capture_time_ms_, &payload, | 
| 66                                     encoded_image._length, nullptr, _, _)) | 62                                     encoded_image._length, nullptr, _, _)) | 
| 67       .Times(0); | 63       .Times(0); | 
| 68   EXPECT_NE( | 64   EXPECT_EQ(-1, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 
| 69       EncodedImageCallback::Result::OK, |  | 
| 70       payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); |  | 
| 71 | 65 | 
| 72   payload_router.set_active(true); | 66   payload_router.set_active(true); | 
| 73   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 67   EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 74                                     encoded_image._timeStamp, | 68                                     encoded_image._timeStamp, | 
| 75                                     encoded_image.capture_time_ms_, &payload, | 69                                     encoded_image.capture_time_ms_, &payload, | 
| 76                                     encoded_image._length, nullptr, _, _)) | 70                                     encoded_image._length, nullptr, _, _)) | 
| 77       .Times(1); | 71       .Times(1); | 
| 78   EXPECT_EQ( | 72   EXPECT_EQ(0, payload_router.Encoded(encoded_image, nullptr, nullptr)); | 
| 79       EncodedImageCallback::Result::OK, |  | 
| 80       payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); |  | 
| 81 } | 73 } | 
| 82 | 74 | 
| 83 TEST(PayloadRouterTest, SendSimulcast) { | 75 TEST(PayloadRouterTest, SendSimulcast) { | 
| 84   NiceMock<MockRtpRtcp> rtp_1; | 76   NiceMock<MockRtpRtcp> rtp_1; | 
| 85   NiceMock<MockRtpRtcp> rtp_2; | 77   NiceMock<MockRtpRtcp> rtp_2; | 
| 86   std::vector<RtpRtcp*> modules; | 78   std::vector<RtpRtcp*> modules; | 
| 87   modules.push_back(&rtp_1); | 79   modules.push_back(&rtp_1); | 
| 88   modules.push_back(&rtp_2); | 80   modules.push_back(&rtp_2); | 
| 89   std::vector<VideoStream> streams(2); | 81   std::vector<VideoStream> streams(2); | 
| 90 | 82 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 104   codec_info_1.codecType = kVideoCodecVP8; | 96   codec_info_1.codecType = kVideoCodecVP8; | 
| 105   codec_info_1.codecSpecific.VP8.simulcastIdx = 0; | 97   codec_info_1.codecSpecific.VP8.simulcastIdx = 0; | 
| 106 | 98 | 
| 107   payload_router.set_active(true); | 99   payload_router.set_active(true); | 
| 108   EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, | 100   EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 109                                       encoded_image._timeStamp, | 101                                       encoded_image._timeStamp, | 
| 110                                       encoded_image.capture_time_ms_, &payload, | 102                                       encoded_image.capture_time_ms_, &payload, | 
| 111                                       encoded_image._length, nullptr, _, _)) | 103                                       encoded_image._length, nullptr, _, _)) | 
| 112       .Times(1); | 104       .Times(1); | 
| 113   EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); | 105   EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); | 
| 114   EXPECT_EQ(EncodedImageCallback::Result::OK, | 106   EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 
| 115             payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr) |  | 
| 116                 .error); |  | 
| 117 | 107 | 
| 118   CodecSpecificInfo codec_info_2; | 108   CodecSpecificInfo codec_info_2; | 
| 119   memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); | 109   memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); | 
| 120   codec_info_2.codecType = kVideoCodecVP8; | 110   codec_info_2.codecType = kVideoCodecVP8; | 
| 121   codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 111   codec_info_2.codecSpecific.VP8.simulcastIdx = 1; | 
| 122 | 112 | 
| 123   EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, | 113   EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, | 
| 124                                       encoded_image._timeStamp, | 114                                       encoded_image._timeStamp, | 
| 125                                       encoded_image.capture_time_ms_, &payload, | 115                                       encoded_image.capture_time_ms_, &payload, | 
| 126                                       encoded_image._length, nullptr, _, _)) | 116                                       encoded_image._length, nullptr, _, _)) | 
| 127       .Times(1); | 117       .Times(1); | 
| 128   EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 118   EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 
| 129       .Times(0); | 119       .Times(0); | 
| 130   EXPECT_EQ(EncodedImageCallback::Result::OK, | 120   EXPECT_EQ(0, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 
| 131             payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr) |  | 
| 132                 .error); |  | 
| 133 | 121 | 
| 134   // Inactive. | 122   // Inactive. | 
| 135   payload_router.set_active(false); | 123   payload_router.set_active(false); | 
| 136   EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 124   EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 
| 137       .Times(0); | 125       .Times(0); | 
| 138   EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 126   EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) | 
| 139       .Times(0); | 127       .Times(0); | 
| 140   EXPECT_NE(EncodedImageCallback::Result::OK, | 128   EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_1, nullptr)); | 
| 141             payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr) | 129   EXPECT_EQ(-1, payload_router.Encoded(encoded_image, &codec_info_2, nullptr)); | 
| 142                 .error); |  | 
| 143   EXPECT_NE(EncodedImageCallback::Result::OK, |  | 
| 144             payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr) |  | 
| 145                 .error); |  | 
| 146 } | 130 } | 
| 147 | 131 | 
| 148 TEST(PayloadRouterTest, MaxPayloadLength) { | 132 TEST(PayloadRouterTest, MaxPayloadLength) { | 
| 149   // 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 | 
| 150   // length for IP/UDP/SRTP with a MTU of 150 bytes. | 134   // length for IP/UDP/SRTP with a MTU of 150 bytes. | 
| 151   const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 135   const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 
| 152   NiceMock<MockRtpRtcp> rtp_1; | 136   NiceMock<MockRtpRtcp> rtp_1; | 
| 153   NiceMock<MockRtpRtcp> rtp_2; | 137   NiceMock<MockRtpRtcp> rtp_2; | 
| 154   std::vector<RtpRtcp*> modules; | 138   std::vector<RtpRtcp*> modules; | 
| 155   modules.push_back(&rtp_1); | 139   modules.push_back(&rtp_1); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 172   const size_t kTestMinPayloadLength = 1001; | 156   const size_t kTestMinPayloadLength = 1001; | 
| 173   EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 157   EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 
| 174       .Times(1) | 158       .Times(1) | 
| 175       .WillOnce(Return(kTestMinPayloadLength + 10)); | 159       .WillOnce(Return(kTestMinPayloadLength + 10)); | 
| 176   EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 160   EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 
| 177       .Times(1) | 161       .Times(1) | 
| 178       .WillOnce(Return(kTestMinPayloadLength)); | 162       .WillOnce(Return(kTestMinPayloadLength)); | 
| 179   EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); | 163   EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); | 
| 180 } | 164 } | 
| 181 }  // namespace webrtc | 165 }  // namespace webrtc | 
| OLD | NEW | 
|---|