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", | |
184 "RTP/SAVPF"}; | |
185 static const char* kMediaProtocolsDtls[] = { | |
186 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", | |
187 "UDP/TLS/RTP/SAVP"}; | |
188 | |
183 static bool IsMediaContentOfType(const ContentInfo* content, | 189 static bool IsMediaContentOfType(const ContentInfo* content, |
184 MediaType media_type) { | 190 MediaType media_type) { |
185 const MediaContentDescription* mdesc = | 191 const MediaContentDescription* mdesc = |
186 static_cast<const MediaContentDescription*>(content->description); | 192 static_cast<const MediaContentDescription*>(content->description); |
187 return mdesc && mdesc->type() == media_type; | 193 return mdesc && mdesc->type() == media_type; |
188 } | 194 } |
189 | 195 |
190 static cricket::MediaContentDirection | 196 static cricket::MediaContentDirection |
191 GetMediaDirection(const ContentInfo* content) { | 197 GetMediaDirection(const ContentInfo* content) { |
192 cricket::MediaContentDescription* desc = | 198 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()); | 2390 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2385 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2391 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2386 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2392 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2387 ASSERT_TRUE(audio_content != nullptr); | 2393 ASSERT_TRUE(audio_content != nullptr); |
2388 ASSERT_TRUE(video_content != nullptr); | 2394 ASSERT_TRUE(video_content != nullptr); |
2389 ASSERT_TRUE(data_content != nullptr); | 2395 ASSERT_TRUE(data_content != nullptr); |
2390 EXPECT_EQ("audio_modified", audio_content->name); | 2396 EXPECT_EQ("audio_modified", audio_content->name); |
2391 EXPECT_EQ("video_modified", video_content->name); | 2397 EXPECT_EQ("video_modified", video_content->name); |
2392 EXPECT_EQ("data_modified", data_content->name); | 2398 EXPECT_EQ("data_modified", data_content->name); |
2393 } | 2399 } |
2400 | |
2401 class MediaProtocolTest : public ::testing::TestWithParam<const char*> { | |
2402 public: | |
2403 MediaProtocolTest() : f1_(&tdf1_), f2_(&tdf2_) { | |
2404 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1)); | |
2405 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | |
2406 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | |
2407 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2)); | |
2408 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | |
2409 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); | |
2410 f1_.set_secure(SEC_ENABLED); | |
2411 f2_.set_secure(SEC_ENABLED); | |
2412 tdf1_.set_certificate(rtc::RTCCertificate::Create( | |
2413 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); | |
2414 tdf2_.set_certificate(rtc::RTCCertificate::Create( | |
2415 rtc::scoped_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id2")))); | |
2416 tdf1_.set_secure(SEC_ENABLED); | |
2417 tdf2_.set_secure(SEC_ENABLED); | |
2418 } | |
2419 | |
2420 protected: | |
2421 MediaSessionDescriptionFactory f1_; | |
2422 MediaSessionDescriptionFactory f2_; | |
2423 TransportDescriptionFactory tdf1_; | |
2424 TransportDescriptionFactory tdf2_; | |
2425 }; | |
2426 | |
2427 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { | |
2428 MediaSessionOptions opts; | |
2429 opts.recv_video = true; | |
2430 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | |
2431 ASSERT_TRUE(offer.get() != nullptr); | |
2432 // Set the protocol for all the contents. | |
2433 for (auto content : offer.get()->contents()) { | |
2434 static_cast<MediaContentDescription*>(content.description) | |
2435 ->set_protocol(GetParam()); | |
2436 } | |
2437 std::unique_ptr<SessionDescription> answer( | |
2438 f2_.CreateAnswer(offer.get(), opts, nullptr)); | |
2439 const ContentInfo* ac = answer->GetContentByName("audio"); | |
2440 const ContentInfo* vc = answer->GetContentByName("video"); | |
2441 ASSERT_TRUE(ac != nullptr); | |
2442 ASSERT_TRUE(vc != nullptr); | |
2443 EXPECT_FALSE(ac->rejected); // the offer is accepted | |
2444 EXPECT_FALSE(vc->rejected); | |
2445 const AudioContentDescription* acd = | |
2446 static_cast<const AudioContentDescription*>(ac->description); | |
2447 const VideoContentDescription* vcd = | |
2448 static_cast<const VideoContentDescription*>(vc->description); | |
2449 EXPECT_EQ(GetParam(), acd->protocol()); | |
2450 EXPECT_EQ(GetParam(), vcd->protocol()); | |
2451 } | |
2452 | |
2453 INSTANTIATE_TEST_CASE_P(MediaProtocolPatternTest, | |
2454 MediaProtocolTest, | |
2455 ::testing::ValuesIn(kMediaProtocols)); | |
2456 INSTANTIATE_TEST_CASE_P(MediaProtocolDtlsPatternTest, | |
2457 MediaProtocolTest, | |
2458 ::testing::ValuesIn(kMediaProtocolsDtls)); | |
pthatcher1
2016/04/12 23:08:36
Wow. That's slick.
| |
OLD | NEW |