Allow video decoder capabilities to be set at runtime

This commit is contained in:
Cameron Gutman 2017-05-15 22:28:24 -07:00
parent 203fcd82e7
commit ae852eb911
5 changed files with 13 additions and 4 deletions

View File

@ -19,4 +19,6 @@ public class ConnectionContext {
public int negotiatedWidth, negotiatedHeight; public int negotiatedWidth, negotiatedHeight;
public int negotiatedFps; public int negotiatedFps;
public int videoCapabilities;
} }

View File

@ -230,13 +230,15 @@ public class NvConnection {
context.negotiatedWidth, context.negotiatedHeight, context.negotiatedWidth, context.negotiatedHeight,
context.negotiatedFps, context.streamConfig.getBitrate(), context.negotiatedFps, context.streamConfig.getBitrate(),
context.streamConfig.getRemote(), context.streamConfig.getAudioConfiguration(), context.streamConfig.getRemote(), context.streamConfig.getAudioConfiguration(),
context.streamConfig.getHevcSupported(), context.riKey.getEncoded(), ib.array()); context.streamConfig.getHevcSupported(), context.riKey.getEncoded(), ib.array(),
context.videoCapabilities);
} }
public void start(AudioRenderer audioRenderer, VideoDecoderRenderer videoDecoderRenderer, NvConnectionListener connectionListener) public void start(AudioRenderer audioRenderer, VideoDecoderRenderer videoDecoderRenderer, NvConnectionListener connectionListener)
{ {
MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener); MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener);
context.connListener = connectionListener; context.connListener = connectionListener;
context.videoCapabilities = videoDecoderRenderer.getCapabilities();
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {

View File

@ -6,4 +6,6 @@ public abstract class VideoDecoderRenderer {
public abstract int submitDecodeUnit(byte[] frameData); public abstract int submitDecodeUnit(byte[] frameData);
public abstract void cleanup(); public abstract void cleanup();
public abstract int getCapabilities();
} }

View File

@ -127,7 +127,8 @@ public class MoonBridge {
int width, int height, int fps, int width, int height, int fps,
int bitrate, boolean streamingRemotely, int bitrate, boolean streamingRemotely,
int audioConfiguration, boolean supportsHevc, int audioConfiguration, boolean supportsHevc,
byte[] riAesKey, byte[] riAesIv); byte[] riAesKey, byte[] riAesIv,
int videoCapabilities);
public static native void stopConnection(); public static native void stopConnection();

View File

@ -269,7 +269,6 @@ static DECODER_RENDERER_CALLBACKS BridgeVideoRendererCallbacks = {
.setup = BridgeDrSetup, .setup = BridgeDrSetup,
.cleanup = BridgeDrCleanup, .cleanup = BridgeDrCleanup,
.submitDecodeUnit = BridgeDrSubmitDecodeUnit, .submitDecodeUnit = BridgeDrSubmitDecodeUnit,
.capabilities = CAPABILITY_SLICES_PER_FRAME(4), // HACK: This was common-java's default
}; };
static AUDIO_RENDERER_CALLBACKS BridgeAudioRendererCallbacks = { static AUDIO_RENDERER_CALLBACKS BridgeAudioRendererCallbacks = {
@ -294,7 +293,8 @@ Java_com_limelight_nvstream_jni_MoonBridge_startConnection(JNIEnv *env, jobject
jint width, jint height, jint fps, jint width, jint height, jint fps,
jint bitrate, jboolean streamingRemotely, jint bitrate, jboolean streamingRemotely,
jint audioConfiguration, jboolean supportsHevc, jint audioConfiguration, jboolean supportsHevc,
jbyteArray riAesKey, jbyteArray riAesIv) { jbyteArray riAesKey, jbyteArray riAesIv,
jint videoCapabilities) {
SERVER_INFORMATION serverInfo = { SERVER_INFORMATION serverInfo = {
.address = (*env)->GetStringUTFChars(env, address, 0), .address = (*env)->GetStringUTFChars(env, address, 0),
.serverInfoAppVersion = (*env)->GetStringUTFChars(env, appVersion, 0), .serverInfoAppVersion = (*env)->GetStringUTFChars(env, appVersion, 0),
@ -318,6 +318,8 @@ Java_com_limelight_nvstream_jni_MoonBridge_startConnection(JNIEnv *env, jobject
memcpy(streamConfig.remoteInputAesIv, riAesIvBuf, sizeof(streamConfig.remoteInputAesIv)); memcpy(streamConfig.remoteInputAesIv, riAesIvBuf, sizeof(streamConfig.remoteInputAesIv));
(*env)->ReleaseByteArrayElements(env, riAesIv, riAesIvBuf, JNI_ABORT); (*env)->ReleaseByteArrayElements(env, riAesIv, riAesIvBuf, JNI_ABORT);
BridgeVideoRendererCallbacks.capabilities = videoCapabilities;
int ret = LiStartConnection(&serverInfo, &streamConfig, &BridgeConnListenerCallbacks, &BridgeVideoRendererCallbacks, &BridgeAudioRendererCallbacks, NULL, 0); int ret = LiStartConnection(&serverInfo, &streamConfig, &BridgeConnListenerCallbacks, &BridgeVideoRendererCallbacks, &BridgeAudioRendererCallbacks, NULL, 0);
(*env)->ReleaseStringUTFChars(env, address, serverInfo.address); (*env)->ReleaseStringUTFChars(env, address, serverInfo.address);