mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 03:52:48 +00:00
Add start and stop callbacks for audio and video renderers
This commit is contained in:
parent
5d90950591
commit
636c20d67b
@ -3,6 +3,10 @@ package com.limelight.nvstream.av.audio;
|
|||||||
public interface AudioRenderer {
|
public interface AudioRenderer {
|
||||||
int setup(int audioConfiguration);
|
int setup(int audioConfiguration);
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
|
void stop();
|
||||||
|
|
||||||
void playDecodedAudio(byte[] audioData);
|
void playDecodedAudio(byte[] audioData);
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
@ -3,6 +3,10 @@ package com.limelight.nvstream.av.video;
|
|||||||
public abstract class VideoDecoderRenderer {
|
public abstract class VideoDecoderRenderer {
|
||||||
public abstract int setup(int format, int width, int height, int redrawRate);
|
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 int submitDecodeUnit(byte[] frameData, int frameLength);
|
||||||
|
|
||||||
public abstract void cleanup();
|
public abstract void cleanup();
|
||||||
|
@ -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() {
|
public static void bridgeDrCleanup() {
|
||||||
if (videoRenderer != null) {
|
if (videoRenderer != null) {
|
||||||
videoRenderer.cleanup();
|
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() {
|
public static void bridgeArCleanup() {
|
||||||
if (audioRenderer != null) {
|
if (audioRenderer != null) {
|
||||||
audioRenderer.cleanup();
|
audioRenderer.cleanup();
|
||||||
|
@ -16,9 +16,13 @@ static pthread_key_t JniEnvKey;
|
|||||||
static pthread_once_t JniEnvKeyInitOnce = PTHREAD_ONCE_INIT;
|
static pthread_once_t JniEnvKeyInitOnce = PTHREAD_ONCE_INIT;
|
||||||
static jclass GlobalBridgeClass;
|
static jclass GlobalBridgeClass;
|
||||||
static jmethodID BridgeDrSetupMethod;
|
static jmethodID BridgeDrSetupMethod;
|
||||||
|
static jmethodID BridgeDrStartMethod;
|
||||||
|
static jmethodID BridgeDrStopMethod;
|
||||||
static jmethodID BridgeDrCleanupMethod;
|
static jmethodID BridgeDrCleanupMethod;
|
||||||
static jmethodID BridgeDrSubmitDecodeUnitMethod;
|
static jmethodID BridgeDrSubmitDecodeUnitMethod;
|
||||||
static jmethodID BridgeArInitMethod;
|
static jmethodID BridgeArInitMethod;
|
||||||
|
static jmethodID BridgeArStartMethod;
|
||||||
|
static jmethodID BridgeArStopMethod;
|
||||||
static jmethodID BridgeArCleanupMethod;
|
static jmethodID BridgeArCleanupMethod;
|
||||||
static jmethodID BridgeArPlaySampleMethod;
|
static jmethodID BridgeArPlaySampleMethod;
|
||||||
static jmethodID BridgeClStageStartingMethod;
|
static jmethodID BridgeClStageStartingMethod;
|
||||||
@ -72,9 +76,13 @@ Java_com_limelight_nvstream_jni_MoonBridge_init(JNIEnv *env, jobject class) {
|
|||||||
(*env)->GetJavaVM(env, &JVM);
|
(*env)->GetJavaVM(env, &JVM);
|
||||||
GlobalBridgeClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/limelight/nvstream/jni/MoonBridge"));
|
GlobalBridgeClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/limelight/nvstream/jni/MoonBridge"));
|
||||||
BridgeDrSetupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSetup", "(IIII)I");
|
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");
|
BridgeDrCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrCleanup", "()V");
|
||||||
BridgeDrSubmitDecodeUnitMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSubmitDecodeUnit", "([BI)I");
|
BridgeDrSubmitDecodeUnitMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSubmitDecodeUnit", "([BI)I");
|
||||||
BridgeArInitMethod = (*env)->GetStaticMethodID(env, class, "bridgeArInit", "(I)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");
|
BridgeArCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeArCleanup", "()V");
|
||||||
BridgeArPlaySampleMethod = (*env)->GetStaticMethodID(env, class, "bridgeArPlaySample", "([B)V");
|
BridgeArPlaySampleMethod = (*env)->GetStaticMethodID(env, class, "bridgeArPlaySample", "([B)V");
|
||||||
BridgeClStageStartingMethod = (*env)->GetStaticMethodID(env, class, "bridgeClStageStarting", "(I)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;
|
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) {
|
void BridgeDrCleanup(void) {
|
||||||
JNIEnv* env = GetThreadEnv();
|
JNIEnv* env = GetThreadEnv();
|
||||||
|
|
||||||
@ -180,6 +208,26 @@ int BridgeArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusCon
|
|||||||
return err;
|
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() {
|
void BridgeArCleanup() {
|
||||||
JNIEnv* env = GetThreadEnv();
|
JNIEnv* env = GetThreadEnv();
|
||||||
|
|
||||||
@ -293,12 +341,16 @@ void BridgeClDisplayTransientMessage(const char* message) {
|
|||||||
|
|
||||||
static DECODER_RENDERER_CALLBACKS BridgeVideoRendererCallbacks = {
|
static DECODER_RENDERER_CALLBACKS BridgeVideoRendererCallbacks = {
|
||||||
.setup = BridgeDrSetup,
|
.setup = BridgeDrSetup,
|
||||||
|
.start = BridgeDrStart,
|
||||||
|
.stop = BridgeDrStop,
|
||||||
.cleanup = BridgeDrCleanup,
|
.cleanup = BridgeDrCleanup,
|
||||||
.submitDecodeUnit = BridgeDrSubmitDecodeUnit,
|
.submitDecodeUnit = BridgeDrSubmitDecodeUnit,
|
||||||
};
|
};
|
||||||
|
|
||||||
static AUDIO_RENDERER_CALLBACKS BridgeAudioRendererCallbacks = {
|
static AUDIO_RENDERER_CALLBACKS BridgeAudioRendererCallbacks = {
|
||||||
.init = BridgeArInit,
|
.init = BridgeArInit,
|
||||||
|
.start = BridgeArStart,
|
||||||
|
.stop = BridgeArStop,
|
||||||
.cleanup = BridgeArCleanup,
|
.cleanup = BridgeArCleanup,
|
||||||
.decodeAndPlaySample = BridgeArDecodeAndPlaySample,
|
.decodeAndPlaySample = BridgeArDecodeAndPlaySample,
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 92951e1309a4c1f49f1a965eefff367912a07558
|
Subproject commit 86447399a97472797a3c7333c36b1f9156c7c101
|
Loading…
x
Reference in New Issue
Block a user