From 5a40ac88a4829943be968a564abbf8c99b5c14df Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Wed, 13 May 2020 01:28:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87=EF=BC=8C?= =?UTF-8?q?=E5=B0=9A=E5=B7=AE=E9=93=BE=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yuvgl/media/CameraCapture.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/client/qt_gl_render/yuvgl/media/CameraCapture.cpp b/client/qt_gl_render/yuvgl/media/CameraCapture.cpp index 0328604..bc0b89d 100644 --- a/client/qt_gl_render/yuvgl/media/CameraCapture.cpp +++ b/client/qt_gl_render/yuvgl/media/CameraCapture.cpp @@ -1,6 +1,7 @@ #include "CameraCapture.h" #include "Debuger.h" + #pragma comment(lib, "strmiids") //define release maco @@ -237,20 +238,23 @@ bool Camera::Open(std::wstring &camera_name) if (names.empty()) { - Close(); return false; + Close(); + return false; } + bool founded = false; + for(std::wstring i : names ){ + if(i == camera_name){ + founded = true; + } + } + if (!founded){ - auto name_it = find(names.begin(), names.end(), camera_name); - if (name_it == names.end()) - { - Close(); return false; - } - - int deviceID = static_cast(distance(names.begin(), name_it)); + } + int deviceID = 0; // create grabber filter instance - CHECK_HR(CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, + CHECK_HR(CoCreateInstance(IID_ISampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (LPVOID*)&pSampleGrabberFilter)); // bind source device @@ -294,7 +298,7 @@ bool Camera::Open(std::wstring &camera_name) mediaType.formattype = FORMAT_VideoInfo; hr = mSampGrabber->SetMediaType(&mediaType); - CHECK_HR(CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)(&dest_filter))); + CHECK_HR(CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)(&dest_filter))); mGraphBuilder->AddFilter(dest_filter, L"NullRenderer"); // connect source filter to grabber filter