generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71b8d7b
commit 9f117c7
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...p/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package app.revanced.patches.youtube.misc.videobuffer.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[Package( | ||
"com.google.android.youtube", arrayOf("17.25.34", "17.29.34") | ||
)] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class CustomVideoBufferCompatibility |
32 changes: 32 additions & 0 deletions
32
...kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/MaxBufferFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app.revanced.patches.youtube.misc.videobuffer.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction | ||
|
||
@Name("maxbuffer-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "r" | ||
) | ||
@DirectPatternScanMethod | ||
@CustomVideoBufferCompatibility | ||
@Version("0.0.1") | ||
object MaxBufferFingerprint : MethodFingerprint( | ||
"I", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), | ||
listOf(Opcode.SGET_OBJECT, Opcode.IGET, Opcode.IF_EQZ, Opcode.RETURN), | ||
null, | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.equals("Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;") | ||
&& methodDef.implementation!!.instructions.any { | ||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 120000) | ||
&& methodDef.name.equals("r") | ||
} | ||
} | ||
) |
31 changes: 31 additions & 0 deletions
31
...n/app/revanced/patches/youtube/misc/videobuffer/fingerprints/PlaybackBufferFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package app.revanced.patches.youtube.misc.videobuffer.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction | ||
|
||
@Name("playbackbuffer-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "p" | ||
) | ||
@DirectPatternScanMethod | ||
@CustomVideoBufferCompatibility | ||
@Version("0.0.1") | ||
object PlaybackBufferFingerprint : MethodFingerprint( | ||
"I", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), | ||
listOf(Opcode.IF_LEZ, Opcode.RETURN), | ||
null, | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.equals("Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;") | ||
&& methodDef.implementation!!.instructions.any { | ||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 1600) | ||
} | ||
} | ||
) |
31 changes: 31 additions & 0 deletions
31
.../kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/ReBufferFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package app.revanced.patches.youtube.misc.videobuffer.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction | ||
|
||
@Name("playbackbuffer-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "t" | ||
) | ||
@DirectPatternScanMethod | ||
@CustomVideoBufferCompatibility | ||
@Version("0.0.1") | ||
object ReBufferFingerprint : MethodFingerprint( | ||
"I", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), | ||
listOf(Opcode.IF_LEZ, Opcode.RETURN), | ||
null, | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.equals("Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;") | ||
&& methodDef.implementation!!.instructions.any { | ||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 5000) | ||
} | ||
} | ||
) |
73 changes: 73 additions & 0 deletions
73
...main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package app.revanced.patches.youtube.misc.videobuffer.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility | ||
import app.revanced.patches.youtube.misc.videobuffer.fingerprints.MaxBufferFingerprint | ||
import app.revanced.patches.youtube.misc.videobuffer.fingerprints.PlaybackBufferFingerprint | ||
import app.revanced.patches.youtube.misc.videobuffer.fingerprints.ReBufferFingerprint | ||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@Name("custom-video-buffer") | ||
@Description("Lets you change the buffers of videos. Has no use without settings yet.") | ||
@CustomVideoBufferCompatibility | ||
@Version("0.0.1") | ||
class CustomVideoBufferPatch : BytecodePatch( | ||
listOf( | ||
MaxBufferFingerprint, PlaybackBufferFingerprint, ReBufferFingerprint | ||
) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
execMaxBuffer(data) | ||
execPlaybackBuffer(data) | ||
execReBuffer(data) | ||
return PatchResultSuccess() | ||
} | ||
|
||
private fun execMaxBuffer(data: BytecodeData) { | ||
val result = MaxBufferFingerprint.result!! | ||
val method = result.mutableMethod | ||
val index = result.patternScanResult!!.endIndex - 1 | ||
val register = (method.implementation!!.instructions.get(index) as OneRegisterInstruction).registerA | ||
method.addInstructions( | ||
index + 1, """ | ||
invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getMaxBuffer()I | ||
move-result v$register | ||
""" | ||
) | ||
} | ||
|
||
private fun execPlaybackBuffer(data: BytecodeData) { | ||
val result = PlaybackBufferFingerprint.result!! | ||
val method = result.mutableMethod | ||
val index = result.patternScanResult!!.startIndex | ||
val register = (method.implementation!!.instructions.get(index) as OneRegisterInstruction).registerA | ||
method.addInstructions( | ||
index + 1, """ | ||
invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getPlaybackBuffer()I | ||
move-result v$register | ||
""" | ||
) | ||
} | ||
|
||
private fun execReBuffer(data: BytecodeData) { | ||
val result = ReBufferFingerprint.result!! | ||
val method = result.mutableMethod | ||
val index = result.patternScanResult!!.startIndex | ||
val register = (method.implementation!!.instructions.get(index) as OneRegisterInstruction).registerA | ||
method.addInstructions( | ||
index + 1, """ | ||
invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getReBuffer()I | ||
move-result v$register | ||
""" | ||
) | ||
} | ||
} |