Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: talk/session/media/mediasession.cc

Issue 1416673006: Convert internal representation of Srtp cryptos from string to int. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: remove thread checker Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 it != cryptos.end(); ++it) { 145 it != cryptos.end(); ++it) {
146 if (crypto.Matches(*it)) { 146 if (crypto.Matches(*it)) {
147 *out = *it; 147 *out = *it;
148 return true; 148 return true;
149 } 149 }
150 } 150 }
151 return false; 151 return false;
152 } 152 }
153 153
154 // For audio, HMAC 32 is prefered because of the low overhead. 154 // For audio, HMAC 32 is prefered because of the low overhead.
155 void GetSupportedAudioCryptoSuites( 155 void GetSupportedAudioCryptoSuites(std::vector<int>* crypto_suites) {
156 std::vector<std::string>* crypto_suites) {
157 #ifdef HAVE_SRTP 156 #ifdef HAVE_SRTP
158 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_32); 157 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_32);
159 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); 158 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80);
160 #endif 159 #endif
161 } 160 }
162 161
163 void GetSupportedVideoCryptoSuites( 162 void GetSupportedAudioCryptoSuiteNames(
163 std::vector<std::string>* crypto_suite_names) {
164 #ifdef HAVE_SRTP
165 std::vector<int> crypto_suites;
166 GetSupportedAudioCryptoSuites(&crypto_suites);
167 for (const auto crypto : crypto_suites) {
168 crypto_suite_names->push_back(rtc::SrtpCryptoSuiteToName(crypto));
169 }
170 #endif
171 }
172
173 void GetSupportedVideoCryptoSuites(std::vector<int>* crypto_suites) {
174 GetDefaultSrtpCryptoSuites(crypto_suites);
175 }
176
177 void GetSupportedVideoCryptoSuiteNames(
164 std::vector<std::string>* crypto_suites) { 178 std::vector<std::string>* crypto_suites) {
165 GetDefaultSrtpCryptoSuiteNames(crypto_suites); 179 GetDefaultSrtpCryptoSuiteNames(crypto_suites);
166 } 180 }
167 181
168 void GetSupportedDataCryptoSuites( 182 void GetSupportedDataCryptoSuites(std::vector<int>* crypto_suites) {
169 std::vector<std::string>* crypto_suites) { 183 GetDefaultSrtpCryptoSuites(crypto_suites);
184 }
185
186 void GetSupportedDataCryptoSuiteNames(std::vector<std::string>* crypto_suites) {
170 GetDefaultSrtpCryptoSuiteNames(crypto_suites); 187 GetDefaultSrtpCryptoSuiteNames(crypto_suites);
171 } 188 }
172 189
173 void GetDefaultSrtpCryptoSuiteNames(std::vector<std::string>* crypto_suites) { 190 void GetDefaultSrtpCryptoSuites(std::vector<int>* crypto_suites) {
174 #ifdef HAVE_SRTP 191 #ifdef HAVE_SRTP
175 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); 192 crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80);
176 #endif 193 #endif
177 } 194 }
178 195
196 void GetDefaultSrtpCryptoSuiteNames(
juberti 2015/11/17 21:19:08 Seems like it would be simplest to have a wrapper
guoweis_webrtc 2015/11/18 19:17:17 Do you mean the following: std::vector<int> GetSu
juberti 2015/11/18 20:19:15 more like GetSupportedCryptoSuiteNames(void (*func
197 std::vector<std::string>* crypto_suite_names) {
198 #ifdef HAVE_SRTP
199 std::vector<int> crypto_suites;
200 GetDefaultSrtpCryptoSuites(&crypto_suites);
201 for (const auto crypto : crypto_suites) {
202 crypto_suite_names->push_back(rtc::SrtpCryptoSuiteToName(crypto));
203 }
204 #endif
205 }
206
179 // For video support only 80-bit SHA1 HMAC. For audio 32-bit HMAC is 207 // For video support only 80-bit SHA1 HMAC. For audio 32-bit HMAC is
180 // tolerated unless bundle is enabled because it is low overhead. Pick the 208 // tolerated unless bundle is enabled because it is low overhead. Pick the
181 // crypto in the list that is supported. 209 // crypto in the list that is supported.
182 static bool SelectCrypto(const MediaContentDescription* offer, 210 static bool SelectCrypto(const MediaContentDescription* offer,
183 bool bundle, 211 bool bundle,
184 CryptoParams *crypto) { 212 CryptoParams *crypto) {
185 bool audio = offer->type() == MEDIA_TYPE_AUDIO; 213 bool audio = offer->type() == MEDIA_TYPE_AUDIO;
186 const CryptoParamsVec& cryptos = offer->cryptos(); 214 const CryptoParamsVec& cryptos = offer->cryptos();
187 215
188 for (CryptoParamsVec::const_iterator i = cryptos.begin(); 216 for (CryptoParamsVec::const_iterator i = cryptos.begin();
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 const RtpHeaderExtensions& audio_rtp_extensions, 1535 const RtpHeaderExtensions& audio_rtp_extensions,
1508 const AudioCodecs& audio_codecs, 1536 const AudioCodecs& audio_codecs,
1509 StreamParamsVec* current_streams, 1537 StreamParamsVec* current_streams,
1510 SessionDescription* desc) const { 1538 SessionDescription* desc) const {
1511 cricket::SecurePolicy sdes_policy = 1539 cricket::SecurePolicy sdes_policy =
1512 IsDtlsActive(CN_AUDIO, current_description) ? 1540 IsDtlsActive(CN_AUDIO, current_description) ?
1513 cricket::SEC_DISABLED : secure(); 1541 cricket::SEC_DISABLED : secure();
1514 1542
1515 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription()); 1543 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription());
1516 std::vector<std::string> crypto_suites; 1544 std::vector<std::string> crypto_suites;
1517 GetSupportedAudioCryptoSuites(&crypto_suites); 1545 GetSupportedAudioCryptoSuiteNames(&crypto_suites);
1518 if (!CreateMediaContentOffer( 1546 if (!CreateMediaContentOffer(
1519 options, 1547 options,
1520 audio_codecs, 1548 audio_codecs,
1521 sdes_policy, 1549 sdes_policy,
1522 GetCryptos(GetFirstAudioContentDescription(current_description)), 1550 GetCryptos(GetFirstAudioContentDescription(current_description)),
1523 crypto_suites, 1551 crypto_suites,
1524 audio_rtp_extensions, 1552 audio_rtp_extensions,
1525 add_legacy_, 1553 add_legacy_,
1526 current_streams, 1554 current_streams,
1527 audio.get())) { 1555 audio.get())) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 const RtpHeaderExtensions& video_rtp_extensions, 1589 const RtpHeaderExtensions& video_rtp_extensions,
1562 const VideoCodecs& video_codecs, 1590 const VideoCodecs& video_codecs,
1563 StreamParamsVec* current_streams, 1591 StreamParamsVec* current_streams,
1564 SessionDescription* desc) const { 1592 SessionDescription* desc) const {
1565 cricket::SecurePolicy sdes_policy = 1593 cricket::SecurePolicy sdes_policy =
1566 IsDtlsActive(CN_VIDEO, current_description) ? 1594 IsDtlsActive(CN_VIDEO, current_description) ?
1567 cricket::SEC_DISABLED : secure(); 1595 cricket::SEC_DISABLED : secure();
1568 1596
1569 scoped_ptr<VideoContentDescription> video(new VideoContentDescription()); 1597 scoped_ptr<VideoContentDescription> video(new VideoContentDescription());
1570 std::vector<std::string> crypto_suites; 1598 std::vector<std::string> crypto_suites;
1571 GetSupportedVideoCryptoSuites(&crypto_suites); 1599 GetSupportedVideoCryptoSuiteNames(&crypto_suites);
1572 if (!CreateMediaContentOffer( 1600 if (!CreateMediaContentOffer(
1573 options, 1601 options,
1574 video_codecs, 1602 video_codecs,
1575 sdes_policy, 1603 sdes_policy,
1576 GetCryptos(GetFirstVideoContentDescription(current_description)), 1604 GetCryptos(GetFirstVideoContentDescription(current_description)),
1577 crypto_suites, 1605 crypto_suites,
1578 video_rtp_extensions, 1606 video_rtp_extensions,
1579 add_legacy_, 1607 add_legacy_,
1580 current_streams, 1608 current_streams,
1581 video.get())) { 1609 video.get())) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 // SDES doesn't make sense for SCTP, so we disable it, and we only 1659 // SDES doesn't make sense for SCTP, so we disable it, and we only
1632 // get SDES crypto suites for RTP-based data channels. 1660 // get SDES crypto suites for RTP-based data channels.
1633 sdes_policy = cricket::SEC_DISABLED; 1661 sdes_policy = cricket::SEC_DISABLED;
1634 // Unlike SetMediaProtocol below, we need to set the protocol 1662 // Unlike SetMediaProtocol below, we need to set the protocol
1635 // before we call CreateMediaContentOffer. Otherwise, 1663 // before we call CreateMediaContentOffer. Otherwise,
1636 // CreateMediaContentOffer won't know this is SCTP and will 1664 // CreateMediaContentOffer won't know this is SCTP and will
1637 // generate SSRCs rather than SIDs. 1665 // generate SSRCs rather than SIDs.
1638 data->set_protocol( 1666 data->set_protocol(
1639 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); 1667 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp);
1640 } else { 1668 } else {
1641 GetSupportedDataCryptoSuites(&crypto_suites); 1669 GetSupportedDataCryptoSuiteNames(&crypto_suites);
1642 } 1670 }
1643 1671
1644 if (!CreateMediaContentOffer( 1672 if (!CreateMediaContentOffer(
1645 options, 1673 options,
1646 *data_codecs, 1674 *data_codecs,
1647 sdes_policy, 1675 sdes_policy,
1648 GetCryptos(GetFirstDataContentDescription(current_description)), 1676 GetCryptos(GetFirstDataContentDescription(current_description)),
1649 crypto_suites, 1677 crypto_suites,
1650 RtpHeaderExtensions(), 1678 RtpHeaderExtensions(),
1651 add_legacy_, 1679 add_legacy_,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 1952 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1925 } 1953 }
1926 1954
1927 const DataContentDescription* GetFirstDataContentDescription( 1955 const DataContentDescription* GetFirstDataContentDescription(
1928 const SessionDescription* sdesc) { 1956 const SessionDescription* sdesc) {
1929 return static_cast<const DataContentDescription*>( 1957 return static_cast<const DataContentDescription*>(
1930 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 1958 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
1931 } 1959 }
1932 1960
1933 } // namespace cricket 1961 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698