mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Add support for requesting an H265 stream (negotiation TBD)
This commit is contained in:
parent
d8c7d10ed6
commit
920154b4b6
@ -5,6 +5,7 @@ import java.net.InetAddress;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer.VideoFormat;
|
||||
|
||||
public class ConnectionContext {
|
||||
// Gen 3 servers are 2.1.1 - 2.2.1
|
||||
@ -21,4 +22,6 @@ public class ConnectionContext {
|
||||
public int riKeyId;
|
||||
|
||||
public int serverGeneration;
|
||||
|
||||
public VideoFormat negotiatedVideoFormat;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class StreamConfiguration {
|
||||
private boolean remote;
|
||||
private int audioChannelMask;
|
||||
private int audioChannelCount;
|
||||
private boolean supportsHevc;
|
||||
|
||||
public static class Builder {
|
||||
private StreamConfiguration config = new StreamConfiguration();
|
||||
@ -91,6 +92,11 @@ public class StreamConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public StreamConfiguration.Builder setHevcSupported(boolean supportsHevc) {
|
||||
config.supportsHevc = supportsHevc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StreamConfiguration build() {
|
||||
return config;
|
||||
}
|
||||
@ -108,6 +114,7 @@ public class StreamConfiguration {
|
||||
this.enableAdaptiveResolution = false;
|
||||
this.audioChannelCount = CHANNEL_COUNT_STEREO;
|
||||
this.audioChannelMask = CHANNEL_MASK_STEREO;
|
||||
this.supportsHevc = false;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
@ -157,4 +164,8 @@ public class StreamConfiguration {
|
||||
public int getAudioChannelMask() {
|
||||
return audioChannelMask;
|
||||
}
|
||||
|
||||
public boolean getHevcSupported() {
|
||||
return supportsHevc;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,11 @@ package com.limelight.nvstream.av.video;
|
||||
import com.limelight.nvstream.av.DecodeUnit;
|
||||
|
||||
public abstract class VideoDecoderRenderer {
|
||||
public enum VideoFormat {
|
||||
H264,
|
||||
H265
|
||||
};
|
||||
|
||||
public static final int FLAG_PREFER_QUALITY = 0x1;
|
||||
public static final int FLAG_FORCE_HARDWARE_DECODING = 0x2;
|
||||
public static final int FLAG_FORCE_SOFTWARE_DECODING = 0x4;
|
||||
@ -34,7 +39,7 @@ public abstract class VideoDecoderRenderer {
|
||||
throw new UnsupportedOperationException("CAPABILITY_DIRECT_SUBMIT requires overriding directSubmitDecodeUnit()");
|
||||
}
|
||||
|
||||
public abstract boolean setup(int width, int height, int redrawRate, Object renderTarget, int drFlags);
|
||||
public abstract boolean setup(VideoFormat format, int width, int height, int redrawRate, Object renderTarget, int drFlags);
|
||||
|
||||
public abstract boolean start(VideoDepacketizer depacketizer);
|
||||
|
||||
|
@ -122,8 +122,9 @@ public class VideoStream {
|
||||
|
||||
if (decRend != null) {
|
||||
try {
|
||||
if (!decRend.setup(context.streamConfig.getWidth(), context.streamConfig.getHeight(),
|
||||
context.streamConfig.getRefreshRate(), renderTarget, drFlags)) {
|
||||
if (!decRend.setup(context.negotiatedVideoFormat, context.streamConfig.getWidth(),
|
||||
context.streamConfig.getHeight(), context.streamConfig.getRefreshRate(),
|
||||
renderTarget, drFlags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import com.limelight.nvstream.ConnectionContext;
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer.VideoFormat;
|
||||
|
||||
public class SdpGenerator {
|
||||
private static void addSessionAttribute(StringBuilder config, String attribute, String value) {
|
||||
@ -53,6 +54,17 @@ public class SdpGenerator {
|
||||
private static void addGen4Attributes(StringBuilder config, ConnectionContext context) {
|
||||
addSessionAttribute(config, "x-nv-general.serverAddress", "rtsp://"+context.serverAddress.getHostAddress()+":48010");
|
||||
|
||||
// If client and server are able, request HEVC
|
||||
if (context.negotiatedVideoFormat == VideoFormat.H265) {
|
||||
addSessionAttribute(config, "x-nv-clientSupportHevc", "1");
|
||||
addSessionAttribute(config, "x-nv-vqos[0].bitStreamFormat", "1");
|
||||
}
|
||||
else {
|
||||
// Otherwise, use AVC
|
||||
addSessionAttribute(config, "x-nv-clientSupportHevc", "0");
|
||||
addSessionAttribute(config, "x-nv-vqos[0].bitStreamFormat", "0");
|
||||
}
|
||||
|
||||
addSessionAttribute(config, "x-nv-video[0].rateControlMode", "4");
|
||||
|
||||
// Use slicing for increased performance on some decoders
|
||||
|
Loading…
x
Reference in New Issue
Block a user