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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 467 f1_.CreateOffer(MediaSessionOptions(), NULL)); |
468 ASSERT_TRUE(offer.get() != NULL); | 468 ASSERT_TRUE(offer.get() != NULL); |
469 const ContentInfo* ac = offer->GetContentByName("audio"); | 469 const ContentInfo* ac = offer->GetContentByName("audio"); |
470 const ContentInfo* vc = offer->GetContentByName("video"); | 470 const ContentInfo* vc = offer->GetContentByName("video"); |
471 ASSERT_TRUE(ac != NULL); | 471 ASSERT_TRUE(ac != NULL); |
472 ASSERT_TRUE(vc == NULL); | 472 ASSERT_TRUE(vc == NULL); |
473 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 473 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
474 const AudioContentDescription* acd = | 474 const AudioContentDescription* acd = |
475 static_cast<const AudioContentDescription*>(ac->description); | 475 static_cast<const AudioContentDescription*>(ac->description); |
476 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 476 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
477 EXPECT_EQ(f1_.audio_codecs(), acd->codecs()); | 477 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
478 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 478 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
479 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 479 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
480 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 480 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
481 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 481 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
482 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 482 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
483 } | 483 } |
484 | 484 |
485 // Create a typical video offer, and ensure it matches what we expect. | 485 // Create a typical video offer, and ensure it matches what we expect. |
486 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { | 486 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { |
487 MediaSessionOptions opts; | 487 MediaSessionOptions opts; |
488 opts.recv_video = true; | 488 opts.recv_video = true; |
489 f1_.set_secure(SEC_ENABLED); | 489 f1_.set_secure(SEC_ENABLED); |
490 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 490 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
491 ASSERT_TRUE(offer.get() != NULL); | 491 ASSERT_TRUE(offer.get() != NULL); |
492 const ContentInfo* ac = offer->GetContentByName("audio"); | 492 const ContentInfo* ac = offer->GetContentByName("audio"); |
493 const ContentInfo* vc = offer->GetContentByName("video"); | 493 const ContentInfo* vc = offer->GetContentByName("video"); |
494 ASSERT_TRUE(ac != NULL); | 494 ASSERT_TRUE(ac != NULL); |
495 ASSERT_TRUE(vc != NULL); | 495 ASSERT_TRUE(vc != NULL); |
496 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 496 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
497 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 497 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
498 const AudioContentDescription* acd = | 498 const AudioContentDescription* acd = |
499 static_cast<const AudioContentDescription*>(ac->description); | 499 static_cast<const AudioContentDescription*>(ac->description); |
500 const VideoContentDescription* vcd = | 500 const VideoContentDescription* vcd = |
501 static_cast<const VideoContentDescription*>(vc->description); | 501 static_cast<const VideoContentDescription*>(vc->description); |
502 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 502 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
503 EXPECT_EQ(f1_.audio_codecs(), acd->codecs()); | 503 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
504 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 504 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
505 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 505 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
506 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 506 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
507 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 507 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
508 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 508 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
509 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 509 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
510 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); | 510 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); |
511 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 511 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc |
512 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) | 512 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) |
513 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on | 513 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on |
514 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 514 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
515 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 515 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
516 } | 516 } |
517 | 517 |
518 // Test creating an offer with bundle where the Codecs have the same dynamic | 518 // Test creating an offer with bundle where the Codecs have the same dynamic |
519 // RTP playlod type. The test verifies that the offer don't contain the | 519 // RTP playlod type. The test verifies that the offer don't contain the |
520 // duplicate RTP payload types. | 520 // duplicate RTP payload types. |
521 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { | 521 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { |
522 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; | 522 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; |
523 const AudioCodec& offered_audio_codec = f2_.audio_codecs()[0]; | 523 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; |
524 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; | 524 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; |
525 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); | 525 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); |
526 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); | 526 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); |
527 | 527 |
528 MediaSessionOptions opts; | 528 MediaSessionOptions opts; |
529 opts.recv_audio = true; | 529 opts.recv_audio = true; |
530 opts.recv_video = true; | 530 opts.recv_video = true; |
531 opts.data_channel_type = cricket::DCT_RTP; | 531 opts.data_channel_type = cricket::DCT_RTP; |
532 opts.bundle_enabled = true; | 532 opts.bundle_enabled = true; |
533 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); | 533 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 const ContentInfo* dc = offer->GetContentByName("data"); | 600 const ContentInfo* dc = offer->GetContentByName("data"); |
601 ASSERT_TRUE(ac != NULL); | 601 ASSERT_TRUE(ac != NULL); |
602 ASSERT_TRUE(dc != NULL); | 602 ASSERT_TRUE(dc != NULL); |
603 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 603 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
604 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 604 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
605 const AudioContentDescription* acd = | 605 const AudioContentDescription* acd = |
606 static_cast<const AudioContentDescription*>(ac->description); | 606 static_cast<const AudioContentDescription*>(ac->description); |
607 const DataContentDescription* dcd = | 607 const DataContentDescription* dcd = |
608 static_cast<const DataContentDescription*>(dc->description); | 608 static_cast<const DataContentDescription*>(dc->description); |
609 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 609 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
610 EXPECT_EQ(f1_.audio_codecs(), acd->codecs()); | 610 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
611 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 611 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
612 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 612 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
613 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 613 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
614 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 614 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
615 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 615 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
616 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 616 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
617 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); | 617 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); |
618 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 618 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc |
619 EXPECT_EQ(cricket::kDataMaxBandwidth, | 619 EXPECT_EQ(cricket::kDataMaxBandwidth, |
620 dcd->bandwidth()); // default bandwidth (auto) | 620 dcd->bandwidth()); // default bandwidth (auto) |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 ASSERT_TRUE(ac != NULL); | 1215 ASSERT_TRUE(ac != NULL); |
1216 ASSERT_TRUE(vc != NULL); | 1216 ASSERT_TRUE(vc != NULL); |
1217 ASSERT_TRUE(dc != NULL); | 1217 ASSERT_TRUE(dc != NULL); |
1218 const AudioContentDescription* acd = | 1218 const AudioContentDescription* acd = |
1219 static_cast<const AudioContentDescription*>(ac->description); | 1219 static_cast<const AudioContentDescription*>(ac->description); |
1220 const VideoContentDescription* vcd = | 1220 const VideoContentDescription* vcd = |
1221 static_cast<const VideoContentDescription*>(vc->description); | 1221 static_cast<const VideoContentDescription*>(vc->description); |
1222 const DataContentDescription* dcd = | 1222 const DataContentDescription* dcd = |
1223 static_cast<const DataContentDescription*>(dc->description); | 1223 static_cast<const DataContentDescription*>(dc->description); |
1224 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1224 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
1225 EXPECT_EQ(f1_.audio_codecs(), acd->codecs()); | 1225 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
1226 | 1226 |
1227 const StreamParamsVec& audio_streams = acd->streams(); | 1227 const StreamParamsVec& audio_streams = acd->streams(); |
1228 ASSERT_EQ(2U, audio_streams.size()); | 1228 ASSERT_EQ(2U, audio_streams.size()); |
1229 EXPECT_EQ(audio_streams[0].cname , audio_streams[1].cname); | 1229 EXPECT_EQ(audio_streams[0].cname , audio_streams[1].cname); |
1230 EXPECT_EQ(kAudioTrack1, audio_streams[0].id); | 1230 EXPECT_EQ(kAudioTrack1, audio_streams[0].id); |
1231 ASSERT_EQ(1U, audio_streams[0].ssrcs.size()); | 1231 ASSERT_EQ(1U, audio_streams[0].ssrcs.size()); |
1232 EXPECT_NE(0U, audio_streams[0].ssrcs[0]); | 1232 EXPECT_NE(0U, audio_streams[0].ssrcs[0]); |
1233 EXPECT_EQ(kAudioTrack2, audio_streams[1].id); | 1233 EXPECT_EQ(kAudioTrack2, audio_streams[1].id); |
1234 ASSERT_EQ(1U, audio_streams[1].ssrcs.size()); | 1234 ASSERT_EQ(1U, audio_streams[1].ssrcs.size()); |
1235 EXPECT_NE(0U, audio_streams[1].ssrcs[0]); | 1235 EXPECT_NE(0U, audio_streams[1].ssrcs[0]); |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 send_codecs[1].channels = 0; | 2483 send_codecs[1].channels = 0; |
2484 | 2484 |
2485 // Alther iLBC receive codec to be lowercase, to test that case conversions | 2485 // Alther iLBC receive codec to be lowercase, to test that case conversions |
2486 // are handled properly. | 2486 // are handled properly. |
2487 recv_codecs[2].name = "ilbc"; | 2487 recv_codecs[2].name = "ilbc"; |
2488 | 2488 |
2489 // Test proper merge | 2489 // Test proper merge |
2490 sf.set_audio_codecs(send_codecs, recv_codecs); | 2490 sf.set_audio_codecs(send_codecs, recv_codecs); |
2491 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 2491 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); |
2492 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 2492 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); |
2493 EXPECT_TRUE(sf.audio_codecs() == sendrecv_codecs); | 2493 EXPECT_TRUE(sf.audio_sendrecv_codecs() == sendrecv_codecs); |
2494 | 2494 |
2495 // Test empty send codecs list | 2495 // Test empty send codecs list |
2496 sf.set_audio_codecs(no_codecs, recv_codecs); | 2496 sf.set_audio_codecs(no_codecs, recv_codecs); |
2497 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 2497 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); |
2498 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 2498 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); |
2499 EXPECT_TRUE(sf.audio_codecs() == no_codecs); | 2499 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); |
2500 | 2500 |
2501 // Test empty recv codecs list | 2501 // Test empty recv codecs list |
2502 sf.set_audio_codecs(send_codecs, no_codecs); | 2502 sf.set_audio_codecs(send_codecs, no_codecs); |
2503 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 2503 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); |
2504 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 2504 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); |
2505 EXPECT_TRUE(sf.audio_codecs() == no_codecs); | 2505 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); |
2506 | 2506 |
2507 // Test all empty codec lists | 2507 // Test all empty codec lists |
2508 sf.set_audio_codecs(no_codecs, no_codecs); | 2508 sf.set_audio_codecs(no_codecs, no_codecs); |
2509 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 2509 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); |
2510 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 2510 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); |
2511 EXPECT_TRUE(sf.audio_codecs() == no_codecs); | 2511 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); |
2512 } | 2512 } |
2513 | 2513 |
2514 namespace { | 2514 namespace { |
2515 void TestAudioCodecsOffer(MediaContentDirection direction, | 2515 void TestAudioCodecsOffer(MediaContentDirection direction, |
2516 bool add_legacy_stream) { | 2516 bool add_legacy_stream) { |
2517 TransportDescriptionFactory tdf; | 2517 TransportDescriptionFactory tdf; |
2518 MediaSessionDescriptionFactory sf(&tdf); | 2518 MediaSessionDescriptionFactory sf(&tdf); |
2519 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); | 2519 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); |
2520 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); | 2520 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); |
2521 const std::vector<AudioCodec> sendrecv_codecs = | 2521 const std::vector<AudioCodec> sendrecv_codecs = |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 ::testing::Combine( | 2752 ::testing::Combine( |
2753 ::testing::Values(cricket::MD_SENDONLY, | 2753 ::testing::Values(cricket::MD_SENDONLY, |
2754 cricket::MD_RECVONLY, | 2754 cricket::MD_RECVONLY, |
2755 cricket::MD_SENDRECV, | 2755 cricket::MD_SENDRECV, |
2756 cricket::MD_INACTIVE), | 2756 cricket::MD_INACTIVE), |
2757 ::testing::Values(cricket::MD_SENDONLY, | 2757 ::testing::Values(cricket::MD_SENDONLY, |
2758 cricket::MD_RECVONLY, | 2758 cricket::MD_RECVONLY, |
2759 cricket::MD_SENDRECV, | 2759 cricket::MD_SENDRECV, |
2760 cricket::MD_INACTIVE), | 2760 cricket::MD_INACTIVE), |
2761 ::testing::Bool())); | 2761 ::testing::Bool())); |
OLD | NEW |