ソースを参照

#IQRV #comment 处理编码问题 showdev

80374374 1 年間 前
コミット
75ad053963

+ 20 - 1
Module/mod_sipphone/win/audio_session.cpp

@@ -1000,10 +1000,14 @@ CSimpleStringA audio_get_dev_name(bool in_direction, int idx)
 		if (in_direction) {
 			if (info->maxInputChannels) {
 				if (idx == ii) {
+#if _MSC_VER < 1929 //VS2010
 					char* str_audioin = utf8togb2312(info->name);
 					CSimpleStringA strInDevice = CSimpleStringA(str_audioin);
 					delete str_audioin;
 					str_audioin = NULL;
+#else
+					CSimpleStringA strInDevice = CSimpleStringA(info->name);
+#endif
 					return strInDevice;
 				}
 				ii++;
@@ -1011,17 +1015,20 @@ CSimpleStringA audio_get_dev_name(bool in_direction, int idx)
 		} else {
 			if (info->maxOutputChannels) {
 				if (idx == ii) {
+#if _MSC_VER < 1929 //VS2010
 					char* str_audioout = utf8togb2312(info->name);
 					CSimpleStringA strOutDevice = CSimpleStringA(str_audioout);
 					delete str_audioout;
 					str_audioout = NULL;
+#else
+					CSimpleStringA strOutDevice = CSimpleStringA(info->name);
+#endif
 					return strOutDevice;
 				}
 				ii++;
 			}
 		}
 	}
-
 	return CSimpleStringA();
 }
 
@@ -1033,6 +1040,7 @@ int capture_get_audio_device_id(bool in_direction, const char *dev_name)
 		const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
 		if (in_direction) {
 			if (info->maxInputChannels) {
+#if _MSC_VER < 1929 //VS2010
 				char* straudio = gb2312toutf8(dev_name);
 				if (strstr(info->name, straudio) != NULL) {
 					delete straudio;
@@ -1041,11 +1049,17 @@ int capture_get_audio_device_id(bool in_direction, const char *dev_name)
 				}
 				delete straudio;
 				straudio = NULL;
+#else
+				if (strstr(info->name, dev_name) != NULL) {
+					return ii;
+				}
+#endif
 				ii++;
 			}
 		} 
 		else {
 			if (info->maxOutputChannels) {
+#if _MSC_VER < 1929 //VS2010
 				char* straudioout = gb2312toutf8(dev_name);
 				if (strstr(info->name, straudioout) != NULL) {
 					delete straudioout;
@@ -1054,6 +1068,11 @@ int capture_get_audio_device_id(bool in_direction, const char *dev_name)
 				}
 				delete straudioout;
 				straudioout = NULL;
+#else
+				if (strstr(info->name, dev_name) != NULL) {
+					return ii;
+				}
+#endif
 				ii++;
 			}
 		}

+ 102 - 0
Other/unix/showdev/CMakeLists.txt

@@ -0,0 +1,102 @@
+set(MODULE_NAME "showdev")
+set(MODULE_PREFIX "SHOWDEV_FUNC")
+
+
+if(RVC_DEBUG_MODE)
+    set(TOOLKIT_LIB libtoolkitd)
+else()
+    set(TOOLKIT_LIB libtoolkit)
+endif(RVC_DEBUG_MODE)
+
+
+if(MSVC)
+    set(MAINFILE main.c)
+else()
+    set(MAINFILE main.cpp)
+endif(MSVC)
+
+set(${MODULE_PREFIX}_SRCS
+	${MAINFILE}
+)
+
+add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
+
+
+target_include_directories(${MODULE_NAME} PRIVATE
+	${CONAN_INCLUDE_DIRS_APACHE-APR}/include
+	${CONAN_INCLUDE_DIRS_PORTAUDIO}
+	${RVC_TOOLKIT_INCLUDE_DIR}
+	${CONAN_RVCFRAMEWORK_ROOT}/include
+	${CONAN_INCLUDE_DIRS_FFMPEG}
+	${CONAN_INCLUDE_DIRS_SPANDSP}
+	)
+
+target_link_directories(${MODULE_NAME} PRIVATE
+	${CONAN_LIB_DIRS_APACHE-APR}
+	${CONAN_LIB_DIRS_PORTAUDIO}
+	${CONAN_LIB_DIRS_RVCFRAMEWORK}
+	${CONAN_LIB_DIRS_FFMPEG}
+	${CONAN_LIB_DIRS_LIB8K}
+	${CONAN_LIB_DIRS_SPANDSP}
+	${CONAN_LIB_DIRS_ALSA}
+	)
+
+
+# 添加实体需要依赖的其他共享库(包括系统库)
+if(WIN32)
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} 
+	${CONAN_PKG_LIBS_PORTAUDIO}
+	${TOOLKIT_LIB}
+	${CONAN_PKG_LIBS_FFMPEG}
+	${CONAN_PKG_LIBS_APACHE-APR}
+	${CONAN_PKG_LIBS_LIB8K}
+	${CONAN_PKG_LIBS_SPANDSP}
+	libaudioframework
+	libvideoframework
+	libvideohorflip
+	ws2_32
+	strmiids)
+else(WIN32)
+
+
+message(STATUS "CONAN_LIB_DIRS_ALSA ${CONAN_LIB_DIRS_ALSA}")
+message(STATUS "CONAN_PKG_LIBS_ALSA ${CONAN_PKG_LIBS_ALSA}")
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} 
+	${CONAN_PKG_LIBS_PORTAUDIO}
+#	${TOOLKIT_LIB}
+#	mediadeviceinfo
+	pthread
+	m
+	asound
+	dl
+)
+endif(WIN32)
+
+target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
+
+if(RVC_DEBUG_MODE)
+target_compile_definitions(${MODULE_NAME} PUBLIC "LIBDEBUG_MODE")
+else()
+target_compile_definitions(${MODULE_NAME} PUBLIC "LIBRELEASE_MODE")
+endif(RVC_DEBUG_MODE)
+
+if(MSVC)
+	install(TARGETS ${MODULE_NAME} 
+    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}" COMPONENT libraries
+    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT develops EXCLUDE_FROM_ALL
+    LIBRARY DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT libraries
+    )
+else()
+install(TARGETS ${MODULE_NAME} 
+    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}"
+    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}"
+    LIBRARY DESTINATION "${RVC_RUNTIME_PATH}"
+    COMPONENT libraries)
+endif(MSVC)
+
+# 设置要依赖拷贝的第三方库
+if(MSVC)
+set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_BIN_DIRS} PARENT_SCOPE)
+else()
+set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_LIB_DIRS} PARENT_SCOPE)
+ENDIF(MSVC)

+ 0 - 0
Other/win/showdev/main.c → Other/unix/showdev/main.c


+ 470 - 0
Other/unix/showdev/main.cpp

@@ -0,0 +1,470 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <portaudio.h>
+
+//#include <pa_debugprint.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <poll.h>
+#include <sys/ioctl.h>
+#include <string.h>
+#include <unistd.h>
+//v4l includes
+#include <linux/videodev2.h>
+#include <dlfcn.h>
+#include <alsa/asoundlib.h>
+
+#include "../libmediadeviceinfo/imediadeviceinfo.h"
+
+
+#ifndef MAX_STR_LEN
+#define MAX_STR_LEN 512
+#endif // !MAX_STR_LEN
+
+
+#ifndef MAX_PATH
+#define MAX_PATH 260
+#endif // !MAX_PATH
+
+
+typedef int (*lpfn_get_cameracountfun)();
+typedef int (*lpfn_get_videodevice_namefun)(int device_id, char* buf, int len);
+typedef int (*lpfn_get_videodevice_infofun)(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen);
+typedef int (*lpfn_get_videodeviceid)(const char* dev_name);
+
+static lpfn_get_cameracountfun get_cameracount = NULL;
+static lpfn_get_videodevice_namefun get_videodevice_name = NULL;
+static lpfn_get_videodevice_infofun get_videodevice_info = NULL; 
+static lpfn_get_videodevice_namefun	get_device_fullpathname = NULL;
+static lpfn_get_videodeviceid get_videodeviceid = NULL;
+
+
+static int audio_translate_id(int in_direction, int idx)
+{
+	int i, n, ii;
+	//audio_log_set_func(NULL);
+	n = Pa_GetDeviceCount();
+	for (i = 0, ii = 0; i < n; ++i) {
+		const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
+		if (in_direction) {
+			if (info->maxInputChannels) {
+				if (ii == idx) {
+					//audio_log_set_func(__audio_log_func);
+					return i;
+				}
+				ii++;
+			}
+		} else {
+			if (info->maxOutputChannels) {
+				if (ii == idx) {
+					//audio_log_set_func(__audio_log_func);
+					return i;
+				}
+				ii++;
+			}
+		}
+	}
+	//audio_log_set_func(__audio_log_func);
+	return -1;
+}
+
+int audio_get_dev_count(int *in_cnt, int *out_cnt)
+{
+	int i;
+	int icnt = 0, ocnt = 0;
+	int cnt = Pa_GetDeviceCount();
+	printf("\n\ndevice count is %d.\n", cnt);
+	for (i = 0; i < cnt; ++i) {
+		const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
+		if (info->maxInputChannels)
+			icnt ++;
+		if (info->maxOutputChannels)
+			ocnt ++;
+	}
+	if (in_cnt)
+		*in_cnt = icnt;
+	if (out_cnt)
+		*out_cnt = ocnt;
+	return 0;
+}
+
+static char *audio_get_dev_name(char *buf, bool in_direction, int idx)
+{
+	int cnt = Pa_GetDeviceCount();
+	int ii, i;
+	for (i = 0, ii = 0; i < cnt; ++i) {
+		const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
+		if (in_direction) {
+			if (info->maxInputChannels) {
+				if (idx == ii) {
+					strcpy(buf, info->name);
+					return buf;
+				}
+				ii++;
+			}
+		} else {
+			if (info->maxOutputChannels) {
+				if (idx == ii) {
+					strcpy(buf, info->name);
+					return buf;
+				}
+				ii++;
+			}
+		}
+	}
+	return NULL;
+}
+
+static void show_audio_dev()
+{
+	int icnt, ocnt;
+	int rc = audio_get_dev_count(&icnt, &ocnt);
+	if (rc == 0) {
+		int i;
+		char tmp[128];
+		printf("audio input devices(%d):\n", icnt);
+		for (i = 0; i < icnt; ++i) {
+			audio_get_dev_name(tmp, true, i);
+			printf("%d = %s\n", i, tmp);
+		}
+		printf("audio output devices(%d):\n", ocnt);
+		for (i = 0; i < ocnt; ++i) {
+			audio_get_dev_name(tmp, false, i);
+			printf("%d = %s\n", i, tmp);
+		}
+		printf("\n");
+	}
+}
+
+
+
+static int Bin2Str(unsigned char *x, int xlen, char *str, int str_size)
+{
+	static const char *hex2char = "0123456789ABCDEF";
+	int i, k = 0;
+	if (str_size <= xlen * 2)
+		return -1;
+	for (i = 0; i < xlen; ++i) {
+		int h = x[i] >> 4;
+		int l = x[i] & 0xf;
+		str[k++] = hex2char[h];
+		str[k++] = hex2char[l];
+	}
+	str[k] = 0;
+	return k;
+}
+
+
+//static int isSupportThisFormat(int iPixelFormat)
+//{
+//	unsigned int i;
+//	for (i = 0; i < sizeof(g_aiSupportedFormats) / sizeof(g_aiSupportedFormats[0]); i++)
+//	{
+//		if (g_aiSupportedFormats[i] == iPixelFormat)
+//			return 1;
+//	}
+//	return 0;
+//}
+
+static void show_video_dev()
+{
+
+	//uint32_t count = 0;
+	//char device[20];
+	//int fd = -1;
+	//bool found = false;
+	//int n = 0;
+	//for (; n < 64; n++)
+	//{
+	//	sprintf(device, "/dev/video%d", n);
+	//	if ((fd = open(device, O_RDONLY)) != -1)
+	//	{
+	//		count++;
+	//		// query device capabilities
+	//		struct v4l2_capability cap;
+	//		struct v4l2_fmtdesc tFmtDesc;
+	//		struct v4l2_format  tV4l2Fmt;
+	//		int iPixelFormat = 0;
+	//		if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0)
+	//		{
+	//			printf("error in querying the device capability for device %s. errno = %d.\n",device, errno);
+	//			close(fd);
+	//			continue;
+	//		}
+	//		//printf("device[%s] Name UTF8 is: %s\n", device, cap.card);
+	//		if (cap.bus_info[0] != 0) // may not available in all drivers
+	//		{
+	//			//printf("device[%s] UniqueId UTF8 is: %s\n", device, cap.bus_info);
+	//		}
+
+	//		if (cap.driver[0] != 0) // may not available in all drivers
+	//		{
+	//			//printf("device[%s] driver UTF8 is: %s\n", device, cap.driver);
+	//		}
+
+	//		//printf("capabilities is 0x%x\n", cap.capabilities);
+
+	//		if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
+	//		{
+	//			//printf("%s is not a video capture device\n", device);
+	//			continue;
+	//		}
+	//		/* ------------------------------------------------------------------ */
+
+	//		if (cap.capabilities & V4L2_CAP_STREAMING) {
+	//			//printf("%s supports streaming i/o\n", device);
+	//		}
+
+	//		if (cap.capabilities & V4L2_CAP_READWRITE) {
+	//			//printf("%s supports read i/o\n", device);
+	//		}
+
+	//		/* 查询支持的格式 */
+	//		memset(&tFmtDesc, 0, sizeof(tFmtDesc));
+	//		tFmtDesc.index = 0;
+	//		tFmtDesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	//		while ((ioctl(fd, VIDIOC_ENUM_FMT, &tFmtDesc)) == 0) {
+	//			//if (isSupportThisFormat(tFmtDesc.pixelformat))
+	//			//printf("tFmtDesc.pixelformat == 0x:%x\n", tFmtDesc.pixelformat);
+	//			if(V4L2_PIX_FMT_YUYV == tFmtDesc.pixelformat || V4L2_PIX_FMT_RGB565 == tFmtDesc.pixelformat)
+	//			{
+	//				//printf("Support this format!\n");
+	//				iPixelFormat = tFmtDesc.pixelformat;
+	//				break;
+	//			}
+	//			//printf("Support this format +++!\n");
+	//			tFmtDesc.index++;
+	//		}
+
+	//		if (0 != iPixelFormat)
+	//		{
+	//			char strCameraName[MAX_PATH] = { 0 };
+	//			snprintf(strCameraName, MAX_PATH, "%s%s%s", cap.card,";",cap.bus_info);
+	//			printf("%s\n\n", strCameraName);
+	//		}
+	//		else {
+	//			//printf("can not support the format of this device[%s]\n\n", device);
+	//			continue;
+	//		}
+
+
+	//		/* 获取当前显示设备支持的分辨率 */
+	//		memset(&tV4l2Fmt, 0, sizeof(struct v4l2_format));
+	//		tV4l2Fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	//		tV4l2Fmt.fmt.pix.pixelformat = iPixelFormat;
+	//		tV4l2Fmt.fmt.pix.width = 1920;
+	//		tV4l2Fmt.fmt.pix.height = 1080;
+	//		tV4l2Fmt.fmt.pix.field = V4L2_FIELD_ANY;
+
+	//		/* 如果驱动程序发现无法某些参数(比如分辨率),
+	//		 * 它会调整这些参数, 并且返回给应用程序
+	//		 */
+	//		if (ioctl(fd, VIDIOC_S_FMT, &tV4l2Fmt))
+	//		{
+	//			//printf("Unable to set format\n\n");
+	//			continue;
+	//		}
+	//		{
+	//			int iWidth = tV4l2Fmt.fmt.pix.width;
+	//			int iHeight = tV4l2Fmt.fmt.pix.height;
+
+	//			//printf("width is %d\nheight is %d\nformat is %d\n\n", iWidth, iHeight, iPixelFormat);
+	//		}
+
+	//		close(fd);
+	//	}
+	//}
+
+	int icount = get_cameracount();
+	printf("video devices(%d):\n", icount);
+
+	int inumber = 0;
+	for (int i = 0; i < 64 && inumber < icount; ++i) {
+		char strcamera[2*MAX_PATH] = { 0 };
+		char strpath[MAX_PATH] = { 0 };
+
+		if(0 == get_device_fullpathname(i, strcamera, 2*MAX_PATH))
+		{
+			printf("%d = %s\n", inumber++, strcamera);
+		}
+	}
+}
+
+
+static void __dummy_log_callback(const char *log)
+{
+
+}
+
+static int load_dll_functions()
+{
+	int iret = -1;
+
+	void* handle = NULL;
+	char* error = NULL;
+	handle = dlopen("./libmediadeviceinfo.so", RTLD_LAZY);
+	if (NULL == handle)
+	{
+		printf("dlopen failed %s.\n", dlerror());
+		return iret;
+	}
+
+	get_cameracount = (lpfn_get_cameracountfun)dlsym(handle, "rvc_videocap_get_device_count");
+	if ((error = dlerror()) != NULL) {
+		printf("%s\n", error);
+		return iret;
+	}
+
+	get_videodevice_name = (lpfn_get_videodevice_namefun)dlsym(handle, "rvc_videocap_get_device_name");
+	if ((error = dlerror()) != NULL) {
+		printf("%s\n", error);
+		return iret;
+	}
+ 
+	get_videodevice_info = (lpfn_get_videodevice_infofun)dlsym(handle, "rvc_videocap_get_device_info");
+	if ((error = dlerror()) != NULL) {
+		printf("%s\n", error);
+		return iret;
+	}
+
+	get_device_fullpathname = (lpfn_get_videodevice_namefun)dlsym(handle, "rvc_videocap_get_device_fullpathname");
+	if ((error = dlerror()) != NULL) {
+		printf("%s\n", error);
+		return iret;
+	}
+
+	get_videodeviceid = (lpfn_get_videodeviceid)dlsym(handle, "rvc_videocap_get_video_device_id");
+	if ((error = dlerror()) != NULL) {
+		printf("%s\n", error);
+		return iret;
+	}
+
+	iret = 0;
+
+	return iret;
+}
+
+static int app_init()
+{
+	Pa_Initialize();
+	//PaUtil_SetDebugPrintFunction(&__dummy_log_callback);
+	int iret = load_dll_functions();
+
+	return iret;
+}
+
+static void app_term()
+{
+	Pa_Terminate();
+}
+
+
+static void device_list(bool in_direction)
+{
+	snd_ctl_t* handle = NULL;
+	int card = 0, err = 0, dev = 0, idx = 0;
+	snd_ctl_card_info_t* info = NULL;
+	snd_pcm_info_t* pcminfo = NULL;
+	snd_ctl_card_info_alloca(&info);
+	snd_pcm_info_alloca(&pcminfo);
+	snd_pcm_stream_t instream = SND_PCM_STREAM_CAPTURE;
+	if (!in_direction){
+		instream = SND_PCM_STREAM_PLAYBACK;
+	}
+
+	card = -1;
+	if (snd_card_next(&card) < 0 || card < 0) {
+		printf("no soundcards found...\n");
+		return;
+	}
+	printf("**** List of %s Hardware Devices ****\n",snd_pcm_stream_name(instream));
+	while (card >= 0) {
+		char name[32] = {0};
+		sprintf(name, "hw:%d", card);
+		if ((err = snd_ctl_open(&handle, name, 0)) < 0) {
+			printf("control open (%i): %s\n", card, snd_strerror(err));
+			goto next_card;
+		}
+		if ((err = snd_ctl_card_info(handle, info)) < 0) {
+			printf("control hardware info (%i): %s\n", card, snd_strerror(err));
+			snd_ctl_close(handle);
+			goto next_card;
+		}
+		dev = -1;
+		while (1) {
+			unsigned int count = 0;
+			if (snd_ctl_pcm_next_device(handle, &dev) < 0)
+				printf("snd_ctl_pcm_next_device\n");
+			if (dev < 0)
+				break;
+			snd_pcm_info_set_device(pcminfo, dev);
+			snd_pcm_info_set_subdevice(pcminfo, 0);
+			snd_pcm_info_set_stream(pcminfo, instream);
+			if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
+				if (err != -ENOENT)
+					printf("control digital audio info (%i): %s\n", card, snd_strerror(err));
+				continue;
+			}
+			printf("card %i: %s [%s], device %i: %s [%s]\n",
+				card, snd_ctl_card_info_get_id(info), snd_ctl_card_info_get_name(info),
+				dev,
+				snd_pcm_info_get_id(pcminfo),
+				snd_pcm_info_get_name(pcminfo));
+			//printf("%s\n",snd_ctl_card_info_get_name(info));
+			count = snd_pcm_info_get_subdevices_count(pcminfo);
+			//printf("  Subdevices: %i/%i\n",snd_pcm_info_get_subdevices_avail(pcminfo), count);
+			for (idx = 0; idx < (int)count; idx++) {
+				snd_pcm_info_set_subdevice(pcminfo, idx);
+				if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
+					printf("control digital audio playback info (%i): %s\n", card, snd_strerror(err));
+				}
+				else {
+					//printf("  Subdevice #%i: %s\n",idx, snd_pcm_info_get_subdevice_name(pcminfo));
+				}
+			}
+		}
+		snd_ctl_close(handle);
+	next_card:
+		if (snd_card_next(&card) < 0) {
+			printf("snd_card_next\n");
+			break;
+		}
+	}
+}
+
+int main() 
+{
+	if (app_init() != 0) {
+		printf("app init failed!\n");
+		return -1;
+	}
+
+	show_audio_dev();
+	show_video_dev();
+
+	//getchar();
+
+	app_term();
+
+	printf("\n--------------------------------------------------------------\n");
+	printf("               get audio device info from alsa.               \n");
+	printf("--------------------------------------------------------------\n");
+
+	device_list(true);
+	printf("--------------------------------------------------------------\n");
+	device_list(false);
+
+	return 0;
+}

+ 0 - 0
Other/win/showdev/showdev.bat → Other/unix/showdev/showdev.bat


+ 2 - 2
Other/win/CMakeLists.txt

@@ -2,8 +2,6 @@ if(SIMULATE_ON)
 	rvc_set_library_output_dir("${RVC_INSTALL_PREFIX}${RVC_RUNTIME_PATH}")
 endif(SIMULATE_ON)
 
-# add_subdirectory(showdev)
-
 add_subdirectory(libvideohorflip)
 
 add_subdirectory(libsharememory)
@@ -26,5 +24,7 @@ add_subdirectory(libaudions)
 add_subdirectory(libvideorecord)
 add_subdirectory(libvideorender)
 
+add_subdirectory(showdev)
+
 # 汇总要依赖拷贝的第三方库
 set(RVC_CONAN_DEP_LIBS ${RVC_CONAN_DEP_LIBS} ${OTHER_CONAN_DEP_LIBS} PARENT_SCOPE)

+ 11 - 10
Other/win/libaudioframework/CMakeLists.txt

@@ -110,6 +110,7 @@ target_link_directories(${MODULE_NAME} PRIVATE
 	if(WIN32)
 	${CONAN_LIB_DIRS_APACHE-APR}
 	${CONAN_LIB_DIRS_PORTAUDIO}
+	${CONAN_LIB_DIRS_SOFIA}
 	else
 	${CONAN_LIB_DIRS_APR}
 	${CONAN_LIB_DIRS_PULSEAUDIO}
@@ -119,16 +120,16 @@ target_link_directories(${MODULE_NAME} PRIVATE
 
 	# 添加实体需要依赖的其他共享库(包括系统库)
 if(WIN32)
-set(${MODULE_PREFIX}_LIBS PRIVATE
-	${CONAN_PKG_LIBS_PORTAUDIO}
-	${CONAN_PKG_LIBS_FFMPEG}
-	${SPBASE_LIB}
-	${TOOLKIT_LIB}
-	${CONAN_PKG_LIBS_APACHE-APR}
-	${CONAN_PKG_LIBS_LIB8K}
-	${CONAN_PKG_LIBS_SPANDSP}
-	${CONAN_PKG_LIBS_SOFIA}
-	${CONAN_PKG_LIBS_IPP}
+set(${MODULE_PREFIX}_LIBS 
+	${CONAN_PKG_LIBS_SOFIA} PRIVATE
+	${CONAN_PKG_LIBS_PORTAUDIO} PRIVATE
+	${CONAN_PKG_LIBS_FFMPEG} PRIVATE
+	${SPBASE_LIB} PRIVATE
+	${TOOLKIT_LIB} PRIVATE
+	${CONAN_PKG_LIBS_APACHE-APR} PRIVATE
+	${CONAN_PKG_LIBS_LIB8K} PRIVATE
+	${CONAN_PKG_LIBS_SPANDSP} PRIVATE
+	${CONAN_PKG_LIBS_IPP} PRIVATE
 	${CONAN_PKG_LIBS_SPEEXDSP}
 
 )

+ 20 - 23
Other/win/showdev/CMakeLists.txt

@@ -1,30 +1,24 @@
 set(MODULE_NAME "showdev")
 set(MODULE_PREFIX "SHOWDEV_FUNC")
 
-
 if(RVC_DEBUG_MODE)
     set(TOOLKIT_LIB libtoolkitd)
 else()
     set(TOOLKIT_LIB libtoolkit)
 endif(RVC_DEBUG_MODE)
 
-
-if(MSVC)
-    set(MAINFILE main.c)
-else()
-    set(MAINFILE main.cpp)
-endif(MSVC)
-
 set(${MODULE_PREFIX}_SRCS
-	${MAINFILE}
+	main.cpp
 )
 
 add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
 
-
 target_include_directories(${MODULE_NAME} PRIVATE
+    ${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioframework
+    ${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
 	${CONAN_INCLUDE_DIRS_APACHE-APR}/include
 	${CONAN_INCLUDE_DIRS_PORTAUDIO}
+	${CONAN_INCLUDE_DIRS_PORTAUDIO}/common
 	${RVC_TOOLKIT_INCLUDE_DIR}
 	${CONAN_RVCFRAMEWORK_ROOT}/include
 	${CONAN_INCLUDE_DIRS_FFMPEG}
@@ -39,22 +33,26 @@ target_link_directories(${MODULE_NAME} PRIVATE
 	${CONAN_LIB_DIRS_LIB8K}
 	${CONAN_LIB_DIRS_SPANDSP}
 	${CONAN_LIB_DIRS_ALSA}
+	${CONAN_LIB_DIRS_SOFIA}
+	${CONAN_LIB_DIRS_IPP}
+	${CONAN_LIB_DIRS_SPEEXDSP}
+	${CONAN_LIB_DIRS_LIBYUV}
 	)
 
 
 # 添加实体需要依赖的其他共享库(包括系统库)
 if(WIN32)
-set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} 
-	${CONAN_PKG_LIBS_PORTAUDIO}
-	${TOOLKIT_LIB}
-	${CONAN_PKG_LIBS_FFMPEG}
-	${CONAN_PKG_LIBS_APACHE-APR}
-	${CONAN_PKG_LIBS_LIB8K}
-	${CONAN_PKG_LIBS_SPANDSP}
-	libaudioframework
-	libvideoframework
-	libvideohorflip
-	ws2_32
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} PRIVATE
+	${CONAN_PKG_LIBS_PORTAUDIO} PRIVATE
+	${TOOLKIT_LIB} PRIVATE
+	${CONAN_PKG_LIBS_FFMPEG} PRIVATE 
+	${CONAN_PKG_LIBS_APACHE-APR} PRIVATE 
+	${CONAN_PKG_LIBS_LIB8K} PRIVATE 
+	${CONAN_PKG_LIBS_SPANDSP} PRIVATE 
+	libaudioframework PRIVATE 
+	libvideoframework PRIVATE 
+	libvideohorflip PRIVATE 
+	ws2_32 PRIVATE 
 	strmiids)
 else(WIN32)
 
@@ -63,7 +61,6 @@ message(STATUS "CONAN_LIB_DIRS_ALSA ${CONAN_LIB_DIRS_ALSA}")
 message(STATUS "CONAN_PKG_LIBS_ALSA ${CONAN_PKG_LIBS_ALSA}")
 set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} 
 	${CONAN_PKG_LIBS_PORTAUDIO}
-#	${TOOLKIT_LIB}
 #	mediadeviceinfo
 	pthread
 	m
@@ -72,7 +69,7 @@ set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS}
 )
 endif(WIN32)
 
-target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
+target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS})
 
 if(RVC_DEBUG_MODE)
 target_compile_definitions(${MODULE_NAME} PUBLIC "LIBDEBUG_MODE")

+ 216 - 303
Other/win/showdev/main.cpp

@@ -1,54 +1,48 @@
-
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
-
+#include <WinSock2.h>
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif //
+#include <windows.h>
+
+#include <audioframework.h>
+#include <videoframework.h>
 #include <portaudio.h>
+#include <pa_debugprint.h>
 
-//#include <pa_debugprint.h>
+#include <MMDeviceApi.h>
+#include <AudioEngineEndPoint.h>
+#include <DeviceTopology.h>
+#include <EndpointVolume.h>
+#include <functiondiscoverykeys.h>
+
+#include <md5.h>
 
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <poll.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <unistd.h>
-//v4l includes
-#include <linux/videodev2.h>
-#include <dlfcn.h>
-#include <alsa/asoundlib.h>
-
-#include "../libmediadeviceinfo/imediadeviceinfo.h"
-
-
-#ifndef MAX_STR_LEN
 #define MAX_STR_LEN 512
-#endif // !MAX_STR_LEN
 
+static char* utf8togb2312(const char* utf8)
+{
+	int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
+
+	wchar_t* wstr = new wchar_t[len + 1];
+	memset(wstr, 0, len + 1);
 
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif // !MAX_PATH
+	MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len);
+	len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
 
+	char* str = new char[len + 1];
+	memset(str, 0, len + 1);
 
-typedef int (*lpfn_get_cameracountfun)();
-typedef int (*lpfn_get_videodevice_namefun)(int device_id, char* buf, int len);
-typedef int (*lpfn_get_videodevice_infofun)(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen);
-typedef int (*lpfn_get_videodeviceid)(const char* dev_name);
+	WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL);
 
-static lpfn_get_cameracountfun get_cameracount = NULL;
-static lpfn_get_videodevice_namefun get_videodevice_name = NULL;
-static lpfn_get_videodevice_infofun get_videodevice_info = NULL; 
-static lpfn_get_videodevice_namefun	get_device_fullpathname = NULL;
-static lpfn_get_videodeviceid get_videodeviceid = NULL;
+	if (wstr) {
+		delete[]wstr;
+		wstr = NULL;
+	}
+	return str;
+}
 
 
 static int audio_translate_id(int in_direction, int idx)
@@ -85,7 +79,6 @@ int audio_get_dev_count(int *in_cnt, int *out_cnt)
 	int i;
 	int icnt = 0, ocnt = 0;
 	int cnt = Pa_GetDeviceCount();
-	printf("\n\ndevice count is %d.\n", cnt);
 	for (i = 0; i < cnt; ++i) {
 		const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
 		if (info->maxInputChannels)
@@ -100,7 +93,7 @@ int audio_get_dev_count(int *in_cnt, int *out_cnt)
 	return 0;
 }
 
-static char *audio_get_dev_name(char *buf, bool in_direction, int idx)
+static char *audio_get_dev_name(char *buf, BOOL in_direction, int idx)
 {
 	int cnt = Pa_GetDeviceCount();
 	int ii, i;
@@ -133,22 +126,153 @@ static void show_audio_dev()
 	int rc = audio_get_dev_count(&icnt, &ocnt);
 	if (rc == 0) {
 		int i;
-		char tmp[128];
+		char tmp[128] = {0};
 		printf("audio input devices(%d):\n", icnt);
 		for (i = 0; i < icnt; ++i) {
-			audio_get_dev_name(tmp, true, i);
+			audio_get_dev_name(tmp, TRUE, i);
+#if _MSC_VER < 1929 //VS2010
+			char* straudioin = utf8togb2312(tmp);
+			printf("%d = %s\n", i, straudioin);
+			delete straudioin;
+#else
 			printf("%d = %s\n", i, tmp);
+#endif
 		}
 		printf("audio output devices(%d):\n", ocnt);
 		for (i = 0; i < ocnt; ++i) {
-			audio_get_dev_name(tmp, false, i);
+			audio_get_dev_name(tmp, FALSE, i);
+#if _MSC_VER < 1929 //VS2010
+			char* straudioout = utf8togb2312(tmp);
+			printf("%d = %s\n", i, straudioout);
+			delete straudioout;
+#else
 			printf("%d = %s\n", i, tmp);
+#endif
 		}
 		printf("\n");
 	}
 }
 
+typedef struct tagAUDIO_DEVICE_INFO
+{
+	char szDeviceName[MAX_STR_LEN];
+	char szDeviceID[MAX_STR_LEN];
+} AUDIO_DEVICE_INFO, *PAUDIO_DEVICE_INFO;
+
+static HRESULT GetDeviceNum(EDataFlow eDataFlow, UINT *uDevCount)
+{
+	IMMDeviceEnumerator *pEnumerator = NULL;
+	IMMDeviceCollection *pEndpoints = NULL;
+	HRESULT hr;
+
+	hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
+	if (FAILED(hr))
+		goto on_error;
+	hr = pEnumerator->EnumAudioEndpoints(eDataFlow, DEVICE_STATE_ACTIVE, (IMMDeviceCollection**)&pEndpoints);
+	if (FAILED(hr))
+		goto on_error;
+	hr = pEndpoints->GetCount(uDevCount);
+	if (FAILED(hr))
+		goto on_error;
+
+on_error:
+	if (pEndpoints)
+		pEndpoints->Release();
+	if (pEnumerator)
+		pEnumerator->Release();
+	return hr;
+}
+
+static HRESULT EnumDevice(EDataFlow eDataFlow, UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
+{
+	IMMDeviceEnumerator *pEnumerator = NULL;
+	IMMDeviceCollection *pEndpoints = NULL;
+	HRESULT hr;
+	UINT uCount;
+	UINT uIdx;
+
+	hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
+	if (FAILED(hr))
+		goto on_error;
+	hr = pEnumerator->EnumAudioEndpoints(eDataFlow, DEVICE_STATE_ACTIVE, (IMMDeviceCollection**)&pEndpoints);
+	if (FAILED(hr))
+		goto on_error;
+	hr = pEndpoints->GetCount(&uCount);
+	if (FAILED(hr))
+		goto on_error;
+
+	ZeroMemory(pDevicInfo, sizeof(AUDIO_DEVICE_INFO)*uNumElements);
+
+	for (uIdx = 0; uIdx < uCount && uIdx < uNumElements; ++uIdx) {
+		IMMDevice *pDevice = NULL;
+		IPropertyStore *pPS = NULL;
+		WCHAR* pszDeviceId = NULL;
+		PROPVARIANT value;
+		PropVariantInit(&value);
+		pEndpoints->Item(uIdx, &pDevice);
+		pDevice->GetId(&pszDeviceId);
+		pDevice->OpenPropertyStore(STGM_READ, &pPS);
+		pPS->GetValue(PKEY_Device_FriendlyName, &value);
+		WideCharToMultiByte(CP_ACP, 0, pszDeviceId, -1, pDevicInfo[uIdx].szDeviceID, MAX_STR_LEN-1, NULL, NULL);
+		WideCharToMultiByte(CP_ACP, 0, value.pwszVal, -1, pDevicInfo[uIdx].szDeviceName, MAX_STR_LEN-1, NULL, NULL);
+		PropVariantClear(&value);
+		CoTaskMemFree(pszDeviceId);
+		pPS->Release();
+		pDevice->Release();
+	}
+
+on_error:
+	if (pEndpoints)
+		pEndpoints->Release();
+	if (pEnumerator)
+		pEnumerator->Release();
+	return hr;
+}
+
+static int get_device_index(int indev, const char *key)
+{
+	EDataFlow df = indev ? eCapture : eRender;
+	UINT i;
+	UINT n;
+	AUDIO_DEVICE_INFO *pInfo = NULL;
+	GetDeviceNum(df, &n);
+	pInfo = (AUDIO_DEVICE_INFO*)malloc(sizeof(AUDIO_DEVICE_INFO) * n);
+	EnumDevice(df, n, pInfo);
+	for (i = 0; i < n; ++i) {
+		if (strstr(pInfo[i].szDeviceName, key)) {
+			free(pInfo);
+			return i;
+		}
+	}
+	free(pInfo);
+	return -1;
+}
+
 
+static void show_audio_dev2()
+{
+	UINT i;
+	UINT n;
+	AUDIO_DEVICE_INFO *pInfo = NULL;
+
+	GetDeviceNum(eCapture, &n);
+	pInfo = (AUDIO_DEVICE_INFO*)malloc(sizeof(AUDIO_DEVICE_INFO) * n);
+	EnumDevice(eCapture, n, pInfo);
+	printf("audio input devices -- win7 (%d):\n", n);
+	for (i = 0; i < n; ++i) {
+		printf("%d = %s\n", i, pInfo[i].szDeviceName);
+	}
+	free(pInfo);
+
+	GetDeviceNum(eRender, &n);
+	pInfo = (AUDIO_DEVICE_INFO*)malloc(sizeof(AUDIO_DEVICE_INFO) * n);
+	EnumDevice(eRender, n, pInfo);
+	printf("audio output devices -- win7 (%d):\n", n);
+	for (i = 0; i < n; ++i) {
+		printf("%d = %s\n", i, pInfo[i].szDeviceName);
+	}
+	free(pInfo);
+}
 
 static int Bin2Str(unsigned char *x, int xlen, char *str, int str_size)
 {
@@ -167,285 +291,77 @@ static int Bin2Str(unsigned char *x, int xlen, char *str, int str_size)
 }
 
 
-//static int isSupportThisFormat(int iPixelFormat)
-//{
-//	unsigned int i;
-//	for (i = 0; i < sizeof(g_aiSupportedFormats) / sizeof(g_aiSupportedFormats[0]); i++)
-//	{
-//		if (g_aiSupportedFormats[i] == iPixelFormat)
-//			return 1;
-//	}
-//	return 0;
-//}
-
 static void show_video_dev()
 {
-
-	//uint32_t count = 0;
-	//char device[20];
-	//int fd = -1;
-	//bool found = false;
-	//int n = 0;
-	//for (; n < 64; n++)
-	//{
-	//	sprintf(device, "/dev/video%d", n);
-	//	if ((fd = open(device, O_RDONLY)) != -1)
-	//	{
-	//		count++;
-	//		// query device capabilities
-	//		struct v4l2_capability cap;
-	//		struct v4l2_fmtdesc tFmtDesc;
-	//		struct v4l2_format  tV4l2Fmt;
-	//		int iPixelFormat = 0;
-	//		if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0)
-	//		{
-	//			printf("error in querying the device capability for device %s. errno = %d.\n",device, errno);
-	//			close(fd);
-	//			continue;
-	//		}
-	//		//printf("device[%s] Name UTF8 is: %s\n", device, cap.card);
-	//		if (cap.bus_info[0] != 0) // may not available in all drivers
-	//		{
-	//			//printf("device[%s] UniqueId UTF8 is: %s\n", device, cap.bus_info);
-	//		}
-
-	//		if (cap.driver[0] != 0) // may not available in all drivers
-	//		{
-	//			//printf("device[%s] driver UTF8 is: %s\n", device, cap.driver);
-	//		}
-
-	//		//printf("capabilities is 0x%x\n", cap.capabilities);
-
-	//		if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
-	//		{
-	//			//printf("%s is not a video capture device\n", device);
-	//			continue;
-	//		}
-	//		/* ------------------------------------------------------------------ */
-
-	//		if (cap.capabilities & V4L2_CAP_STREAMING) {
-	//			//printf("%s supports streaming i/o\n", device);
-	//		}
-
-	//		if (cap.capabilities & V4L2_CAP_READWRITE) {
-	//			//printf("%s supports read i/o\n", device);
-	//		}
-
-	//		/* 查询支持的格式 */
-	//		memset(&tFmtDesc, 0, sizeof(tFmtDesc));
-	//		tFmtDesc.index = 0;
-	//		tFmtDesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	//		while ((ioctl(fd, VIDIOC_ENUM_FMT, &tFmtDesc)) == 0) {
-	//			//if (isSupportThisFormat(tFmtDesc.pixelformat))
-	//			//printf("tFmtDesc.pixelformat == 0x:%x\n", tFmtDesc.pixelformat);
-	//			if(V4L2_PIX_FMT_YUYV == tFmtDesc.pixelformat || V4L2_PIX_FMT_RGB565 == tFmtDesc.pixelformat)
-	//			{
-	//				//printf("Support this format!\n");
-	//				iPixelFormat = tFmtDesc.pixelformat;
-	//				break;
-	//			}
-	//			//printf("Support this format +++!\n");
-	//			tFmtDesc.index++;
-	//		}
-
-	//		if (0 != iPixelFormat)
-	//		{
-	//			char strCameraName[MAX_PATH] = { 0 };
-	//			snprintf(strCameraName, MAX_PATH, "%s%s%s", cap.card,";",cap.bus_info);
-	//			printf("%s\n\n", strCameraName);
-	//		}
-	//		else {
-	//			//printf("can not support the format of this device[%s]\n\n", device);
-	//			continue;
-	//		}
-
-
-	//		/* 获取当前显示设备支持的分辨率 */
-	//		memset(&tV4l2Fmt, 0, sizeof(struct v4l2_format));
-	//		tV4l2Fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	//		tV4l2Fmt.fmt.pix.pixelformat = iPixelFormat;
-	//		tV4l2Fmt.fmt.pix.width = 1920;
-	//		tV4l2Fmt.fmt.pix.height = 1080;
-	//		tV4l2Fmt.fmt.pix.field = V4L2_FIELD_ANY;
-
-	//		/* 如果驱动程序发现无法某些参数(比如分辨率),
-	//		 * 它会调整这些参数, 并且返回给应用程序
-	//		 */
-	//		if (ioctl(fd, VIDIOC_S_FMT, &tV4l2Fmt))
-	//		{
-	//			//printf("Unable to set format\n\n");
-	//			continue;
-	//		}
-	//		{
-	//			int iWidth = tV4l2Fmt.fmt.pix.width;
-	//			int iHeight = tV4l2Fmt.fmt.pix.height;
-
-	//			//printf("width is %d\nheight is %d\nformat is %d\n\n", iWidth, iHeight, iPixelFormat);
-	//		}
-
-	//		close(fd);
-	//	}
-	//}
-
-	int icount = get_cameracount();
-	printf("video devices(%d):\n", icount);
-
-	int inumber = 0;
-	for (int i = 0; i < 64 && inumber < icount; ++i) {
-		char strcamera[2*MAX_PATH] = { 0 };
-		char strpath[MAX_PATH] = { 0 };
-
-		if(0 == get_device_fullpathname(i, strcamera, 2*MAX_PATH))
+	int i, n;
+
+	n = videocap_get_device_count();
+	printf("video devices(%d):\n", n);
+	for (i = 0; i < n; ++i) {
+		WCHAR tmp[256];
+		char t[256];
+		videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+		WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+		printf("%d = %s;", i, t);
+		videocap_get_device_path(i, tmp, ARRAYSIZE(tmp));
+		WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
 		{
-			printf("%d = %s\n", inumber++, strcamera);
+			unsigned char x[MD5_DIGESTSIZE];
+			md5_ctx_t ctx;
+			md5_init(&ctx);
+			md5(x, t, strlen(t));
+			Bin2Str(x, sizeof(x), t, sizeof(t));
 		}
+		printf("%s\n", t);
+		
 	}
+	printf("\n");
 }
 
-
 static void __dummy_log_callback(const char *log)
 {
-
 }
 
-static int load_dll_functions()
+static int app_init()
 {
-	int iret = -1;
+	CoInitialize(NULL);
 
-	void* handle = NULL;
-	char* error = NULL;
-	handle = dlopen("./libmediadeviceinfo.so", RTLD_LAZY);
-	if (NULL == handle)
-	{
-		printf("dlopen failed %s.\n", dlerror());
-		return iret;
-	}
-
-	get_cameracount = (lpfn_get_cameracountfun)dlsym(handle, "rvc_videocap_get_device_count");
-	if ((error = dlerror()) != NULL) {
-		printf("%s\n", error);
-		return iret;
-	}
-
-	get_videodevice_name = (lpfn_get_videodevice_namefun)dlsym(handle, "rvc_videocap_get_device_name");
-	if ((error = dlerror()) != NULL) {
-		printf("%s\n", error);
-		return iret;
-	}
- 
-	get_videodevice_info = (lpfn_get_videodevice_infofun)dlsym(handle, "rvc_videocap_get_device_info");
-	if ((error = dlerror()) != NULL) {
-		printf("%s\n", error);
-		return iret;
-	}
-
-	get_device_fullpathname = (lpfn_get_videodevice_namefun)dlsym(handle, "rvc_videocap_get_device_fullpathname");
-	if ((error = dlerror()) != NULL) {
-		printf("%s\n", error);
-		return iret;
-	}
-
-	get_videodeviceid = (lpfn_get_videodeviceid)dlsym(handle, "rvc_videocap_get_video_device_id");
-	if ((error = dlerror()) != NULL) {
-		printf("%s\n", error);
-		return iret;
-	}
+	Pa_Initialize();
+	PaUtil_SetDebugPrintFunction(&__dummy_log_callback);
 
-	iret = 0;
+	audioframework_init();
+	videoframework_init();
 
-	return iret;
-}
+	audio_log_set_func(NULL);
 
-static int app_init()
-{
-	Pa_Initialize();
-	//PaUtil_SetDebugPrintFunction(&__dummy_log_callback);
-	int iret = load_dll_functions();
-
-	return iret;
+	return 0;
 }
 
 static void app_term()
 {
+	videoframework_term();
+	audioframework_term();
 	Pa_Terminate();
+	CoUninitialize();
 }
 
-
-static void device_list(bool in_direction)
+int main() 
 {
-	snd_ctl_t* handle = NULL;
-	int card = 0, err = 0, dev = 0, idx = 0;
-	snd_ctl_card_info_t* info = NULL;
-	snd_pcm_info_t* pcminfo = NULL;
-	snd_ctl_card_info_alloca(&info);
-	snd_pcm_info_alloca(&pcminfo);
-	snd_pcm_stream_t instream = SND_PCM_STREAM_CAPTURE;
-	if (!in_direction){
-		instream = SND_PCM_STREAM_PLAYBACK;
-	}
+	printf("%s\n", setlocale(LC_ALL, "chs"));
 
-	card = -1;
-	if (snd_card_next(&card) < 0 || card < 0) {
-		printf("no soundcards found...\n");
-		return;
-	}
-	printf("**** List of %s Hardware Devices ****\n",snd_pcm_stream_name(instream));
-	while (card >= 0) {
-		char name[32] = {0};
-		sprintf(name, "hw:%d", card);
-		if ((err = snd_ctl_open(&handle, name, 0)) < 0) {
-			printf("control open (%i): %s\n", card, snd_strerror(err));
-			goto next_card;
-		}
-		if ((err = snd_ctl_card_info(handle, info)) < 0) {
-			printf("control hardware info (%i): %s\n", card, snd_strerror(err));
-			snd_ctl_close(handle);
-			goto next_card;
-		}
-		dev = -1;
-		while (1) {
-			unsigned int count = 0;
-			if (snd_ctl_pcm_next_device(handle, &dev) < 0)
-				printf("snd_ctl_pcm_next_device\n");
-			if (dev < 0)
-				break;
-			snd_pcm_info_set_device(pcminfo, dev);
-			snd_pcm_info_set_subdevice(pcminfo, 0);
-			snd_pcm_info_set_stream(pcminfo, instream);
-			if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
-				if (err != -ENOENT)
-					printf("control digital audio info (%i): %s\n", card, snd_strerror(err));
-				continue;
-			}
-			printf("card %i: %s [%s], device %i: %s [%s]\n",
-				card, snd_ctl_card_info_get_id(info), snd_ctl_card_info_get_name(info),
-				dev,
-				snd_pcm_info_get_id(pcminfo),
-				snd_pcm_info_get_name(pcminfo));
-			//printf("%s\n",snd_ctl_card_info_get_name(info));
-			count = snd_pcm_info_get_subdevices_count(pcminfo);
-			//printf("  Subdevices: %i/%i\n",snd_pcm_info_get_subdevices_avail(pcminfo), count);
-			for (idx = 0; idx < (int)count; idx++) {
-				snd_pcm_info_set_subdevice(pcminfo, idx);
-				if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
-					printf("control digital audio playback info (%i): %s\n", card, snd_strerror(err));
-				}
-				else {
-					//printf("  Subdevice #%i: %s\n",idx, snd_pcm_info_get_subdevice_name(pcminfo));
-				}
-			}
-		}
-		snd_ctl_close(handle);
-	next_card:
-		if (snd_card_next(&card) < 0) {
-			printf("snd_card_next\n");
-			break;
+	if(0)
+	{
+		HMODULE hModule = GetModuleHandleA("MSVCR100.dll");
+		if (hModule) {
+			typedef char *(*f_setlocale)(int, const char*);
+			f_setlocale f = (f_setlocale)GetProcAddress(hModule, "setlocale");
+			(*f)(LC_ALL, "chs");
 		}
 	}
-}
+	//setlocale(LC_ALL, setlocale(LC_ALL, NULL));
+
+	//getchar();
 
-int main() 
-{
 	if (app_init() != 0) {
 		printf("app init failed!\n");
 		return -1;
@@ -454,17 +370,14 @@ int main()
 	show_audio_dev();
 	show_video_dev();
 
+	//MessageBoxA(0,0,0,0);
+	//show_audio_dev2();
+
 	//getchar();
 
 	app_term();
 
-	printf("\n--------------------------------------------------------------\n");
-	printf("               get audio device info from alsa.               \n");
-	printf("--------------------------------------------------------------\n");
-
-	device_list(true);
-	printf("--------------------------------------------------------------\n");
-	device_list(false);
+	system("pause");
 
 	return 0;
 }

+ 9 - 0
Other/win/showdev/uuid.cpp

@@ -0,0 +1,9 @@
+#include <Windows.h>
+#include <MMDeviceApi.h>
+#include <AudioEngineEndPoint.h>
+#include <DeviceTopology.h>
+#include <EndpointVolume.h>
+#include <functiondiscoverykeys.h>
+
+const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
+const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);

+ 1 - 0
addin/din/win/showdev.bat

@@ -0,0 +1 @@
+showdev.exe >> devlist.txt