From 0ec6dcd67e221fc4a9b33f58c00231914059ae38 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 24 Feb 2018 21:05:45 -0800 Subject: [PATCH] Add 360p option and change bitrate to kbps --- app/src/main/java/com/limelight/Game.java | 2 +- .../video/MediaCodecDecoderRenderer.java | 11 +++-- .../preferences/PreferenceConfiguration.java | 44 ++++++++++++++----- .../preferences/SeekBarPreference.java | 25 +++++++---- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values-nl/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-zh-rCN/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/arrays.xml | 4 ++ app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/preferences.xml | 9 ++-- 16 files changed, 80 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 94dca216..6221f9e1 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -350,7 +350,7 @@ public class Game extends Activity implements SurfaceHolder.Callback, .setResolution(prefConfig.width, prefConfig.height) .setRefreshRate(prefConfig.fps) .setApp(new NvApp(appName, appId, willStreamHdr)) - .setBitrate(prefConfig.bitrate * 1000) + .setBitrate(prefConfig.bitrate) .setEnableSops(prefConfig.enableSops) .enableLocalAudioPlayback(prefConfig.playHostAudio) .setMaxPacketSize((remote || prefConfig.width <= 1920) ? 1024 : 1292) diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index 972233ee..b16f779f 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -713,12 +713,17 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer { // for known resolution combinations. Reference frame invalidation may need // these, so leave them be for those decoders. if (!refFrameInvalidationActive) { - if (initialWidth == 1280 && initialHeight == 720) { + if (initialWidth <= 720 && initialHeight <= 480) { + // Max 5 buffered frames at 720x480x60 + LimeLog.info("Patching level_idc to 31"); + sps.levelIdc = 31; + } + if (initialWidth <= 1280 && initialHeight <= 720) { // Max 5 buffered frames at 1280x720x60 LimeLog.info("Patching level_idc to 32"); sps.levelIdc = 32; } - else if (initialWidth == 1920 && initialHeight == 1080) { + else if (initialWidth <= 1920 && initialHeight <= 1080) { // Max 4 buffered frames at 1920x1080x64 LimeLog.info("Patching level_idc to 42"); sps.levelIdc = 42; @@ -1053,7 +1058,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer { str += "RFI active: "+renderer.refFrameInvalidationActive+"\n"; str += "Video dimensions: "+renderer.initialWidth+"x"+renderer.initialHeight+"\n"; str += "FPS target: "+renderer.refreshRate+"\n"; - str += "Bitrate: "+renderer.prefs.bitrate+" Mbps \n"; + str += "Bitrate: "+renderer.prefs.bitrate+" Kbps \n"; str += "In stats: "+renderer.numVpsIn+", "+renderer.numSpsIn+", "+renderer.numPpsIn+"\n"; str += "Total frames received: "+renderer.totalFramesReceived+"\n"; str += "Total frames rendered: "+renderer.totalFramesRendered+"\n"; diff --git a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java index f3750c7a..ba751023 100644 --- a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java +++ b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java @@ -8,7 +8,8 @@ import android.preference.PreferenceManager; public class PreferenceConfiguration { static final String RES_FPS_PREF_STRING = "list_resolution_fps"; - static final String BITRATE_PREF_STRING = "seekbar_bitrate"; + static final String BITRATE_PREF_STRING = "seekbar_bitrate_kbps"; + private static final String BITRATE_PREF_OLD_STRING = "seekbar_bitrate"; private static final String STRETCH_PREF_STRING = "checkbox_stretch_video"; private static final String SOPS_PREF_STRING = "checkbox_enable_sops"; private static final String DISABLE_TOASTS_PREF_STRING = "checkbox_disable_warnings"; @@ -30,12 +31,14 @@ public class PreferenceConfiguration { private static final String BIND_ALL_USB_STRING = "checkbox_usb_bind_all"; private static final String MOUSE_EMULATION_STRING = "checkbox_mouse_emulation"; - private static final int BITRATE_DEFAULT_720_30 = 5; - private static final int BITRATE_DEFAULT_720_60 = 10; - private static final int BITRATE_DEFAULT_1080_30 = 10; - private static final int BITRATE_DEFAULT_1080_60 = 20; - private static final int BITRATE_DEFAULT_4K_30 = 40; - private static final int BITRATE_DEFAULT_4K_60 = 80; + private static final int BITRATE_DEFAULT_360_30 = 1000; + private static final int BITRATE_DEFAULT_360_60 = 2000; + private static final int BITRATE_DEFAULT_720_30 = 5000; + private static final int BITRATE_DEFAULT_720_60 = 10000; + private static final int BITRATE_DEFAULT_1080_30 = 10000; + private static final int BITRATE_DEFAULT_1080_60 = 20000; + private static final int BITRATE_DEFAULT_4K_30 = 40000; + private static final int BITRATE_DEFAULT_4K_60 = 80000; private static final String DEFAULT_RES_FPS = "720p60"; private static final int DEFAULT_BITRATE = BITRATE_DEFAULT_720_60; @@ -80,7 +83,13 @@ public class PreferenceConfiguration { public boolean mouseEmulation; public static int getDefaultBitrate(String resFpsString) { - if (resFpsString.equals("720p30")) { + if (resFpsString.equals("360p30")) { + return BITRATE_DEFAULT_360_30; + } + else if (resFpsString.equals("360p60")) { + return BITRATE_DEFAULT_360_60; + } + else if (resFpsString.equals("720p30")) { return BITRATE_DEFAULT_720_30; } else if (resFpsString.equals("720p60")) { @@ -153,6 +162,7 @@ public class PreferenceConfiguration { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit() .remove(BITRATE_PREF_STRING) + .remove(BITRATE_PREF_OLD_STRING) .remove(RES_FPS_PREF_STRING) .remove(VIDEO_FORMAT_PREF_STRING) .remove(ENABLE_HDR_PREF_STRING) @@ -163,9 +173,23 @@ public class PreferenceConfiguration { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); PreferenceConfiguration config = new PreferenceConfiguration(); - config.bitrate = prefs.getInt(BITRATE_PREF_STRING, getDefaultBitrate(context)); + config.bitrate = prefs.getInt(BITRATE_PREF_STRING, prefs.getInt(BITRATE_PREF_OLD_STRING, 0) * 1000); + if (config.bitrate == 0) { + config.bitrate = getDefaultBitrate(context); + } + String str = prefs.getString(RES_FPS_PREF_STRING, DEFAULT_RES_FPS); - if (str.equals("720p30")) { + if (str.equals("360p30")) { + config.width = 640; + config.height = 360; + config.fps = 30; + } + else if (str.equals("360p60")) { + config.width = 640; + config.height = 360; + config.fps = 60; + } + else if (str.equals("720p30")) { config.width = 1280; config.height = 720; config.fps = 30; diff --git a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java index 617e8afb..8c3a59a9 100644 --- a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java +++ b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java @@ -16,7 +16,8 @@ import android.widget.TextView; // Based on a Stack Overflow example: http://stackoverflow.com/questions/1974193/slider-on-my-preferencescreen public class SeekBarPreference extends DialogPreference { - private static final String SCHEMA_URL = "http://schemas.android.com/apk/res/android"; + private static final String ANDROID_SCHEMA_URL = "http://schemas.android.com/apk/res/android"; + private static final String SEEKBAR_SCHEMA_URL = "http://schemas.moonlight-stream.com/apk/res/seekbar"; private SeekBar seekBar; private TextView valueText; @@ -27,6 +28,7 @@ public class SeekBarPreference extends DialogPreference private final int defaultValue; private final int maxValue; private final int minValue; + private final int stepSize; private int currentValue; public SeekBarPreference(Context context, AttributeSet attrs) { @@ -34,27 +36,28 @@ public class SeekBarPreference extends DialogPreference this.context = context; // Read the message from XML - int dialogMessageId = attrs.getAttributeResourceValue(SCHEMA_URL, "dialogMessage", 0); + int dialogMessageId = attrs.getAttributeResourceValue(ANDROID_SCHEMA_URL, "dialogMessage", 0); if (dialogMessageId == 0) { - dialogMessage = attrs.getAttributeValue(SCHEMA_URL, "dialogMessage"); + dialogMessage = attrs.getAttributeValue(ANDROID_SCHEMA_URL, "dialogMessage"); } else { dialogMessage = context.getString(dialogMessageId); } // Get the suffix for the number displayed in the dialog - int suffixId = attrs.getAttributeResourceValue(SCHEMA_URL, "text", 0); + int suffixId = attrs.getAttributeResourceValue(ANDROID_SCHEMA_URL, "text", 0); if (suffixId == 0) { - suffix = attrs.getAttributeValue(SCHEMA_URL, "text"); + suffix = attrs.getAttributeValue(ANDROID_SCHEMA_URL, "text"); } else { suffix = context.getString(suffixId); } // Get default, min, and max seekbar values - defaultValue = attrs.getAttributeIntValue(SCHEMA_URL, "defaultValue", PreferenceConfiguration.getDefaultBitrate(context)); - maxValue = attrs.getAttributeIntValue(SCHEMA_URL, "max", 100); - minValue = 1; + defaultValue = attrs.getAttributeIntValue(ANDROID_SCHEMA_URL, "defaultValue", PreferenceConfiguration.getDefaultBitrate(context)); + maxValue = attrs.getAttributeIntValue(ANDROID_SCHEMA_URL, "max", 100); + minValue = attrs.getAttributeIntValue(SEEKBAR_SCHEMA_URL, "min", 1); + stepSize = attrs.getAttributeIntValue(SEEKBAR_SCHEMA_URL, "step", 1); } @Override @@ -89,6 +92,12 @@ public class SeekBarPreference extends DialogPreference return; } + int roundedValue = ((value + (stepSize - 1))/stepSize)*stepSize; + if (roundedValue != value) { + seekBar.setProgress(roundedValue); + return; + } + String t = String.valueOf(value); valueText.setText(suffix == null ? t : t.concat(suffix.length() > 1 ? " "+suffix : suffix)); } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 331cf491..c489ec26 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -89,7 +89,7 @@ Establecer unos valores demasiado altos puede causar lag o cierres inesperados Seleccionar bitrate de vídeo Usa bitrate bajo para reducir "parpadeo". Incrementa el bitrate para mayor calidad de imagen. - Mbps + Kbps Ajustar vídeo a pantalla completa Desactivar mensajes de advertencia Desactivar mensajes de advertencia en pantalla durante la transmisión diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 822e1df6..3387bd0d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -100,7 +100,7 @@ Le réglage de valeurs trop élevées pour votre appareil peut provoquer un retard ou un plantage Sélectionnez le bitrate vidéo à obtenir Bitrate inférieur pour réduire la saccade. Augmentez le bitrate pour augmenter la qualité de l\'image. - Mbps + Kbps Étirez la vidéo en plein écran Désactiver les messages d\'avertissement Désactiver les messages d\'avertissement de connexion à l\'écran pendant le streaming diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7ccb55f7..55dfebc9 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -89,7 +89,7 @@ Valori troppo elevati possono causare lag o crash Bitrate video Abbassa il bitrate per ridurre lo stuttering; alza il bitrate per aumenteare la qualità dell\'immagine - Mbps + Kbps Forza video in full-screen Disabilita messaggi di warning Disabilita i messaggi di warning sullo schermo durante lo streaming diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index f60faabf..57d67cc2 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -85,7 +85,7 @@ 品質が高いほどラグとクラッシュが発生しやすくなります 映像のビットレート ビットレートを低くすればカクつきが抑制され、高くすれば画質が向上します - Mbps + Kbps 映像を全画面に拡大 警告を無効化 ストリーミング中に画面に警告メッセージを表示しない diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 64fe1dbf..58083823 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -100,7 +100,7 @@ 세팅 값이 자신의 PC 성능보다 너무 높으면 렉이나 깨짐을 유발할 수 있습니다. 비트레이트 타겟 지정 낮은 비트레이트는 끊김을 줄이고, 높은 비트레이트는 품질을 높입니다. - Mbps + Kbps 전체 화면으로 렌더링 스크린 늘이기 경고 메세지 끄기 화면 상의 연결 경고 메세지를 스트리밍 중에 비활성화합니다. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 2df6ae2f..7a8fee1c 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -89,7 +89,7 @@ Te hoge instellingen kunnen crashes en haperingen veroorzaken. Selecteer doel video bitsnelheid Verlaag bitsnelheid om haperingen te verminderen. Verhoog de bitsnelheid voor een betere videokwaliteit. - Mbps + Kbps Rek video uit tot volledig scherm Verberg waarschuwingsberichten Verberg on-screen verbindingswaarschuwingen tijdens het streamen diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3f72c4ec..75bf6ab2 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -89,7 +89,7 @@ Выбор слишком высокого значеня для своего устройства может вызвать тормоза или вылеты. Выберите битрейт видео. Низкий битрейт уменьшит зависания. Увеличение битрейта улучшит качество изображения. - Mbps + Kbps Растягивать видео на весь экран Отключить сообщения с предупреждениями Выключить экранные предупреждения о соединении во время стрима. diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 8502f06f..0bf8e96c 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -100,7 +100,7 @@ 过高的设定会引起串流卡顿甚至软件闪退 选择目标视频码率 低码率减少卡顿,高码率提高画质 - Mbps + Kbps 将画面拉伸至全屏 禁用错误提示 串流过程中禁用连接错误提示 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f5fc8c04..a8d0533e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -100,7 +100,7 @@ 過高的設定會引起串流卡頓甚至軟體閃退 選擇目標視頻碼率 低碼率減少卡頓,高碼率提高畫質 - Mbps + Kbps 將畫面拉伸至全屏 禁用錯誤提示 串流過程中禁用連接錯誤提示 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index a897b405..9a30df7d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,6 +1,8 @@ + 360p 30 FPS + 360p 60 FPS 720p 30 FPS 720p 60 FPS 1080p 30 FPS @@ -9,6 +11,8 @@ 4K 60 FPS + 360p30 + 360p60 720p30 720p60 1080p30 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f87bcf9..0d856397 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -106,7 +106,7 @@ Setting values too high for your device may cause lag or crashing Select target video bitrate Lower bitrate to reduce stuttering. Raise bitrate to increase image quality. - Mbps + Kbps Stretch video to full-screen Disable warning messages Disable on-screen connection warning messages while streaming diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index ce9d4f08..e6b3c71b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,5 +1,6 @@ - + @@ -11,9 +12,11 @@ android:entryValues="@array/resolution_values" android:defaultValue="720p60" />