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(CS_AES_CM_128_HMAC_SHA1_32); | 158 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_32); |
159 crypto_suites->push_back(CS_AES_CM_128_HMAC_SHA1_80); | 159 crypto_suites->push_back(rtc::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 GetSupportedDefaultCryptoSuites(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 GetSupportedDefaultCryptoSuites(crypto_suites); | 170 GetSupportedDefaultCryptoSuites(crypto_suites); |
171 } | 171 } |
172 | 172 |
173 void GetSupportedDefaultCryptoSuites( | 173 void GetSupportedDefaultCryptoSuites( |
174 std::vector<std::string>* crypto_suites) { | 174 std::vector<std::string>* crypto_suites) { |
175 #ifdef HAVE_SRTP | 175 #ifdef HAVE_SRTP |
176 crypto_suites->push_back(CS_AES_CM_128_HMAC_SHA1_80); | 176 crypto_suites->push_back(rtc::CS_AES_CM_128_HMAC_SHA1_80); |
177 #endif | 177 #endif |
178 } | 178 } |
179 | 179 |
180 // 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 |
181 // 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 |
182 // crypto in the list that is supported. | 182 // crypto in the list that is supported. |
183 static bool SelectCrypto(const MediaContentDescription* offer, | 183 static bool SelectCrypto(const MediaContentDescription* offer, |
184 bool bundle, | 184 bool bundle, |
185 CryptoParams *crypto) { | 185 CryptoParams *crypto) { |
186 bool audio = offer->type() == MEDIA_TYPE_AUDIO; | 186 bool audio = offer->type() == MEDIA_TYPE_AUDIO; |
187 const CryptoParamsVec& cryptos = offer->cryptos(); | 187 const CryptoParamsVec& cryptos = offer->cryptos(); |
188 | 188 |
189 for (CryptoParamsVec::const_iterator i = cryptos.begin(); | 189 for (CryptoParamsVec::const_iterator i = cryptos.begin(); |
190 i != cryptos.end(); ++i) { | 190 i != cryptos.end(); ++i) { |
191 if (CS_AES_CM_128_HMAC_SHA1_80 == i->cipher_suite || | 191 if (rtc::CS_AES_CM_128_HMAC_SHA1_80 == i->cipher_suite || |
192 (CS_AES_CM_128_HMAC_SHA1_32 == i->cipher_suite && audio && !bundle)) { | 192 (rtc::CS_AES_CM_128_HMAC_SHA1_32 == i->cipher_suite && audio && |
| 193 !bundle)) { |
193 return CreateCryptoParams(i->tag, i->cipher_suite, crypto); | 194 return CreateCryptoParams(i->tag, i->cipher_suite, crypto); |
194 } | 195 } |
195 } | 196 } |
196 return false; | 197 return false; |
197 } | 198 } |
198 | 199 |
199 static const StreamParams* FindFirstStreamParamsByCname( | 200 static const StreamParams* FindFirstStreamParamsByCname( |
200 const StreamParamsVec& params_vec, | 201 const StreamParamsVec& params_vec, |
201 const std::string& cname) { | 202 const std::string& cname) { |
202 for (StreamParamsVec::const_iterator it = params_vec.begin(); | 203 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)); | 1903 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1903 } | 1904 } |
1904 | 1905 |
1905 const DataContentDescription* GetFirstDataContentDescription( | 1906 const DataContentDescription* GetFirstDataContentDescription( |
1906 const SessionDescription* sdesc) { | 1907 const SessionDescription* sdesc) { |
1907 return static_cast<const DataContentDescription*>( | 1908 return static_cast<const DataContentDescription*>( |
1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1909 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1909 } | 1910 } |
1910 | 1911 |
1911 } // namespace cricket | 1912 } // namespace cricket |
OLD | NEW |