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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { | 905 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { |
906 MediaSessionOptions opts; | 906 MediaSessionOptions opts; |
907 opts.data_channel_type = cricket::DCT_RTP; | 907 opts.data_channel_type = cricket::DCT_RTP; |
908 f1_.set_secure(SEC_ENABLED); | 908 f1_.set_secure(SEC_ENABLED); |
909 f2_.set_secure(SEC_ENABLED); | 909 f2_.set_secure(SEC_ENABLED); |
910 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 910 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
911 ASSERT_TRUE(offer.get() != NULL); | 911 ASSERT_TRUE(offer.get() != NULL); |
912 std::unique_ptr<SessionDescription> answer( | 912 std::unique_ptr<SessionDescription> answer( |
913 f2_.CreateAnswer(offer.get(), opts, NULL)); | 913 f2_.CreateAnswer(offer.get(), opts, NULL)); |
914 const ContentInfo* ac = answer->GetContentByName("audio"); | 914 const ContentInfo* ac = answer->GetContentByName("audio"); |
915 const ContentInfo* vc = answer->GetContentByName("data"); | 915 const ContentInfo* dc = answer->GetContentByName("data"); |
916 ASSERT_TRUE(ac != NULL); | 916 ASSERT_TRUE(ac != NULL); |
917 ASSERT_TRUE(vc != NULL); | 917 ASSERT_TRUE(dc != NULL); |
918 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 918 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
919 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 919 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
920 const AudioContentDescription* acd = | 920 const AudioContentDescription* acd = |
921 static_cast<const AudioContentDescription*>(ac->description); | 921 static_cast<const AudioContentDescription*>(ac->description); |
922 const DataContentDescription* vcd = | 922 const DataContentDescription* dcd = |
923 static_cast<const DataContentDescription*>(vc->description); | 923 static_cast<const DataContentDescription*>(dc->description); |
924 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 924 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
925 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 925 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
926 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 926 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
927 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 927 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
928 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 928 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
929 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 929 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
930 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); | 930 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
931 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); | 931 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
932 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 932 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc |
933 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 933 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
934 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 934 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
935 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 935 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
936 } | 936 } |
937 | 937 |
938 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { | 938 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { |
939 MediaSessionOptions opts; | 939 MediaSessionOptions opts; |
940 opts.data_channel_type = cricket::DCT_RTP; | 940 opts.data_channel_type = cricket::DCT_RTP; |
941 opts.crypto_options.enable_gcm_crypto_suites = true; | 941 opts.crypto_options.enable_gcm_crypto_suites = true; |
942 f1_.set_secure(SEC_ENABLED); | 942 f1_.set_secure(SEC_ENABLED); |
943 f2_.set_secure(SEC_ENABLED); | 943 f2_.set_secure(SEC_ENABLED); |
944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
945 ASSERT_TRUE(offer.get() != NULL); | 945 ASSERT_TRUE(offer.get() != NULL); |
946 std::unique_ptr<SessionDescription> answer( | 946 std::unique_ptr<SessionDescription> answer( |
947 f2_.CreateAnswer(offer.get(), opts, NULL)); | 947 f2_.CreateAnswer(offer.get(), opts, NULL)); |
948 const ContentInfo* ac = answer->GetContentByName("audio"); | 948 const ContentInfo* ac = answer->GetContentByName("audio"); |
949 const ContentInfo* vc = answer->GetContentByName("data"); | 949 const ContentInfo* dc = answer->GetContentByName("data"); |
950 ASSERT_TRUE(ac != NULL); | 950 ASSERT_TRUE(ac != NULL); |
951 ASSERT_TRUE(vc != NULL); | 951 ASSERT_TRUE(dc != NULL); |
952 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 952 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
953 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 953 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
954 const AudioContentDescription* acd = | 954 const AudioContentDescription* acd = |
955 static_cast<const AudioContentDescription*>(ac->description); | 955 static_cast<const AudioContentDescription*>(ac->description); |
956 const DataContentDescription* vcd = | 956 const DataContentDescription* dcd = |
957 static_cast<const DataContentDescription*>(vc->description); | 957 static_cast<const DataContentDescription*>(dc->description); |
958 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 958 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
959 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 959 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
960 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 960 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
961 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 961 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
962 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 962 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
963 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 963 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
964 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); | 964 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
965 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); | 965 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
966 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 966 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc |
967 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 967 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
968 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); | 968 ASSERT_CRYPTO(dcd, 1U, CS_AEAD_AES_256_GCM); |
969 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 969 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
| 970 } |
| 971 |
| 972 // The use_sctpmap flag should be set in a DataContentDescription by default. |
| 973 // The answer's use_sctpmap flag should match the offer's. |
| 974 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { |
| 975 MediaSessionOptions opts; |
| 976 opts.data_channel_type = cricket::DCT_SCTP; |
| 977 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 978 ASSERT_TRUE(offer.get() != NULL); |
| 979 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 980 ASSERT_TRUE(dc_offer != NULL); |
| 981 DataContentDescription* dcd_offer = |
| 982 static_cast<DataContentDescription*>(dc_offer->description); |
| 983 EXPECT_TRUE(dcd_offer->use_sctpmap()); |
| 984 |
| 985 std::unique_ptr<SessionDescription> answer( |
| 986 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 987 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 988 ASSERT_TRUE(dc_answer != NULL); |
| 989 const DataContentDescription* dcd_answer = |
| 990 static_cast<const DataContentDescription*>(dc_answer->description); |
| 991 EXPECT_TRUE(dcd_answer->use_sctpmap()); |
| 992 } |
| 993 |
| 994 // The answer's use_sctpmap flag should match the offer's. |
| 995 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { |
| 996 MediaSessionOptions opts; |
| 997 opts.data_channel_type = cricket::DCT_SCTP; |
| 998 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 999 ASSERT_TRUE(offer.get() != NULL); |
| 1000 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 1001 ASSERT_TRUE(dc_offer != NULL); |
| 1002 DataContentDescription* dcd_offer = |
| 1003 static_cast<DataContentDescription*>(dc_offer->description); |
| 1004 dcd_offer->set_use_sctpmap(false); |
| 1005 |
| 1006 std::unique_ptr<SessionDescription> answer( |
| 1007 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1008 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 1009 ASSERT_TRUE(dc_answer != NULL); |
| 1010 const DataContentDescription* dcd_answer = |
| 1011 static_cast<const DataContentDescription*>(dc_answer->description); |
| 1012 EXPECT_FALSE(dcd_answer->use_sctpmap()); |
970 } | 1013 } |
971 | 1014 |
972 // Verifies that the order of the media contents in the offer is preserved in | 1015 // Verifies that the order of the media contents in the offer is preserved in |
973 // the answer. | 1016 // the answer. |
974 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { | 1017 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { |
975 MediaSessionOptions opts; | 1018 MediaSessionOptions opts; |
976 | 1019 |
977 // Creates a data only offer. | 1020 // Creates a data only offer. |
978 opts.recv_audio = false; | 1021 opts.recv_audio = false; |
979 opts.data_channel_type = cricket::DCT_SCTP; | 1022 opts.data_channel_type = cricket::DCT_SCTP; |
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 ::testing::Combine( | 3023 ::testing::Combine( |
2981 ::testing::Values(cricket::MD_SENDONLY, | 3024 ::testing::Values(cricket::MD_SENDONLY, |
2982 cricket::MD_RECVONLY, | 3025 cricket::MD_RECVONLY, |
2983 cricket::MD_SENDRECV, | 3026 cricket::MD_SENDRECV, |
2984 cricket::MD_INACTIVE), | 3027 cricket::MD_INACTIVE), |
2985 ::testing::Values(cricket::MD_SENDONLY, | 3028 ::testing::Values(cricket::MD_SENDONLY, |
2986 cricket::MD_RECVONLY, | 3029 cricket::MD_RECVONLY, |
2987 cricket::MD_SENDRECV, | 3030 cricket::MD_SENDRECV, |
2988 cricket::MD_INACTIVE), | 3031 cricket::MD_INACTIVE), |
2989 ::testing::Bool())); | 3032 ::testing::Bool())); |
OLD | NEW |