Skip to content

Commit

Permalink
优化在没有替换视频的处理流程,避免卡住。
Browse files Browse the repository at this point in the history
  • Loading branch information
w2016561536 committed Oct 1, 2021
1 parent bcb8b13 commit 197f978
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.example.vcam"
minSdk 21
targetSdk 28
versionCode 16
versionName "3.3"
versionCode 17
versionName "3.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 16,
"versionName": "3.3",
"versionCode": 17,
"versionName": "3.4",
"outputFile": "app-release.apk"
}
],
Expand Down
36 changes: 27 additions & 9 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class HookMain implements IXposedHookLoadPackage {

public static Camera data_camera;
public static Camera start_preview_camera;
public static volatile byte[] data_buffer;
public static volatile byte[] data_buffer = {0};
public static byte[] input;
public static int mhight;
public static int mwidth;
Expand Down Expand Up @@ -104,7 +104,7 @@ protected void beforeHookedMethod(MethodHookParam param) {
if (param.args[0] == null) {
return;
}
if (param.args[0].equals(c1_fake_texture)) {
if (param.args[0].equals(c1_fake_texture)){
return;
}
if (reallycamera != null && reallycamera.equals(param.thisObject)) {
Expand Down Expand Up @@ -144,6 +144,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!file.exists()) {
if (toast_content != null) {
Toast.makeText(toast_content, "不存在替换视频", Toast.LENGTH_SHORT).show();
return;
}
}
XposedBridge.log("1位参数初始化相机,类:" + c2_state_callback.toString());
Expand All @@ -165,6 +166,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!file.exists()) {
if (toast_content != null) {
Toast.makeText(toast_content, "不存在替换视频", Toast.LENGTH_SHORT).show();
return;
}
}
c2_state_callback = param.args[2].getClass();
Expand Down Expand Up @@ -216,11 +218,13 @@ protected void beforeHookedMethod(MethodHookParam param) {
@Override
protected void afterHookedMethod(MethodHookParam param) {
XposedBridge.log("4参数拍照");
if (param.args[1] == null) {
process_a_shot_jpeg(param, 3);
} else {
if (param.args[1] != null) {
process_a_shot_YUV(param);
}

if (param.args[3] != null) {
process_a_shot_jpeg(param, 3);
}
}
});

Expand All @@ -236,7 +240,7 @@ protected void afterHookedMethod(MethodHookParam param) {
}
});*/

XposedHelpers.findAndHookMethod("android.media.MediaRecorder", lpparam.classLoader, "setCamera", Camera.class, new XC_MethodHook() {
/*XposedHelpers.findAndHookMethod("android.media.MediaRecorder", lpparam.classLoader, "setCamera", Camera.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
Expand All @@ -246,7 +250,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
param.args[0] = null;
}
});
});*/

XposedHelpers.findAndHookMethod("android.app.Instrumentation", lpparam.classLoader, "callApplicationOnCreate", Application.class, new XC_MethodHook() {
@Override
Expand All @@ -261,6 +265,13 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.hardware.Camera", lpparam.classLoader, "startPreview", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/virtual.mp4");
if (!file.exists()) {
if (toast_content != null) {
Toast.makeText(toast_content, "不存在替换视频", Toast.LENGTH_SHORT).show();
return;
}
}
is_someone_playing = false;
XposedBridge.log("开始预览");
start_preview_camera = (Camera) param.thisObject;
Expand Down Expand Up @@ -349,6 +360,13 @@ public void onPrepared(MediaPlayer mp) {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("添加Surfaceview预览");
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/virtual.mp4");
if (!file.exists()) {
if (toast_content != null) {
Toast.makeText(toast_content, "不存在替换视频", Toast.LENGTH_SHORT).show();
return;
}
}
mcamera1 = (Camera) param.thisObject;
ori_holder = (SurfaceHolder) param.args[0];
if (c1_fake_texture == null) {
Expand Down Expand Up @@ -763,7 +781,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
onemhight = loaclcam.getParameters().getPreviewSize().height;
XposedBridge.log("YUV拍照回调初始化:宽:" + onemwidth + "高:" + onemhight + "对应的类:" + loaclcam.toString());
if (toast_content != null) {
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:YUV_420_888", Toast.LENGTH_LONG).show();
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:YUV_420_888" , Toast.LENGTH_LONG).show();
}
input = getYUVByBitmap(getBMP(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/1000.bmp"));
paramd.args[0] = input;
Expand Down Expand Up @@ -792,7 +810,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
int frame_Rate = data_camera.getParameters().getPreviewFrameRate();
XposedBridge.log("帧预览回调初始化:宽:" + mwidth + " 高:" + mhight + " 帧率:" + frame_Rate);
if (toast_content != null) {
Toast.makeText(toast_content, ":" + mwidth + "\n高:" + mhight + "\n" + "帧率:" + frame_Rate, Toast.LENGTH_LONG).show();
Toast.makeText(toast_content, "发现预览\n:" + mwidth + "\n高:" + mhight + "\n" + "需要完全匹配分辨率", Toast.LENGTH_LONG).show();
}
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/virtual.mp4");
if (!file.exists()) {
Expand Down

0 comments on commit 197f978

Please sign in to comment.