Commit 93dd6b52 authored by Nicolas Michon's avatar Nicolas Michon

Add camera device Id to name to avoid duplicates

parent c93e578e
......@@ -96,8 +96,8 @@ set(LIBS ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_LIBRARIES} mf
add_library(mswinrtvid MODULE ${SOURCE_FILES})
set_target_properties(mswinrtvid PROPERTIES VERSION 0)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/libmswinrtvid.pdb
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libmswinrtvid.pdb
DESTINATION lib/mediastreamer/plugins
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
......
......@@ -400,17 +400,26 @@ void MSWinRTCap::configure()
void MSWinRTCap::addCamera(MSWebCamManager *manager, MSWebCamDesc *desc, DeviceInformation^ DeviceInfo)
{
char *idStr = NULL;
char *nameStr = NULL;
size_t returnlen;
size_t inputlen = wcslen(DeviceInfo->Name->Data()) + 1;
char *name = (char *)ms_malloc(inputlen);
if (wcstombs_s(&returnlen, name, inputlen, DeviceInfo->Name->Data(), inputlen) != 0) {
nameStr = (char *)ms_malloc(inputlen);
if (!nameStr || wcstombs_s(&returnlen, nameStr, inputlen, DeviceInfo->Name->Data(), inputlen) != 0) {
ms_error("MSWinRTCap: Cannot convert webcam name to multi-byte string.");
goto error;
}
const wchar_t *id = DeviceInfo->Id->Data();
inputlen = wcslen(id) + 1;
idStr = (char *)ms_malloc(inputlen);
if (!idStr || wcstombs_s(&returnlen, idStr, inputlen, DeviceInfo->Id->Data(), inputlen) != 0) {
ms_error("MSWinRTCap: Cannot convert webcam id to multi-byte string.");
goto error;
}
char *name = bctbx_strdup_printf("%s--%s", nameStr, idStr);
MSWebCam *cam = ms_web_cam_new(desc);
cam->name = ms_strdup(name);
const wchar_t *id = DeviceInfo->Id->Data();
cam->name = name;
WinRTWebcam *winrtwebcam = new WinRTWebcam();
winrtwebcam->id_vector = new std::vector<wchar_t>(wcslen(id) + 1);
wcscpy_s(&winrtwebcam->id_vector->front(), winrtwebcam->id_vector->size(), id);
......@@ -438,7 +447,12 @@ void MSWinRTCap::addCamera(MSWebCamManager *manager, MSWebCamDesc *desc, DeviceI
}
error:
ms_free(name);
if (nameStr) {
ms_free(nameStr);
}
if (idStr) {
ms_free(idStr);
}
}
void MSWinRTCap::registerCameras(MSWebCamManager *manager)
......
......@@ -50,7 +50,7 @@ namespace libmswinrtvid
void MSWinRTCapHelper::OnSampleAvailable(BYTE *buf, DWORD bufLen, LONGLONG presentationTime);
MSVideoSize SelectBestVideoSize(MSVideoSize vs);
mblk_t * GetSample();
property Platform::Agile<MediaCapture^> CaptureDevice
{
Platform::Agile<MediaCapture^> get() { return mCapture; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment