Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

fix(YouTube): Fix issues related to playback by replace streaming data #680

Merged
merged 52 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d498d79
fix(YouTube - Spoof Client): Fix playback by replace streaming data
zainarbani Aug 24, 2024
ab0543b
Merge branch 'dev' into fix/yt-spoof-stream
zainarbani Aug 24, 2024
109a83e
Fix missmerge
zainarbani Aug 24, 2024
0bc88bd
Add iOS client as streaming data source
zainarbani Aug 25, 2024
38a54d1
refactor
LisoUseInAIKyrios Aug 26, 2024
3c07c12
Update desc
zainarbani Aug 26, 2024
06824a8
refactor: Present stream replacement in the settings as an option sim…
LisoUseInAIKyrios Aug 26, 2024
6649e0c
refactor
LisoUseInAIKyrios Aug 26, 2024
3c31b6a
fix: Close byte array stream, do not show toast if all streams return…
LisoUseInAIKyrios Aug 26, 2024
612a65b
fix: Remove debug code
LisoUseInAIKyrios Aug 26, 2024
36e072c
fix: Show error toast only if last attempt fails. Add more logging.
LisoUseInAIKyrios Aug 26, 2024
6c46060
fix refactoring typo, use correct Android SDK version
LisoUseInAIKyrios Aug 26, 2024
ab2791d
fix: If debug is enabled, then use a random client order
LisoUseInAIKyrios Aug 26, 2024
cf62175
fix: Comments, warnings
LisoUseInAIKyrios Aug 26, 2024
f419920
fix: Don't override player responses when all spoofing is off
LisoUseInAIKyrios Aug 26, 2024
9b1e84b
fix: Remove unused setting
LisoUseInAIKyrios Aug 26, 2024
bfe7faa
fix: Remove client type spoofing and use only stream replacement
LisoUseInAIKyrios Aug 26, 2024
69a1a88
Fix: Remove obsolete code that no longer works
LisoUseInAIKyrios Aug 26, 2024
7fc164c
fix: Comments
LisoUseInAIKyrios Aug 27, 2024
2e3f219
Cleanup
LisoUseInAIKyrios Aug 27, 2024
4248422
fix: Can use non experimental parent class type
LisoUseInAIKyrios Aug 28, 2024
760bc11
Don't block /get_watch
zainarbani Aug 31, 2024
3319922
Remove debug
zainarbani Aug 31, 2024
f46a46d
Update app/src/main/java/app/revanced/integrations/youtube/patches/sp…
LisoUseInAIKyrios Aug 31, 2024
9010ba4
fix compilation
LisoUseInAIKyrios Aug 31, 2024
f99572f
refactor: Can use a simpler synchronized map since there is little to…
LisoUseInAIKyrios Aug 31, 2024
e5a6981
fix: Do not fetch Shorts streams until the Short is opened
LisoUseInAIKyrios Aug 31, 2024
397f5cf
refactor
LisoUseInAIKyrios Aug 31, 2024
1a30868
refactor
LisoUseInAIKyrios Aug 31, 2024
6c24707
refactor
LisoUseInAIKyrios Aug 31, 2024
6d3f796
Merge branch 'dev' into fix/yt-spoof-stream
LisoUseInAIKyrios Sep 2, 2024
fa81832
Revert "Don't block /get_watch"
LisoUseInAIKyrios Sep 3, 2024
2d7ea04
refactor
LisoUseInAIKyrios Sep 3, 2024
90fee40
Merge remote-tracking branch 'refs/remotes/upstream/dev' into fix/yt-…
LisoUseInAIKyrios Sep 7, 2024
55c7ab8
fix: Remove assert until a way around it is figured out
LisoUseInAIKyrios Sep 7, 2024
bb45316
Comments, logging
LisoUseInAIKyrios Sep 7, 2024
b2693a9
fix: Use a cache again, to handle if any recently used video ids are …
LisoUseInAIKyrios Sep 7, 2024
0bd6dc5
fix: Always fetch if YT is fetching
LisoUseInAIKyrios Sep 7, 2024
7859fc6
fix: Don't use an cache expiration for streams since they are always …
LisoUseInAIKyrios Sep 7, 2024
f6d8196
fix: Allow selecting the preferred client steam
LisoUseInAIKyrios Sep 9, 2024
dad0974
fix toast string
LisoUseInAIKyrios Sep 9, 2024
b8641be
fix: Add missing timeout, add comments.
LisoUseInAIKyrios Sep 10, 2024
45740b2
Comments
LisoUseInAIKyrios Sep 10, 2024
6df5f07
fix: Use more descriptive parameter, don't use enum name since that c…
LisoUseInAIKyrios Sep 10, 2024
69f0314
fix: Simplify fetch request hook
LisoUseInAIKyrios Sep 10, 2024
cfa746c
comments
LisoUseInAIKyrios Sep 10, 2024
2389a92
Add custom preference for force AVC that behaves differently for devi…
LisoUseInAIKyrios Sep 10, 2024
2895a2d
fix: Show the AVC switch forced on or off
LisoUseInAIKyrios Sep 10, 2024
40a488f
refactor: Simplify
LisoUseInAIKyrios Sep 10, 2024
8733f80
fix: Show same message for AVC switch and any client type
LisoUseInAIKyrios Sep 10, 2024
390b6fc
refactor: Rename to `Spoof video streams`
LisoUseInAIKyrios Sep 17, 2024
502d29f
Merge branch 'dev' into fix/yt-spoof-stream
oSumAtrIX Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package app.revanced.integrations.youtube.patches.spoof;

import static app.revanced.integrations.youtube.patches.spoof.DeviceHardwareSupport.allowAV1;
import static app.revanced.integrations.youtube.patches.spoof.DeviceHardwareSupport.allowVP9;

import android.os.Build;

import androidx.annotation.Nullable;

public enum ClientType {
// https://dumps.tadiphone.dev/dumps/oculus/eureka
IOS(5,
// iPhone 15 supports AV1 hardware decoding.
// Only use if this Android device also has hardware decoding.
allowAV1()
? "iPhone16,2" // 15 Pro Max
: "iPhone11,4", // XS Max
// iOS 14+ forces VP9.
allowVP9()
? "17.5.1.21F90"
: "13.7.17H35",
allowVP9()
? "com.google.ios.youtube/19.10.7 (iPhone; U; CPU iOS 17_5_1 like Mac OS X)"
: "com.google.ios.youtube/19.10.7 (iPhone; U; CPU iOS 13_7 like Mac OS X)",
null,
// Version number should be a valid iOS release.
// https://www.ipa4fun.com/history/185230
"19.10.7"
),
ANDROID_VR(28,
"Quest 3",
"12",
"com.google.android.apps.youtube.vr.oculus/1.56.21 (Linux; U; Android 12; GB) gzip",
"32", // Android 12.1
"1.56.21"
);

/**
* YouTube
* <a href="https://github.com/zerodytrash/YouTube-Internal-Clients?tab=readme-ov-file#clients">client type</a>
*/
public final int id;

/**
* Device model, equivalent to {@link Build#MODEL} (System property: ro.product.model)
*/
public final String model;

/**
* Device OS version.
*/
public final String osVersion;

/**
* Player user-agent.
*/
public final String userAgent;

/**
* Android SDK version, equivalent to {@link Build.VERSION#SDK} (System property: ro.build.version.sdk)
* Field is null if not applicable.
*/
@Nullable
public final String androidSdkVersion;

/**
* App version.
*/
public final String appVersion;

ClientType(int id, String model, String osVersion, String userAgent, @Nullable String androidSdkVersion, String appVersion) {
this.id = id;
this.model = model;
this.osVersion = osVersion;
this.userAgent = userAgent;
this.androidSdkVersion = androidSdkVersion;
this.appVersion = appVersion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package app.revanced.integrations.youtube.patches.spoof;

import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.os.Build;

import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.youtube.settings.Settings;

public class DeviceHardwareSupport {
private static final boolean DEVICE_HAS_HARDWARE_DECODING_VP9 = deviceHasVP9HardwareDecoding();
private static final boolean DEVICE_HAS_HARDWARE_DECODING_AV1 = deviceHasAV1HardwareDecoding();

private static boolean deviceHasVP9HardwareDecoding() {
MediaCodecList codecList = new MediaCodecList(MediaCodecList.ALL_CODECS);

for (MediaCodecInfo codecInfo : codecList.getCodecInfos()) {
final boolean isHardwareAccelerated = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
? 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")) {
Logger.printDebug(() -> "Device supports VP9 hardware decoding.");
return true;
}
}
}
}

Logger.printDebug(() -> "Device does not support VP9 hardware decoding.");
return false;
}

private static boolean deviceHasAV1HardwareDecoding() {
// It appears all devices with hardware AV1 are also Android 10 or newer.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
MediaCodecList codecList = new MediaCodecList(MediaCodecList.ALL_CODECS);

for (MediaCodecInfo codecInfo : codecList.getCodecInfos()) {
if (codecInfo.isHardwareAccelerated() && !codecInfo.isEncoder()) {
for (String type : codecInfo.getSupportedTypes()) {
if (type.equalsIgnoreCase("video/av01")) {
Logger.printDebug(() -> "Device supports AV1 hardware decoding.");
return true;
}
}
}
}
}
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved

Logger.printDebug(() -> "Device does not support AV1 hardware decoding.");
return false;
}

public static boolean allowVP9() {
return DEVICE_HAS_HARDWARE_DECODING_VP9 && !Settings.SPOOF_CLIENT_FORCE_AVC.get();
}

public static boolean allowAV1() {
return allowVP9() && DEVICE_HAS_HARDWARE_DECODING_AV1;
}
}
Loading
Loading