[Android] Implement Chromecast rendering options
Geoffrey Métais
git at videolan.org
Thu Jan 25 10:32:33 CET 2018
vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 22 15:48:22 2018 +0100| [c4709475dddf69bdde18b8909797a29ed12f1044] | committer: Geoffrey Métais
Implement Chromecast rendering options
> https://code.videolan.org/videolan/vlc-android/commit/c4709475dddf69bdde18b8909797a29ed12f1044
---
vlc-android/res/values/arrays.xml | 13 +++++++++
vlc-android/res/values/strings.xml | 9 ++++++
vlc-android/res/xml/preferences.xml | 3 ++
vlc-android/res/xml/preferences_casting.xml | 20 ++++++++++++++
.../vlc/gui/preferences/PreferencesCasting.kt | 32 ++++++++++++++++++++++
.../vlc/gui/preferences/PreferencesFragment.java | 3 ++
.../gui/tv/preferences/PreferencesFragment.java | 1 +
.../src/org/videolan/vlc/util/VLCOptions.java | 9 ++++--
8 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/values/arrays.xml b/vlc-android/res/values/arrays.xml
index eb24c3fd4..9c2356b8b 100644
--- a/vlc-android/res/values/arrays.xml
+++ b/vlc-android/res/values/arrays.xml
@@ -371,6 +371,19 @@
<item>1</item>
</string-array>
+ <string-array name="casting_quality">
+ <item>@string/casting_quality_high</item>
+ <item>@string/casting_quality_medium</item>
+ <item>@string/casting_quality_low</item>
+ <item>@string/casting_quality_lowcpu</item>
+ </string-array>
+ <string-array name="casting_quality_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
<string-array name="opengl_list">
<item>@string/opengl_automatic</item>
<item>@string/opengl_on</item>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index d9f9568a3..614de0325 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -369,6 +369,15 @@
<string name="aout_opensles" translatable="false">OpenSL ES</string>
<string name="audio_ducking_title">Lower VLC volume on notifications</string>
<string name="audio_ducking_summary">Helps to hear audio notifications, navigation instructions or assistant talking</string>
+ <string name="casting_category">Casting</string>
+ <string name="casting_passthrough_title">Audio Passthrough</string>
+ <string name="casting_passthrough_summary">Let your TV manage audio rendering</string>
+ <string name="casting_conversion_quality_title">Conversion quality</string>
+ <string name="casting_conversion_quality_summary">Select the conversion quality when casting on remote screen</string>
+ <string name="casting_quality_high">High</string>
+ <string name="casting_quality_medium">Medium</string>
+ <string name="casting_quality_low">Low</string>
+ <string name="casting_quality_lowcpu">Lowest</string>
<string name="extensions_prefs_category">Extensions</string>
<string name="extensions_enable_category">Chose extensions to enable</string>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 7133616e7..339abc21c 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -59,6 +59,9 @@
<Preference
android:title="@string/audio_prefs_category"
android:key="audio_category" />
+ <Preference
+ android:title="@string/casting_category"
+ android:key="casting_category" />
<Preference
android:title="@string/extensions_prefs_category"
android:key="extensions_category" />
diff --git a/vlc-android/res/xml/preferences_casting.xml b/vlc-android/res/xml/preferences_casting.xml
new file mode 100644
index 000000000..99a9383aa
--- /dev/null
+++ b/vlc-android/res/xml/preferences_casting.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="audio_category"
+ android:title="@string/casting_category">
+ <PreferenceCategory android:title="@string/casting_category">
+ <CheckBoxPreference
+ android:key="casting_passthrough"
+ android:defaultValue="true"
+ android:summary="@string/casting_passthrough_summary"
+ android:title="@string/casting_passthrough_title" />
+ <ListPreference
+ android:defaultValue="2"
+ android:entries="@array/casting_quality"
+ android:entryValues="@array/casting_quality_values"
+ android:key="casting_quality"
+ android:summary="@string/casting_conversion_quality_summary"
+ android:title="@string/casting_conversion_quality_title" />
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt
new file mode 100644
index 000000000..2137dbced
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt
@@ -0,0 +1,32 @@
+/*
+ * *************************************************************************
+ * PreferencesCasting.kt
+ * **************************************************************************
+ * Copyright © 2018 VLC authors and VideoLAN
+ * Author: Geoffrey Métais
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * ***************************************************************************
+ */
+package org.videolan.vlc.gui.preferences
+
+import org.videolan.vlc.R
+
+class PreferencesCasting : BasePreferenceFragment() {
+
+ override fun getTitleId() = R.string.casting_category
+
+ override fun getXml() = R.xml.preferences_casting
+}
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
index b8c8da98b..665c8e96b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
@@ -98,6 +98,9 @@ public class PreferencesFragment extends BasePreferenceFragment {
case "adv_category":
loadFragment(new PreferencesAdvanced());
break;
+ case "casting_category":
+ loadFragment(new PreferencesCasting());
+ break;
case PLAYBACK_HISTORY:
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
return true;
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesFragment.java
index 491de981d..37c3190e0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesFragment.java
@@ -64,6 +64,7 @@ public class PreferencesFragment extends BasePreferenceFragment {
super.onCreate(savedInstanceState);
findPreference("screen_orientation").setVisible(false);
findPreference("extensions_category").setVisible(false);
+ findPreference("casting_category").setVisible(false);
findPreference(KEY_VIDEO_APP_SWITCH).setVisible(AndroidDevices.hasPiP);
}
diff --git a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
index c6b63762d..572bdb265 100644
--- a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
+++ b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
@@ -32,6 +32,7 @@ import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.vlc.R;
+import org.videolan.vlc.RendererDelegate;
import org.videolan.vlc.VLCApplication;
import org.videolan.medialibrary.media.MediaWrapper;
@@ -184,8 +185,7 @@ public class VLCOptions {
if (!noHardwareAcceleration) {
try {
- final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
- hardwareAcceleration = Integer.parseInt(pref.getString("hardware_acceleration", "-1"));
+ hardwareAcceleration = Integer.parseInt(prefs.getString("hardware_acceleration", "-1"));
} catch (NumberFormatException ignored) {}
}
if (hardwareAcceleration == HW_ACCELERATION_DISABLED)
@@ -202,6 +202,11 @@ public class VLCOptions {
if (paused) media.addOption(":start-paused");
if (!prefs.getBoolean("subtitles_autoload", true)) media.addOption(":sub-language=none");
if (prefs.getBoolean("media_fast_seek", false)) media.addOption(":input-fast-seek");
+
+ if (RendererDelegate.INSTANCE.getSelectedRenderer() != null) {
+ media.addOption(":sout-chromecast-audio-passthrough="+pref.getBoolean("casting_passthrough", true));
+ media.addOption(":sout-chromecast-conversion-quality="+pref.getString("casting_quality", "2"));
+ }
}
private static MediaPlayer.Equalizer getEqualizerSetFromSettings(SharedPreferences pref) {
More information about the Android
mailing list