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 24 matching lines...) Expand all Loading... |
35 MockRtpRtcp rtp; | 35 MockRtpRtcp rtp; |
36 std::vector<RtpRtcp*> modules(1, &rtp); | 36 std::vector<RtpRtcp*> modules(1, &rtp); |
37 | 37 |
38 payload_router_->Init(modules); | 38 payload_router_->Init(modules); |
39 payload_router_->SetSendingRtpModules(modules.size()); | 39 payload_router_->SetSendingRtpModules(modules.size()); |
40 | 40 |
41 uint8_t payload = 'a'; | 41 uint8_t payload = 'a'; |
42 FrameType frame_type = kVideoFrameKey; | 42 FrameType frame_type = kVideoFrameKey; |
43 int8_t payload_type = 96; | 43 int8_t payload_type = 96; |
44 | 44 |
45 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 45 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
46 NULL)) | 46 nullptr, nullptr)) |
47 .Times(0); | 47 .Times(0); |
48 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 48 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
49 &payload, 1, NULL, NULL)); | 49 &payload, 1, nullptr, nullptr)); |
50 | 50 |
51 payload_router_->set_active(true); | 51 payload_router_->set_active(true); |
52 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 52 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
53 NULL)) | 53 nullptr, nullptr)) |
54 .Times(1); | 54 .Times(1); |
55 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 55 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
56 &payload, 1, NULL, NULL)); | 56 &payload, 1, nullptr, nullptr)); |
57 | 57 |
58 payload_router_->set_active(false); | 58 payload_router_->set_active(false); |
59 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 59 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
60 NULL)) | 60 nullptr, nullptr)) |
61 .Times(0); | 61 .Times(0); |
62 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 62 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
63 &payload, 1, NULL, NULL)); | 63 &payload, 1, nullptr, nullptr)); |
64 | 64 |
65 payload_router_->set_active(true); | 65 payload_router_->set_active(true); |
66 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 66 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
67 NULL)) | 67 nullptr, nullptr)) |
68 .Times(1); | 68 .Times(1); |
69 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 69 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
70 &payload, 1, NULL, NULL)); | 70 &payload, 1, nullptr, nullptr)); |
71 | 71 |
72 payload_router_->SetSendingRtpModules(0); | 72 payload_router_->SetSendingRtpModules(0); |
73 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 73 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
74 NULL)) | 74 nullptr, nullptr)) |
75 .Times(0); | 75 .Times(0); |
76 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 76 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
77 &payload, 1, NULL, NULL)); | 77 &payload, 1, nullptr, nullptr)); |
78 } | 78 } |
79 | 79 |
80 TEST_F(PayloadRouterTest, SendSimulcast) { | 80 TEST_F(PayloadRouterTest, SendSimulcast) { |
81 MockRtpRtcp rtp_1; | 81 MockRtpRtcp rtp_1; |
82 MockRtpRtcp rtp_2; | 82 MockRtpRtcp rtp_2; |
83 std::vector<RtpRtcp*> modules; | 83 std::vector<RtpRtcp*> modules; |
84 modules.push_back(&rtp_1); | 84 modules.push_back(&rtp_1); |
85 modules.push_back(&rtp_2); | 85 modules.push_back(&rtp_2); |
86 | 86 |
87 payload_router_->Init(modules); | 87 payload_router_->Init(modules); |
88 payload_router_->SetSendingRtpModules(modules.size()); | 88 payload_router_->SetSendingRtpModules(modules.size()); |
89 | 89 |
90 uint8_t payload_1 = 'a'; | 90 uint8_t payload_1 = 'a'; |
91 FrameType frame_type_1 = kVideoFrameKey; | 91 FrameType frame_type_1 = kVideoFrameKey; |
92 int8_t payload_type_1 = 96; | 92 int8_t payload_type_1 = 96; |
93 RTPVideoHeader rtp_hdr_1; | 93 RTPVideoHeader rtp_hdr_1; |
94 rtp_hdr_1.simulcastIdx = 0; | 94 rtp_hdr_1.simulcastIdx = 0; |
95 | 95 |
96 payload_router_->set_active(true); | 96 payload_router_->set_active(true); |
97 EXPECT_CALL(rtp_1, SendOutgoingData(frame_type_1, payload_type_1, 0, 0, _, 1, | 97 EXPECT_CALL(rtp_1, SendOutgoingData(frame_type_1, payload_type_1, 0, 0, _, 1, |
98 NULL, &rtp_hdr_1)) | 98 nullptr, &rtp_hdr_1)) |
99 .Times(1); | 99 .Times(1); |
100 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) | 100 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
101 .Times(0); | 101 .Times(0); |
102 EXPECT_TRUE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0, | 102 EXPECT_TRUE(payload_router_->RoutePayload( |
103 &payload_1, 1, NULL, &rtp_hdr_1)); | 103 frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
104 | 104 |
105 uint8_t payload_2 = 'b'; | 105 uint8_t payload_2 = 'b'; |
106 FrameType frame_type_2 = kVideoFrameDelta; | 106 FrameType frame_type_2 = kVideoFrameDelta; |
107 int8_t payload_type_2 = 97; | 107 int8_t payload_type_2 = 97; |
108 RTPVideoHeader rtp_hdr_2; | 108 RTPVideoHeader rtp_hdr_2; |
109 rtp_hdr_2.simulcastIdx = 1; | 109 rtp_hdr_2.simulcastIdx = 1; |
110 EXPECT_CALL(rtp_2, SendOutgoingData(frame_type_2, payload_type_2, 0, 0, _, 1, | 110 EXPECT_CALL(rtp_2, SendOutgoingData(frame_type_2, payload_type_2, 0, 0, _, 1, |
111 NULL, &rtp_hdr_2)) | 111 nullptr, &rtp_hdr_2)) |
112 .Times(1); | 112 .Times(1); |
113 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 113 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
114 .Times(0); | 114 .Times(0); |
115 EXPECT_TRUE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0, | 115 EXPECT_TRUE(payload_router_->RoutePayload( |
116 &payload_2, 1, NULL, &rtp_hdr_2)); | 116 frame_type_2, payload_type_2, 0, 0, &payload_2, 1, nullptr, &rtp_hdr_2)); |
117 | 117 |
118 // Inactive. | 118 // Inactive. |
119 payload_router_->set_active(false); | 119 payload_router_->set_active(false); |
120 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 120 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
121 .Times(0); | 121 .Times(0); |
122 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) | 122 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
123 .Times(0); | 123 .Times(0); |
124 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0, | 124 EXPECT_FALSE(payload_router_->RoutePayload( |
125 &payload_1, 1, NULL, &rtp_hdr_1)); | 125 frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
126 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0, | 126 EXPECT_FALSE(payload_router_->RoutePayload( |
127 &payload_2, 1, NULL, &rtp_hdr_2)); | 127 frame_type_2, payload_type_2, 0, 0, &payload_2, 1, nullptr, &rtp_hdr_2)); |
128 | 128 |
129 // Invalid simulcast index. | 129 // Invalid simulcast index. |
130 payload_router_->SetSendingRtpModules(1); | 130 payload_router_->SetSendingRtpModules(1); |
131 payload_router_->set_active(true); | 131 payload_router_->set_active(true); |
132 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) | 132 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
133 .Times(0); | 133 .Times(0); |
134 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) | 134 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
135 .Times(0); | 135 .Times(0); |
136 rtp_hdr_1.simulcastIdx = 1; | 136 rtp_hdr_1.simulcastIdx = 1; |
137 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0, | 137 EXPECT_FALSE(payload_router_->RoutePayload( |
138 &payload_1, 1, NULL, &rtp_hdr_1)); | 138 frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
139 } | 139 } |
140 | 140 |
141 TEST_F(PayloadRouterTest, MaxPayloadLength) { | 141 TEST_F(PayloadRouterTest, MaxPayloadLength) { |
142 // Without any limitations from the modules, verify we get the max payload | 142 // Without any limitations from the modules, verify we get the max payload |
143 // length for IP/UDP/SRTP with a MTU of 150 bytes. | 143 // length for IP/UDP/SRTP with a MTU of 150 bytes. |
144 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 144 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
145 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); | 145 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); |
146 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); | 146 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); |
147 | 147 |
148 MockRtpRtcp rtp_1; | 148 MockRtpRtcp rtp_1; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 payload_router_->SetTargetSendBitrates(bitrates); | 193 payload_router_->SetTargetSendBitrates(bitrates); |
194 | 194 |
195 bitrates.resize(1); | 195 bitrates.resize(1); |
196 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) | 196 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) |
197 .Times(1); | 197 .Times(1); |
198 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) | 198 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) |
199 .Times(0); | 199 .Times(0); |
200 payload_router_->SetTargetSendBitrates(bitrates); | 200 payload_router_->SetTargetSendBitrates(bitrates); |
201 } | 201 } |
202 } // namespace webrtc | 202 } // namespace webrtc |
OLD | NEW |