Skip to content

Commit

Permalink
修复bug,也把使用说明写在里面了
Browse files Browse the repository at this point in the history
  • Loading branch information
w2016561536 committed Aug 28, 2021
1 parent 7a82360 commit 1271f44
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified app/release/app-release.apk
Binary file not shown.
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
android:supportsRtl="true"
android:theme="@style/Theme.VCAM">

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.VCAM">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>



<meta-data
android:name="xposedmodule"
Expand Down
25 changes: 10 additions & 15 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,44 +208,39 @@ public void onPrepared(MediaPlayer mp) {
@SuppressLint("SdCardPath")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (param.args[0] == null){
return;
if (param.args[0] != null) {
process_callback(param);
}
process_callback(param);
}
});

XposedHelpers.findAndHookMethod("android.hardware.Camera", lpparam.classLoader, "addCallbackBuffer", byte[].class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (param.args[0] == null){
return;
if (param.args[0] != null) {
param.args[0] = new byte[((byte[])param.args[0]).length];
}
Camera thiscam = (Camera) param.thisObject;
param.args[0] = new byte[thiscam.getParameters().getPreviewSize().width*thiscam.getParameters().getPreviewSize().height*3/2];
}
});

XposedHelpers.findAndHookMethod("android.hardware.Camera", lpparam.classLoader, "setPreviewCallback", Camera.PreviewCallback.class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (param.args[0] == null){
return;
if (param.args[0] != null) {
process_callback(param);
}
process_callback(param);
}
});

XposedHelpers.findAndHookMethod("android.hardware.Camera", lpparam.classLoader, "setOneShotPreviewCallback", Camera.PreviewCallback.class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (param.args[0] == null){
return;
if (param.args[0] != null) {
process_callback(param);
}
process_callback(param);
}
});

Expand Down Expand Up @@ -279,7 +274,7 @@ protected void afterHookedMethod(MethodHookParam param) {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
XposedBridge.log("在录象,已打断");
XposedBridge.log("在录像,已打断");
param.args[0] = null;
}
});
Expand Down Expand Up @@ -346,7 +341,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
@SuppressLint("SdCardPath")
public void process_a_shot_YUV(XC_MethodHook.MethodHookParam param) {
try {
XposedBridge.log("发现拍照raw:" + param.args[1].toString());
XposedBridge.log("发现拍照YUV:" + param.args[1].toString());
} catch (Exception eee) {
XposedBridge.log(eee.toString());

Expand Down
16 changes: 0 additions & 16 deletions app/src/main/java/com/example/vcam/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,5 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button = (Button) findViewById(R.id.button);
EditText viewt1 =(EditText) findViewById(R.id.editTextTextPersonName);
SharedPreferences stored_id = getSharedPreferences("camera_id", Context.MODE_PRIVATE);
String Texture_path = stored_id.getString("id","");

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View viewa) {
String text_string = viewt1.getText().toString();
SharedPreferences.Editor ideditor = stored_id.edit();
ideditor.putString("id",text_string);
ideditor.commit();
Toast Toast1 =Toast.makeText(getApplicationContext(),"已保存",Toast.LENGTH_SHORT);
Toast1.show();
}
});
}
}
65 changes: 19 additions & 46 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,34 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/editTextTextPersonName"
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="38dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="36dp"
android:ems="10"
android:hint="@string/text1"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintBottom_toTopOf="@+id/editTextTextPersonName2"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:text="@string/_1_xposed_xposed_edxp_lsp_vmos_2_lsp_app_3_virtual_mp4_sdcard_dcim_camera_4_premiere_bmp_premiere_1000_1_bmp_sdcard_dcim_camera_bmp_5"
app:layout_constraintBottom_toTopOf="@+id/textView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TouchTargetSizeCheck" />

<EditText
android:id="@+id/editTextTextPersonName2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="14dp"
android:layout_marginEnd="14dp"
android:layout_marginBottom="31dp"
android:ems="10"
android:hint="@string/text2"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName"
tools:ignore="TouchTargetSizeCheck" />
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="240dp"
android:text="@string/textureview_m3u8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button" />

<Button
android:id="@+id/button"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:text="保存"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="38dp"
android:inputType="text"
android:scrollbarSize="20dp"
android:text="请勿用于任何非法用途,所有后果自负"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName2" />
app:layout_constraintTop_toBottomOf="@+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<string name="text1">替换预览资源,空为停用</string>
<string name="text2">回调资源,仅支持本地YUV420,空为停用</string>
<string name="textureview_m3u8">注:预览资源指TextureView的替换,支持视频(支持在线资源,如M3U8)\n回调资源指onPreviewFrame的替换,仅支持本地YUV420的图片,添加图片请确认图片尺寸与摄像头预览尺寸匹配(可在xposed的日志中看到摄像头预览尺寸)</string>
<string name="_1_xposed_xposed_edxp_lsp_vmos_2_lsp_app_3_virtual_mp4_sdcard_dcim_camera_4_premiere_bmp_premiere_1000_1_bmp_sdcard_dcim_camera_bmp_5">## 具体的使用方法:\n\n 1、安装xposed框架(传统xposed,edxp,lsp等均可,不确定虚拟框架能否使用,已经确定VMOS可用,应用转生不可用) \n\n2、安装模块,启用模块,lsp等包含定义域的框架需要选勾目标app,但无需选勾系统框架。 \n\n3、对于大多数应用,只需要将替换的视频命名为virtual.mp4,放在/sdcard/DCIM/Camera/目录下。 \n\n4、对于少部分应用(如腾讯会议,和其他应用大部分的二维码扫描),需要使用premiere或其它剪辑软件将视频拆分成BMP格式图片(命名格式:1000.bmp,1001.bmp,1002.bmp…………,最少1张图片,最大不超过1000张。premiere中视频总帧数超过1000帧,导出时名字设置为1.bmp,会自动按以上的命名格式命名),要注意的是图片分辨率需要与目标分辨率匹配(可在xposed日志中看到),将这些图片放在/sdcard/DCIM/Camera/bmp/目录下(没有的话自己创建)。 \n\n5、强制结束目标应用/重启手机。\n\n 开源地址:https://github.com/w2016561536/android_virtual_cam </string>
</resources>

0 comments on commit 1271f44

Please sign in to comment.