Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into fix/spoof_stream_for…
Browse files Browse the repository at this point in the history
…ce_avc

# Conflicts:
#	extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java
#	extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/DeviceHardwareSupport.java
  • Loading branch information
LisoUseInAIKyrios committed Dec 8, 2024
2 parents 65e12af + 5aedc09 commit 05642ba
Show file tree
Hide file tree
Showing 21 changed files with 550 additions and 484 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [5.3.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.2.4-dev.3...v5.3.0-dev.1) (2024-12-08)


### Features

* **YouTube Music:** Add `Spoof video streams` patch to fix playback ([#4065](https://github.com/ReVanced/revanced-patches/issues/4065)) ([cf3116a](https://github.com/ReVanced/revanced-patches/commit/cf3116a7583d09c25c798a85687a056f143656f0))

## [5.2.4-dev.3](https://github.com/ReVanced/revanced-patches/compare/v5.2.4-dev.2...v5.2.4-dev.3) (2024-12-07)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package app.revanced.extension.shared.settings;

import app.revanced.extension.shared.spoof.ClientType;
import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static app.revanced.extension.shared.settings.Setting.parent;

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

public static final IntegerSetting CHECK_ENVIRONMENT_WARNINGS_ISSUED = new IntegerSetting("revanced_check_environment_warnings_issued", 0, true, false);

public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
public static final BooleanSetting SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_video_streams_ios_force_avc", FALSE, true,
"revanced_spoof_video_streams_ios_force_avc_user_dialog_message", new SpoofVideoStreamsPatch.ForceiOSAVCAvailability());
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));

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package app.revanced.extension.youtube.patches.spoof;
package app.revanced.extension.shared.spoof;

import android.os.Build;

import androidx.annotation.Nullable;

import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.shared.settings.BaseSettings;

public enum ClientType {
// Specific purpose for age restricted, or private videos, because the iOS client is not logged in.
Expand Down Expand Up @@ -33,15 +33,15 @@ public enum ClientType {
// Version number should be a valid iOS release.
// https://www.ipa4fun.com/history/185230
forceAVC()
// Some newer versions can also give AVC,
// Some newer versions can also force AVC,
// but 17.40 is the last version that supports iOS 13.
? "17.40.5"
: "19.47.7",
false
);

private static boolean forceAVC() {
return Settings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get()
return BaseSettings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get()
&& DeviceHardwareSupport.DEVICE_HAS_HARDWARE_DECODING_VP9;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.youtube.patches.spoof;
package app.revanced.extension.shared.spoof;

import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.youtube.patches.spoof;
package app.revanced.extension.shared.spoof;

import android.net.Uri;

Expand All @@ -12,20 +12,12 @@
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.youtube.patches.spoof.requests.StreamingDataRequest;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.shared.spoof.requests.StreamingDataRequest;
import app.revanced.extension.shared.settings.BaseSettings;

@SuppressWarnings("unused")
public class SpoofVideoStreamsPatch {
public static final class ForceiOSAVCAvailability implements Setting.Availability {
@Override
public boolean isAvailable() {
return Settings.SPOOF_VIDEO_STREAMS.get() && Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS;
}
}

private static final boolean SPOOF_STREAMING_DATA = Settings.SPOOF_VIDEO_STREAMS.get();

private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get();
/**
* Any unreachable ip address. Used to intentionally fail requests.
*/
Expand Down Expand Up @@ -165,4 +157,11 @@ public static byte[] removeVideoPlaybackPostBody(Uri uri, int method, byte[] pos

return postData;
}

public static final class ForceiOSAVCAvailability implements Setting.Availability {
@Override
public boolean isAvailable() {
return BaseSettings.SPOOF_VIDEO_STREAMS.get() && BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.youtube.patches.spoof.requests;
package app.revanced.extension.shared.spoof.requests;

import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -10,7 +10,7 @@
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.requests.Requester;
import app.revanced.extension.shared.requests.Route;
import app.revanced.extension.youtube.patches.spoof.ClientType;
import app.revanced.extension.shared.spoof.ClientType;

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

import static app.revanced.extension.youtube.patches.spoof.requests.PlayerRoutes.GET_STREAMING_DATA;
import static app.revanced.extension.shared.spoof.requests.PlayerRoutes.GET_STREAMING_DATA;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -22,8 +22,7 @@
import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.youtube.patches.spoof.ClientType;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.shared.spoof.ClientType;

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

static {
ClientType[] allClientTypes = ClientType.values();
ClientType preferredClient = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
ClientType preferredClient = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();

CLIENT_ORDER_TO_USE = new ClientType[allClientTypes.length];
CLIENT_ORDER_TO_USE[0] = preferredClient;
Expand Down

This file was deleted.

Loading

0 comments on commit 05642ba

Please sign in to comment.