OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 EXPECT_TRUE(controller_result1.ok()); | 59 EXPECT_TRUE(controller_result1.ok()); |
60 auto controller_result2 = ortc_factory_->CreateRtpTransportController(); | 60 auto controller_result2 = ortc_factory_->CreateRtpTransportController(); |
61 EXPECT_TRUE(controller_result1.ok()); | 61 EXPECT_TRUE(controller_result1.ok()); |
62 } | 62 } |
63 | 63 |
64 // Simple test for the successful cases of CreateRtpTransport. | 64 // Simple test for the successful cases of CreateRtpTransport. |
65 TEST_F(OrtcFactoryTest, CreateRtpTransportWithAndWithoutMux) { | 65 TEST_F(OrtcFactoryTest, CreateRtpTransportWithAndWithoutMux) { |
66 rtc::FakePacketTransport rtp("rtp"); | 66 rtc::FakePacketTransport rtp("rtp"); |
67 rtc::FakePacketTransport rtcp("rtcp"); | 67 rtc::FakePacketTransport rtcp("rtcp"); |
68 // With muxed RTCP. | 68 // With muxed RTCP. |
69 RtcpParameters rtcp_parameters; | 69 RtpTransportParameters parameters = MakeRtcpMuxParameters(); |
70 rtcp_parameters.mux = true; | 70 auto result = |
71 auto result = ortc_factory_->CreateRtpTransport(rtcp_parameters, &rtp, | 71 ortc_factory_->CreateRtpTransport(parameters, &rtp, nullptr, nullptr); |
72 nullptr, nullptr); | |
73 EXPECT_TRUE(result.ok()); | 72 EXPECT_TRUE(result.ok()); |
74 result.MoveValue().reset(); | 73 result.MoveValue().reset(); |
75 // With non-muxed RTCP. | 74 // With non-muxed RTCP. |
76 rtcp_parameters.mux = false; | 75 parameters.rtcp.mux = false; |
77 result = | 76 result = ortc_factory_->CreateRtpTransport(parameters, &rtp, &rtcp, nullptr); |
78 ortc_factory_->CreateRtpTransport(rtcp_parameters, &rtp, &rtcp, nullptr); | |
79 EXPECT_TRUE(result.ok()); | 77 EXPECT_TRUE(result.ok()); |
80 } | 78 } |
81 | 79 |
82 // Simple test for the successful cases of CreateSrtpTransport. | 80 // Simple test for the successful cases of CreateSrtpTransport. |
83 TEST_F(OrtcFactoryTest, CreateSrtpTransport) { | 81 TEST_F(OrtcFactoryTest, CreateSrtpTransport) { |
84 rtc::FakePacketTransport rtp("rtp"); | 82 rtc::FakePacketTransport rtp("rtp"); |
85 rtc::FakePacketTransport rtcp("rtcp"); | 83 rtc::FakePacketTransport rtcp("rtcp"); |
86 // With muxed RTCP. | 84 // With muxed RTCP. |
87 RtcpParameters rtcp_parameters; | 85 RtpTransportParameters parameters = MakeRtcpMuxParameters(); |
88 rtcp_parameters.mux = true; | 86 auto result = |
89 auto result = ortc_factory_->CreateSrtpTransport(rtcp_parameters, &rtp, | 87 ortc_factory_->CreateSrtpTransport(parameters, &rtp, nullptr, nullptr); |
90 nullptr, nullptr); | |
91 EXPECT_TRUE(result.ok()); | 88 EXPECT_TRUE(result.ok()); |
92 result.MoveValue().reset(); | 89 result.MoveValue().reset(); |
93 // With non-muxed RTCP. | 90 // With non-muxed RTCP. |
94 rtcp_parameters.mux = false; | 91 parameters.rtcp.mux = false; |
95 result = | 92 result = ortc_factory_->CreateSrtpTransport(parameters, &rtp, &rtcp, nullptr); |
96 ortc_factory_->CreateSrtpTransport(rtcp_parameters, &rtp, &rtcp, nullptr); | |
97 EXPECT_TRUE(result.ok()); | 93 EXPECT_TRUE(result.ok()); |
98 } | 94 } |
99 | 95 |
100 // If no CNAME is provided, one should be generated and returned by | 96 // If no CNAME is provided, one should be generated and returned by |
101 // GetRtpParameters. | 97 // GetRtpParameters. |
102 TEST_F(OrtcFactoryTest, CreateRtpTransportGeneratesCname) { | 98 TEST_F(OrtcFactoryTest, CreateRtpTransportGeneratesCname) { |
103 rtc::FakePacketTransport rtp("rtp"); | 99 rtc::FakePacketTransport rtp("rtp"); |
104 RtcpParameters rtcp_parameters; | 100 auto result = ortc_factory_->CreateRtpTransport(MakeRtcpMuxParameters(), &rtp, |
105 rtcp_parameters.mux = true; | |
106 auto result = ortc_factory_->CreateRtpTransport(rtcp_parameters, &rtp, | |
107 nullptr, nullptr); | 101 nullptr, nullptr); |
108 ASSERT_TRUE(result.ok()); | 102 ASSERT_TRUE(result.ok()); |
109 EXPECT_FALSE(result.value()->GetRtcpParameters().cname.empty()); | 103 EXPECT_FALSE(result.value()->GetParameters().rtcp.cname.empty()); |
110 } | 104 } |
111 | 105 |
112 // Extension of the above test; multiple transports created by the same factory | 106 // Extension of the above test; multiple transports created by the same factory |
113 // should use the same generated CNAME. | 107 // should use the same generated CNAME. |
114 TEST_F(OrtcFactoryTest, MultipleRtpTransportsUseSameGeneratedCname) { | 108 TEST_F(OrtcFactoryTest, MultipleRtpTransportsUseSameGeneratedCname) { |
115 rtc::FakePacketTransport packet_transport1("1"); | 109 rtc::FakePacketTransport packet_transport1("1"); |
116 rtc::FakePacketTransport packet_transport2("2"); | 110 rtc::FakePacketTransport packet_transport2("2"); |
117 RtcpParameters rtcp_parameters; | 111 RtpTransportParameters parameters = MakeRtcpMuxParameters(); |
118 rtcp_parameters.mux = true; | |
119 // Sanity check. | 112 // Sanity check. |
120 ASSERT_TRUE(rtcp_parameters.cname.empty()); | 113 ASSERT_TRUE(parameters.rtcp.cname.empty()); |
121 auto result = ortc_factory_->CreateRtpTransport( | 114 auto result = ortc_factory_->CreateRtpTransport( |
122 rtcp_parameters, &packet_transport1, nullptr, nullptr); | 115 parameters, &packet_transport1, nullptr, nullptr); |
123 ASSERT_TRUE(result.ok()); | 116 ASSERT_TRUE(result.ok()); |
124 auto rtp_transport1 = result.MoveValue(); | 117 auto rtp_transport1 = result.MoveValue(); |
125 result = ortc_factory_->CreateRtpTransport( | 118 result = ortc_factory_->CreateRtpTransport(parameters, &packet_transport2, |
126 rtcp_parameters, &packet_transport2, nullptr, nullptr); | 119 nullptr, nullptr); |
127 ASSERT_TRUE(result.ok()); | 120 ASSERT_TRUE(result.ok()); |
128 auto rtp_transport2 = result.MoveValue(); | 121 auto rtp_transport2 = result.MoveValue(); |
129 RtcpParameters params1 = rtp_transport1->GetRtcpParameters(); | 122 RtcpParameters params1 = rtp_transport1->GetParameters().rtcp; |
130 RtcpParameters params2 = rtp_transport2->GetRtcpParameters(); | 123 RtcpParameters params2 = rtp_transport2->GetParameters().rtcp; |
131 EXPECT_FALSE(params1.cname.empty()); | 124 EXPECT_FALSE(params1.cname.empty()); |
132 EXPECT_EQ(params1.cname, params2.cname); | 125 EXPECT_EQ(params1.cname, params2.cname); |
133 } | 126 } |
134 | 127 |
135 TEST_F(OrtcFactoryTest, CreateRtpTransportWithNoPacketTransport) { | 128 TEST_F(OrtcFactoryTest, CreateRtpTransportWithNoPacketTransport) { |
136 auto result = ortc_factory_->CreateRtpTransport(MakeRtcpMuxParameters(), | 129 auto result = ortc_factory_->CreateRtpTransport(MakeRtcpMuxParameters(), |
137 nullptr, nullptr, nullptr); | 130 nullptr, nullptr, nullptr); |
138 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); | 131 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); |
139 } | 132 } |
140 | 133 |
141 // If the |mux| member of the RtcpParameters is false, both an RTP and RTCP | 134 // If the |mux| member of the RtcpParameters is false, both an RTP and RTCP |
142 // packet transport are needed. | 135 // packet transport are needed. |
143 TEST_F(OrtcFactoryTest, CreateRtpTransportWithMissingRtcpTransport) { | 136 TEST_F(OrtcFactoryTest, CreateRtpTransportWithMissingRtcpTransport) { |
144 rtc::FakePacketTransport rtp("rtp"); | 137 rtc::FakePacketTransport rtp("rtp"); |
145 RtcpParameters rtcp_parameters; | 138 RtpTransportParameters parameters; |
146 rtcp_parameters.mux = false; | 139 parameters.rtcp.mux = false; |
147 auto result = ortc_factory_->CreateRtpTransport(rtcp_parameters, &rtp, | 140 auto result = |
148 nullptr, nullptr); | 141 ortc_factory_->CreateRtpTransport(parameters, &rtp, nullptr, nullptr); |
149 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); | 142 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); |
150 } | 143 } |
151 | 144 |
152 // If the |mux| member of the RtcpParameters is true, only an RTP packet | 145 // If the |mux| member of the RtcpParameters is true, only an RTP packet |
153 // transport is necessary. So, passing in an RTCP transport is most likely | 146 // transport is necessary. So, passing in an RTCP transport is most likely |
154 // an accident, and thus should be treated as an error. | 147 // an accident, and thus should be treated as an error. |
155 TEST_F(OrtcFactoryTest, CreateRtpTransportWithExtraneousRtcpTransport) { | 148 TEST_F(OrtcFactoryTest, CreateRtpTransportWithExtraneousRtcpTransport) { |
156 rtc::FakePacketTransport rtp("rtp"); | 149 rtc::FakePacketTransport rtp("rtp"); |
157 rtc::FakePacketTransport rtcp("rtcp"); | 150 rtc::FakePacketTransport rtcp("rtcp"); |
158 RtcpParameters rtcp_parameters; | 151 auto result = ortc_factory_->CreateRtpTransport(MakeRtcpMuxParameters(), &rtp, |
159 rtcp_parameters.mux = true; | 152 &rtcp, nullptr); |
160 auto result = | |
161 ortc_factory_->CreateRtpTransport(rtcp_parameters, &rtp, &rtcp, nullptr); | |
162 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); | 153 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); |
163 } | 154 } |
164 | 155 |
165 // Basic test that CreateUdpTransport works with AF_INET and AF_INET6. | 156 // Basic test that CreateUdpTransport works with AF_INET and AF_INET6. |
166 TEST_F(OrtcFactoryTest, CreateUdpTransport) { | 157 TEST_F(OrtcFactoryTest, CreateUdpTransport) { |
167 auto result = ortc_factory_->CreateUdpTransport(AF_INET); | 158 auto result = ortc_factory_->CreateUdpTransport(AF_INET); |
168 EXPECT_TRUE(result.ok()); | 159 EXPECT_TRUE(result.ok()); |
169 result = ortc_factory_->CreateUdpTransport(AF_INET6); | 160 result = ortc_factory_->CreateUdpTransport(AF_INET6); |
170 EXPECT_TRUE(result.ok()); | 161 EXPECT_TRUE(result.ok()); |
171 } | 162 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 TEST_F(OrtcFactoryTest, CreateSendersOrReceieversWithNullTransport) { | 237 TEST_F(OrtcFactoryTest, CreateSendersOrReceieversWithNullTransport) { |
247 auto sender_result = | 238 auto sender_result = |
248 ortc_factory_->CreateRtpSender(cricket::MEDIA_TYPE_AUDIO, nullptr); | 239 ortc_factory_->CreateRtpSender(cricket::MEDIA_TYPE_AUDIO, nullptr); |
249 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, sender_result.error().type()); | 240 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, sender_result.error().type()); |
250 auto receiver_result = | 241 auto receiver_result = |
251 ortc_factory_->CreateRtpReceiver(cricket::MEDIA_TYPE_AUDIO, nullptr); | 242 ortc_factory_->CreateRtpReceiver(cricket::MEDIA_TYPE_AUDIO, nullptr); |
252 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, receiver_result.error().type()); | 243 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, receiver_result.error().type()); |
253 } | 244 } |
254 | 245 |
255 } // namespace webrtc | 246 } // namespace webrtc |
OLD | NEW |