Add start and stop callbacks for audio and video renderers

This commit is contained in:
Cameron Gutman
2017-05-21 13:04:50 -07:00
parent 5d90950591
commit 636c20d67b
5 changed files with 85 additions and 1 deletions

View File

@@ -2,6 +2,10 @@ package com.limelight.nvstream.av.audio;
public interface AudioRenderer {
int setup(int audioConfiguration);
void start();
void stop();
void playDecodedAudio(byte[] audioData);

View File

@@ -3,6 +3,10 @@ package com.limelight.nvstream.av.video;
public abstract class VideoDecoderRenderer {
public abstract int setup(int format, int width, int height, int redrawRate);
public abstract void start();
public abstract void stop();
public abstract int submitDecodeUnit(byte[] frameData, int frameLength);
public abstract void cleanup();

View File

@@ -42,6 +42,18 @@ public class MoonBridge {
}
}
public static void bridgeDrStart() {
if (videoRenderer != null) {
videoRenderer.start();
}
}
public static void bridgeDrStop() {
if (videoRenderer != null) {
videoRenderer.stop();
}
}
public static void bridgeDrCleanup() {
if (videoRenderer != null) {
videoRenderer.cleanup();
@@ -66,6 +78,18 @@ public class MoonBridge {
}
}
public static void bridgeArStart() {
if (audioRenderer != null) {
audioRenderer.start();
}
}
public static void bridgeArStop() {
if (audioRenderer != null) {
audioRenderer.stop();
}
}
public static void bridgeArCleanup() {
if (audioRenderer != null) {
audioRenderer.cleanup();

View File

@@ -16,9 +16,13 @@ static pthread_key_t JniEnvKey;
static pthread_once_t JniEnvKeyInitOnce = PTHREAD_ONCE_INIT;
static jclass GlobalBridgeClass;
static jmethodID BridgeDrSetupMethod;
static jmethodID BridgeDrStartMethod;
static jmethodID BridgeDrStopMethod;
static jmethodID BridgeDrCleanupMethod;
static jmethodID BridgeDrSubmitDecodeUnitMethod;
static jmethodID BridgeArInitMethod;
static jmethodID BridgeArStartMethod;
static jmethodID BridgeArStopMethod;
static jmethodID BridgeArCleanupMethod;
static jmethodID BridgeArPlaySampleMethod;
static jmethodID BridgeClStageStartingMethod;
@@ -72,9 +76,13 @@ Java_com_limelight_nvstream_jni_MoonBridge_init(JNIEnv *env, jobject class) {
(*env)->GetJavaVM(env, &JVM);
GlobalBridgeClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/limelight/nvstream/jni/MoonBridge"));
BridgeDrSetupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSetup", "(IIII)I");
BridgeDrStartMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrStart", "()V");
BridgeDrStopMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrStop", "()V");
BridgeDrCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrCleanup", "()V");
BridgeDrSubmitDecodeUnitMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSubmitDecodeUnit", "([BI)I");
BridgeArInitMethod = (*env)->GetStaticMethodID(env, class, "bridgeArInit", "(I)I");
BridgeArStartMethod = (*env)->GetStaticMethodID(env, class, "bridgeArStart", "()V");
BridgeArStopMethod = (*env)->GetStaticMethodID(env, class, "bridgeArStop", "()V");
BridgeArCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeArCleanup", "()V");
BridgeArPlaySampleMethod = (*env)->GetStaticMethodID(env, class, "bridgeArPlaySample", "([B)V");
BridgeClStageStartingMethod = (*env)->GetStaticMethodID(env, class, "bridgeClStageStarting", "(I)V");
@@ -108,6 +116,26 @@ int BridgeDrSetup(int videoFormat, int width, int height, int redrawRate, void*
return 0;
}
void BridgeDrStart(void) {
JNIEnv* env = GetThreadEnv();
if ((*env)->ExceptionCheck(env)) {
return;
}
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeDrStartMethod);
}
void BridgeDrStop(void) {
JNIEnv* env = GetThreadEnv();
if ((*env)->ExceptionCheck(env)) {
return;
}
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeDrStopMethod);
}
void BridgeDrCleanup(void) {
JNIEnv* env = GetThreadEnv();
@@ -180,6 +208,26 @@ int BridgeArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusCon
return err;
}
void BridgeArStart(void) {
JNIEnv* env = GetThreadEnv();
if ((*env)->ExceptionCheck(env)) {
return;
}
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeArStartMethod);
}
void BridgeArStop(void) {
JNIEnv* env = GetThreadEnv();
if ((*env)->ExceptionCheck(env)) {
return;
}
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeArStopMethod);
}
void BridgeArCleanup() {
JNIEnv* env = GetThreadEnv();
@@ -293,12 +341,16 @@ void BridgeClDisplayTransientMessage(const char* message) {
static DECODER_RENDERER_CALLBACKS BridgeVideoRendererCallbacks = {
.setup = BridgeDrSetup,
.start = BridgeDrStart,
.stop = BridgeDrStop,
.cleanup = BridgeDrCleanup,
.submitDecodeUnit = BridgeDrSubmitDecodeUnit,
};
static AUDIO_RENDERER_CALLBACKS BridgeAudioRendererCallbacks = {
.init = BridgeArInit,
.start = BridgeArStart,
.stop = BridgeArStop,
.cleanup = BridgeArCleanup,
.decodeAndPlaySample = BridgeArDecodeAndPlaySample,
};

Submodule moonlight-common/src/main/jni/moonlight-core/moonlight-common-c updated: 92951e1309...86447399a9