| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 using cricket::ContentInfo; | 48 using cricket::ContentInfo; |
| 49 using cricket::CryptoParams; | 49 using cricket::CryptoParams; |
| 50 using cricket::ContentGroup; | 50 using cricket::ContentGroup; |
| 51 using cricket::DataCodec; | 51 using cricket::DataCodec; |
| 52 using cricket::DataContentDescription; | 52 using cricket::DataContentDescription; |
| 53 using cricket::ICE_CANDIDATE_COMPONENT_RTCP; | 53 using cricket::ICE_CANDIDATE_COMPONENT_RTCP; |
| 54 using cricket::ICE_CANDIDATE_COMPONENT_RTP; | 54 using cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 55 using cricket::kFecSsrcGroupSemantics; | 55 using cricket::kFecSsrcGroupSemantics; |
| 56 using cricket::LOCAL_PORT_TYPE; | 56 using cricket::LOCAL_PORT_TYPE; |
| 57 using cricket::NS_JINGLE_DRAFT_SCTP; | 57 using cricket::NS_JINGLE_DRAFT_SCTP; |
| 58 using cricket::NS_JINGLE_ICE_UDP; | |
| 59 using cricket::NS_JINGLE_RTP; | 58 using cricket::NS_JINGLE_RTP; |
| 60 using cricket::RtpHeaderExtension; | 59 using cricket::RtpHeaderExtension; |
| 61 using cricket::RELAY_PORT_TYPE; | 60 using cricket::RELAY_PORT_TYPE; |
| 62 using cricket::SessionDescription; | 61 using cricket::SessionDescription; |
| 63 using cricket::StreamParams; | 62 using cricket::StreamParams; |
| 64 using cricket::STUN_PORT_TYPE; | 63 using cricket::STUN_PORT_TYPE; |
| 65 using cricket::TransportDescription; | 64 using cricket::TransportDescription; |
| 66 using cricket::TransportInfo; | 65 using cricket::TransportInfo; |
| 67 using cricket::VideoCodec; | 66 using cricket::VideoCodec; |
| 68 using cricket::VideoContentDescription; | 67 using cricket::VideoContentDescription; |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 JsepSessionDescription::kMaxVideoCodecHeight, | 572 JsepSessionDescription::kMaxVideoCodecHeight, |
| 574 JsepSessionDescription::kDefaultVideoCodecFramerate, | 573 JsepSessionDescription::kDefaultVideoCodecFramerate, |
| 575 JsepSessionDescription::kDefaultVideoCodecPreference)); | 574 JsepSessionDescription::kDefaultVideoCodecPreference)); |
| 576 | 575 |
| 577 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, | 576 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, |
| 578 video.release()); | 577 video.release()); |
| 579 | 578 |
| 580 // TransportInfo | 579 // TransportInfo |
| 581 EXPECT_TRUE(desc_.AddTransportInfo( | 580 EXPECT_TRUE(desc_.AddTransportInfo( |
| 582 TransportInfo(kAudioContentName, | 581 TransportInfo(kAudioContentName, |
| 583 TransportDescription(NS_JINGLE_ICE_UDP, | 582 TransportDescription(kCandidateUfragVoice, |
| 584 kCandidateUfragVoice, | |
| 585 kCandidatePwdVoice)))); | 583 kCandidatePwdVoice)))); |
| 586 EXPECT_TRUE(desc_.AddTransportInfo( | 584 EXPECT_TRUE(desc_.AddTransportInfo( |
| 587 TransportInfo(kVideoContentName, | 585 TransportInfo(kVideoContentName, |
| 588 TransportDescription(NS_JINGLE_ICE_UDP, | 586 TransportDescription(kCandidateUfragVideo, |
| 589 kCandidateUfragVideo, | |
| 590 kCandidatePwdVideo)))); | 587 kCandidatePwdVideo)))); |
| 591 | 588 |
| 592 // v4 host | 589 // v4 host |
| 593 int port = 1234; | 590 int port = 1234; |
| 594 rtc::SocketAddress address("192.168.1.5", port++); | 591 rtc::SocketAddress address("192.168.1.5", port++); |
| 595 Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, | 592 Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, |
| 596 kCandidatePriority, "", "", LOCAL_PORT_TYPE, | 593 kCandidatePriority, "", "", LOCAL_PORT_TYPE, |
| 597 kCandidateGeneration, kCandidateFoundation1); | 594 kCandidateGeneration, kCandidateFoundation1); |
| 598 address.SetPort(port++); | 595 address.SetPort(port++); |
| 599 Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, | 596 Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 const cricket::TransportInfos transports2 = desc2.transport_infos(); | 853 const cricket::TransportInfos transports2 = desc2.transport_infos(); |
| 857 EXPECT_EQ(transports1.size(), transports2.size()); | 854 EXPECT_EQ(transports1.size(), transports2.size()); |
| 858 if (transports1.size() != transports2.size()) { | 855 if (transports1.size() != transports2.size()) { |
| 859 ADD_FAILURE(); | 856 ADD_FAILURE(); |
| 860 return; | 857 return; |
| 861 } | 858 } |
| 862 for (size_t i = 0; i < transports1.size(); ++i) { | 859 for (size_t i = 0; i < transports1.size(); ++i) { |
| 863 const cricket::TransportInfo transport1 = transports1.at(i); | 860 const cricket::TransportInfo transport1 = transports1.at(i); |
| 864 const cricket::TransportInfo transport2 = transports2.at(i); | 861 const cricket::TransportInfo transport2 = transports2.at(i); |
| 865 EXPECT_EQ(transport1.content_name, transport2.content_name); | 862 EXPECT_EQ(transport1.content_name, transport2.content_name); |
| 866 EXPECT_EQ(transport1.description.transport_type, | |
| 867 transport2.description.transport_type); | |
| 868 EXPECT_EQ(transport1.description.ice_ufrag, | 863 EXPECT_EQ(transport1.description.ice_ufrag, |
| 869 transport2.description.ice_ufrag); | 864 transport2.description.ice_ufrag); |
| 870 EXPECT_EQ(transport1.description.ice_pwd, | 865 EXPECT_EQ(transport1.description.ice_pwd, |
| 871 transport2.description.ice_pwd); | 866 transport2.description.ice_pwd); |
| 872 if (transport1.description.identity_fingerprint) { | 867 if (transport1.description.identity_fingerprint) { |
| 873 EXPECT_EQ(*transport1.description.identity_fingerprint, | 868 EXPECT_EQ(*transport1.description.identity_fingerprint, |
| 874 *transport2.description.identity_fingerprint); | 869 *transport2.description.identity_fingerprint); |
| 875 } else { | 870 } else { |
| 876 EXPECT_EQ(transport1.description.identity_fingerprint.get(), | 871 EXPECT_EQ(transport1.description.identity_fingerprint.get(), |
| 877 transport2.description.identity_fingerprint.get()); | 872 transport2.description.identity_fingerprint.get()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 const std::string& ufrag, const std::string& pwd) { | 933 const std::string& ufrag, const std::string& pwd) { |
| 939 std::string content_name; | 934 std::string content_name; |
| 940 if (mline_index == 0) { | 935 if (mline_index == 0) { |
| 941 content_name = kAudioContentName; | 936 content_name = kAudioContentName; |
| 942 } else if (mline_index == 1) { | 937 } else if (mline_index == 1) { |
| 943 content_name = kVideoContentName; | 938 content_name = kVideoContentName; |
| 944 } else { | 939 } else { |
| 945 ASSERT(false); | 940 ASSERT(false); |
| 946 } | 941 } |
| 947 TransportInfo transport_info( | 942 TransportInfo transport_info( |
| 948 content_name, TransportDescription(NS_JINGLE_ICE_UDP, | 943 content_name, TransportDescription(ufrag, pwd)); |
| 949 ufrag, pwd)); | |
| 950 SessionDescription* desc = | 944 SessionDescription* desc = |
| 951 const_cast<SessionDescription*>(jdesc->description()); | 945 const_cast<SessionDescription*>(jdesc->description()); |
| 952 desc->RemoveTransportInfoByName(content_name); | 946 desc->RemoveTransportInfoByName(content_name); |
| 953 EXPECT_TRUE(desc->AddTransportInfo(transport_info)); | 947 EXPECT_TRUE(desc->AddTransportInfo(transport_info)); |
| 954 for (size_t i = 0; i < jdesc_.number_of_mediasections(); ++i) { | 948 for (size_t i = 0; i < jdesc_.number_of_mediasections(); ++i) { |
| 955 const IceCandidateCollection* cc = jdesc_.candidates(i); | 949 const IceCandidateCollection* cc = jdesc_.candidates(i); |
| 956 for (size_t j = 0; j < cc->count(); ++j) { | 950 for (size_t j = 0; j < cc->count(); ++j) { |
| 957 if (cc->at(j)->sdp_mline_index() == mline_index) { | 951 if (cc->at(j)->sdp_mline_index() == mline_index) { |
| 958 const_cast<Candidate&>(cc->at(j)->candidate()).set_username( | 952 const_cast<Candidate&>(cc->at(j)->candidate()).set_username( |
| 959 ufrag); | 953 ufrag); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 976 } | 970 } |
| 977 | 971 |
| 978 void AddFingerprint() { | 972 void AddFingerprint() { |
| 979 desc_.RemoveTransportInfoByName(kAudioContentName); | 973 desc_.RemoveTransportInfoByName(kAudioContentName); |
| 980 desc_.RemoveTransportInfoByName(kVideoContentName); | 974 desc_.RemoveTransportInfoByName(kVideoContentName); |
| 981 rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1, | 975 rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1, |
| 982 kIdentityDigest, | 976 kIdentityDigest, |
| 983 sizeof(kIdentityDigest)); | 977 sizeof(kIdentityDigest)); |
| 984 EXPECT_TRUE(desc_.AddTransportInfo( | 978 EXPECT_TRUE(desc_.AddTransportInfo( |
| 985 TransportInfo(kAudioContentName, | 979 TransportInfo(kAudioContentName, |
| 986 TransportDescription(NS_JINGLE_ICE_UDP, | 980 TransportDescription(std::vector<std::string>(), |
| 987 std::vector<std::string>(), | |
| 988 kCandidateUfragVoice, | 981 kCandidateUfragVoice, |
| 989 kCandidatePwdVoice, | 982 kCandidatePwdVoice, |
| 990 cricket::ICEMODE_FULL, | 983 cricket::ICEMODE_FULL, |
| 991 cricket::CONNECTIONROLE_NONE, | 984 cricket::CONNECTIONROLE_NONE, |
| 992 &fingerprint, Candidates())))); | 985 &fingerprint, Candidates())))); |
| 993 EXPECT_TRUE(desc_.AddTransportInfo( | 986 EXPECT_TRUE(desc_.AddTransportInfo( |
| 994 TransportInfo(kVideoContentName, | 987 TransportInfo(kVideoContentName, |
| 995 TransportDescription(NS_JINGLE_ICE_UDP, | 988 TransportDescription(std::vector<std::string>(), |
| 996 std::vector<std::string>(), | |
| 997 kCandidateUfragVideo, | 989 kCandidateUfragVideo, |
| 998 kCandidatePwdVideo, | 990 kCandidatePwdVideo, |
| 999 cricket::ICEMODE_FULL, | 991 cricket::ICEMODE_FULL, |
| 1000 cricket::CONNECTIONROLE_NONE, | 992 cricket::CONNECTIONROLE_NONE, |
| 1001 &fingerprint, Candidates())))); | 993 &fingerprint, Candidates())))); |
| 1002 } | 994 } |
| 1003 | 995 |
| 1004 void AddExtmap() { | 996 void AddExtmap() { |
| 1005 audio_desc_ = static_cast<AudioContentDescription*>( | 997 audio_desc_ = static_cast<AudioContentDescription*>( |
| 1006 audio_desc_->Copy()); | 998 audio_desc_->Copy()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 new DataContentDescription()); | 1058 new DataContentDescription()); |
| 1067 data_desc_ = data.get(); | 1059 data_desc_ = data.get(); |
| 1068 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1060 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
| 1069 DataCodec codec(cricket::kGoogleSctpDataCodecId, | 1061 DataCodec codec(cricket::kGoogleSctpDataCodecId, |
| 1070 cricket::kGoogleSctpDataCodecName, 0); | 1062 cricket::kGoogleSctpDataCodecName, 0); |
| 1071 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1063 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
| 1072 data_desc_->AddCodec(codec); | 1064 data_desc_->AddCodec(codec); |
| 1073 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1065 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
| 1074 EXPECT_TRUE(desc_.AddTransportInfo( | 1066 EXPECT_TRUE(desc_.AddTransportInfo( |
| 1075 TransportInfo(kDataContentName, | 1067 TransportInfo(kDataContentName, |
| 1076 TransportDescription(NS_JINGLE_ICE_UDP, | 1068 TransportDescription(kCandidateUfragData, |
| 1077 kCandidateUfragData, | |
| 1078 kCandidatePwdData)))); | 1069 kCandidatePwdData)))); |
| 1079 } | 1070 } |
| 1080 | 1071 |
| 1081 void AddRtpDataChannel() { | 1072 void AddRtpDataChannel() { |
| 1082 rtc::scoped_ptr<DataContentDescription> data( | 1073 rtc::scoped_ptr<DataContentDescription> data( |
| 1083 new DataContentDescription()); | 1074 new DataContentDescription()); |
| 1084 data_desc_ = data.get(); | 1075 data_desc_ = data.get(); |
| 1085 | 1076 |
| 1086 data_desc_->AddCodec(DataCodec(101, "google-data", 1)); | 1077 data_desc_->AddCodec(DataCodec(101, "google-data", 1)); |
| 1087 StreamParams data_stream; | 1078 StreamParams data_stream; |
| 1088 data_stream.id = kDataChannelMsid; | 1079 data_stream.id = kDataChannelMsid; |
| 1089 data_stream.cname = kDataChannelCname; | 1080 data_stream.cname = kDataChannelCname; |
| 1090 data_stream.sync_label = kDataChannelLabel; | 1081 data_stream.sync_label = kDataChannelLabel; |
| 1091 data_stream.ssrcs.push_back(kDataChannelSsrc); | 1082 data_stream.ssrcs.push_back(kDataChannelSsrc); |
| 1092 data_desc_->AddStream(data_stream); | 1083 data_desc_->AddStream(data_stream); |
| 1093 data_desc_->AddCrypto(CryptoParams( | 1084 data_desc_->AddCrypto(CryptoParams( |
| 1094 1, "AES_CM_128_HMAC_SHA1_80", | 1085 1, "AES_CM_128_HMAC_SHA1_80", |
| 1095 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); | 1086 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
| 1096 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); | 1087 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
| 1097 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); | 1088 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); |
| 1098 EXPECT_TRUE(desc_.AddTransportInfo( | 1089 EXPECT_TRUE(desc_.AddTransportInfo( |
| 1099 TransportInfo(kDataContentName, | 1090 TransportInfo(kDataContentName, |
| 1100 TransportDescription(NS_JINGLE_ICE_UDP, | 1091 TransportDescription(kCandidateUfragData, |
| 1101 kCandidateUfragData, | |
| 1102 kCandidatePwdData)))); | 1092 kCandidatePwdData)))); |
| 1103 } | 1093 } |
| 1104 | 1094 |
| 1105 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { | 1095 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { |
| 1106 std::string new_sdp = kSdpFullString; | 1096 std::string new_sdp = kSdpFullString; |
| 1107 ReplaceDirection(direction, &new_sdp); | 1097 ReplaceDirection(direction, &new_sdp); |
| 1108 JsepSessionDescription new_jdesc(kDummyString); | 1098 JsepSessionDescription new_jdesc(kDummyString); |
| 1109 | 1099 |
| 1110 EXPECT_TRUE(SdpDeserialize(new_sdp, &new_jdesc)); | 1100 EXPECT_TRUE(SdpDeserialize(new_sdp, &new_jdesc)); |
| 1111 | 1101 |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 const cricket::MediaContentDescription* mdesc = | 2664 const cricket::MediaContentDescription* mdesc = |
| 2675 static_cast<const cricket::MediaContentDescription*>( | 2665 static_cast<const cricket::MediaContentDescription*>( |
| 2676 desc->contents()[i].description); | 2666 desc->contents()[i].description); |
| 2677 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); | 2667 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); |
| 2678 } | 2668 } |
| 2679 | 2669 |
| 2680 std::string serialized_sdp = webrtc::SdpSerialize(jdesc); | 2670 std::string serialized_sdp = webrtc::SdpSerialize(jdesc); |
| 2681 EXPECT_EQ(sdp_string, serialized_sdp); | 2671 EXPECT_EQ(sdp_string, serialized_sdp); |
| 2682 } | 2672 } |
| 2683 } | 2673 } |
| OLD | NEW |