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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
156 std::vector<std::string>* crypto_suites) { | 156 std::vector<std::string>* crypto_suites) { |
157 #ifdef HAVE_SRTP | 157 #ifdef HAVE_SRTP |
158 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_32); | 158 crypto_suites->push_back(CS_AES_CM_128_HMAC_SHA1_32); |
159 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); | 159 crypto_suites->push_back(CS_AES_CM_128_HMAC_SHA1_80); |
160 #endif | 160 #endif |
161 } | 161 } |
162 | 162 |
163 void GetSupportedVideoCryptoSuites( | 163 void GetSupportedVideoCryptoSuites( |
164 std::vector<std::string>* crypto_suites) { | 164 std::vector<std::string>* crypto_suites) { |
165 GetDefaultSrtpCryptoSuiteNames(crypto_suites); | 165 GetSupportedDefaultCryptoSuites(crypto_suites); |
166 } | 166 } |
167 | 167 |
168 void GetSupportedDataCryptoSuites( | 168 void GetSupportedDataCryptoSuites( |
169 std::vector<std::string>* crypto_suites) { | 169 std::vector<std::string>* crypto_suites) { |
170 GetDefaultSrtpCryptoSuiteNames(crypto_suites); | 170 GetSupportedDefaultCryptoSuites(crypto_suites); |
171 } | 171 } |
172 | 172 |
173 void GetDefaultSrtpCryptoSuiteNames(std::vector<std::string>* crypto_suites) { | 173 void GetSupportedDefaultCryptoSuites( |
| 174 std::vector<std::string>* crypto_suites) { |
174 #ifdef HAVE_SRTP | 175 #ifdef HAVE_SRTP |
175 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); | 176 crypto_suites->push_back(CS_AES_CM_128_HMAC_SHA1_80); |
176 #endif | 177 #endif |
177 } | 178 } |
178 | 179 |
179 // For video support only 80-bit SHA1 HMAC. For audio 32-bit HMAC is | 180 // 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 | 181 // tolerated unless bundle is enabled because it is low overhead. Pick the |
181 // crypto in the list that is supported. | 182 // crypto in the list that is supported. |
182 static bool SelectCrypto(const MediaContentDescription* offer, | 183 static bool SelectCrypto(const MediaContentDescription* offer, |
183 bool bundle, | 184 bool bundle, |
184 CryptoParams *crypto) { | 185 CryptoParams *crypto) { |
185 bool audio = offer->type() == MEDIA_TYPE_AUDIO; | 186 bool audio = offer->type() == MEDIA_TYPE_AUDIO; |
186 const CryptoParamsVec& cryptos = offer->cryptos(); | 187 const CryptoParamsVec& cryptos = offer->cryptos(); |
187 | 188 |
188 for (CryptoParamsVec::const_iterator i = cryptos.begin(); | 189 for (CryptoParamsVec::const_iterator i = cryptos.begin(); |
189 i != cryptos.end(); ++i) { | 190 i != cryptos.end(); ++i) { |
190 if (rtc::CS_AES_CM_128_HMAC_SHA1_80 == i->cipher_suite || | 191 if (CS_AES_CM_128_HMAC_SHA1_80 == i->cipher_suite || |
191 (rtc::CS_AES_CM_128_HMAC_SHA1_32 == i->cipher_suite && audio && | 192 (CS_AES_CM_128_HMAC_SHA1_32 == i->cipher_suite && audio && !bundle)) { |
192 !bundle)) { | |
193 return CreateCryptoParams(i->tag, i->cipher_suite, crypto); | 193 return CreateCryptoParams(i->tag, i->cipher_suite, crypto); |
194 } | 194 } |
195 } | 195 } |
196 return false; | 196 return false; |
197 } | 197 } |
198 | 198 |
199 static const StreamParams* FindFirstStreamParamsByCname( | 199 static const StreamParams* FindFirstStreamParamsByCname( |
200 const StreamParamsVec& params_vec, | 200 const StreamParamsVec& params_vec, |
201 const std::string& cname) { | 201 const std::string& cname) { |
202 for (StreamParamsVec::const_iterator it = params_vec.begin(); | 202 for (StreamParamsVec::const_iterator it = params_vec.begin(); |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1902 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1903 } | 1903 } |
1904 | 1904 |
1905 const DataContentDescription* GetFirstDataContentDescription( | 1905 const DataContentDescription* GetFirstDataContentDescription( |
1906 const SessionDescription* sdesc) { | 1906 const SessionDescription* sdesc) { |
1907 return static_cast<const DataContentDescription*>( | 1907 return static_cast<const DataContentDescription*>( |
1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1909 } | 1909 } |
1910 | 1910 |
1911 } // namespace cricket | 1911 } // namespace cricket |
OLD | NEW |