Add support for adaptive resolution changes

This commit is contained in:
Cameron Gutman 2014-09-19 22:04:48 -07:00
parent 96ad2bcdef
commit bd9c6834b7
3 changed files with 21 additions and 4 deletions

View File

@ -6,6 +6,7 @@ public class StreamConfiguration {
private int refreshRate; private int refreshRate;
private int bitrate; private int bitrate;
private boolean sops; private boolean sops;
private boolean enableAdaptiveResolution;
public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate) { public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate) {
this.app = app; this.app = app;
@ -16,13 +17,15 @@ public class StreamConfiguration {
this.sops = true; this.sops = true;
} }
public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate, boolean sops) { public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate, boolean sops,
boolean enableAdaptiveResolution) {
this.app = app; this.app = app;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.refreshRate = refreshRate; this.refreshRate = refreshRate;
this.bitrate = bitrate; this.bitrate = bitrate;
this.sops = sops; this.sops = sops;
this.enableAdaptiveResolution = enableAdaptiveResolution;
} }
public int getWidth() { public int getWidth() {
@ -52,4 +55,8 @@ public class StreamConfiguration {
public boolean getSops() { public boolean getSops() {
return sops; return sops;
} }
public boolean getAdaptiveResolutionEnabled() {
return enableAdaptiveResolution;
}
} }

View File

@ -6,6 +6,9 @@ public interface VideoDecoderRenderer {
public static final int FLAG_FORCE_SOFTWARE_DECODING = 0x4; public static final int FLAG_FORCE_SOFTWARE_DECODING = 0x4;
public static final int FLAG_FILL_SCREEN = 0x8; public static final int FLAG_FILL_SCREEN = 0x8;
// Allows the resolution to dynamically change mid-stream
public static final int CAPABILITY_ADAPTIVE_RESOLUTION = 0x1;
public int getCapabilities(); public int getCapabilities();
public int getAverageEndToEndLatency(); public int getAverageEndToEndLatency();

View File

@ -64,9 +64,16 @@ public class SdpGenerator {
addSessionAttribute(config, "x-nv-video[0].timeoutLengthMs", "7000"); addSessionAttribute(config, "x-nv-video[0].timeoutLengthMs", "7000");
addSessionAttribute(config, "x-nv-video[0].framesWithInvalidRefThreshold", "0"); addSessionAttribute(config, "x-nv-video[0].framesWithInvalidRefThreshold", "0");
// It should be 16183 but adding 100 but causes resolution to scale in the beginning
// The bit 0x80 enables video scaling on packet loss which we can't support (for now) if (sc.getAdaptiveResolutionEnabled()) {
addSessionAttribute(config, "x-nv-vqos[0].bw.flags", "16083"); addSessionAttribute(config, "x-nv-vqos[0].bw.flags", "16183");
}
else {
addSessionAttribute(config, "x-nv-vqos[0].bw.flags", "16083");
// Lock the bitrate if we're not scaling resolution so the picture doesn't get too bad
addSessionAttribute(config, "x-nv-vqos[0].bw.minimumBitrate", ""+sc.getBitrate());
}
addSessionAttribute(config, "x-nv-vqos[0].bw.maximumBitrate", ""+sc.getBitrate()); addSessionAttribute(config, "x-nv-vqos[0].bw.maximumBitrate", ""+sc.getBitrate());