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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "webrtc/p2p/base/constants.h" | 43 #include "webrtc/p2p/base/constants.h" |
44 | 44 |
45 #ifdef HAVE_SCTP | 45 #ifdef HAVE_SCTP |
46 #include "talk/media/sctp/sctpdataengine.h" | 46 #include "talk/media/sctp/sctpdataengine.h" |
47 #else | 47 #else |
48 static const uint32_t kMaxSctpSid = 1023; | 48 static const uint32_t kMaxSctpSid = 1023; |
49 #endif | 49 #endif |
50 | 50 |
51 namespace { | 51 namespace { |
52 const char kInline[] = "inline:"; | 52 const char kInline[] = "inline:"; |
53 | |
54 void GetSupportedCryptoSuiteNames(void (*func)(std::vector<int>*), | |
55 std::vector<std::string>* names) { | |
56 #ifdef HAVE_SRTP | |
57 std::vector<int> crypto_suites; | |
58 func(&crypto_suites); | |
59 for (const auto crypto : crypto_suites) { | |
60 names->push_back(rtc::SrtpCryptoSuiteToName(crypto)); | |
61 } | |
62 #endif | |
63 } | |
64 } | 53 } |
65 | 54 |
66 namespace cricket { | 55 namespace cricket { |
67 | 56 |
68 using rtc::scoped_ptr; | 57 using rtc::scoped_ptr; |
69 | 58 |
70 // RTP Profile names | 59 // RTP Profile names |
71 // http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml | 60 // http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml |
72 // RFC4585 | 61 // RFC4585 |
73 const char kMediaProtocolAvpf[] = "RTP/AVPF"; | 62 const char kMediaProtocolAvpf[] = "RTP/AVPF"; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 it != cryptos.end(); ++it) { | 145 it != cryptos.end(); ++it) { |
157 if (crypto.Matches(*it)) { | 146 if (crypto.Matches(*it)) { |
158 *out = *it; | 147 *out = *it; |
159 return true; | 148 return true; |
160 } | 149 } |
161 } | 150 } |
162 return false; | 151 return false; |
163 } | 152 } |
164 | 153 |
165 // For audio, HMAC 32 is prefered because of the low overhead. | 154 // For audio, HMAC 32 is prefered because of the low overhead. |
166 void GetSupportedAudioCryptoSuites(std::vector<int>* crypto_suites) { | 155 void GetSupportedAudioCryptoSuites( |
| 156 std::vector<std::string>* crypto_suites) { |
167 #ifdef HAVE_SRTP | 157 #ifdef HAVE_SRTP |
168 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_32); | 158 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_32); |
169 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80); | 159 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); |
170 #endif | 160 #endif |
171 } | 161 } |
172 | 162 |
173 void GetSupportedAudioCryptoSuiteNames( | 163 void GetSupportedVideoCryptoSuites( |
174 std::vector<std::string>* crypto_suite_names) { | 164 std::vector<std::string>* crypto_suites) { |
175 GetSupportedCryptoSuiteNames(GetSupportedAudioCryptoSuites, | 165 GetDefaultSrtpCryptoSuiteNames(crypto_suites); |
176 crypto_suite_names); | |
177 } | 166 } |
178 | 167 |
179 void GetSupportedVideoCryptoSuites(std::vector<int>* crypto_suites) { | 168 void GetSupportedDataCryptoSuites( |
180 GetDefaultSrtpCryptoSuites(crypto_suites); | 169 std::vector<std::string>* crypto_suites) { |
| 170 GetDefaultSrtpCryptoSuiteNames(crypto_suites); |
181 } | 171 } |
182 | 172 |
183 void GetSupportedVideoCryptoSuiteNames( | 173 void GetDefaultSrtpCryptoSuiteNames(std::vector<std::string>* crypto_suites) { |
184 std::vector<std::string>* crypto_suite_names) { | |
185 GetSupportedCryptoSuiteNames(GetSupportedVideoCryptoSuites, | |
186 crypto_suite_names); | |
187 } | |
188 | |
189 void GetSupportedDataCryptoSuites(std::vector<int>* crypto_suites) { | |
190 GetDefaultSrtpCryptoSuites(crypto_suites); | |
191 } | |
192 | |
193 void GetSupportedDataCryptoSuiteNames( | |
194 std::vector<std::string>* crypto_suite_names) { | |
195 GetSupportedCryptoSuiteNames(GetSupportedDataCryptoSuites, | |
196 crypto_suite_names); | |
197 } | |
198 | |
199 void GetDefaultSrtpCryptoSuites(std::vector<int>* crypto_suites) { | |
200 #ifdef HAVE_SRTP | 174 #ifdef HAVE_SRTP |
201 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80); | 175 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); |
202 #endif | 176 #endif |
203 } | 177 } |
204 | 178 |
205 void GetDefaultSrtpCryptoSuiteNames( | |
206 std::vector<std::string>* crypto_suite_names) { | |
207 GetSupportedCryptoSuiteNames(GetDefaultSrtpCryptoSuites, crypto_suite_names); | |
208 } | |
209 | |
210 // For video support only 80-bit SHA1 HMAC. For audio 32-bit HMAC is | 179 // For video support only 80-bit SHA1 HMAC. For audio 32-bit HMAC is |
211 // tolerated unless bundle is enabled because it is low overhead. Pick the | 180 // tolerated unless bundle is enabled because it is low overhead. Pick the |
212 // crypto in the list that is supported. | 181 // crypto in the list that is supported. |
213 static bool SelectCrypto(const MediaContentDescription* offer, | 182 static bool SelectCrypto(const MediaContentDescription* offer, |
214 bool bundle, | 183 bool bundle, |
215 CryptoParams *crypto) { | 184 CryptoParams *crypto) { |
216 bool audio = offer->type() == MEDIA_TYPE_AUDIO; | 185 bool audio = offer->type() == MEDIA_TYPE_AUDIO; |
217 const CryptoParamsVec& cryptos = offer->cryptos(); | 186 const CryptoParamsVec& cryptos = offer->cryptos(); |
218 | 187 |
219 for (CryptoParamsVec::const_iterator i = cryptos.begin(); | 188 for (CryptoParamsVec::const_iterator i = cryptos.begin(); |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 const RtpHeaderExtensions& audio_rtp_extensions, | 1507 const RtpHeaderExtensions& audio_rtp_extensions, |
1539 const AudioCodecs& audio_codecs, | 1508 const AudioCodecs& audio_codecs, |
1540 StreamParamsVec* current_streams, | 1509 StreamParamsVec* current_streams, |
1541 SessionDescription* desc) const { | 1510 SessionDescription* desc) const { |
1542 cricket::SecurePolicy sdes_policy = | 1511 cricket::SecurePolicy sdes_policy = |
1543 IsDtlsActive(CN_AUDIO, current_description) ? | 1512 IsDtlsActive(CN_AUDIO, current_description) ? |
1544 cricket::SEC_DISABLED : secure(); | 1513 cricket::SEC_DISABLED : secure(); |
1545 | 1514 |
1546 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription()); | 1515 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription()); |
1547 std::vector<std::string> crypto_suites; | 1516 std::vector<std::string> crypto_suites; |
1548 GetSupportedAudioCryptoSuiteNames(&crypto_suites); | 1517 GetSupportedAudioCryptoSuites(&crypto_suites); |
1549 if (!CreateMediaContentOffer( | 1518 if (!CreateMediaContentOffer( |
1550 options, | 1519 options, |
1551 audio_codecs, | 1520 audio_codecs, |
1552 sdes_policy, | 1521 sdes_policy, |
1553 GetCryptos(GetFirstAudioContentDescription(current_description)), | 1522 GetCryptos(GetFirstAudioContentDescription(current_description)), |
1554 crypto_suites, | 1523 crypto_suites, |
1555 audio_rtp_extensions, | 1524 audio_rtp_extensions, |
1556 add_legacy_, | 1525 add_legacy_, |
1557 current_streams, | 1526 current_streams, |
1558 audio.get())) { | 1527 audio.get())) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 const RtpHeaderExtensions& video_rtp_extensions, | 1561 const RtpHeaderExtensions& video_rtp_extensions, |
1593 const VideoCodecs& video_codecs, | 1562 const VideoCodecs& video_codecs, |
1594 StreamParamsVec* current_streams, | 1563 StreamParamsVec* current_streams, |
1595 SessionDescription* desc) const { | 1564 SessionDescription* desc) const { |
1596 cricket::SecurePolicy sdes_policy = | 1565 cricket::SecurePolicy sdes_policy = |
1597 IsDtlsActive(CN_VIDEO, current_description) ? | 1566 IsDtlsActive(CN_VIDEO, current_description) ? |
1598 cricket::SEC_DISABLED : secure(); | 1567 cricket::SEC_DISABLED : secure(); |
1599 | 1568 |
1600 scoped_ptr<VideoContentDescription> video(new VideoContentDescription()); | 1569 scoped_ptr<VideoContentDescription> video(new VideoContentDescription()); |
1601 std::vector<std::string> crypto_suites; | 1570 std::vector<std::string> crypto_suites; |
1602 GetSupportedVideoCryptoSuiteNames(&crypto_suites); | 1571 GetSupportedVideoCryptoSuites(&crypto_suites); |
1603 if (!CreateMediaContentOffer( | 1572 if (!CreateMediaContentOffer( |
1604 options, | 1573 options, |
1605 video_codecs, | 1574 video_codecs, |
1606 sdes_policy, | 1575 sdes_policy, |
1607 GetCryptos(GetFirstVideoContentDescription(current_description)), | 1576 GetCryptos(GetFirstVideoContentDescription(current_description)), |
1608 crypto_suites, | 1577 crypto_suites, |
1609 video_rtp_extensions, | 1578 video_rtp_extensions, |
1610 add_legacy_, | 1579 add_legacy_, |
1611 current_streams, | 1580 current_streams, |
1612 video.get())) { | 1581 video.get())) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 // SDES doesn't make sense for SCTP, so we disable it, and we only | 1631 // SDES doesn't make sense for SCTP, so we disable it, and we only |
1663 // get SDES crypto suites for RTP-based data channels. | 1632 // get SDES crypto suites for RTP-based data channels. |
1664 sdes_policy = cricket::SEC_DISABLED; | 1633 sdes_policy = cricket::SEC_DISABLED; |
1665 // Unlike SetMediaProtocol below, we need to set the protocol | 1634 // Unlike SetMediaProtocol below, we need to set the protocol |
1666 // before we call CreateMediaContentOffer. Otherwise, | 1635 // before we call CreateMediaContentOffer. Otherwise, |
1667 // CreateMediaContentOffer won't know this is SCTP and will | 1636 // CreateMediaContentOffer won't know this is SCTP and will |
1668 // generate SSRCs rather than SIDs. | 1637 // generate SSRCs rather than SIDs. |
1669 data->set_protocol( | 1638 data->set_protocol( |
1670 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); | 1639 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); |
1671 } else { | 1640 } else { |
1672 GetSupportedDataCryptoSuiteNames(&crypto_suites); | 1641 GetSupportedDataCryptoSuites(&crypto_suites); |
1673 } | 1642 } |
1674 | 1643 |
1675 if (!CreateMediaContentOffer( | 1644 if (!CreateMediaContentOffer( |
1676 options, | 1645 options, |
1677 *data_codecs, | 1646 *data_codecs, |
1678 sdes_policy, | 1647 sdes_policy, |
1679 GetCryptos(GetFirstDataContentDescription(current_description)), | 1648 GetCryptos(GetFirstDataContentDescription(current_description)), |
1680 crypto_suites, | 1649 crypto_suites, |
1681 RtpHeaderExtensions(), | 1650 RtpHeaderExtensions(), |
1682 add_legacy_, | 1651 add_legacy_, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1924 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1956 } | 1925 } |
1957 | 1926 |
1958 const DataContentDescription* GetFirstDataContentDescription( | 1927 const DataContentDescription* GetFirstDataContentDescription( |
1959 const SessionDescription* sdesc) { | 1928 const SessionDescription* sdesc) { |
1960 return static_cast<const DataContentDescription*>( | 1929 return static_cast<const DataContentDescription*>( |
1961 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1930 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1962 } | 1931 } |
1963 | 1932 |
1964 } // namespace cricket | 1933 } // namespace cricket |
OLD | NEW |