• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2018 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "sdk/android/src/jni/pc/crypto_options.h"
12 
13 #include "sdk/android/generated_peerconnection_jni/CryptoOptions_jni.h"
14 
15 namespace webrtc {
16 namespace jni {
17 
JavaToNativeOptionalCryptoOptions(JNIEnv * jni,const JavaRef<jobject> & j_crypto_options)18 absl::optional<CryptoOptions> JavaToNativeOptionalCryptoOptions(
19     JNIEnv* jni,
20     const JavaRef<jobject>& j_crypto_options) {
21   if (j_crypto_options.is_null()) {
22     return absl::nullopt;
23   }
24 
25   ScopedJavaLocalRef<jobject> j_srtp =
26       Java_CryptoOptions_getSrtp(jni, j_crypto_options);
27   ScopedJavaLocalRef<jobject> j_sframe =
28       Java_CryptoOptions_getSFrame(jni, j_crypto_options);
29 
30   CryptoOptions native_crypto_options;
31   native_crypto_options.srtp.enable_gcm_crypto_suites =
32       Java_Srtp_getEnableGcmCryptoSuites(jni, j_srtp);
33   native_crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher =
34       Java_Srtp_getEnableAes128Sha1_32CryptoCipher(jni, j_srtp);
35   native_crypto_options.srtp.enable_encrypted_rtp_header_extensions =
36       Java_Srtp_getEnableEncryptedRtpHeaderExtensions(jni, j_srtp);
37   native_crypto_options.sframe.require_frame_encryption =
38       Java_SFrame_getRequireFrameEncryption(jni, j_sframe);
39   return absl::optional<CryptoOptions>(native_crypto_options);
40 }
41 
42 }  // namespace jni
43 }  // namespace webrtc
44