Adds the Java interface points for FrameEncryptor/FrameDecryptor.
This changes adds the API surface for injecting the FrameEncryptor and FrameDecryptor from Java. This assumes that the API User will be able to provide native implementations of both the Encryptor and Decryptor. Optional Java implementations may come later but due to the significant performance issues around copying every frame across the JNI boundary it doesn't seem like a good idea to support a non native backed implementation for now. Bug: webrtc:9681 Change-Id: Ib4471e69fdf0a99705f824de652c621637b92326 Reviewed-on: https://webrtc-review.googlesource.com/96865 Commit-Queue: Benjamin Wright <benwright@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Emad Omara <emadomara@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24610}
This commit is contained in:

committed by
Commit Bot

parent
c003a1f067
commit
ea8b6f95c7
@ -282,6 +282,8 @@ if (is_android) {
|
||||
"api/org/webrtc/DataChannel.java",
|
||||
"api/org/webrtc/DtmfSender.java",
|
||||
"api/org/webrtc/FecControllerFactoryFactoryInterface.java",
|
||||
"api/org/webrtc/FrameDecryptor.java",
|
||||
"api/org/webrtc/FrameEncryptor.java",
|
||||
"api/org/webrtc/IceCandidate.java",
|
||||
"api/org/webrtc/MediaCodecVideoDecoder.java",
|
||||
"api/org/webrtc/MediaCodecVideoEncoder.java",
|
||||
|
26
sdk/android/api/org/webrtc/FrameDecryptor.java
Normal file
26
sdk/android/api/org/webrtc/FrameDecryptor.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
/**
|
||||
* The FrameDecryptor interface allows Java API users to provide a
|
||||
* pointer to their native implementation of the FrameDecryptorInterface.
|
||||
* FrameDecryptors are extremely performance sensitive as they must process all
|
||||
* incoming video and audio frames. Due to this reason they should always be
|
||||
* backed by a native implementation
|
||||
* @note Not ready for production use.
|
||||
*/
|
||||
public interface FrameDecryptor {
|
||||
/**
|
||||
* @return A FrameDecryptorInterface pointer.
|
||||
*/
|
||||
long getNativeFrameDecryptor();
|
||||
}
|
26
sdk/android/api/org/webrtc/FrameEncryptor.java
Normal file
26
sdk/android/api/org/webrtc/FrameEncryptor.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
/**
|
||||
* The FrameEncryptor interface allows Java API users to provide a pointer to
|
||||
* their native implementation of the FrameEncryptorInterface.
|
||||
* FrameEncyptors are extremely performance sensitive as they must process all
|
||||
* outgoing video and audio frames. Due to this reason they should always be
|
||||
* backed by a native implementation.
|
||||
* @note Not ready for production use.
|
||||
*/
|
||||
public interface FrameEncryptor {
|
||||
/**
|
||||
* @return A FrameEncryptorInterface pointer.
|
||||
*/
|
||||
long getNativeFrameEncryptor();
|
||||
}
|
@ -69,6 +69,10 @@ public class RtpReceiver {
|
||||
nativeObserver = nativeSetObserver(nativeRtpReceiver, observer);
|
||||
}
|
||||
|
||||
public void setFrameDecryptor(FrameDecryptor frameDecryptor) {
|
||||
nativeSetFrameDecryptor(nativeRtpReceiver, frameDecryptor.getNativeFrameDecryptor());
|
||||
}
|
||||
|
||||
// This should increment the reference count of the track.
|
||||
// Will be released in dispose().
|
||||
private static native long nativeGetTrack(long rtpReceiver);
|
||||
@ -77,4 +81,5 @@ public class RtpReceiver {
|
||||
private static native String nativeGetId(long rtpReceiver);
|
||||
private static native long nativeSetObserver(long rtpReceiver, Observer observer);
|
||||
private static native void nativeUnsetObserver(long rtpReceiver, long nativeObserver);
|
||||
private static native void nativeSetFrameDecryptor(long rtpReceiver, long nativeFrameDecryptor);
|
||||
};
|
||||
|
@ -18,7 +18,6 @@ public class RtpSender {
|
||||
|
||||
@Nullable private MediaStreamTrack cachedTrack;
|
||||
private boolean ownsTrack = true;
|
||||
|
||||
private final @Nullable DtmfSender dtmfSender;
|
||||
|
||||
@CalledByNative
|
||||
@ -79,6 +78,10 @@ public class RtpSender {
|
||||
return dtmfSender;
|
||||
}
|
||||
|
||||
public void setFrameEncryptor(FrameEncryptor frameEncryptor) {
|
||||
nativeSetFrameEncryptor(nativeRtpSender, frameEncryptor.getNativeFrameEncryptor());
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (dtmfSender != null) {
|
||||
dtmfSender.dispose();
|
||||
@ -104,4 +107,6 @@ public class RtpSender {
|
||||
private static native RtpParameters nativeGetParameters(long rtpSender);
|
||||
|
||||
private static native String nativeGetId(long rtpSender);
|
||||
|
||||
private static native void nativeSetFrameEncryptor(long rtpSender, long nativeFrameEncryptor);
|
||||
};
|
||||
|
@ -129,5 +129,14 @@ static void JNI_RtpReceiver_UnsetObserver(JNIEnv* jni,
|
||||
}
|
||||
}
|
||||
|
||||
static void JNI_RtpReceiver_SetFrameDecryptor(JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
jlong j_rtp_sender_pointer,
|
||||
jlong j_frame_decryptor_pointer) {
|
||||
reinterpret_cast<RtpReceiverInterface*>(j_rtp_sender_pointer)
|
||||
->SetFrameDecryptor(reinterpret_cast<FrameDecryptorInterface*>(
|
||||
j_frame_decryptor_pointer));
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
@ -87,5 +87,14 @@ ScopedJavaLocalRef<jstring> JNI_RtpSender_GetId(JNIEnv* jni,
|
||||
jni, reinterpret_cast<RtpSenderInterface*>(j_rtp_sender_pointer)->id());
|
||||
}
|
||||
|
||||
static void JNI_RtpSender_SetFrameEncryptor(JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
jlong j_rtp_sender_pointer,
|
||||
jlong j_frame_encryptor_pointer) {
|
||||
reinterpret_cast<RtpSenderInterface*>(j_rtp_sender_pointer)
|
||||
->SetFrameEncryptor(reinterpret_cast<FrameEncryptorInterface*>(
|
||||
j_frame_encryptor_pointer));
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user