P/Invoke传递的callback中会用到的一个很有用的属性

本文讨论了在.NET环境中调用C/C++导出的函数时,如何处理不同函数调用约定导致的问题,特别是在需要传递委托(callback delegate)的情况下。.NET 2.0引入了UnmanagedFunctionPointerAttribute特性来指定委托的调用约定,解决了这一难题。

就像这个帖子中提到的,如果要调用C/C++ dll export出来的一个函数,并且要传一个callback的delegate进去,就会产生一个问题: delegate默认的函数调用约定是stdcall,但是C++端一般会要求这个callback是cdecl的。这个问题在.net 1.1中没有好的解决方法,只能反汇编你的assembly然后手动修改对应delegate的属性。

在.net 2.0中,可以使用UnmanagedFunctionPointer Attribute来解决这个问题。因为它可以控制delegate中函数调用的calling convention。这个在.net CF编程中应该会比较有用,希望能够帮助有此需求的朋友。

package com.example.vcam; import android.Manifest; import android.app.Application; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.SurfaceTexture; //import android.hardware.Camera; import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CaptureFailure; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.params.InputConfiguration; import android.hardware.camera2.params.OutputConfiguration; import android.hardware.camera2.params.SessionConfiguration; import android.media.MediaPlayer; import android.os.Build; import android.os.Environment; import android.os.Handler; import android.view.Surface; import android.view.SurfaceHolder; import android.view.View; import android.widget.Toast; import com.example.vcam.event.EventProxyHandler; import com.example.vcam.event.SomeEvent; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.concurrent.Executor; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.callbacks.XC_LoadPackage; public class HookMain implements IXposedHookLoadPackage { public static Surface mSurface; public static SurfaceTexture mSurfacetexture; public static MediaPlayer mMediaPlayer; public static SurfaceTexture fake_SurfaceTexture; //public static Camera origin_preview_camera; //public static Camera camera_onPreviewFrame; //public static Camera start_preview_camera; public static volatile byte[] data_buffer = {0}; public static byte[] input; public static int mhight; public static int mwidth; public static boolean is_someone_playing; public static boolean is_hooked; public static VideoToFrames hw_decode_obj; public static VideoToFrames c2_hw_decode_obj; public static VideoToFrames c2_hw_decode_obj_1; public static SurfaceTexture c1_fake_texture; public static Surface c1_fake_surface; public static SurfaceHolder ori_holder; public static MediaPlayer mplayer1; //public static Camera mcamera1; public int imageReaderFormat = 0; public static boolean is_first_hook_build = true; public static int onemhight; public static int onemwidth; public static Class camera_callback_calss; public static String video_path = "/storage/emulated/0/DCIM/Camera1/"; public static Surface c2_preview_Surfcae; public static Surface c2_preview_Surfcae_1; public static Surface c2_reader_Surfcae; public static Surface c2_reader_Surfcae_1; public static MediaPlayer c2_player; public static MediaPlayer c2_player_1; public static Surface c2_virtual_surface; public static SurfaceTexture c2_virtual_surfaceTexture; public boolean need_recreate; public static CameraDevice.StateCallback c2_state_cb; public static CaptureRequest.Builder c2_builder; public static SessionConfiguration fake_sessionConfiguration; public static SessionConfiguration sessionConfiguration; public static OutputConfiguration outputConfiguration; public boolean need_to_show_toast = true; private static Context appContext; public int c2_ori_width = 1280; public int c2_ori_height = 720; public static Class c2_state_callback; public Context toast_content; private static ClassLoader hostClassLoader; // 视频源管理器 //public static VideoSourceManager videoSourceManager = new VideoSourceManager(); VideoSourceManager manager = VideoSourceManager.getInstance(); public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Exception { // 初始化视频源管理器 if (manager == null) { manager = new VideoSourceManager(); } // 添加默认视频源 String defaultVideo = video_path + "virtual.mp4"; manager.addVideoSource("default", defaultVideo); manager.setCurrentSource("default"); if (lpparam.packageName.equals("com.example.vcam")){ XposedBridge.log("【VCAM】event2 " + lpparam.packageName); hostClassLoader = lpparam.classLoader; Class<?> mainActivityClass = hostClassLoader.loadClass( "com.example.vcam.MainActivity" ); Class<?> iEventInterface = hostClassLoader.loadClass( "com.example.vcam.IEvent" ); XposedHelpers.findAndHookMethod(mainActivityClass,"onEvent", iEventInterface,new XC_MethodHook(){ @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { //XposedBridge.log("【VCAM】event2 onEvent" ); Object event = param.args[0]; // EventProxyHandler.handleEvent( // event, // event.getClass() // 使用实际运行时类 // ); Method getMessage = iEventInterface.getMethod("getMessage"); String MessageStr = (String) getMessage.invoke(event); Method getBeiCan1 = iEventInterface.getMethod("getBeiCan1"); String BeiCan1Str = (String) getBeiCan1.invoke(event); XposedBridge.log("【VCAM】event " + MessageStr); XposedBridge.log("【VCAM】eventpath " + BeiCan1Str); if (MessageStr == "qiehuan1") { String sourceName = "source_virtual21"; // 添加新视频源(如果不存在) if (!manager.videoSources.containsKey(sourceName)) { manager.addVideoSource(sourceName, BeiCan1Str); } // 切换到新视频源 manager.switchToSource(sourceName); // 通知相机重启 // manager.onCameraRestart(); // 强制重启相机 // forceRestartCamera(lpparam); process_camera2_play(); } } }); } XposedHelpers.findAndHookMethod("android.hardware.camera2.CameraManager", lpparam.classLoader, "openCamera", String.class, CameraDevice.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (param.args[1] == null) { return; } if (param.args[1].equals(c2_state_cb)) { return; } c2_state_cb = (CameraDevice.StateCallback) param.args[1]; c2_state_callback = c2_state_cb.getClass(); //param.args[1].getClass(); File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { return; } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + lpparam.packageName + "当前路径1:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } XposedBridge.log("【VCAM】1位参数初始化相机,类:" + c2_state_callback.getName().toString()); is_first_hook_build = true; process_camera2_init(c2_state_callback); if(c2_state_callback ==null){ XposedBridge.log("【VCAM】c2_state_callback33 为null" ); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { XposedHelpers.findAndHookMethod("android.hardware.camera2.CameraManager", lpparam.classLoader, "openCamera", String.class, Executor.class, CameraDevice.StateCallback.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】2位参数初始化相机,类:" + c2_state_callback.toString()); if (param.args[2] == null) { return; } if (param.args[2].equals(c2_state_cb)) { return; } c2_state_cb = (CameraDevice.StateCallback) param.args[2]; File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { return; } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + lpparam.packageName + "当前路径2:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } c2_state_callback = param.args[2].getClass(); XposedBridge.log("【VCAM】2位参数初始化相机,类:" + c2_state_callback.toString()); is_first_hook_build = true; process_camera2_init(c2_state_callback); } }); } // XposedHelpers.findAndHookMethod("android.media.MediaRecorder", lpparam.classLoader, "setCamera", Camera.class, new XC_MethodHook() { // @Override // protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // super.beforeHookedMethod(param); // File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); // need_to_show_toast = !toast_control.exists(); // XposedBridge.log("【VCAM】[record]" + lpparam.packageName); // if (toast_content != null && need_to_show_toast) { // try { // Toast.makeText(toast_content, "应用:" + lpparam.appInfo.name + "(" + lpparam.packageName + ")" + "触发了录像,但目前无法拦截", Toast.LENGTH_SHORT).show(); // }catch (Exception ee){ // XposedBridge.log("【VCAM】[toast]" + Arrays.toString(ee.getStackTrace())); // } // } // } // }); XposedHelpers.findAndHookMethod("android.app.Instrumentation", lpparam.classLoader, "callApplicationOnCreate", Application.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { super.afterHookedMethod(param); if (param.args[0] instanceof Application) { try { toast_content = ((Application) param.args[0]).getApplicationContext(); } catch (Exception ee) { XposedBridge.log("【VCAM】" + ee.toString()); } File force_private = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera1/private_dir.jpg"); if (toast_content != null) {//后半段用于强制私有目录 int auth_statue = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { try { auth_statue += (toast_content.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) + 1); } catch (Exception ee) { XposedBridge.log("【VCAM】[permission-check]" + ee.toString()); } try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { auth_statue += (toast_content.checkSelfPermission(Manifest.permission.MANAGE_EXTERNAL_STORAGE) + 1); } } catch (Exception ee) { XposedBridge.log("【VCAM】[permission-check]" + ee.toString()); } }else { if (toast_content.checkCallingPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ){ auth_statue = 2; } } //权限判断完毕 if (auth_statue < 1 || force_private.exists()) { File shown_file = new File(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/"); if ((!shown_file.isDirectory()) && shown_file.exists()) { shown_file.delete(); } if (!shown_file.exists()) { shown_file.mkdir(); } shown_file = new File(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/" + "has_shown"); File toast_force_file = new File(Environment.getExternalStorageDirectory().getPath()+ "/DCIM/Camera1/force_show.jpg"); if ((!lpparam.packageName.equals(BuildConfig.APPLICATION_ID)) && ((!shown_file.exists()) || toast_force_file.exists())) { try { Toast.makeText(toast_content, lpparam.packageName+"未授予读取本地目录权限,请检查权限\nCamera1目前重定向为 " + toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/", Toast.LENGTH_SHORT).show(); FileOutputStream fos = new FileOutputStream(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/" + "has_shown"); String info = "shown"; fos.write(info.getBytes()); fos.flush(); fos.close(); } catch (Exception e) { XposedBridge.log("【VCAM】[switch-dir]" + e.toString()); } } video_path = toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/"; }else { video_path = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"; } } else { video_path = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"; File uni_DCIM_path = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"); if (uni_DCIM_path.canWrite()) { File uni_Camera1_path = new File(video_path); if (!uni_Camera1_path.exists()) { uni_Camera1_path.mkdir(); } } } } } }); XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "addTarget", Surface.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { if (param.args[0] == null) { return; } if (param.thisObject == null) { return; } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + lpparam.packageName + "当前路径3:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } if (param.args[0].equals(c2_virtual_surface)) { return; } File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { return; } String surfaceInfo = param.args[0].toString(); if (surfaceInfo.contains("Surface(name=null)")) { if (c2_reader_Surfcae == null) { c2_reader_Surfcae = (Surface) param.args[0]; } else { if ((!c2_reader_Surfcae.equals(param.args[0])) && c2_reader_Surfcae_1 == null) { c2_reader_Surfcae_1 = (Surface) param.args[0]; } } } else { if (c2_preview_Surfcae == null) { c2_preview_Surfcae = (Surface) param.args[0]; } else { if ((!c2_preview_Surfcae.equals(param.args[0])) && c2_preview_Surfcae_1 == null) { c2_preview_Surfcae_1 = (Surface) param.args[0]; } } } XposedBridge.log("【VCAM】添加目标:" + param.args[0].toString()); if(c2_state_callback ==null){ XposedBridge.log("【VCAM】c2_state_callback4 为null" ); } param.args[0] = c2_virtual_surface; } }); XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "addTarget", Surface.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Surface surface = (Surface) param.args[0]; // VideoSourceManager.getInstance().prepareForSurface(surface); } }); XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "removeTarget", Surface.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { if (param.args[0] == null) { return; } if (param.thisObject == null) { return; } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + lpparam.packageName + "当前路径4:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { return; } Surface rm_surf = (Surface) param.args[0]; if (rm_surf.equals(c2_preview_Surfcae)) { c2_preview_Surfcae = null; } if (rm_surf.equals(c2_preview_Surfcae_1)) { c2_preview_Surfcae_1 = null; } if (rm_surf.equals(c2_reader_Surfcae_1)) { c2_reader_Surfcae_1 = null; } if (rm_surf.equals(c2_reader_Surfcae)) { c2_reader_Surfcae = null; } XposedBridge.log("【VCAM】移除目标:" + param.args[0].toString()); } }); XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "build", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (param.thisObject == null) { return; } if (param.thisObject.equals(c2_builder)) { return; } c2_builder = (CaptureRequest.Builder) param.thisObject; File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists() && need_to_show_toast) { if (toast_content != null) { try { Toast.makeText(toast_content, "不存在替换视频\n" + lpparam.packageName + "当前路径5:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { return; } XposedBridge.log("【VCAM】开始build请求"); if(c2_state_callback ==null){ XposedBridge.log("【VCAM】c2_state_callback5 为null" ); } process_camera2_play(); // XposedBridge.log("【VCAM】c2_state_callback6 为null" ); } }); XposedHelpers.findAndHookMethod("android.media.ImageReader", lpparam.classLoader, "newInstance", int.class, int.class, int.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { XposedBridge.log("【VCAM】应用创建了渲染器:宽:" + param.args[0] + " 高:" + param.args[1] + "格式" + param.args[2]); c2_ori_width = (int) param.args[0]; c2_ori_height = (int) param.args[1]; imageReaderFormat = (int) param.args[2]; File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "应用创建了渲染器:\n宽:" + param.args[0] + "\n高:" + param.args[1] + "\n一般只需要宽高比与视频相同", Toast.LENGTH_SHORT).show(); } catch (Exception e) { XposedBridge.log("【VCAM】[toast]" + e.toString()); } } } }); XposedHelpers.findAndHookMethod("android.hardware.camera2.CameraCaptureSession.CaptureCallback", lpparam.classLoader, "onCaptureFailed", CameraCaptureSession.class, CaptureRequest.class, CaptureFailure.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { XposedBridge.log("【VCAM】onCaptureFailed" + "原因:" + ((CaptureFailure) param.args[2]).getReason()); } }); } private void process_camera2_play() { if (c2_reader_Surfcae != null) { XposedBridge.log("【VCAM c2_reader_Surfcae 非空】" ); if (c2_hw_decode_obj != null) { c2_hw_decode_obj.stopDecode(); c2_hw_decode_obj = null; } c2_hw_decode_obj = new VideoToFrames(); try { if (imageReaderFormat == 256) { c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.JPEG); } else { c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.NV21); } c2_hw_decode_obj.set_surfcae(c2_reader_Surfcae); // c2_hw_decode_obj.decode(video_path + "virtual.mp4"); c2_hw_decode_obj.decode(VideoSourceManager.getInstance().getCurrentSource().path); } catch (Throwable throwable) { XposedBridge.log("【VCAM】" + throwable); } } if (c2_reader_Surfcae_1 != null) { XposedBridge.log("【VCAM c2_reader_Surfcae_1 非空】" ); if (c2_hw_decode_obj_1 != null) { c2_hw_decode_obj_1.stopDecode(); c2_hw_decode_obj_1 = null; } c2_hw_decode_obj_1 = new VideoToFrames(); try { if (imageReaderFormat == 256) { c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.JPEG); } else { c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.NV21); } c2_hw_decode_obj_1.set_surfcae(c2_reader_Surfcae_1); // c2_hw_decode_obj_1.decode(video_path + "virtual.mp4"); c2_hw_decode_obj_1.decode(VideoSourceManager.getInstance().getCurrentSource().path); } catch (Throwable throwable) { XposedBridge.log("【VCAM】" + throwable); } } if (c2_preview_Surfcae != null) { XposedBridge.log("【VCAM c2_preview_Surfcae 非空】" ); if (c2_player == null) { c2_player = new MediaPlayer(); } else { c2_player.release(); c2_player = new MediaPlayer(); } c2_player.setSurface(c2_preview_Surfcae); File sfile = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no-silent.jpg"); if (!sfile.exists()) { c2_player.setVolume(0, 0); } c2_player.setLooping(true); try { c2_player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mp) { c2_player.start(); } }); // c2_player.setDataSource(video_path + "virtual.mp4"); c2_player.setDataSource(VideoSourceManager.getInstance().getCurrentSource().path); c2_player.prepare(); } catch (Exception e) { XposedBridge.log("【VCAM】[c2player][" + c2_preview_Surfcae.toString() + "]" + e); } } if (c2_preview_Surfcae_1 != null) { XposedBridge.log("【VCAM c2_preview_Surfcae_1 非空】" ); if (c2_player_1 == null) { c2_player_1 = new MediaPlayer(); } else { c2_player_1.release(); c2_player_1 = new MediaPlayer(); } c2_player_1.setSurface(c2_preview_Surfcae_1); File sfile = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no-silent.jpg"); if (!sfile.exists()) { c2_player_1.setVolume(0, 0); } c2_player_1.setLooping(true); try { c2_player_1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mp) { c2_player_1.start(); } }); //c2_player_1.setDataSource(video_path + "virtual.mp4"); c2_player_1.setDataSource(VideoSourceManager.getInstance().getCurrentSource().path); c2_player_1.prepare(); } catch (Exception e) { XposedBridge.log("【VCAM】[c2player1]" + "[ " + c2_preview_Surfcae_1.toString() + "]" + e); } } XposedBridge.log("【VCAM】Camera2处理过程完全执行"); } private Surface create_virtual_surface() { if (need_recreate) { if (c2_virtual_surfaceTexture != null) { c2_virtual_surfaceTexture.release(); c2_virtual_surfaceTexture = null; } if (c2_virtual_surface != null) { c2_virtual_surface.release(); c2_virtual_surface = null; } c2_virtual_surfaceTexture = new SurfaceTexture(15); c2_virtual_surface = new Surface(c2_virtual_surfaceTexture); need_recreate = false; } else { if (c2_virtual_surface == null) { need_recreate = true; c2_virtual_surface = create_virtual_surface(); } } XposedBridge.log("【VCAM】【重建垃圾场】" + c2_virtual_surface.toString()); return c2_virtual_surface; } // 在HookMain类中添加 private void recreateVirtualSurface() { if (c2_virtual_surface != null) { XposedBridge.log("【VCAM】重建虚拟Surface: 1"); c2_virtual_surface.release(); c2_virtual_surface = null; } if (c2_virtual_surfaceTexture != null) { XposedBridge.log("【VCAM】重建虚拟Surface: 2"); c2_virtual_surfaceTexture.release(); c2_virtual_surfaceTexture = null; } c2_virtual_surfaceTexture = new SurfaceTexture(15); c2_virtual_surface = new Surface(c2_virtual_surfaceTexture); need_recreate = false; XposedBridge.log("【VCAM】重建虚拟Surface: " + c2_virtual_surface.toString()); } // 释放Camera2相关资源 private void releaseCamera2Resources() { if (c2_player != null) { c2_player.stop(); c2_player.release(); c2_player = null; } if (c2_player_1 != null) { c2_player_1.stop(); c2_player_1.release(); c2_player_1 = null; } if (c2_hw_decode_obj != null) { c2_hw_decode_obj.stopDecode(); c2_hw_decode_obj = null; } if (c2_hw_decode_obj_1 != null) { c2_hw_decode_obj_1.stopDecode(); c2_hw_decode_obj_1 = null; } c2_preview_Surfcae = null; c2_preview_Surfcae_1 = null; c2_reader_Surfcae = null; c2_reader_Surfcae_1 = null; } private void process_camera2_init(Class hooked_class) { XposedBridge.log("【VCAM】重启跟踪1" ); if(hooked_class==null){ XposedBridge.log("【VCAM】hooked_class 为null" ); } //c2_state_callback if(c2_state_callback ==null){ XposedBridge.log("【VCAM】c2_state_callback1 为null" ); } XposedHelpers.findAndHookMethod(hooked_class, "onOpened", CameraDevice.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】重启跟踪2"); // 重建虚拟Surface recreateVirtualSurface(); XposedBridge.log("【VCAM】重启跟踪3"); // 释放旧资源 releaseCamera2Resources(); XposedBridge.log("【VCAM】重启跟踪4"); XposedBridge.log("【VCAM】相机设备已打开"); XposedBridge.log("【VCAM】打开相机C2"); final CameraDevice cameraDevice = (CameraDevice) param.args[0]; if(c2_state_callback ==null){ XposedBridge.log("【VCAM】c2_state_callback2 为null" ); } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + toast_content.getPackageName() + "当前路径6:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee.toString()); } } return; } XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createCaptureSession", List.class, CameraCaptureSession.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable { // 替换为虚拟Surface paramd.args[0] = Arrays.asList(c2_virtual_surface); XposedBridge.log("【VCAM】配置CaptureSession使用虚拟Surface"); // if (paramd.args[0] != null) { // XposedBridge.log("【VCAM】createCaptureSession创捷捕获,原始:" + paramd.args[0].toString() + "虚拟:" + c2_virtual_surface.toString()); // paramd.args[0] = Arrays.asList(c2_virtual_surface); // if (paramd.args[1] != null) { // process_camera2Session_callback((CameraCaptureSession.StateCallback) paramd.args[1]); // } // } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createCaptureSessionByOutputConfigurations", List.class, CameraCaptureSession.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); if (param.args[0] != null) { outputConfiguration = new OutputConfiguration(c2_virtual_surface); param.args[0] = Arrays.asList(outputConfiguration); XposedBridge.log("【VCAM】执行了createCaptureSessionByOutputConfigurations-144777"); if (param.args[1] != null) { process_camera2Session_callback((CameraCaptureSession.StateCallback) param.args[1]); } } } }); } XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createConstrainedHighSpeedCaptureSession", List.class, CameraCaptureSession.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); if (param.args[0] != null) { param.args[0] = Arrays.asList(c2_virtual_surface); XposedBridge.log("【VCAM】执行了 createConstrainedHighSpeedCaptureSession -5484987"); if (param.args[1] != null) { process_camera2Session_callback((CameraCaptureSession.StateCallback) param.args[1]); } } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createReprocessableCaptureSession", InputConfiguration.class, List.class, CameraCaptureSession.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); if (param.args[1] != null) { param.args[1] = Arrays.asList(c2_virtual_surface); XposedBridge.log("【VCAM】执行了 createReprocessableCaptureSession "); if (param.args[2] != null) { process_camera2Session_callback((CameraCaptureSession.StateCallback) param.args[2]); } } } }); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createReprocessableCaptureSessionByConfigurations", InputConfiguration.class, List.class, CameraCaptureSession.StateCallback.class, Handler.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); if (param.args[1] != null) { outputConfiguration = new OutputConfiguration(c2_virtual_surface); param.args[0] = Arrays.asList(outputConfiguration); XposedBridge.log("【VCAM】执行了 createReprocessableCaptureSessionByConfigurations"); if (param.args[2] != null) { process_camera2Session_callback((CameraCaptureSession.StateCallback) param.args[2]); } } } }); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createCaptureSession", SessionConfiguration.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); if (param.args[0] != null) { XposedBridge.log("【VCAM】执行了 createCaptureSession -5484987"); sessionConfiguration = (SessionConfiguration) param.args[0]; outputConfiguration = new OutputConfiguration(c2_virtual_surface); fake_sessionConfiguration = new SessionConfiguration(sessionConfiguration.getSessionType(), Arrays.asList(outputConfiguration), sessionConfiguration.getExecutor(), sessionConfiguration.getStateCallback()); param.args[0] = fake_sessionConfiguration; process_camera2Session_callback(sessionConfiguration.getStateCallback()); } } }); } } }); XposedHelpers.findAndHookMethod(hooked_class, "onError", CameraDevice.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】相机错误onerror:" + (int) param.args[1]); } }); XposedHelpers.findAndHookMethod(hooked_class, "onDisconnected", CameraDevice.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】相机断开onDisconnected :"); } }); } private void process_a_shot_jpeg(XC_MethodHook.MethodHookParam param, int index) { try { XposedBridge.log("【VCAM】第二个jpeg:" + param.args[index].toString()); } catch (Exception eee) { XposedBridge.log("【VCAM】" + eee); } Class callback = param.args[index].getClass(); } private void process_a_shot_YUV(XC_MethodHook.MethodHookParam param) { try { XposedBridge.log("【VCAM】发现拍照YUV:" + param.args[1].toString()); } catch (Exception eee) { XposedBridge.log("【VCAM】" + eee); } Class callback = param.args[1].getClass(); } private void process_callback(XC_MethodHook.MethodHookParam param) { Class preview_cb_class = param.args[0].getClass(); int need_stop = 0; File control_file = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "disable.jpg"); if (control_file.exists()) { need_stop = 1; } File file = new File(video_path + "virtual.mp4"); File toast_control = new File(Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/" + "no_toast.jpg"); need_to_show_toast = !toast_control.exists(); if (!file.exists()) { if (toast_content != null && need_to_show_toast) { try { Toast.makeText(toast_content, "不存在替换视频\n" + toast_content.getPackageName() + "当前路径7:" + video_path, Toast.LENGTH_SHORT).show(); } catch (Exception ee) { XposedBridge.log("【VCAM】[toast]" + ee); } } need_stop = 1; } int finalNeed_stop = need_stop; } private void process_camera2Session_callback(CameraCaptureSession.StateCallback callback_calss){ if (callback_calss == null){ return; } XposedBridge.log("【VCAM】process_camera2Session_callback :" + callback_calss.toString()); XposedHelpers.findAndHookMethod(callback_calss.getClass(), "onConfigureFailed", CameraCaptureSession.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】onConfigureFailed :" + param.args[0].toString()); } }); XposedHelpers.findAndHookMethod(callback_calss.getClass(), "onConfigured", CameraCaptureSession.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】onConfigured :" + param.args.length); CameraCaptureSession aaa = (CameraCaptureSession)param.args[0]; XposedBridge.log("【VCAM】onConfigured :" + param.args[0].toString()); } }); // XposedHelpers.findAndHookMethod( callback_calss.getClass(), "onClosed", CameraCaptureSession.class, new XC_MethodHook() { // @Override // protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // XposedBridge.log("【VCAM】onClosed :"+ param.args[0].toString()); // } // }); } // 强制重启相机方法 private void forceRestartCamera(XC_LoadPackage.LoadPackageParam lpparam) { try { // 1. 关闭当前相机会话 if (c2_state_cb != null) { XposedBridge.log("【VCAM】断开相机链接 onDisconnected"); Method onDisconnected = c2_state_callback.getMethod("onDisconnected", CameraDevice.class); onDisconnected.invoke(c2_state_cb, (Object)null); } // 2. 重建虚拟Surface recreateVirtualSurface(); // 3. 模拟重新打开相机 XposedBridge.log("【VCAM】准备重启相机 openCamera"); if(c2_state_callback !=null){ XposedBridge.log("【VCAM】c2_state_callback " + c2_state_callback.getClass().getName().toString()); } process_camera2_init(c2_state_callback); process_camera2_play(); XposedBridge.log("【VCAM】强制重启相机成功"); } catch (Exception e) { XposedBridge.log("【VCAM】强制重启相机失败: " + e.toString()); } } //以下代码来源:https://blog.csdn.net/jacke121/article/details/73888732 private Bitmap getBMP(String file) throws Throwable { return BitmapFactory.decodeFile(file); } private static byte[] rgb2YCbCr420(int[] pixels, int width, int height) { int len = width * height; // yuv格式数组大小,y亮度占len长度,u,v各占len/4长度。 byte[] yuv = new byte[len * 3 / 2]; int y, u, v; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int rgb = (pixels[i * width + j]) & 0x00FFFFFF; int r = rgb & 0xFF; int g = (rgb >> 8) & 0xFF; int b = (rgb >> 16) & 0xFF; // 套用公式 y = ((66 * r + 129 * g + 25 * b + 128) >> 8) + 16; u = ((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128; v = ((112 * r - 94 * g - 18 * b + 128) >> 8) + 128; y = y < 16 ? 16 : (Math.min(y, 255)); u = u < 0 ? 0 : (Math.min(u, 255)); v = v < 0 ? 0 : (Math.min(v, 255)); // 赋值 yuv[i * width + j] = (byte) y; yuv[len + (i >> 1) * width + (j & ~1)] = (byte) u; yuv[len + +(i >> 1) * width + (j & ~1) + 1] = (byte) v; } } return yuv; } private static byte[] getYUVByBitmap(Bitmap bitmap) { if (bitmap == null) { return null; } int width = bitmap.getWidth(); int height = bitmap.getHeight(); int size = width * height; int[] pixels = new int[size]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); return rgb2YCbCr420(pixels, width, height); } } package com.example.vcam; import android.media.MediaPlayer; import android.view.Surface; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import de.robv.android.xposed.XposedBridge; //VideoSourceManager import android.media.MediaPlayer; import android.view.Surface; import java.io.IOException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import de.robv.android.xposed.XposedBridge; public class VideoSourceManager { private static volatile VideoSourceManager instance; final Map<String, VideoSource> videoSources = new ConcurrentHashMap<>(); private String currentSourceId; private Surface currentSurface; private boolean surfacePrepared = false; private boolean isCameraRestarting = false; public static VideoSourceManager getInstance() { if (instance == null) { synchronized (VideoSourceManager.class) { if (instance == null) { instance = new VideoSourceManager(); } } } return instance; } public static class VideoSource { public final String id; public final String path; public MediaPlayer player; public VideoToFrames decoder; public boolean isInitialized = false; public boolean needsInitialization = false; public boolean isActive = false; public VideoSource(String id, String path) { this.id = id; this.path = path; } public void initialize(Surface surface) { // 如果已使用相同Surface初始化则跳过 if (isInitialized && !needsInitialization) { return; } XposedBridge.log("初始化视频源: " + id + ", Surface: " + surface); // 释放旧资源 releaseResources(); try { // 初始化播放器 player = new MediaPlayer(); player.setDataSource(path); player.setSurface(surface); player.setLooping(true); player.setVolume(0, 0); player.setOnPreparedListener(mp -> { isActive = true; mp.start(); XposedBridge.log("视频源 " + id + " 开始播放"); }); player.setOnErrorListener((mp, what, extra) -> { XposedBridge.log("播放错误: " + what + ", extra: " + extra); return true; }); player.prepareAsync(); // 初始化解码器 decoder = new VideoToFrames(); decoder.set_surfcae(surface); decoder.setSaveFrames("null", OutputImageFormat.NV21); decoder.decode(this.path); isInitialized = true; needsInitialization = false; } catch (Throwable e) { XposedBridge.log("初始化失败: " + e.getMessage()); } } public void releaseResources() { if (player != null) { if (player.isPlaying()) { player.stop(); } player.release(); player = null; XposedBridge.log("释放播放器资源: " + id); } if (decoder != null) { decoder.stopDecode(); decoder = null; XposedBridge.log("释放解码器资源: " + id); } isInitialized = false; isActive = false; } } public void addVideoSource(String id, String path) { if (!videoSources.containsKey(id)) { videoSources.put(id, new VideoSource(id, path)); XposedBridge.log("添加视频源: " + id + ", 路径: " + path); } } public void setCurrentSource(String id) { currentSourceId = id; } public VideoSource getCurrentSource() { return videoSources.get(currentSourceId); } public void prepareForSurface(Surface surface) { // 避免在相机重启过程中处理 if (isCameraRestarting) { XposedBridge.log("相机重启中,跳过Surface准备"); return; } if (surface == null || !surface.isValid()) { XposedBridge.log("无效的Surface,跳过准备"); return; } this.currentSurface = surface; this.surfacePrepared = true; XposedBridge.log("Surface准备就绪: " + surface); VideoSource source = getCurrentSource(); if (source != null) { if (source.needsInitialization) { source.initialize(surface); } else if (source.isInitialized && !source.isActive) { // 如果已初始化但未激活,恢复播放 if (source.player != null && !source.player.isPlaying()) { source.player.start(); source.isActive = true; } } } } public void switchToSource(String sourceId) { XposedBridge.log("切换到视频源: " + sourceId); VideoSource newSource = videoSources.get(sourceId); if (newSource == null) { XposedBridge.log("视频源不存在: " + sourceId); return; } // 暂停当前源 VideoSource current = getCurrentSource(); if (current != null) { if (current.player != null && current.player.isPlaying()) { current.player.pause(); } current.isActive = false; } // 设置新源 currentSourceId = sourceId; // 如果Surface已准备,立即初始化 if (surfacePrepared && currentSurface != null && currentSurface.isValid()) { newSource.initialize(currentSurface); } else { // 标记需要初始化,等待Surface准备 newSource.needsInitialization = true; } } public void onCameraRestart() { XposedBridge.log("相机重启事件"); isCameraRestarting = true; // 暂停所有视频源 for (VideoSource source : videoSources.values()) { if (source.player != null && source.player.isPlaying()) { source.player.pause(); } source.isActive = false; // 标记需要重新初始化 source.needsInitialization = true; } // 重置Surface状态 currentSurface = null; surfacePrepared = false; isCameraRestarting = false; } public void resumePlayback() { VideoSource source = getCurrentSource(); if (source != null && source.isInitialized && !source.isActive) { if (source.player != null && !source.player.isPlaying()) { source.player.start(); source.isActive = true; } } } } 在不重启相机的情况下,如何切换视频源
06-22
#include "form_voip.h" #include "ui_form_voip.h" #include "parammanager.h" #include <QPushButton> #include <QMediaDevices> #include <QVideoSink> #include <QCamera> #include <QTimer> #include <QAudioInput> #include <QVideoFrame> using namespace pj; class MyEndpoint : public Endpoint { public: MyEndpoint() : Endpoint() {}; virtual pj_status_t onCredAuth(OnCredAuthParam &prm) { PJ_UNUSED_ARG(prm); std::cout << "*** Callback onCredAuth called ***" << std::endl; /* Return PJ_ENOTSUP to use * pjsip_auth_create_aka_response()/<b>libmilenage</b> (default), * if PJSIP_HAS_DIGEST_AKA_AUTH is defined. */ return PJ_ENOTSUP; } }; class MyAccount; class MyAudioMediaPort: public AudioMediaPort { virtual void onFrameRequested(MediaFrame &frame) { // Give the input frame here frame.type = PJMEDIA_FRAME_TYPE_AUDIO; // frame.buf.assign(frame.size, 'c'); } virtual void onFrameReceived(MediaFrame &frame) { PJ_UNUSED_ARG(frame); // Process the incoming frame here } }; class MyCall : public Call { private: MyAccount *myAcc; AudioMediaPlayer *wav_player; AudioMediaPort *med_port; // 视频窗口指针 VideoWindow *localVideoWin = nullptr; VideoWindow *remoteVideoWin = nullptr; public: MyCall(Account &acc, int call_id = PJSUA_INVALID_ID) : Call(acc, call_id) { wav_player = NULL; med_port = NULL; myAcc = (MyAccount *)&acc; } ~MyCall() { if (wav_player) delete wav_player; if (med_port) delete med_port; // 清理视频窗口 if (localVideoWin) delete localVideoWin; if (remoteVideoWin) delete remoteVideoWin; } virtual void onCallState(OnCallStateParam &prm); virtual void onCallTransferRequest(OnCallTransferRequestParam &prm); virtual void onCallReplaceRequest(OnCallReplaceRequestParam &prm); virtual void onCallMediaState(OnCallMediaStateParam &prm); }; class MyAccount : public Account { public: std::vector<Call *> calls; public: MyAccount() {} ~MyAccount() { std::cout << "*** Account is being deleted: No of calls=" << calls.size() << std::endl; for (std::vector<Call *>::iterator it = calls.begin(); it != calls.end(); ) { delete (*it); it = calls.erase(it); } } void removeCall(Call *call) { for (std::vector<Call *>::iterator it = calls.begin(); it != calls.end(); ++it) { if (*it == call) { calls.erase(it); break; } } } //‌ OnRegStateParam ‌是 PJSUA2 开发框架中的一个参数类,用于处理注册状态的变化。当帐户的注册状态发生变化时, Account 类会触发一个事件,该事件传递 OnRegStateParam 参数,其中包含了注册状态变化的详细信息。 virtual void onRegState(OnRegStateParam &prm) { AccountInfo ai = getInfo(); std::cout << (ai.regIsActive? "***** Register: code=" : "***** Unregister: code=") << prm.code << std::endl; } virtual void onIncomingCall(OnIncomingCallParam &iprm) { Call *call = new MyCall(*this, iprm.callId); CallInfo ci = call->getInfo(); CallOpParam prm; std::cout << "*** Incoming Call: " << ci.remoteUri << " [" << ci.stateText << "]" << std::endl; calls.push_back(call); prm.statusCode = (pjsip_status_code)200; // 2.15.1 必须设置这两个参数 prm.opt.videoCount = 1; //opt 是 CallSetting 类型 call->answer(prm); //currentCall = call; // 启动来电铃声 // pjmedia_tonegen_param toneParam; // pj_bzero(&toneParam, sizeof(toneParam)); // toneParam.flags = PJMEDIA_TONEGEN_LOOP; // toneParam.tones[0].freq1 = 440; // 音频频率 // toneParam.tones[0].duration = -1; // 持续时间(无限循环) // pjmedia_tonegen_create(pjsua_get_media_transport(), NULL, &toneParam, &call->ringToneId); //使用 pjmedia_tonegen_create 函数创建一个音频生成器来播放铃声。上述代码中,ringToneId 是生成的铃声音频流 ID,用于后续停止铃声 //当用户点击接听按钮时,可以通过调用 answer 方法接听电话,并停止铃声播放 // void MyCall::answerCall() { // CallOpParam answer_op; // answer_op.statusCode = PJSIP_SC_OK; // 使用 200 OK 表示接听电话 // answer(answer_op); // // 停止来电铃声 // if (ringToneId != PJMEDIA_TONEGEN_ID_INVALID) { // pjmedia_tonegen_destroy(ringToneId); // ringToneId = PJMEDIA_TONEGEN_ID_INVALID; // } // PJ_LOG(3, (pj_get_log_writer(), "Call answered!")); // } // 假设这是 GUI 框架中的按钮点击事件处理函数 // void onAnswerButtonClicked(MyCall *call) { // call->answerCall(); // } } // void MyAccount::onIncomingCall(OnIncomingCallParam &iprm) { // PJ_LOG(3, (pj_get_log_writer(), "Incoming call from %.*s!", // (int)iprm.rinfo.fromUri.slen, iprm.rinfo.fromUri.ptr)); // // 创建一个新的 Call 对象 // MyCall *call = new MyCall(*this, iprm.callId); // // 启动来电铃声 // pjmedia_tonegen_param toneParam; // pj_bzero(&toneParam, sizeof(toneParam)); // toneParam.flags = PJMEDIA_TONEGEN_LOOP; // toneParam.tones[0].freq1 = 440; // 音频频率 // toneParam.tones[0].duration = -1; // 持续时间(无限循环) // pjmedia_tonegen_create(pjsua_get_media_transport(), NULL, &toneParam, &call->ringToneId); // } }; //condition_variable cv; void MyCall::onCallState(OnCallStateParam &prm) { PJ_UNUSED_ARG(prm); CallInfo ci = getInfo(); std::cout << "*** Call: " << ci.remoteUri << " [" << ci.stateText << "]" << std::endl; if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { //myAcc->removeCall(this); /* Delete the call */ //delete this; } else if (ci.state == PJSIP_INV_STATE_CONFIRMED) { std::cout << "*** 通话已连接" << std::endl; //callConnected = true; //cv.notify_one(); } } // 创建视频窗口 // void createVideoWindows(int med_idx) { // // 获取视频媒体 // VideoMedia vid_med = getVideoMedia(med_idx); // // 创建本地预览窗口 // VideoPreviewOpParam pre_param; // VideoWindowHandle wnd_handle; // try { // VideoPreview *preview = vid_med.startPreview(pre_param); // VideoWindow win = preview->getVideoWindow(); // win.Show(true); // cout << "本地预览窗口ID: " << win.getInfo().winId << endl; // } catch(Error& err) { // cout << "预览窗口错误: " << err.info() << endl; // } // // 创建远程视频窗口 // try { // VideoWindow remote_win = vid_med.getRemoteVideoWindow(); // remote_win.Show(true); // cout << "远程视频窗口ID: " << remote_win.getInfo().winId << endl; // } catch(Error& err) { // cout << "远程窗口错误: " << err.info() << endl; // } // } void MyCall::onCallMediaState(OnCallMediaStateParam &prm) { PJ_UNUSED_ARG(prm); CallInfo ci = getInfo(); AudioMedia aud_med; AudioMedia& play_dev_med = MyEndpoint::instance().audDevManager().getPlaybackDevMedia(); qDebug()<<"AudioMedia& play_dev_med = MyEndpoint::instance().audDevManager().getPlaybackDevMedia();"; try { // Get the first audio media aud_med = getAudioMedia(-1); } catch(...) { std::cout << "Failed to get audio media" << std::endl; return; } if (!wav_player) { wav_player = new AudioMediaPlayer(); try { wav_player->createPlayer( "./closecall.wav", 0); std::cout << "Success opened wav file" << std::endl; } catch (...) { std::cout << "Failed opening wav file" << std::endl; delete wav_player; wav_player = NULL; } } // This will connect the wav file to the call audio media if (wav_player) wav_player->startTransmit(aud_med); if (!med_port) { med_port = new MyAudioMediaPort(); MediaFormatAudio fmt; fmt.init(PJMEDIA_FORMAT_PCM, 16000, 1, 20000, 16); med_port->createPort("med_port", fmt); // Connect the media port to the call audio media in both directions med_port->startTransmit(aud_med); aud_med.startTransmit(*med_port); } // And this will connect the call audio media to the sound device/speaker aud_med.startTransmit(play_dev_med); // 遍历媒体流 // for (unsigned i = 0; i < ci.media.size(); i++) { // if (ci.media[i].type == PJMEDIA_TYPE_VIDEO) { // // 获取视频媒体流 // VideoMedia *vid_med = (VideoMedia *)getMedia(i); // if (vid_med) { // // 创建本地预览窗口 // try { // VideoPreviewOpParam pre_param; // VideoPreview *preview = vid_med->startPreview(pre_param); // localVideoWin = new VideoWindow(preview->getVideoWindow()); // localVideoWin->Show(true); // std::cout << "本地预览窗口ID: " << localVideoWin->getInfo().winId << std::endl; // } catch(Error& err) { // std::cout << "预览窗口错误: " << err.info() << std::endl; // } // // 创建远程视频窗口 // try { // remoteVideoWin = new VideoWindow(vid_med->getRemoteVideoWindow()); // remoteVideoWin->Show(true); // std::cout << "远程视频窗口ID: " << remoteVideoWin->getInfo().winId << std::endl; // } catch(Error& err) { // std::cout << "远程窗口错误: " << err.info() << std::endl; // } // } // } // } } void MyCall::onCallTransferRequest(OnCallTransferRequestParam &prm) { /* Create new Call for call transfer */ prm.newCall = new MyCall(*myAcc); } void MyCall::onCallReplaceRequest(OnCallReplaceRequestParam &prm) { /* Create new Call for call replace */ prm.newCall = new MyCall(*myAcc); } Form_VoIP::Form_VoIP(QWidget *parent) : QWidget(parent) , ui(new Ui::Form_VoIP) { ui->setupUi(this); this->resize(1680,920); // 初始化GStreamer qputenv("GST_DEBUG", "2"); // 设置GStreamer调试级别 qputenv("GST_PLUGIN_PATH", "/usr/lib/gstreamer-1.0"); // 设置插件路径 connect(ui->registerButton, &QPushButton::clicked, this, &Form_VoIP::onRegisterClicked); connect(ui->unregisterButton, &QPushButton::clicked, this, &Form_VoIP::onUnRegisterClicked); connect(ui->callButton, &QPushButton::clicked, this, &Form_VoIP::onCallClicked); connect(ui->hangupButton, &QPushButton::clicked, this, &Form_VoIP::onHangupClicked); connect(this, &Form_VoIP::callStateChanged, this, &Form_VoIP::onCallStateChanged); connect(this, &Form_VoIP::incomingVideoFrame, this, &Form_VoIP::handleIncomingFrame); connect(this, &Form_VoIP::outgoingVideoFrame, this, &Form_VoIP::handleOutgoingFrame); } Form_VoIP::~Form_VoIP() { // if (registered) { // this->setRegistration(false); // } ep.libDestroy(); delete ui; } void Form_VoIP::PJSUA2_Init() { if (ep.libGetState() == PJSUA_STATE_NULL) { ep.libCreate(); // 安全调用 } else { return; } qDebug() << "ep.libCreate(); 完成"; pj::EpConfig ep_cfg; ep_cfg.logConfig.level = 5; // 关键设置:启用视频支持 //ep_cfg.medConfig.vidCount = 1; // 必须 >=1 才能支持视频 // 设备配置(使用 PJSUA2 常量) // ep_cfg.vidConfig.capDev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; // ep_cfg.vidConfig.rendDev = PJMEDIA_VID_DEFAULT_RENDER_DEV; // 2.15.1 特定参数 // ep_cfg.uaConfig.threadCnt = 0; // 自动选择线程数 // ep_cfg.medConfig.clockRate = 16000; // 推荐时钟频率 // Linux (强制使用 V4L2) //ep_cfg.medConfig. = "v4l2"; // 检查是否已执行 libCreate // 检查是否已执行 libInit if (ep.libGetState() == PJSUA_STATE_CREATED) { qDebug() << "开始 ep.libInit(ep_cfg)"; ep.libInit(ep_cfg); } else { return; } qDebug() << "配置视频编解码器参数"; // 配置视频编解码器参数 VidCodecParam vid_codec_param; vid_codec_param.ignoreFmtp = true; ep.videoCodecSetPriority("H264/97/98", PJMEDIA_CODEC_PRIO_HIGHEST); ep.setVideoCodecParam("H264", vid_codec_param); qDebug() << "传输配置"; // 传输配置 pj::TransportConfig tcfg; tcfg.port = 5060; ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg); // 设置默认设备 // ep.audDevManager().setCaptureDev(1); // ep.audDevManager().setPlaybackDev(1); //ep.audDevManager().refreshDevs();// 刷新设备列表 qDebug() << "检查设备"; // 检查设备 if (ep.audDevManager().getDevCount() == 0) { qDebug() << "无音频设备,加载虚拟设备..."; // 调用系统命令加载 snd-dummy(需提前配置) system("sudo modprobe snd-dummy"); ep.audDevManager().refreshDevs(); // 重新刷新 } else { qDebug() << "音频设备数量:"<<ep.audDevManager().getDevCount(); AudioDevInfoVector2 aud_devices = ep.audDevManager().enumDev2(); qDebug() << aud_devices.size(); for (int i = 0; i < aud_devices.size(); i++) { qDebug()<< "设备 " << i << ": " << aud_devices[i].name << " (输入通道: " << aud_devices[i].inputCount << ", 输出通道: " << aud_devices[i].outputCount << ")\n"; } } // ep.audDevManager().setCaptureDev(3); // ep.audDevManager().setPlaybackDev(3); ep.vidDevManager().refreshDevs(); // 手动刷新设备枚举 if (ep.vidDevManager().getDevCount() == 0) { qDebug() << "无视频设备,..."; } else { qDebug() << "视频设备数量:"<<ep.vidDevManager().getDevCount(); } // 获取当前音频设备参数 // AudDevMgr::Param param = ep.audDevMgr().getParam(); // // 设置输入和输出设备ID // param.input_dev = inputDevId; // param.output_dev = outputDevId; // try { // // 应用新的音频设备参数 // ep.audDevMgr().setParam(param); // std::cout << "Successfully configured audio devices with IDs: " // << inputDevId << " (input), " << outputDevId << " (output)." << std::endl; // } catch (Error &err) { // std::cerr << "Failed to set audio device settings: " << err.info() << std::endl; // } // 启动 PJSUA2 ep.libStart(); // 新增自动注册逻辑 QTimer::singleShot(1000, this, [this]() { auto& paramMgr = ParamManager::instance(); QString server = paramMgr.getParamValue("SIP", "Server").toString(); QString user = paramMgr.getParamValue("SIP", "User").toString(); QString pass = paramMgr.getParamValue("SIP", "Password").toString(); if(!server.isEmpty() && !user.isEmpty()) { registerAccount(server, user, pass); } }); } void Form_VoIP::showEvent(QShowEvent *event) { Q_UNUSED(event); qDebug()<<"Form_VoIP::showEvent"; PJSUA2_Init(); //qDebug() << "音频设备数量:"<<ep.audDevManager().getDevCount(); } void Form_VoIP::startStream() { if (streaming) return; streaming = true; VideoDevice::init(); AudioDevice::init(); // 启动视频采集定时器 QTimer *videoTimer = new QTimer(this); connect(videoTimer, &QTimer::timeout, [this](){ QVideoFrame frame = VideoDevice::captureFrame(); if (frame.isValid()) { emit outgoingVideoFrame(frame); } }); videoTimer->start(33); // ~30fps // 音频流处理类似... } void Form_VoIP::stopStream() { if (!streaming) return; streaming = false; VideoDevice::cleanup(); AudioDevice::cleanup(); } void Form_VoIP::handleIncomingFrame(const QVideoFrame &frame) { // 处理接收到的视频帧 // 这里可以添加解码和显示逻辑 } void Form_VoIP::handleOutgoingFrame(const QVideoFrame &frame) { // 处理要发送的视频帧 // 这里可以添加编码和网络传输逻辑 } void Form_VoIP::onRegisterClicked() { m_sipserver = ui->serverEdit->text(); m_sipuser = ui->userEdit->text(); m_sippassword = ui->passwordEdit->text(); registerAccount(m_sipserver, m_sipuser, m_sippassword); } void Form_VoIP::onUnRegisterClicked() { try { if(!acc)return; // 获取已注册的账户对象 Account& account = *acc; // 发送Expires=0的REGISTER请求(注销) account.setRegistration(false); // 核心注销指令 若Account已经注销,则该方法会报错 } catch (pj::Error &e) { std::cerr << "PJSIP Error: " << e.reason << std::endl; // 输出具体错误:ml-citation{ref="4" data="citationList"} } } void Form_VoIP::onCallClicked() { QString number = ui->numberEdit->text(); //makeCall(number); if (currentCall) return; // Make outgoing call Call *call = new MyCall(*acc); acc->calls.push_back(call); CallOpParam prm(true); prm.opt.audioCount = 1; prm.opt.videoCount = 0; // 带视频呼叫 // 设置媒体方向(2.15.1 要求) // prm.opt.audioDir = PJMEDIA_DIR_ENCODING_DECODING; // prm.opt.videoDir = PJMEDIA_DIR_ENCODING_DECODING; const QString uri = QString("sip:%1@%2").arg(number).arg(m_sipserver); try { call->makeCall(uri.toStdString(), prm); currentCall = call; } catch (pj::Error &e) { delete call; currentCall = nullptr; std::cerr << "PJSIP Error: " << e.reason << std::endl; // 输出具体错误:ml-citation{ref="4" data="citationList"} } // pj::Call *call = new pj::Call(*this); // pj::CallOpParam prm(true); // currentCall = call; // try { // call->makeCall("sip:" + uri.toStdString(), prm); // emit callStateChanged(1); // 连接中 // } catch (...) { // delete call; // currentCall = nullptr; // emit callStateChanged(0); // 空闲状态 // } } void Form_VoIP::onHangupClicked() { //hangup(); currentCall = nullptr; ep.hangupAllCalls(); } void Form_VoIP::onCallStateChanged(int state) { // 更新界面状态 // 0: 空闲, 1: 连接中, 2: 通话中 if (state == 2) { // 通话中 setupVideoCall(); } //有拨号界面时,关闭拨号 // else if (callWindow) { // callWindow->close(); // callWindow = nullptr; // } } void Form_VoIP::setupVideoCall() { // if (!callWindow) // { // callWindow = new CallWindow(this); // VideoDevice::init(); // connect(VideoDevice::instance(), &VideoDevice::frameAvailable, // callWindow, [this](const QVideoFrame &frame) { // // 获取本地视频项的videoSink并设置视频帧 // if (auto sink = callWindow->localVideoItem()->videoSink()) { // sink->setVideoFrame(frame); // } // }); // } // callWindow->show(); VideoDevice::init(); connect(VideoDevice::instance(), &VideoDevice::frameAvailable, this, [this](const QVideoFrame &frame) { // if (auto* sink = this->localVideoItem()->videoSink()) { // 明确指出 sink 是指针类型 // if (sink && sink->isActive()) { // 添加必要的有效性检查 // qDebug() << "Video sink is active."; // sink->setVideoFrame(frame); // } else { // qDebug() << "No valid video sink or it's inactive."; // } // } // 获取本地视频项的videoSink并设置视频帧 if (auto sink = this->localVideoItem->videoSink()) { sink->setVideoFrame(frame); } }); } AudioFilter::AudioFilter(int frameSize, int sampleRate) : frameSize(frameSize), sampleRate(sampleRate) { m_format.setSampleRate(sampleRate); m_format.setChannelCount(1); m_format.setSampleFormat(QAudioFormat::Int16); // 获取默认音频输入设备并创建QAudioInput QAudioDevice inputDevice = QMediaDevices::defaultAudioInput(); if (!inputDevice.isFormatSupported(m_format)) { qWarning() << "Default audio input device does not support the required format"; m_format = inputDevice.preferredFormat(); } // m_audioInput = new QAudioInput(inputDevice, m_format, this); // // 设置音频处理选项 // QAudioInputOptions options; // options.setEchoCancel(true); // options.setNoiseSuppression(true); // m_audioInput->setOptions(options); // // 启动音频输入 // m_audioInput->start(); } AudioFilter::~AudioFilter() { //m_audioDevice.stop(); } void AudioFilter::processCapture(const QAudioBuffer &input, QAudioBuffer &output) { // Qt6.7处理逻辑 - 使用QAudioSink处理输入 // QAudioSink sink(m_audioDevice, m_format); // sink.start(); // sink.write(input.data(), input.byteCount()); // // 处理输出缓冲区 // QAudioSource source(m_audioDevice, m_format); // source.start(); // source.read(output.data(), output.byteCount()); } void AudioFilter::processPlayback(const QAudioBuffer &input) { // QAudioSink sink(m_audioDevice, m_format); // QIODevice *ioDevice = sink.start(); // if (ioDevice) { // ioDevice->write(input.constData<char>(), input.byteCount()); // } // sink.stop(); // sink.write(input.data(), input.byteCount()); } // 静态成员变量定义 QAudioDevice AudioDevice::m_inputDevice; QAudioDevice AudioDevice::m_outputDevice; QAudioFormat AudioDevice::m_format; void AudioDevice::init() { // 初始化音频格式 m_format.setSampleRate(44100); m_format.setChannelCount(2); m_format.setSampleFormat(QAudioFormat::Int16); // 获取默认输入输出设备 m_inputDevice = QMediaDevices::defaultAudioInput(); m_outputDevice = QMediaDevices::defaultAudioOutput(); // 验证设备是否支持所需格式 if (!m_inputDevice.isFormatSupported(m_format)) { qWarning() << "Default input device does not support required format"; } if (!m_outputDevice.isFormatSupported(m_format)) { qWarning() << "Default output device does not support required format"; } } void AudioDevice::cleanup() { // 清理音频资源 m_inputDevice = QAudioDevice(); m_outputDevice = QAudioDevice(); } int AudioDevice::capture(void *buffer, int samples) { static QAudioSource *input = nullptr; if (!input) { input = new QAudioSource(m_inputDevice, m_format); } if (input->state() == QAudio::StoppedState) { //input->start(buffer); } return 0;//input->read((char*)buffer, samples * m_format.bytesPerSample()); } int AudioDevice::play(void *buffer, int samples) { static QAudioSink *output = nullptr; static QIODevice *ioDevice = nullptr; if (!output) { output = new QAudioSink(m_outputDevice, m_format); ioDevice = output->start(); } if (ioDevice) { return ioDevice->write(static_cast<const char*>(buffer), samples); } return 0; if (output->state() == QAudio::StoppedState) { //output->start(buffer); } return 0;//output->write((const char*)buffer, samples * m_format.bytesPerSample()); } VideoDevice *VideoDevice::m_instance = nullptr; QCamera *VideoDevice::camera = nullptr; VideoDevice *VideoDevice::instance() { if (!m_instance) { m_instance = new VideoDevice(); } return m_instance; } VideoDevice::VideoDevice(QObject *parent) : QObject(parent) {} void VideoDevice::init() { auto videoInputs = QMediaDevices::videoInputs(); if (videoInputs.isEmpty()) { qWarning() << "No video input devices found"; return; } // camera = new QCamera(videoInputs.first()); // auto *captureSession = new QMediaCaptureSession; // captureSession->setCamera(camera); // auto *videoSink = new QVideoSink; // QObject::connect(videoSink, &QVideoSink::videoFrameChanged, // [](const QVideoFrame &frame) { // QVideoFrame mappedFrame(frame); // if (mappedFrame.map(QVideoFrame::ReadOnly)) { // emit VideoDevice::instance()->frameAvailable(mappedFrame); // mappedFrame.unmap(); // } // }); // captureSession->setVideoSink(videoSink); // camera->start(); } void VideoDevice::cleanup() { if (camera) { camera->stop(); delete camera; camera = nullptr; } } QVideoFrame VideoDevice::captureFrame() { if (!camera) return QVideoFrame(); // 创建视频帧并映射内存 //QVideoFrame frame(QSize(640, 480), QVideoFrameFormat::Format_ARGB8888); // 先创建格式对象 QVideoFrameFormat format( QSize(640, 480), QVideoFrameFormat::Format_ARGB8888 ); // 再创建视频帧对象 QVideoFrame frame(format); if (frame.map(QVideoFrame::WriteOnly)) { // 这里可以填充帧数据 frame.unmap(); } return frame; } void Form_VoIP::registerAccount(const QString &server, const QString &user, const QString &pass) { accCfg.idUri = "sip:" + user.toStdString() + "@" + server.toStdString(); accCfg.regConfig.registrarUri = "sip:" + server.toStdString(); accCfg.callConfig.timerMinSESec = 90; // 强制最小值 accCfg.callConfig.timerSessExpiresSec = 1800; // 推荐30分钟超时 accCfg.sipConfig.authCreds.push_back( pj::AuthCredInfo("digest", "*", user.toStdString(), 0, pass.toStdString()) ); // 添加视频支持 accCfg.videoConfig.autoShowIncoming = true; accCfg.videoConfig.autoTransmitOutgoing = true; // 设置默认设备(使用 PJSUA2 常量) accCfg.videoConfig.defaultCaptureDevice = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; accCfg.videoConfig.defaultRenderDevice = PJMEDIA_VID_DEFAULT_RENDER_DEV; // acc= new MyAccount; try { acc->create(accCfg); } catch (...) { std::cout << "Adding account failed" << std::endl; } registered = true; emit callStateChanged(0); // 空闲状态 } void Form_VoIP::hangup() { if (currentCall) { try { pj::CallOpParam prm; currentCall->hangup(prm); currentCall = nullptr; emit callStateChanged(0); // 空闲状态 } catch (pj::Error &e) { currentCall = nullptr; std::cerr << "PJSIP Error: " << e.reason << std::endl; // 输出具体错误:ml-citation{ref="4" data="citationList"} } } //hangUpAllCalls(); } //还没调好 void Form_VoIP::hangUpAllCalls() { std::vector<pj::Call*> calls = acc->calls; for (auto call : calls) { CallInfo ci = call->getInfo(); if (ci.state != PJSIP_INV_STATE_DISCONNECTED) { try { pj::CallOpParam prm; call->hangup(prm); } catch (...) { // 处理可能的异常 } } } } void Form_VoIP::setVideoWindows(QVideoSink *local, QVideoSink *remote) { // Qt6.7视频架构兼容实现 if (remote) { connect(this, &Form_VoIP::incomingVideoFrame, this, [remote](const QVideoFrame &frame) { QVideoFrame clonedFrame(frame); clonedFrame.map(QVideoFrame::ReadOnly); remote->setVideoFrame(clonedFrame); clonedFrame.unmap(); }, Qt::QueuedConnection); } if (local) { connect(this, &Form_VoIP::outgoingVideoFrame, this, [local](const QVideoFrame &frame) { QVideoFrame clonedFrame(frame); clonedFrame.map(QVideoFrame::ReadOnly); local->setVideoFrame(clonedFrame); clonedFrame.unmap(); }, Qt::QueuedConnection); } } #ifndef FORM_VOIP_H #define FORM_VOIP_H #include <QWidget> #include <QGraphicsScene> #include <QGraphicsVideoItem> #include <QVideoSink> #include <QVideoFrame> #include <QAudioDevice> #include <QAudioFormat> #include <QAudioSink> #include <QAudioSource> #include <QAudioBuffer> #include <QMediaDevices> #include <QAudioInput> #include <QCamera> #include <pjsua2.hpp> #include <iostream> namespace Ui { class Form_VoIP; } class MyAccount; class Form_VoIP : public QWidget { Q_OBJECT public: explicit Form_VoIP(QWidget *parent = nullptr); ~Form_VoIP(); void setLocalVideo(QVideoSink *sink); void setRemoteVideo(QVideoSink *sink); void startStream(); void stopStream(); void registerAccount(const QString &server, const QString &user, const QString &pass); //void makeCall(const QString &uri); void hangup(); void setVideoWindows(QVideoSink *local, QVideoSink *remote); protected: void showEvent(QShowEvent *event); signals: void callStateChanged(int state); void incomingVideoFrame(const QVideoFrame &frame); void outgoingVideoFrame(const QVideoFrame &frame); private slots: void onRegisterClicked(); void onUnRegisterClicked(); void onCallClicked(); void onHangupClicked(); void onCallStateChanged(int state); void handleIncomingFrame(const QVideoFrame &frame); void handleOutgoingFrame(const QVideoFrame &frame); private: Ui::Form_VoIP *ui; bool streaming = false; pj::Endpoint ep; pj::AccountConfig accCfg; MyAccount *acc; pj::Call *currentCall = nullptr; bool registered = false; QString m_sipserver; QString m_sipuser; QString m_sippassword; QGraphicsScene *localScene; QGraphicsScene *remoteScene; QGraphicsVideoItem *localVideoItem; QGraphicsVideoItem *remoteVideoItem; void PJSUA2_Init(); void setupVideoCall(); void hangUpAllCalls(); }; class AudioDevice : public QObject { Q_OBJECT public: static void init(); static void cleanup(); static int capture(void *buffer, int samples); static int play(void *buffer, int samples); private: static QAudioDevice m_inputDevice; static QAudioDevice m_outputDevice; static QAudioFormat m_format; }; class VideoDevice : public QObject { Q_OBJECT public: static VideoDevice* instance(); static void init(); static void cleanup(); static QVideoFrame captureFrame(); signals: void frameAvailable(const QVideoFrame &frame); private: explicit VideoDevice(QObject *parent = nullptr); static VideoDevice *m_instance; static QCamera *camera; }; class AudioFilter { public: AudioFilter(int frameSize, int sampleRate); ~AudioFilter(); void processCapture(const QAudioBuffer &input, QAudioBuffer &output); void processPlayback(const QAudioBuffer &input); private: QAudioDevice m_audioDevice; QAudioFormat m_format; int frameSize; int sampleRate; QAudioInput *m_audioInput; }; #endif // FORM_VOIP_H 我使用debugger模式运行的时候程序崩溃 指向, ui(new Ui::Form_VoIP) 1 __pthread_kill_implementation pthread_kill.c 44 0xfffff46e2978 2 __pthread_kill_internal pthread_kill.c 78 0xfffff46e29c8 3 __GI_raise raise.c 26 0xfffff469bca0 4 __GI_abort abort.c 79 0xfffff4687e70 5 __gnu_cxx::__verbose_terminate_handler() 0xfffff49aacb0 6 ?? 0xfffff49a84d0 7 std::terminate() 0xfffff49a8554 8 __cxa_throw 0xfffff49a88a4 9 pj::Endpoint::Endpoint endpoint.cpp 600 0xfffff75339b8 10 Form_VoIP::Form_VoIP form_voip.cpp 355 0xaaaaaad531b8 11 FormSettings_System::FormSettings_System formsettings_system.cpp 211 0xaaaaaad82e5c 12 Form001::Init_UI_4 form001.cpp 515 0xaaaaaabba708 13 operator() form001.cpp 192 0xaaaaaabb6f40 14 std::__invoke_impl<void, Form001::Form001(QWidget *)::<lambda()>&>(std::__invoke_other, struct {...} &) invoke.h 61 0xaaaaaabc7338 15 std::__invoke_r<void, Form001::Form001(QWidget *)::<lambda()>&>(struct {...} &) invoke.h 111 0xaaaaaabc5d98 16 std::_Function_handler<void(), Form001::Form001(QWidget *)::<lambda()>>::_M_invoke(const std::_Any_data &) std_function.h 290 0xaaaaaabc4344 17 std::function<void ()>::operator()() const std_function.h 591 0xaaaaaabceb2c 18 Form001::doNextInitStep form001.cpp 261 0xaaaaaabb7d20 19 MainForm::timer_100ms_timeout mainform.cpp 205 0xaaaaaadedaac 20 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (MainForm:: *)()>::call(void (MainForm:: *)(), MainForm *, void * *) qobjectdefs_impl.h 145 0xaaaaaadf0c68 ... <更多>
最新发布
09-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值