mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-20 23:40:11 +00:00
Rework interfaces for JNI bridge
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package com.limelight.nvstream.jni;
|
||||
|
||||
import com.limelight.nvstream.NvConnectionListener;
|
||||
import com.limelight.nvstream.av.audio.AudioRenderer;
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||
|
||||
public class MoonBridge {
|
||||
public static final int AUDIO_CONFIGURATION_STEREO = 0;
|
||||
public static final int AUDIO_CONFIGURATION_51_SURROUND = 1;
|
||||
|
||||
public static final int VIDEO_FORMAT_H264 = 1;
|
||||
public static final int VIDEO_FORMAT_H265 = 2;
|
||||
|
||||
public static final int CAPABILITY_DIRECT_SUBMIT = 1;
|
||||
public static final int CAPABILITY_REFERENCE_FRAME_INVALIDATION = 2;
|
||||
|
||||
public static final int DR_OK = 0;
|
||||
public static final int DR_NEED_IDR = -1;
|
||||
|
||||
private static AudioRenderer audioRenderer;
|
||||
private static VideoDecoderRenderer videoRenderer;
|
||||
private static NvConnectionListener connectionListener;
|
||||
|
||||
public static int CAPABILITY_SLICES_PER_FRAME(byte slices) {
|
||||
return slices << 24;
|
||||
}
|
||||
|
||||
public static void bridgeDrSetup(int videoFormat, int width, int height, int redrawRate) {
|
||||
if (videoRenderer != null) {
|
||||
videoRenderer.setup(videoFormat, width, height, redrawRate);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeDrCleanup() {
|
||||
if (videoRenderer != null) {
|
||||
videoRenderer.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
public static int bridgeDrSubmitDecodeUnit(byte[] frameData) {
|
||||
if (videoRenderer != null) {
|
||||
return videoRenderer.submitDecodeUnit(frameData);
|
||||
}
|
||||
else {
|
||||
return DR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeArInit(int audioConfiguration) {
|
||||
if (audioRenderer != null) {
|
||||
audioRenderer.setup(audioConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeArCleanup() {
|
||||
if (audioRenderer != null) {
|
||||
audioRenderer.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeArPlaySample(byte[] pcmData) {
|
||||
if (audioRenderer != null) {
|
||||
audioRenderer.playDecodedAudio(pcmData);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClStageStarting(int stage) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.stageStarting(getStageName(stage));
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClStageComplete(int stage) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.stageComplete(getStageName(stage));
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClStageFailed(int stage, long errorCode) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.stageFailed(getStageName(stage), errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClConnectionStarted() {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.connectionStarted();
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClConnectionTerminated(long errorCode) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.connectionTerminated(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClDisplayMessage(String message) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.displayMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeClDisplayTransientMessage(String message) {
|
||||
if (connectionListener != null) {
|
||||
connectionListener.displayTransientMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static native String getStageName(int stage);
|
||||
}
|
||||
Reference in New Issue
Block a user