Skip to content

Commit cf3116a

Browse files
feat(YouTube Music): Add Spoof video streams patch to fix playback (#4065)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
1 parent 6a44e75 commit cf3116a

File tree

19 files changed

+543
-484
lines changed

19 files changed

+543
-484
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package app.revanced.extension.shared.settings;
22

3+
import app.revanced.extension.shared.spoof.ClientType;
4+
import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch;
5+
36
import static java.lang.Boolean.FALSE;
47
import static java.lang.Boolean.TRUE;
58
import static app.revanced.extension.shared.settings.Setting.parent;
69

710
/**
811
* Settings shared across multiple apps.
9-
*
12+
* <p>
1013
* To ensure this class is loaded when the UI is created, app specific setting bundles should extend
1114
* or reference this class.
1215
*/
@@ -16,4 +19,10 @@ public class BaseSettings {
1619
public static final BooleanSetting DEBUG_TOAST_ON_ERROR = new BooleanSetting("revanced_debug_toast_on_error", TRUE, "revanced_debug_toast_on_error_user_dialog_message");
1720

1821
public static final IntegerSetting CHECK_ENVIRONMENT_WARNINGS_ISSUED = new IntegerSetting("revanced_check_environment_warnings_issued", 0, true, false);
22+
23+
public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
24+
public static final BooleanSetting SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_video_streams_ios_force_avc", FALSE, true,
25+
"revanced_spoof_video_streams_ios_force_avc_user_dialog_message", new SpoofVideoStreamsPatch.ForceiOSAVCAvailability());
26+
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client", ClientType.ANDROID_VR, true, parent(SPOOF_VIDEO_STREAMS));
27+
1928
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/ClientType.java renamed to extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package app.revanced.extension.youtube.patches.spoof;
1+
package app.revanced.extension.shared.spoof;
22

3-
import static app.revanced.extension.youtube.patches.spoof.DeviceHardwareSupport.allowAV1;
4-
import static app.revanced.extension.youtube.patches.spoof.DeviceHardwareSupport.allowVP9;
3+
import static app.revanced.extension.shared.spoof.DeviceHardwareSupport.allowAV1;
4+
import static app.revanced.extension.shared.spoof.DeviceHardwareSupport.allowVP9;
55

66
import android.os.Build;
77

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package app.revanced.extension.youtube.patches.spoof;
1+
package app.revanced.extension.shared.spoof;
22

33
import android.media.MediaCodecInfo;
44
import android.media.MediaCodecList;
55
import android.os.Build;
66

77
import app.revanced.extension.shared.Logger;
8-
import app.revanced.extension.youtube.settings.Settings;
8+
import app.revanced.extension.shared.settings.BaseSettings;
99

1010
public class DeviceHardwareSupport {
1111
public static final boolean DEVICE_HAS_HARDWARE_DECODING_VP9;
@@ -44,7 +44,7 @@ public class DeviceHardwareSupport {
4444
}
4545

4646
public static boolean allowVP9() {
47-
return DEVICE_HAS_HARDWARE_DECODING_VP9 && !Settings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get();
47+
return DEVICE_HAS_HARDWARE_DECODING_VP9 && !BaseSettings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get();
4848
}
4949

5050
public static boolean allowAV1() {
+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.youtube.patches.spoof;
1+
package app.revanced.extension.shared.spoof;
22

33
import android.net.Uri;
44

@@ -12,20 +12,12 @@
1212
import app.revanced.extension.shared.Utils;
1313
import app.revanced.extension.shared.settings.BaseSettings;
1414
import app.revanced.extension.shared.settings.Setting;
15-
import app.revanced.extension.youtube.patches.spoof.requests.StreamingDataRequest;
16-
import app.revanced.extension.youtube.settings.Settings;
15+
import app.revanced.extension.shared.spoof.requests.StreamingDataRequest;
16+
import app.revanced.extension.shared.settings.BaseSettings;
1717

1818
@SuppressWarnings("unused")
1919
public class SpoofVideoStreamsPatch {
20-
public static final class ForceiOSAVCAvailability implements Setting.Availability {
21-
@Override
22-
public boolean isAvailable() {
23-
return Settings.SPOOF_VIDEO_STREAMS.get() && Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS;
24-
}
25-
}
26-
27-
private static final boolean SPOOF_STREAMING_DATA = Settings.SPOOF_VIDEO_STREAMS.get();
28-
20+
private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get();
2921
/**
3022
* Any unreachable ip address. Used to intentionally fail requests.
3123
*/
@@ -165,4 +157,11 @@ public static byte[] removeVideoPlaybackPostBody(Uri uri, int method, byte[] pos
165157

166158
return postData;
167159
}
160+
161+
public static final class ForceiOSAVCAvailability implements Setting.Availability {
162+
@Override
163+
public boolean isAvailable() {
164+
return BaseSettings.SPOOF_VIDEO_STREAMS.get() && BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS;
165+
}
166+
}
168167
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.youtube.patches.spoof.requests;
1+
package app.revanced.extension.shared.spoof.requests;
22

33
import org.json.JSONException;
44
import org.json.JSONObject;
@@ -10,7 +10,7 @@
1010
import app.revanced.extension.shared.Utils;
1111
import app.revanced.extension.shared.requests.Requester;
1212
import app.revanced.extension.shared.requests.Route;
13-
import app.revanced.extension.youtube.patches.spoof.ClientType;
13+
import app.revanced.extension.shared.spoof.ClientType;
1414

1515
final class PlayerRoutes {
1616
static final Route.CompiledRoute GET_STREAMING_DATA = new Route(
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package app.revanced.extension.youtube.patches.spoof.requests;
1+
package app.revanced.extension.shared.spoof.requests;
22

3-
import static app.revanced.extension.youtube.patches.spoof.requests.PlayerRoutes.GET_STREAMING_DATA;
3+
import static app.revanced.extension.shared.spoof.requests.PlayerRoutes.GET_STREAMING_DATA;
44

55
import androidx.annotation.NonNull;
66
import androidx.annotation.Nullable;
@@ -22,8 +22,7 @@
2222
import app.revanced.extension.shared.Logger;
2323
import app.revanced.extension.shared.Utils;
2424
import app.revanced.extension.shared.settings.BaseSettings;
25-
import app.revanced.extension.youtube.patches.spoof.ClientType;
26-
import app.revanced.extension.youtube.settings.Settings;
25+
import app.revanced.extension.shared.spoof.ClientType;
2726

2827
/**
2928
* Video streaming data. Fetching is tied to the behavior YT uses,
@@ -70,7 +69,7 @@ protected boolean removeEldestEntry(Entry eldest) {
7069

7170
static {
7271
ClientType[] allClientTypes = ClientType.values();
73-
ClientType preferredClient = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
72+
ClientType preferredClient = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
7473

7574
CLIENT_ORDER_TO_USE = new ClientType[allClientTypes.length];
7675
CLIENT_ORDER_TO_USE[0] = preferredClient;

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/FullscreenPanelsRemoverPatch.java

-12
This file was deleted.

0 commit comments

Comments
 (0)