Add support for requesting an H265 stream (negotiation TBD)

This commit is contained in:
Cameron Gutman 2015-12-12 02:16:05 -08:00
parent d8c7d10ed6
commit 920154b4b6
5 changed files with 35 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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