Skip to content

Commit

Permalink
add function send Video in 60fps
Browse files Browse the repository at this point in the history
add function send video in real resolution
fix bug to send video in HD on Status
  • Loading branch information
Dev4Mod committed May 2, 2024
1 parent 109558b commit aa4a2d0
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,19 @@ public static Method loadMediaQualityBitrateMethod(ClassLoader classLoader) thro
});
}

public static Method loadMediaQualityVideoMethod(ClassLoader classLoader) throws Exception {
public static Method loadMediaQualityVideoMethod2(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var clazz = loadMediaQualityClass(classLoader);
return Arrays.stream(clazz.getDeclaredMethods()).filter(
method1 -> method1.getParameterTypes().length == 3 &&
method1.getParameterTypes()[2].equals(int.class)
&& method1.getReturnType().equals(Pair.class)
).findFirst().orElse(null);
var method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "getCorrectedResolution");
if (method == null) throw new Exception("MediaQualityVideo method not found");
return method;
});
}

public static Class loadMediaQualityVideoLimitClass(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getClass(classLoader, () -> {
var clazz = findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "videoLimitMb=");
if (clazz == null) throw new Exception("MediaQualityVideoLimit method not found");
return clazz;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.graphics.Bitmap;
import android.graphics.RecordingCanvas;
import android.os.Build;
import android.util.ArraySet;
import android.util.Pair;

import androidx.annotation.NonNull;
Expand All @@ -11,6 +12,8 @@
import com.wmods.wppenhacer.xposed.core.Feature;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
Expand Down Expand Up @@ -44,18 +47,56 @@ protected void afterHookedMethod(MethodHookParam param) {
var bitrateMethod = Unobfuscator.loadMediaQualityBitrateMethod(loader);
logDebug(Unobfuscator.getMethodDescriptor(bitrateMethod));

XposedBridge.hookMethod(bitrateMethod, XC_MethodReplacement.returnConstant((1600000)));
XposedBridge.hookMethod(bitrateMethod, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(96 * 1000 * 1000);
}
});

var videoMethod = Unobfuscator.loadMediaQualityVideoMethod(loader);
var videoMethod = Unobfuscator.loadMediaQualityVideoMethod2(loader);
logDebug(Unobfuscator.getMethodDescriptor(videoMethod));

XposedBridge.hookMethod(videoMethod, new XC_MethodReplacement() {
XposedBridge.hookMethod(videoMethod, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
log(param.args[1]);
if ((int) param.args[1] == 3) {
var resizeVideo = param.getResult();
var originalVieo = param.args[0];
if (prefs.getBoolean("video_real_resolution", false)) {
XposedHelpers.setIntField(resizeVideo, "A09", XposedHelpers.getIntField(originalVieo, "A03"));
XposedHelpers.setIntField(resizeVideo, "A07", XposedHelpers.getIntField(originalVieo, "A05"));
}
if (prefs.getBoolean("video_maxfps", false)) {
XposedHelpers.setIntField(resizeVideo, "A05", 60);
}
log(resizeVideo);
}
}
});

var videoLimitClass = Unobfuscator.loadMediaQualityVideoLimitClass(loader);
logDebug(videoLimitClass);
XposedHelpers.findAndHookConstructor(videoLimitClass, int.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
if (prefs.getBoolean("video_size_limit", false)) {
param.args[0] = 90;
}
param.args[1] = 8000; // 4K Resolution
param.args[2] = 96 * 1000 * 1000; // 96 Mbps
}

@Override
protected Object replaceHookedMethod(MethodHookParam param) {
return new Pair<>(true, new ArrayList<>());
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
log(param.thisObject);
}
});


}

if (imageQuality) {
Expand Down
70 changes: 49 additions & 21 deletions app/src/main/res/xml/fragment_media.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">

<rikka.material.preference.MaterialSwitchPreference
app:key="downloadstatus"
app:summary="@string/statusdowload_sum"
app:title="@string/statusdowload" />

<rikka.material.preference.MaterialSwitchPreference
app:key="downloadviewonce"
app:summary="@string/downloadviewonce_sum"
app:title="@string/downloadviewonce" />

<rikka.material.preference.MaterialSwitchPreference
app:key="videoquality"
app:summary="@string/videoquality_sum"
app:title="@string/videoquality" />

<rikka.material.preference.MaterialSwitchPreference
app:key="imagequality"
app:summary="@string/imagequality_sum"
app:title="@string/imagequality" />
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<PreferenceCategory android:title="Image">

<rikka.material.preference.MaterialSwitchPreference
app:key="downloadstatus"
app:summary="@string/statusdowload_sum"
app:title="@string/statusdowload" />

<rikka.material.preference.MaterialSwitchPreference
app:key="downloadviewonce"
app:summary="@string/downloadviewonce_sum"
app:title="@string/downloadviewonce" />

<rikka.material.preference.MaterialSwitchPreference
app:key="imagequality"
app:summary="@string/imagequality_sum"
app:title="@string/imagequality" />

</PreferenceCategory>

<PreferenceCategory android:title="Video">

<rikka.material.preference.MaterialSwitchPreference
app:key="videoquality"
app:summary="@string/videoquality_sum"
app:title="@string/videoquality" />

<rikka.material.preference.MaterialSwitchPreference
app:dependency="videoquality"
app:key="video_size_limit"
app:summary="Increase Video size limit to 90MB"
app:title="Increase Video Size Limit" />

<rikka.material.preference.MaterialSwitchPreference
app:dependency="videoquality"
app:key="video_real_resolution"
app:summary="Send Video in Real Resolution for for status, group and chats"
app:title="Send Video in Real Resolution" />

<rikka.material.preference.MaterialSwitchPreference
app:dependency="videoquality"
app:key="video_maxfps"
app:summary="Send Video in 60 fps for status, group and chats"
app:title="Send Video in 60fps" />

</PreferenceCategory>


</PreferenceScreen>

0 comments on commit aa4a2d0

Please sign in to comment.