40 #ifndef DOXYGEN_SHOULD_SKIP_THIS 42 #include <visp3/core/vpConfig.h> 43 #if (defined(VISP_HAVE_DIRECTSHOW)) 45 #include <visp3/sensor/vpDirectShowGrabberImpl.h> 47 vpDirectShowDevice *vpDirectShowGrabberImpl::deviceList = NULL;
48 unsigned int vpDirectShowGrabberImpl::nbDevices;
53 void vpDirectShowGrabberImpl::HRtoStr(std::string str)
55 TCHAR szErr[MAX_ERROR_TEXT_LEN];
56 DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
59 str =
"Unknown Error: 0x%2x";
61 char msg[MAX_ERROR_TEXT_LEN];
62 sprintf(msg,
"%s", szErr);
70 vpDirectShowGrabberImpl::vpDirectShowGrabberImpl()
75 if (FAILED(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
83 if (deviceList == NULL) {
84 CComPtr<IEnumMoniker> pVideoInputEnum = NULL;
86 if (enumerate(pVideoInputEnum)) {
87 createDeviceList(pVideoInputEnum);
90 pVideoInputEnum.Release();
98 void vpDirectShowGrabberImpl::open()
101 if (deviceList == NULL) {
102 CComPtr<IEnumMoniker> pVideoInputEnum = NULL;
104 if (enumerate(pVideoInputEnum)) {
105 createDeviceList(pVideoInputEnum);
108 pVideoInputEnum.Release();
111 init = initDirectShow();
135 bool vpDirectShowGrabberImpl::initDirectShow()
139 currentDevice = getFirstUnusedDevice(pCapSource);
141 if (currentDevice == nbDevices)
149 if (FAILED(hr = pGraph->AddFilter(pCapSource, L
"Capture Filter")))
153 if (!createSampleGrabber(pGrabberFilter))
157 if (FAILED(hr = pGraph->AddFilter(pGrabberFilter, L
"SampleGrabber")))
161 if (!connectSourceToGrabber(pCapSource, pGrabberFilter))
165 if (FAILED(hr = pGrabberI->GetConnectedMediaType(&(sgCB.connectedMediaType))))
169 CComPtr<IMediaFilter> pMediaFilter;
171 pGraph->QueryInterface(IID_IMediaFilter, (
void **)&pMediaFilter);
172 pGraph->QueryInterface(IID_IMediaControl, reinterpret_cast<void **>(&pControl));
173 pGraph->QueryInterface(IID_IMediaEvent, (
void **)&pEvent);
175 pMediaFilter->SetSyncSource(NULL);
176 pMediaFilter.Release();
184 vpDirectShowGrabberImpl::~vpDirectShowGrabberImpl() { close(); }
191 bool vpDirectShowGrabberImpl::enumerate(CComPtr<IEnumMoniker> &ppVideoInputEnum)
193 CComPtr<ICreateDevEnum> pDevEnum = NULL;
197 hr = pDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER);
202 hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &ppVideoInputEnum, 0);
217 bool vpDirectShowGrabberImpl::createDeviceList(CComPtr<IEnumMoniker> &ppVideoInputEnum)
219 CComPtr<IMoniker> pMoniker[10];
220 unsigned long nbMoniker;
222 ppVideoInputEnum->Reset();
225 ppVideoInputEnum->Next(10, reinterpret_cast<IMoniker **>(&pMoniker), &nbMoniker);
231 deviceList =
new vpDirectShowDevice[nbMoniker];
233 nbDevices = (
unsigned int)nbMoniker;
239 while (i < nbDevices) {
240 if (!deviceList[i].init(pMoniker[j])) {
255 for (
unsigned int i = 0; i < nbMoniker; i++) {
256 pMoniker[i].Release();
268 bool vpDirectShowGrabberImpl::getDevice(
unsigned int n, CComPtr<IBaseFilter> &ppDevice)
275 if (deviceList[n].getState() ==
true)
279 CComPtr<IEnumMoniker> pVideoInputEnum = NULL;
280 if (!enumerate(pVideoInputEnum))
283 CComPtr<IMoniker> pMoniker = NULL;
284 bool deviceFound =
false;
287 while (pVideoInputEnum->Next(1, &pMoniker, NULL) == S_OK && !deviceFound) {
289 if (deviceList[n] == vpDirectShowDevice(pMoniker)) {
291 if (SUCCEEDED(pMoniker->BindToObject(0, 0, IID_IBaseFilter, (
void **)&ppDevice))) {
293 deviceList[n].setInUse();
302 pVideoInputEnum.Release();
313 unsigned int vpDirectShowGrabberImpl::getFirstUnusedDevice(CComPtr<IBaseFilter> &ppDevice)
318 for (n = 0; n < nbDevices && !found; n++) {
320 if (!deviceList[n].getState()) {
321 if (getDevice(n, ppDevice)) {
323 deviceList[n].setInUse();
336 bool vpDirectShowGrabberImpl::createGraph()
340 hr = pBuild.CoCreateInstance(CLSID_CaptureGraphBuilder2, 0, CLSCTX_INPROC_SERVER);
344 hr = pGraph.CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER);
348 pBuild->SetFiltergraph(pGraph);
362 bool vpDirectShowGrabberImpl::createSampleGrabber(CComPtr<IBaseFilter> &ppGrabberFilter)
365 hr = ppGrabberFilter.CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER);
371 hr = ppGrabberFilter->QueryInterface(IID_ISampleGrabber, reinterpret_cast<void **>(&pGrabberI));
378 ZeroMemory(&mt,
sizeof(AM_MEDIA_TYPE));
380 mt.majortype = MEDIATYPE_Video;
383 mt.subtype = MEDIATYPE_NULL;
385 if (FAILED(hr = pGrabberI->SetMediaType(&mt)))
389 pGrabberI->SetCallback(&sgCB, 1);
392 pGrabberI->SetOneShot(TRUE);
395 pGrabberI->SetBufferSamples(
false);
409 bool vpDirectShowGrabberImpl::checkSourceType(CComPtr<IPin> &pCapSourcePin)
413 if (FAILED(pCapSourcePin->ConnectionMediaType(&mt)))
416 if (mt.majortype != MEDIATYPE_Video)
420 if (mt.subtype == MEDIASUBTYPE_ARGB32 || mt.subtype == MEDIASUBTYPE_RGB32 || mt.subtype == MEDIASUBTYPE_RGB24 ||
421 mt.subtype == MEDIASUBTYPE_RGB555 || mt.subtype == MEDIASUBTYPE_RGB565 || mt.subtype == MEDIASUBTYPE_RGB8 ||
422 mt.subtype == MEDIASUBTYPE_RGB4 || mt.subtype == MEDIASUBTYPE_RGB1) {
424 sgCB.specialMediaType =
false;
427 else if (mt.subtype == MEDIASUBTYPE_AYUV || mt.subtype == MEDIASUBTYPE_UYVY || mt.subtype == MEDIASUBTYPE_Y411 ||
428 mt.subtype == MEDIASUBTYPE_Y41P || mt.subtype == MEDIASUBTYPE_Y211 || mt.subtype == MEDIASUBTYPE_YUY2 ||
429 mt.subtype == MEDIASUBTYPE_YVYU || mt.subtype == MEDIASUBTYPE_YUYV || mt.subtype == MEDIASUBTYPE_IF09 ||
430 mt.subtype == MEDIASUBTYPE_IYUV || mt.subtype == MEDIASUBTYPE_YV12 || mt.subtype == MEDIASUBTYPE_YVU9) {
432 sgCB.specialMediaType =
false;
437 sgCB.specialMediaType =
true;
440 VIDEOINFOHEADER *pVih =
reinterpret_cast<VIDEOINFOHEADER *
>(mt.pbFormat);
441 BITMAPINFOHEADER bmpInfo = pVih->bmiHeader;
444 format = ((bmpInfo.biCompression & 0xFF000000) >> 24) | ((bmpInfo.biCompression & 0x00FF0000) >> 8) |
445 ((bmpInfo.biCompression & 0x0000FF00) << 8) | (bmpInfo.biCompression & 0x000000FF) << 24;
447 std::cout <<
"This format is not one of the standard YUV or RGB format " 448 "supported by DirectShow.\n" 449 <<
"FourCC : " << (char)(bmpInfo.biCompression & 0x000000FF)
450 << (char)((bmpInfo.biCompression & 0x0000FF00) >> 8) << (
char)((bmpInfo.biCompression & 0x00FF0000) >> 16)
451 << (char)((bmpInfo.biCompression & 0xFF000000) >> 24) << std::endl;
455 if (format ==
'Y800') {
456 sgCB.invertedSource =
false;
460 else if (format ==
'cyuv') {
461 sgCB.invertedSource =
true;
467 std::cout <<
"Unknown FourCC compression type, assuming top-down " 468 "orientation. Image may be inverted." 470 sgCB.invertedSource =
false;
483 bool vpDirectShowGrabberImpl::connectSourceToGrabber(CComPtr<IBaseFilter> &_pCapSource,
484 CComPtr<IBaseFilter> &_pGrabberFilter)
504 if (FAILED(hr = pBuild->RenderStream(NULL, NULL, _pCapSource, NULL, _pGrabberFilter)))
514 CComPtr<IBaseFilter> pNull = NULL;
515 if (FAILED(pNull.CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER)))
529 if (FAILED(pGraph->AddFilter(pNull, L
"NullRenderer")) ||
530 FAILED(pBuild->RenderStream(NULL, NULL, _pGrabberFilter, NULL, pNull)))
534 CComPtr<IPin> pCapSourcePin;
535 if (FAILED(pBuild->FindPin(_pCapSource, PINDIR_OUTPUT, NULL, NULL,
false, 0, &pCapSourcePin)))
539 if (!checkSourceType(pCapSourcePin))
543 pCapSourcePin.Release();
556 bool vpDirectShowGrabberImpl::removeAll()
558 CComPtr<IEnumFilters> pEnum = NULL;
559 CComPtr<IBaseFilter> pFilter;
562 if (FAILED(hr = pGraph->EnumFilters(&pEnum)))
565 while (pEnum->Next(1, &pFilter, &cFetched) == S_OK) {
566 if (FAILED(hr = pGraph->RemoveFilter(pFilter)))
595 sgCB.acqRGBaDemand =
true;
602 hr = pEvent->WaitForCompletion(MAX_DELAY, &ev);
608 if (WaitForSingleObject(sgCB.copySem, MAX_DELAY) != WAIT_OBJECT_0)
631 sgCB.acqGrayDemand =
true;
638 hr = pEvent->WaitForCompletion(MAX_DELAY, &ev);
644 if (WaitForSingleObject(sgCB.copySem, MAX_DELAY) != WAIT_OBJECT_0)
654 bool vpDirectShowGrabberImpl::setDevice(
unsigned int id)
662 if (
id >= nbDevices || deviceList[
id].getState() ==
true)
673 pCapSource.Release();
676 deviceList[currentDevice].resetInUse();
679 pGraph->AddFilter(pGrabberFilter, L
"SampleGrabber");
682 if (!getDevice(
id, pCapSource))
686 if (FAILED(hr = pGraph->AddFilter(pCapSource, L
"Capture Filter")))
690 if (!connectSourceToGrabber(pCapSource, pGrabberFilter))
694 if (FAILED(hr = pGrabberI->GetConnectedMediaType(&(sgCB.connectedMediaType)))) {
699 deviceList[id].setInUse();
708 void vpDirectShowGrabberImpl::displayDevices()
710 if (deviceList == NULL) {
714 for (
unsigned int i = 0; i < nbDevices; i++)
715 std::cout << i <<
" : " << deviceList[i].getName() << std::endl;
717 std::cout <<
"Current device : " << currentDevice << std::endl << std::endl;
724 void vpDirectShowGrabberImpl::close()
728 deviceList[currentDevice].resetInUse();
740 bool vpDirectShowGrabberImpl::setImageSize(
unsigned int width,
unsigned int height)
747 return setFormat(width, height, NULL);
753 bool vpDirectShowGrabberImpl::setFramerate(
double framerate)
760 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat;
761 return setFormat(pVih->bmiHeader.biWidth, pVih->bmiHeader.biHeight, framerate);
766 bool vpDirectShowGrabberImpl::setFormat(
unsigned int width,
unsigned int height,
double framerate)
776 IAMStreamConfig *pConfig = NULL;
778 if (FAILED(hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY,
781 IID_IAMStreamConfig, (
void **)&pConfig)))
785 IAMVideoControl *pVideoControl = NULL;
787 if (FAILED(hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY,
790 IID_IAMVideoControl, (
void **)&pVideoControl)))
794 CComPtr<IPin> pCapSourcePin;
795 if (FAILED(pBuild->FindPin(pCapSource, PINDIR_OUTPUT, NULL, NULL,
false, 0, &pCapSourcePin)))
798 int iCount = 0, iSize = 0;
799 if (FAILED(hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize)))
803 if (iSize ==
sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
806 for (
int iFormat = 0; iFormat < iCount; iFormat++) {
807 VIDEO_STREAM_CONFIG_CAPS scc;
808 AM_MEDIA_TYPE *pmtConfig;
809 hr = pConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE *)&scc);
821 if (SUCCEEDED(hr) && found ==
false) {
823 if ((pmtConfig->majortype == sgCB.connectedMediaType.majortype) &&
824 (pmtConfig->subtype == sgCB.connectedMediaType.subtype) &&
825 (pmtConfig->formattype == sgCB.connectedMediaType.formattype) &&
826 (pmtConfig->cbFormat >=
sizeof(VIDEOINFOHEADER)) && (pmtConfig->pbFormat != NULL)) {
827 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)pmtConfig->pbFormat;
829 LONG lWidth = pVih->bmiHeader.biWidth;
830 LONG lHeight = pVih->bmiHeader.biHeight;
831 if (framerate != NULL) {
832 if ((
unsigned int)lWidth == width && (
unsigned int)lHeight == height) {
834 pVih->AvgTimePerFrame = (LONGLONG)(10000000 / framerate);
836 if (FAILED(hr = pConfig->SetFormat(pmtConfig)) || FAILED(hr = pGrabberI->SetMediaType(pmtConfig)))
842 if (FAILED(hr = pGrabberI->GetConnectedMediaType(&(sgCB.connectedMediaType))))
844 pVih = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat;
845 LONGLONG ActualFrameDuration;
846 if (FAILED(hr = pVideoControl->GetCurrentActualFrameRate(pCapSourcePin, &ActualFrameDuration)))
847 std::cout <<
"Current format (not sure): " << width <<
" x " << height <<
" at " 848 << 10000000 / pVih->AvgTimePerFrame <<
" fps" << std::endl
851 std::cout <<
"Current format : " << width <<
" x " << height <<
" at " << 10000000 / ActualFrameDuration
852 <<
" fps" << std::endl
854 pVih->AvgTimePerFrame = ActualFrameDuration;
859 if ((
unsigned int)lWidth == width && (
unsigned int)lHeight == height) {
860 pVih->AvgTimePerFrame = scc.MinFrameInterval;
862 if (FAILED(hr = pConfig->SetFormat(pmtConfig)) || FAILED(hr = pGrabberI->SetMediaType(pmtConfig)))
865 if (FAILED(hr = pGrabberI->GetConnectedMediaType(&(sgCB.connectedMediaType))))
867 pVih = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat;
869 std::cout <<
"Current format : " << width <<
" x " << height <<
" at " 870 << (10000000 / pVih->AvgTimePerFrame) <<
" fps" << std::endl
877 MyDeleteMediaType(pmtConfig);
881 if (framerate != NULL)
882 std::cout <<
"The " << width <<
" x " << height <<
" at " << framerate
883 <<
" fps source image format is not available. " << std::endl
886 std::cout <<
"The " << width <<
" x " << height <<
"source image size is not available. " << std::endl
897 void vpDirectShowGrabberImpl::getFormat(
unsigned int &width,
unsigned int &height,
double &framerate)
903 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat;
904 width = (
unsigned int)pVih->bmiHeader.biWidth;
905 height = (
unsigned int)pVih->bmiHeader.biHeight;
906 framerate = (
double)(10000000 / pVih->AvgTimePerFrame);
911 bool vpDirectShowGrabberImpl::getStreamCapabilities()
919 IAMStreamConfig *pConfig = NULL;
921 if (FAILED(hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY,
924 IID_IAMStreamConfig, (
void **)&pConfig)))
927 int iCount = 0, iSize = 0;
928 if (FAILED(hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize)))
932 if (iSize ==
sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
933 std::cout <<
"Available MediaTypes : " << std::endl << std::endl;
935 for (
int iFormat = 0; iFormat < iCount; iFormat++) {
936 VIDEO_STREAM_CONFIG_CAPS scc;
937 AM_MEDIA_TYPE *pmtConfig;
938 hr = pConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE *)&scc);
942 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)pmtConfig->pbFormat;
950 std::cout <<
"MediaType : " << iFormat << std::endl;
952 if (pmtConfig->subtype == MEDIASUBTYPE_ARGB32)
953 std::cout <<
"subtype (not supported): MEDIASUBTYPE_ARGB32" << std::endl;
954 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB32)
955 std::cout <<
"subtype : MEDIASUBTYPE_RGB32" << std::endl;
956 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB24)
957 std::cout <<
"subtype : MEDIASUBTYPE_RGB24" << std::endl;
958 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB555)
959 std::cout <<
"subtype (not supported): MEDIASUBTYPE_RGB555" << std::endl;
960 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB565)
961 std::cout <<
"subtype (not supported): MEDIASUBTYPE_RGB565" << std::endl;
962 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB8)
963 std::cout <<
"subtype (not supported): MEDIASUBTYPE_RGB8" << std::endl;
964 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB4)
965 std::cout <<
"subtype (not supported): MEDIASUBTYPE_RGB4" << std::endl;
966 else if (pmtConfig->subtype == MEDIASUBTYPE_RGB1)
967 std::cout <<
"subtype (not supported): MEDIASUBTYPE_RGB1" << std::endl;
968 else if (pmtConfig->subtype == MEDIASUBTYPE_YV12)
969 std::cout <<
"subtype : MEDIASUBTYPE_YV12" << std::endl;
970 else if (pmtConfig->subtype == MEDIASUBTYPE_YVU9)
971 std::cout <<
"subtype : MEDIASUBTYPE_YVU9" << std::endl;
972 else if (pmtConfig->subtype == MEDIASUBTYPE_YUY2)
973 std::cout <<
"subtype : MEDIASUBTYPE_YUY2" << std::endl;
974 else if (pmtConfig->subtype == MEDIASUBTYPE_YUYV)
975 std::cout <<
"subtype : MEDIASUBTYPE_YUYV" << std::endl;
976 else if (pmtConfig->subtype == MEDIASUBTYPE_YVYU)
977 std::cout <<
"subtype : MEDIASUBTYPE_YVYU" << std::endl;
978 else if (pmtConfig->subtype == MEDIASUBTYPE_IYUV)
979 std::cout <<
"subtype : MEDIASUBTYPE_IYUV" << std::endl;
980 else if (pmtConfig->subtype == MEDIASUBTYPE_UYVY)
981 std::cout <<
"subtype : MEDIASUBTYPE_UYVY" << std::endl;
982 else if ((((pVih->bmiHeader.biCompression & 0xFF000000) >> 24) |
983 ((pVih->bmiHeader.biCompression & 0x00FF0000) >> 8) |
984 ((pVih->bmiHeader.biCompression & 0x0000FF00) << 8) |
985 ((pVih->bmiHeader.biCompression & 0x000000FF) << 24)) ==
'I420')
986 std::cout <<
"subtype : I420" << std::endl;
988 std::cout <<
"subtype (not supported) :" << (char)(pVih->bmiHeader.biCompression & 0x000000FF)
989 << (char)((pVih->bmiHeader.biCompression & 0x0000FF00) >> 8)
990 << (
char)((pVih->bmiHeader.biCompression & 0x00FF0000) >> 16)
991 << (char)((pVih->bmiHeader.biCompression & 0xFF000000) >> 24) << std::endl;
993 std::cout <<
"image size : " << pVih->bmiHeader.biWidth <<
" x " << pVih->bmiHeader.biHeight << std::endl;
994 std::cout <<
"framerate range: [" << 10000000 / scc.MaxFrameInterval <<
"," << 10000000 / scc.MinFrameInterval
1014 MyDeleteMediaType(pmtConfig);
1022 bool vpDirectShowGrabberImpl::setMediaType(
int mediaTypeID)
1024 if (init ==
false) {
1030 IAMStreamConfig *pConfig = NULL;
1032 if (FAILED(hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY,
1035 IID_IAMStreamConfig, (
void **)&pConfig)))
1038 VIDEO_STREAM_CONFIG_CAPS scc;
1039 AM_MEDIA_TYPE *pmtConfig;
1040 hr = pConfig->GetStreamCaps(mediaTypeID, &pmtConfig, (BYTE *)&scc);
1042 if (SUCCEEDED(hr)) {
1043 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)pmtConfig->pbFormat;
1044 pVih->AvgTimePerFrame = scc.MinFrameInterval;
1046 if (FAILED(hr = pGrabberI->SetMediaType(pmtConfig)) || FAILED(hr = pConfig->SetFormat(pmtConfig)))
1049 if (FAILED(hr = pGrabberI->GetConnectedMediaType(&(sgCB.connectedMediaType))))
1053 MyDeleteMediaType(pmtConfig);
1061 int vpDirectShowGrabberImpl::getMediaType()
1063 if (init ==
false) {
1068 int mediaTypeID = -1;
1069 VIDEOINFOHEADER *pVihConnected = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat;
1072 IAMStreamConfig *pConfig = NULL;
1074 if (FAILED(hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY,
1077 IID_IAMStreamConfig, (
void **)&pConfig)))
1080 int iCount = 0, iSize = 0;
1081 if (FAILED(hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize)))
1085 if (iSize ==
sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
1087 for (
int iFormat = 0; iFormat < iCount; iFormat++) {
1088 VIDEO_STREAM_CONFIG_CAPS scc;
1089 AM_MEDIA_TYPE *pmtConfig;
1090 hr = pConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE *)&scc);
1092 if (SUCCEEDED(hr)) {
1094 if ((pmtConfig->majortype == sgCB.connectedMediaType.majortype) &&
1095 (pmtConfig->subtype == sgCB.connectedMediaType.subtype) &&
1096 (pmtConfig->formattype == sgCB.connectedMediaType.formattype) &&
1097 (pmtConfig->cbFormat >=
sizeof(VIDEOINFOHEADER)) && (pmtConfig->pbFormat != NULL)) {
1098 VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)pmtConfig->pbFormat;
1099 if (pVih->bmiHeader.biWidth == pVihConnected->bmiHeader.biWidth &&
1100 pVih->bmiHeader.biHeight == pVihConnected->bmiHeader.biHeight)
1101 mediaTypeID = iFormat;
1105 MyDeleteMediaType(pmtConfig);
1115 void vpDirectShowGrabberImpl::MyDeleteMediaType(AM_MEDIA_TYPE *pmt)
1118 MyFreeMediaType(*pmt);
1126 void vpDirectShowGrabberImpl::MyFreeMediaType(AM_MEDIA_TYPE &mt)
1128 if (mt.cbFormat != 0) {
1129 CoTaskMemFree((PVOID)mt.pbFormat);
1133 if (mt.pUnk != NULL) {
1140 #elif !defined(VISP_BUILD_SHARED_LIBS) 1143 void dummy_vpDirectShowGrabberImpl(){};
unsigned int getWidth() const
Error that can be emited by the vpFrameGrabber class and its derivates.
unsigned int getHeight() const