OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 static const char kMediaStream2[] = "stream_2"; | 163 static const char kMediaStream2[] = "stream_2"; |
164 static const char kVideoTrack1[] = "video_1"; | 164 static const char kVideoTrack1[] = "video_1"; |
165 static const char kVideoTrack2[] = "video_2"; | 165 static const char kVideoTrack2[] = "video_2"; |
166 static const char kAudioTrack1[] = "audio_1"; | 166 static const char kAudioTrack1[] = "audio_1"; |
167 static const char kAudioTrack2[] = "audio_2"; | 167 static const char kAudioTrack2[] = "audio_2"; |
168 static const char kAudioTrack3[] = "audio_3"; | 168 static const char kAudioTrack3[] = "audio_3"; |
169 static const char kDataTrack1[] = "data_1"; | 169 static const char kDataTrack1[] = "data_1"; |
170 static const char kDataTrack2[] = "data_2"; | 170 static const char kDataTrack2[] = "data_2"; |
171 static const char kDataTrack3[] = "data_3"; | 171 static const char kDataTrack3[] = "data_3"; |
172 | 172 |
| 173 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", |
| 174 "RTP/SAVPF"}; |
| 175 static const char* kMediaProtocolsDtls[] = { |
| 176 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", |
| 177 "UDP/TLS/RTP/SAVP"}; |
| 178 |
173 static bool IsMediaContentOfType(const ContentInfo* content, | 179 static bool IsMediaContentOfType(const ContentInfo* content, |
174 MediaType media_type) { | 180 MediaType media_type) { |
175 const MediaContentDescription* mdesc = | 181 const MediaContentDescription* mdesc = |
176 static_cast<const MediaContentDescription*>(content->description); | 182 static_cast<const MediaContentDescription*>(content->description); |
177 return mdesc && mdesc->type() == media_type; | 183 return mdesc && mdesc->type() == media_type; |
178 } | 184 } |
179 | 185 |
180 static cricket::MediaContentDirection | 186 static cricket::MediaContentDirection |
181 GetMediaDirection(const ContentInfo* content) { | 187 GetMediaDirection(const ContentInfo* content) { |
182 cricket::MediaContentDescription* desc = | 188 cricket::MediaContentDescription* desc = |
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2378 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2373 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2379 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2374 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2380 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2375 ASSERT_TRUE(audio_content != nullptr); | 2381 ASSERT_TRUE(audio_content != nullptr); |
2376 ASSERT_TRUE(video_content != nullptr); | 2382 ASSERT_TRUE(video_content != nullptr); |
2377 ASSERT_TRUE(data_content != nullptr); | 2383 ASSERT_TRUE(data_content != nullptr); |
2378 EXPECT_EQ("audio_modified", audio_content->name); | 2384 EXPECT_EQ("audio_modified", audio_content->name); |
2379 EXPECT_EQ("video_modified", video_content->name); | 2385 EXPECT_EQ("video_modified", video_content->name); |
2380 EXPECT_EQ("data_modified", data_content->name); | 2386 EXPECT_EQ("data_modified", data_content->name); |
2381 } | 2387 } |
| 2388 |
| 2389 class MediaProtocolTest : public ::testing::TestWithParam<const char*> { |
| 2390 public: |
| 2391 MediaProtocolTest() : f1_(&tdf1_), f2_(&tdf2_) { |
| 2392 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1)); |
| 2393 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); |
| 2394 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); |
| 2395 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2)); |
| 2396 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); |
| 2397 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); |
| 2398 f1_.set_secure(SEC_ENABLED); |
| 2399 f2_.set_secure(SEC_ENABLED); |
| 2400 tdf1_.set_certificate(rtc::RTCCertificate::Create( |
| 2401 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); |
| 2402 tdf2_.set_certificate(rtc::RTCCertificate::Create( |
| 2403 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id2")))); |
| 2404 tdf1_.set_secure(SEC_ENABLED); |
| 2405 tdf2_.set_secure(SEC_ENABLED); |
| 2406 } |
| 2407 |
| 2408 protected: |
| 2409 MediaSessionDescriptionFactory f1_; |
| 2410 MediaSessionDescriptionFactory f2_; |
| 2411 TransportDescriptionFactory tdf1_; |
| 2412 TransportDescriptionFactory tdf2_; |
| 2413 }; |
| 2414 |
| 2415 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { |
| 2416 MediaSessionOptions opts; |
| 2417 opts.recv_video = true; |
| 2418 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2419 ASSERT_TRUE(offer.get() != nullptr); |
| 2420 // Set the protocol for all the contents. |
| 2421 for (auto content : offer.get()->contents()) { |
| 2422 static_cast<MediaContentDescription*>(content.description) |
| 2423 ->set_protocol(GetParam()); |
| 2424 } |
| 2425 std::unique_ptr<SessionDescription> answer( |
| 2426 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 2427 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 2428 const ContentInfo* vc = answer->GetContentByName("video"); |
| 2429 ASSERT_TRUE(ac != nullptr); |
| 2430 ASSERT_TRUE(vc != nullptr); |
| 2431 EXPECT_FALSE(ac->rejected); // the offer is accepted |
| 2432 EXPECT_FALSE(vc->rejected); |
| 2433 const AudioContentDescription* acd = |
| 2434 static_cast<const AudioContentDescription*>(ac->description); |
| 2435 const VideoContentDescription* vcd = |
| 2436 static_cast<const VideoContentDescription*>(vc->description); |
| 2437 EXPECT_EQ(GetParam(), acd->protocol()); |
| 2438 EXPECT_EQ(GetParam(), vcd->protocol()); |
| 2439 } |
| 2440 |
| 2441 INSTANTIATE_TEST_CASE_P(MediaProtocolPatternTest, |
| 2442 MediaProtocolTest, |
| 2443 ::testing::ValuesIn(kMediaProtocols)); |
| 2444 INSTANTIATE_TEST_CASE_P(MediaProtocolDtlsPatternTest, |
| 2445 MediaProtocolTest, |
| 2446 ::testing::ValuesIn(kMediaProtocolsDtls)); |
OLD | NEW |