OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "talk/media/base/codec.h" | 31 #include "talk/media/base/codec.h" |
32 #include "talk/media/base/testutils.h" | 32 #include "talk/media/base/testutils.h" |
33 #include "webrtc/p2p/base/constants.h" | 33 #include "webrtc/p2p/base/constants.h" |
34 #include "webrtc/p2p/base/transportdescription.h" | 34 #include "webrtc/p2p/base/transportdescription.h" |
35 #include "webrtc/p2p/base/transportinfo.h" | 35 #include "webrtc/p2p/base/transportinfo.h" |
36 #include "talk/session/media/mediasession.h" | 36 #include "talk/session/media/mediasession.h" |
37 #include "talk/session/media/srtpfilter.h" | 37 #include "talk/session/media/srtpfilter.h" |
38 #include "webrtc/base/fakesslidentity.h" | 38 #include "webrtc/base/fakesslidentity.h" |
39 #include "webrtc/base/gunit.h" | 39 #include "webrtc/base/gunit.h" |
40 #include "webrtc/base/messagedigest.h" | 40 #include "webrtc/base/messagedigest.h" |
| 41 #include "webrtc/base/scoped_ptr.h" |
41 #include "webrtc/base/ssladapter.h" | 42 #include "webrtc/base/ssladapter.h" |
42 | 43 |
43 #ifdef HAVE_SRTP | 44 #ifdef HAVE_SRTP |
44 #define ASSERT_CRYPTO(cd, s, cs) \ | 45 #define ASSERT_CRYPTO(cd, s, cs) \ |
45 ASSERT_EQ(cricket::CT_NONE, cd->crypto_required()); \ | 46 ASSERT_EQ(cricket::CT_NONE, cd->crypto_required()); \ |
46 ASSERT_EQ(s, cd->cryptos().size()); \ | 47 ASSERT_EQ(s, cd->cryptos().size()); \ |
47 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) | 48 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) |
48 #else | 49 #else |
49 #define ASSERT_CRYPTO(cd, s, cs) \ | 50 #define ASSERT_CRYPTO(cd, s, cs) \ |
50 ASSERT_EQ(cricket::CT_NONE, cd->crypto_required()); \ | 51 ASSERT_EQ(cricket::CT_NONE, cd->crypto_required()); \ |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 std::vector<std::string> codec_names; | 210 std::vector<std::string> codec_names; |
210 for (const auto& codec : codecs) { | 211 for (const auto& codec : codecs) { |
211 codec_names.push_back(codec.name); | 212 codec_names.push_back(codec.name); |
212 } | 213 } |
213 return codec_names; | 214 return codec_names; |
214 } | 215 } |
215 | 216 |
216 class MediaSessionDescriptionFactoryTest : public testing::Test { | 217 class MediaSessionDescriptionFactoryTest : public testing::Test { |
217 public: | 218 public: |
218 MediaSessionDescriptionFactoryTest() | 219 MediaSessionDescriptionFactoryTest() |
219 : f1_(&tdf1_), f2_(&tdf2_), id1_("id1"), id2_("id2") { | 220 : f1_(&tdf1_), |
| 221 f2_(&tdf2_), |
| 222 cert1_(webrtc::DtlsCertificate::Create( |
| 223 rtc::scoped_ptr<rtc::SSLIdentity>( |
| 224 new rtc::FakeSSLIdentity("id1")).Pass())), |
| 225 cert2_(webrtc::DtlsCertificate::Create( |
| 226 rtc::scoped_ptr<rtc::SSLIdentity>( |
| 227 new rtc::FakeSSLIdentity("id2")).Pass())) { |
220 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1)); | 228 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1)); |
221 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | 229 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); |
222 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | 230 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); |
223 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2)); | 231 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2)); |
224 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | 232 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); |
225 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); | 233 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); |
226 tdf1_.set_identity(&id1_); | 234 tdf1_.set_certificate(cert1_); |
227 tdf2_.set_identity(&id2_); | 235 tdf2_.set_certificate(cert2_); |
228 } | 236 } |
229 | 237 |
230 // Create a video StreamParamsVec object with: | 238 // Create a video StreamParamsVec object with: |
231 // - one video stream with 3 simulcast streams and FEC, | 239 // - one video stream with 3 simulcast streams and FEC, |
232 StreamParamsVec CreateComplexVideoStreamParamsVec() { | 240 StreamParamsVec CreateComplexVideoStreamParamsVec() { |
233 SsrcGroup sim_group("SIM", MAKE_VECTOR(kSimSsrc)); | 241 SsrcGroup sim_group("SIM", MAKE_VECTOR(kSimSsrc)); |
234 SsrcGroup fec_group1("FEC", MAKE_VECTOR(kFec1Ssrc)); | 242 SsrcGroup fec_group1("FEC", MAKE_VECTOR(kFec1Ssrc)); |
235 SsrcGroup fec_group2("FEC", MAKE_VECTOR(kFec2Ssrc)); | 243 SsrcGroup fec_group2("FEC", MAKE_VECTOR(kFec2Ssrc)); |
236 SsrcGroup fec_group3("FEC", MAKE_VECTOR(kFec3Ssrc)); | 244 SsrcGroup fec_group3("FEC", MAKE_VECTOR(kFec3Ssrc)); |
237 | 245 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 return false; | 464 return false; |
457 } | 465 } |
458 return true; | 466 return true; |
459 } | 467 } |
460 | 468 |
461 protected: | 469 protected: |
462 MediaSessionDescriptionFactory f1_; | 470 MediaSessionDescriptionFactory f1_; |
463 MediaSessionDescriptionFactory f2_; | 471 MediaSessionDescriptionFactory f2_; |
464 TransportDescriptionFactory tdf1_; | 472 TransportDescriptionFactory tdf1_; |
465 TransportDescriptionFactory tdf2_; | 473 TransportDescriptionFactory tdf2_; |
466 rtc::FakeSSLIdentity id1_; | 474 rtc::scoped_refptr<webrtc::DtlsCertificate> cert1_; |
467 rtc::FakeSSLIdentity id2_; | 475 rtc::scoped_refptr<webrtc::DtlsCertificate> cert2_; |
468 }; | 476 }; |
469 | 477 |
470 // Create a typical audio offer, and ensure it matches what we expect. | 478 // Create a typical audio offer, and ensure it matches what we expect. |
471 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { | 479 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { |
472 f1_.set_secure(SEC_ENABLED); | 480 f1_.set_secure(SEC_ENABLED); |
473 rtc::scoped_ptr<SessionDescription> offer( | 481 rtc::scoped_ptr<SessionDescription> offer( |
474 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 482 f1_.CreateOffer(MediaSessionOptions(), NULL)); |
475 ASSERT_TRUE(offer.get() != NULL); | 483 ASSERT_TRUE(offer.get() != NULL); |
476 const ContentInfo* ac = offer->GetContentByName("audio"); | 484 const ContentInfo* ac = offer->GetContentByName("audio"); |
477 const ContentInfo* vc = offer->GetContentByName("video"); | 485 const ContentInfo* vc = offer->GetContentByName("video"); |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 offer.reset(f1_.CreateOffer(options, NULL)); | 2264 offer.reset(f1_.CreateOffer(options, NULL)); |
2257 ASSERT_TRUE(offer.get() != NULL); | 2265 ASSERT_TRUE(offer.get() != NULL); |
2258 audio_content = offer->GetContentByName("audio"); | 2266 audio_content = offer->GetContentByName("audio"); |
2259 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2267 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2260 rtc::scoped_ptr<SessionDescription> answer( | 2268 rtc::scoped_ptr<SessionDescription> answer( |
2261 f1_.CreateAnswer(offer.get(), options, NULL)); | 2269 f1_.CreateAnswer(offer.get(), options, NULL)); |
2262 ASSERT_TRUE(answer.get() != NULL); | 2270 ASSERT_TRUE(answer.get() != NULL); |
2263 audio_content = answer->GetContentByName("audio"); | 2271 audio_content = answer->GetContentByName("audio"); |
2264 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2272 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2265 } | 2273 } |
OLD | NEW |