mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 04:40:19 +02:00
refactor(YouTube - Spoof streaming data): Remove Force iOS AVC
setting (#103)
* refactor(YouTube - Spoof Streaming Data): Remove `Force AVC` settings * Add missing header * Apply code suggestion
This commit is contained in:
parent
73b95a5143
commit
59b0c7168c
@ -24,7 +24,6 @@ public class AppClient {
|
||||
private static final String CLIENT_VERSION_IOS = "19.47.7";
|
||||
private static final String DEVICE_MAKE_IOS = "Apple";
|
||||
/**
|
||||
* The device machine id for the iPhone XS Max (iPhone11,4), used to get 60fps.
|
||||
* The device machine id for the iPhone 16 Pro Max (iPhone17,2), used to get HDR with AV1 hardware decoding.
|
||||
*
|
||||
* <p>
|
||||
@ -32,20 +31,11 @@ public class AppClient {
|
||||
* information.
|
||||
* </p>
|
||||
*/
|
||||
private static final String DEVICE_MODEL_IOS = DeviceHardwareSupport.allowAV1()
|
||||
? "iPhone17,2"
|
||||
: "iPhone11,4";
|
||||
private static final String DEVICE_MODEL_IOS = "iPhone17,2"
|
||||
private static final String OS_NAME_IOS = "iOS";
|
||||
/**
|
||||
* The minimum supported OS version for the iOS YouTube client is iOS 14.0.
|
||||
* Using an invalid OS version will use the AVC codec.
|
||||
*/
|
||||
private static final String OS_VERSION_IOS = DeviceHardwareSupport.allowVP9()
|
||||
? "18.1.1.22B91"
|
||||
: "13.7.17H35";
|
||||
private static final String USER_AGENT_VERSION_IOS = DeviceHardwareSupport.allowVP9()
|
||||
? "18_1_1"
|
||||
: "13_7";
|
||||
private static final String OS_VERSION_IOS = "18.1.1.22B91"
|
||||
private static final String USER_AGENT_VERSION_IOS = "18_1_1"
|
||||
|
||||
private static final String USER_AGENT_IOS = "com.google.ios.youtube/" +
|
||||
CLIENT_VERSION_IOS +
|
||||
"(" +
|
||||
|
@ -1,54 +0,0 @@
|
||||
package app.revanced.extension.youtube.patches.misc.client;
|
||||
|
||||
import static app.revanced.extension.shared.utils.Utils.isSDKAbove;
|
||||
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecList;
|
||||
|
||||
import app.revanced.extension.shared.utils.Logger;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
public class DeviceHardwareSupport {
|
||||
private static final boolean DEVICE_HAS_HARDWARE_DECODING_VP9;
|
||||
private static final boolean DEVICE_HAS_HARDWARE_DECODING_AV1;
|
||||
|
||||
static {
|
||||
boolean vp9found = false;
|
||||
boolean av1found = false;
|
||||
MediaCodecList codecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
|
||||
final boolean deviceIsAndroidTenOrLater = isSDKAbove(29);
|
||||
|
||||
for (MediaCodecInfo codecInfo : codecList.getCodecInfos()) {
|
||||
final boolean isHardwareAccelerated = deviceIsAndroidTenOrLater
|
||||
? codecInfo.isHardwareAccelerated()
|
||||
: !codecInfo.getName().startsWith("OMX.google"); // Software decoder.
|
||||
if (isHardwareAccelerated && !codecInfo.isEncoder()) {
|
||||
for (String type : codecInfo.getSupportedTypes()) {
|
||||
if (type.equalsIgnoreCase("video/x-vnd.on2.vp9")) {
|
||||
vp9found = true;
|
||||
} else if (type.equalsIgnoreCase("video/av01")) {
|
||||
av1found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_HAS_HARDWARE_DECODING_VP9 = vp9found;
|
||||
DEVICE_HAS_HARDWARE_DECODING_AV1 = av1found;
|
||||
|
||||
Logger.printDebug(() -> DEVICE_HAS_HARDWARE_DECODING_AV1
|
||||
? "Device supports AV1 hardware decoding\n"
|
||||
: "Device does not support AV1 hardware decoding\n"
|
||||
+ (DEVICE_HAS_HARDWARE_DECODING_VP9
|
||||
? "Device supports VP9 hardware decoding"
|
||||
: "Device does not support VP9 hardware decoding"));
|
||||
}
|
||||
|
||||
public static boolean allowVP9() {
|
||||
return DEVICE_HAS_HARDWARE_DECODING_VP9 && !Settings.SPOOF_STREAMING_DATA_IOS_FORCE_AVC.get();
|
||||
}
|
||||
|
||||
public static boolean allowAV1() {
|
||||
return allowVP9() && DEVICE_HAS_HARDWARE_DECODING_AV1;
|
||||
}
|
||||
}
|
@ -92,6 +92,8 @@ public final class PlayerRoutes {
|
||||
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("User-Agent", clientType.userAgent);
|
||||
connection.setRequestProperty("X-YouTube-Client-Name", clientType.id);
|
||||
connection.setRequestProperty("X-YouTube-Client-Version", clientType.clientVersion);
|
||||
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoOutput(true);
|
||||
@ -100,4 +102,4 @@ public final class PlayerRoutes {
|
||||
connection.setReadTimeout(CONNECTION_TIMEOUT_MILLISECONDS);
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,8 +565,6 @@ public class Settings extends BaseSettings {
|
||||
// PreferenceScreen: Miscellaneous - Spoof streaming data
|
||||
// The order of the settings should not be changed otherwise the app may crash
|
||||
public static final BooleanSetting SPOOF_STREAMING_DATA = new BooleanSetting("revanced_spoof_streaming_data", TRUE, true, "revanced_spoof_streaming_data_user_dialog_message");
|
||||
public static final BooleanSetting SPOOF_STREAMING_DATA_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_streaming_data_ios_force_avc", FALSE, true,
|
||||
"revanced_spoof_streaming_data_ios_force_avc_user_dialog_message", new SpoofStreamingDataPatch.iOSAvailability());
|
||||
public static final BooleanSetting SPOOF_STREAMING_DATA_IOS_SKIP_LIVESTREAM_PLAYBACK = new BooleanSetting("revanced_spoof_streaming_data_ios_skip_livestream_playback", TRUE, true, new SpoofStreamingDataPatch.iOSAvailability());
|
||||
public static final EnumSetting<ClientType> SPOOF_STREAMING_DATA_TYPE = new EnumSetting<>("revanced_spoof_streaming_data_type", ClientType.IOS, true, parent(SPOOF_STREAMING_DATA));
|
||||
public static final BooleanSetting SPOOF_STREAMING_DATA_STATS_FOR_NERDS = new BooleanSetting("revanced_spoof_streaming_data_stats_for_nerds", TRUE, parent(SPOOF_STREAMING_DATA));
|
||||
|
@ -1905,12 +1905,6 @@ Tap on the continue button and disable battery optimizations."</string>
|
||||
• Stable volume is not available."</string>
|
||||
<string name="revanced_spoof_streaming_data_side_effects_android_vr">"• Audio track menu is missing.
|
||||
• Stable volume is not available."</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_force_avc_title">Force iOS AVC (H.264)</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_force_avc_summary_on">iOS video codec is AVC (H.264).</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_force_avc_summary_off">iOS video codec is AVC (H.264), VP9, or AV1.</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_force_avc_user_dialog_message">"Enabling this might improve battery life and fix playback stuttering.
|
||||
|
||||
AVC (H.264) has a maximum resolution of 1080p, and video playback will use more internet data than VP9 or AV1."</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_skip_livestream_playback_title">Skip iOS livestream playback</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_skip_livestream_playback_summary_on">iOS client is not used for livestream playback.</string>
|
||||
<string name="revanced_spoof_streaming_data_ios_skip_livestream_playback_summary_off">iOS client is used for livestream playback.</string>
|
||||
|
@ -780,7 +780,6 @@
|
||||
<SwitchPreference android:title="@string/revanced_spoof_streaming_data_title" android:key="revanced_spoof_streaming_data" android:summaryOn="@string/revanced_spoof_streaming_data_summary_on" android:summaryOff="@string/revanced_spoof_streaming_data_summary_off" />
|
||||
<ListPreference android:entries="@array/revanced_spoof_streaming_data_type_entries" android:title="@string/revanced_spoof_streaming_data_type_title" android:key="revanced_spoof_streaming_data_type" android:entryValues="@array/revanced_spoof_streaming_data_type_entry_values" />
|
||||
<app.revanced.extension.youtube.settings.preference.SpoofStreamingDataSideEffectsPreference android:title="@string/revanced_spoof_streaming_data_side_effects_title" />
|
||||
<SwitchPreference android:title="@string/revanced_spoof_streaming_data_ios_force_avc_title" android:key="revanced_spoof_streaming_data_ios_force_avc" android:summaryOn="@string/revanced_spoof_streaming_data_ios_force_avc_summary_on" android:summaryOff="@string/revanced_spoof_streaming_data_ios_force_avc_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_spoof_streaming_data_ios_skip_livestream_playback_title" android:key="revanced_spoof_streaming_data_ios_skip_livestream_playback" android:summaryOn="@string/revanced_spoof_streaming_data_ios_skip_livestream_playback_summary_on" android:summaryOff="@string/revanced_spoof_streaming_data_ios_skip_livestream_playback_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_spoof_streaming_data_stats_for_nerds_title" android:key="revanced_spoof_streaming_data_stats_for_nerds" android:summaryOn="@string/revanced_spoof_streaming_data_stats_for_nerds_summary_on" android:summaryOff="@string/revanced_spoof_streaming_data_stats_for_nerds_summary_off" />
|
||||
</PreferenceScreen>SETTINGS: SPOOF_STREAMING_DATA -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user