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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 static const char kMediaStream2[] = "stream_2"; | 173 static const char kMediaStream2[] = "stream_2"; |
174 static const char kVideoTrack1[] = "video_1"; | 174 static const char kVideoTrack1[] = "video_1"; |
175 static const char kVideoTrack2[] = "video_2"; | 175 static const char kVideoTrack2[] = "video_2"; |
176 static const char kAudioTrack1[] = "audio_1"; | 176 static const char kAudioTrack1[] = "audio_1"; |
177 static const char kAudioTrack2[] = "audio_2"; | 177 static const char kAudioTrack2[] = "audio_2"; |
178 static const char kAudioTrack3[] = "audio_3"; | 178 static const char kAudioTrack3[] = "audio_3"; |
179 static const char kDataTrack1[] = "data_1"; | 179 static const char kDataTrack1[] = "data_1"; |
180 static const char kDataTrack2[] = "data_2"; | 180 static const char kDataTrack2[] = "data_2"; |
181 static const char kDataTrack3[] = "data_3"; | 181 static const char kDataTrack3[] = "data_3"; |
182 | 182 |
183 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF"}; | |
Taylor Brandstetter
2016/04/12 21:50:05
What about RTP/SAVPF?
Zhi Huang
2016/04/12 23:00:20
I thought the RTP/SAVPF is the default protocol us
| |
184 static const char* kMediaProtocolsDtls[] = { | |
185 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", | |
186 "UDP/TLS/RTP/SAVP"}; | |
187 | |
183 static bool IsMediaContentOfType(const ContentInfo* content, | 188 static bool IsMediaContentOfType(const ContentInfo* content, |
184 MediaType media_type) { | 189 MediaType media_type) { |
185 const MediaContentDescription* mdesc = | 190 const MediaContentDescription* mdesc = |
186 static_cast<const MediaContentDescription*>(content->description); | 191 static_cast<const MediaContentDescription*>(content->description); |
187 return mdesc && mdesc->type() == media_type; | 192 return mdesc && mdesc->type() == media_type; |
188 } | 193 } |
189 | 194 |
190 static cricket::MediaContentDirection | 195 static cricket::MediaContentDirection |
191 GetMediaDirection(const ContentInfo* content) { | 196 GetMediaDirection(const ContentInfo* content) { |
192 cricket::MediaContentDescription* desc = | 197 cricket::MediaContentDescription* desc = |
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2384 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2389 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2385 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2390 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2386 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2391 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2387 ASSERT_TRUE(audio_content != nullptr); | 2392 ASSERT_TRUE(audio_content != nullptr); |
2388 ASSERT_TRUE(video_content != nullptr); | 2393 ASSERT_TRUE(video_content != nullptr); |
2389 ASSERT_TRUE(data_content != nullptr); | 2394 ASSERT_TRUE(data_content != nullptr); |
2390 EXPECT_EQ("audio_modified", audio_content->name); | 2395 EXPECT_EQ("audio_modified", audio_content->name); |
2391 EXPECT_EQ("video_modified", video_content->name); | 2396 EXPECT_EQ("video_modified", video_content->name); |
2392 EXPECT_EQ("data_modified", data_content->name); | 2397 EXPECT_EQ("data_modified", data_content->name); |
2393 } | 2398 } |
2399 | |
2400 class MediaProtocolTest : public ::testing::TestWithParam<const char*> { | |
2401 public: | |
2402 MediaProtocolTest() : f1_(&tdf1_), f2_(&tdf2_) { | |
2403 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1)); | |
2404 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | |
2405 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | |
2406 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2)); | |
2407 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | |
2408 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); | |
2409 f1_.set_secure(SEC_ENABLED); | |
2410 f2_.set_secure(SEC_ENABLED); | |
2411 tdf1_.set_certificate(rtc::RTCCertificate::Create( | |
2412 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); | |
2413 tdf2_.set_certificate(rtc::RTCCertificate::Create( | |
2414 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id2")))); | |
2415 tdf1_.set_secure(SEC_ENABLED); | |
2416 tdf2_.set_secure(SEC_ENABLED); | |
2417 } | |
2418 | |
2419 protected: | |
2420 MediaSessionDescriptionFactory f1_; | |
2421 MediaSessionDescriptionFactory f2_; | |
2422 TransportDescriptionFactory tdf1_; | |
2423 TransportDescriptionFactory tdf2_; | |
2424 }; | |
2425 | |
2426 TEST_P(MediaProtocolTest, TestAudioAcceptance) { | |
2427 std::unique_ptr<SessionDescription> offer( | |
2428 f1_.CreateOffer(MediaSessionOptions(), NULL)); | |
2429 ASSERT_TRUE(offer.get() != NULL); | |
2430 static_cast<MediaContentDescription*>(offer.get()->contents()[0].description) | |
2431 ->set_protocol(GetParam()); | |
2432 std::unique_ptr<SessionDescription> answer( | |
2433 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | |
2434 const ContentInfo* ac = answer->GetContentByName("audio"); | |
2435 const ContentInfo* vc = answer->GetContentByName("video"); | |
2436 ASSERT_TRUE(ac != NULL); | |
2437 ASSERT_TRUE(vc == NULL); | |
2438 EXPECT_FALSE(ac->rejected); // the offer is accepted | |
2439 } | |
2440 | |
2441 TEST_P(MediaProtocolTest, TestVideoAcceptance) { | |
Taylor Brandstetter
2016/04/12 21:50:05
I'd rename this to "TestAudioVideoAcceptance". And
| |
2442 MediaSessionOptions opts; | |
2443 opts.recv_video = true; | |
2444 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | |
Taylor Brandstetter
2016/04/12 21:50:05
nit: replace "NULL" with C++11 "nullptr"
| |
2445 ASSERT_TRUE(offer.get() != NULL); | |
2446 static_cast<MediaContentDescription*>(offer.get()->contents()[0].description) | |
2447 ->set_protocol(GetParam()); | |
2448 std::unique_ptr<SessionDescription> answer( | |
2449 f2_.CreateAnswer(offer.get(), opts, NULL)); | |
2450 const ContentInfo* ac = answer->GetContentByName("audio"); | |
2451 const ContentInfo* vc = answer->GetContentByName("video"); | |
2452 ASSERT_TRUE(ac != NULL); | |
2453 ASSERT_TRUE(vc != NULL); | |
2454 EXPECT_FALSE(ac->rejected); // the offer is accepted | |
2455 EXPECT_FALSE(vc->rejected); | |
Taylor Brandstetter
2016/04/12 21:50:05
One extra useful check would be that the protocol
| |
2456 } | |
2457 | |
2458 TEST_P(MediaProtocolTest, TestDataAcceptance) { | |
Taylor Brandstetter
2016/04/12 21:50:05
I'd suggest leaving a TODO to remove this test whe
| |
2459 MediaSessionOptions opts; | |
2460 opts.data_channel_type = cricket::DCT_RTP; | |
2461 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | |
2462 ASSERT_TRUE(offer.get() != NULL); | |
2463 static_cast<MediaContentDescription*>(offer.get()->contents()[0].description) | |
2464 ->set_protocol(GetParam()); | |
2465 std::unique_ptr<SessionDescription> answer( | |
2466 f2_.CreateAnswer(offer.get(), opts, NULL)); | |
2467 const ContentInfo* ac = answer->GetContentByName("audio"); | |
2468 const ContentInfo* vc = answer->GetContentByName("data"); | |
2469 ASSERT_TRUE(ac != NULL); | |
2470 ASSERT_TRUE(vc != NULL); | |
2471 EXPECT_FALSE(ac->rejected); // the offer is accepted | |
2472 EXPECT_FALSE(vc->rejected); | |
2473 } | |
2474 | |
2475 INSTANTIATE_TEST_CASE_P(MediaProtocolPatternTest, | |
2476 MediaProtocolTest, | |
2477 ::testing::ValuesIn(kMediaProtocols)); | |
2478 INSTANTIATE_TEST_CASE_P(MediaProtocolDtlsPatternTest, | |
2479 MediaProtocolTest, | |
2480 ::testing::ValuesIn(kMediaProtocolsDtls)); | |
OLD | NEW |