This commit is contained in:
inotia00
2023-01-30 10:46:54 +09:00
parent 7cc0397ef2
commit 96a55c5049
7 changed files with 0 additions and 202 deletions

View File

@ -1,18 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object MaxBufferFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("J", "J", "F"),
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.CONST_WIDE_16,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL
)
)

View File

@ -1,23 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.Opcode
object PlaybackBufferFingerprint : MethodFingerprint(
returnType = "I",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IF_LEZ,
Opcode.RETURN
),
customFingerprint = {
it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;"
&& it.implementation!!.instructions.any { instruction ->
((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 1600)
}
}
)

View File

@ -1,23 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.Opcode
object ReBufferFingerprint : MethodFingerprint(
returnType = "I",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IF_LEZ,
Opcode.RETURN
),
customFingerprint = {
it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;"
&& it.implementation!!.instructions.any { instruction ->
((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 5000)
}
}
)

View File

@ -1,73 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints.*
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.util.integrations.Constants.MISC_PATH
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("custom-video-buffer-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoBufferBytecodePatch : BytecodePatch(
listOf(
MaxBufferFingerprint,
PlaybackBufferFingerprint,
ReBufferFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
MaxBufferFingerprint.result?.injectMaxBuffer(context) ?: return MaxBufferFingerprint.toErrorResult()
arrayOf(
PlaybackBufferFingerprint to "setPlaybackBuffer",
ReBufferFingerprint to "setReBuffer"
).map { (fingerprint, name) ->
fingerprint.result?.mutableMethod?.insertOverride(name) ?: return fingerprint.toErrorResult()
}
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR =
"$MISC_PATH/CustomVideoBufferPatch;"
}
private fun MethodFingerprintResult.injectMaxBuffer(
context: BytecodeContext
) {
val insertMethod = context.toMethodWalker(this.method)
.nextMethod(this.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod
insertMethod.insertOverride("setMaxBuffer")
}
private fun MutableMethod.insertOverride(
descriptor: String
) {
val index = this.implementation!!.instructions.size - 1 - 2
val register = (this.instruction(index) as OneRegisterInstruction).registerA
this.addInstructions(
index,
"""
invoke-static {}, $INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR->$descriptor()I
move-result v$register
"""
)
}
}

View File

@ -1,48 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch.CustomVideoBufferBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("custom-video-buffer")
@Description("Lets you change the buffers of videos.")
@DependsOn(
[
CustomVideoBufferBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoBufferPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
"PREFERENCE: MISC_SETTINGS",
"SETTINGS: CUSTOM_VIDEO_BUFFER"
)
ResourceHelper.patchSuccess(
context,
"custom-video-buffer"
)
return PatchResultSuccess()
}
}

View File

@ -163,14 +163,6 @@ Is it ready to submit?"</string>
<string name="revanced_adremover_web_search_panel_title">Hide web search panels</string>
<string name="revanced_custom_seekbar_color_value_summary">Type the hex code of the seekbar color to use in dark mode</string>
<string name="revanced_custom_seekbar_color_value_title">Custom seekbar color value</string>
<string name="revanced_custom_video_buffer_maximum_summary">The maximum duration of media that the player will attempt to buffer</string>
<string name="revanced_custom_video_buffer_maximum_title">Maximum buffer size</string>
<string name="revanced_custom_video_buffer_playback_start_summary">The duration of media that must be buffered for playback to start or resume following a user action such as seeking</string>
<string name="revanced_custom_video_buffer_playback_start_title">Playback start buffer size</string>
<string name="revanced_custom_video_buffer_rebuffer_summary">The duration of media that must be buffered for playback to resume after a rebuffer</string>
<string name="revanced_custom_video_buffer_rebuffer_title">Rebuffer size</string>
<string name="revanced_custom_video_buffer_summary">Video buffer size related settings</string>
<string name="revanced_custom_video_buffer_title">Video buffer settings</string>
<string name="revanced_default_video_quality_mobile_summary">Select default video resolution on Cellular Network</string>
<string name="revanced_default_video_quality_mobile_title">Default video quality Cellular</string>
<string name="revanced_default_video_quality_wifi_summary">Select default video resolution on Wi-Fi Network</string>

View File

@ -279,14 +279,6 @@
<!-- SETTINGS: ENABLE_MINIMIZED_PLAYBACK
<SwitchPreference android:title="@string/revanced_enable_minimized_playback_title" android:key="revanced_enable_minimized_playback" android:defaultValue="true" android:summaryOn="@string/revanced_enable_minimized_playback_summary_on" android:summaryOff="@string/revanced_enable_minimized_playback_summary_off" />SETTINGS: ENABLE_MINIMIZED_PLAYBACK -->
<!-- SETTINGS: CUSTOM_VIDEO_BUFFER
<PreferenceScreen android:title="@string/revanced_custom_video_buffer_title" android:key="revanced_custom_video_buffer" android:summary="@string/revanced_custom_video_buffer_summary">
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_custom_video_buffer_title" />
<EditTextPreference android:title="@string/revanced_custom_video_buffer_maximum_title" android:key="revanced_custom_video_buffer_maximum" android:summary="@string/revanced_custom_video_buffer_maximum_summary" android:defaultValue="120000" android:inputType="number" />
<EditTextPreference android:title="@string/revanced_custom_video_buffer_playback_start_title" android:key="revanced_custom_video_buffer_playback_start" android:summary="@string/revanced_custom_video_buffer_playback_start_summary" android:defaultValue="2500" android:inputType="number" />
<EditTextPreference android:title="@string/revanced_custom_video_buffer_rebuffer_title" android:key="revanced_custom_video_buffer_rebuffer" android:summary="@string/revanced_custom_video_buffer_rebuffer_summary" android:defaultValue="5000" android:inputType="number" />
</PreferenceScreen>SETTINGS: CUSTOM_VIDEO_BUFFER -->
<!-- PREFERENCE: MISC_SETTINGS
</PreferenceScreen>PREFERENCE: MISC_SETTINGS -->
@ -416,7 +408,6 @@
<Preference android:title="enable-external-browser" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="enable-open-links-directly" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="enable-minimized-playback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="custom-video-buffer" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_video_settings_title" />
<Preference android:title="default-video-quality" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>