//STUFF YOU CAN CHANGE
+#ifdef _DEBUG
+
//change for verbose debug info
-static bool verbose = true;
+static bool gs_verbose = true;
+
+static void DebugPrintOut(const char *format, ...)
+{
+ if (gs_verbose)
+ {
+ va_list args;
+ va_start(args, format);
+ if( ::IsDebuggerPresent() )
+ {
+ CHAR szMsg[512];
+ ::StringCbVPrintfA(szMsg, sizeof(szMsg), format, args);
+ ::OutputDebugStringA(szMsg);
+ }
+ else
+ {
+ vprintf(format, args);
+ }
+ va_end (args);
+ }
+}
+#else
+#define DebugPrintOut(...) void()
+#endif
//if you need VI to use multi threaded com
//#define VI_COM_MULTI_THREADED
LeaveCriticalSection(&critSection);
SetEvent(hEvent);
}else{
- printf("ERROR: SampleCB() - buffer sizes do not match\n");
+ DebugPrintOut("ERROR: SampleCB() - buffer sizes do not match\n");
}
}
void videoDevice::setSize(int w, int h){
if(sizeSet){
- if(verbose)printf("SETUP: Error device size should not be set more than once \n");
+ DebugPrintOut("SETUP: Error device size should not be set more than once\n");
}
else
{
// We must get the enumerator again every time because removing a filter from the graph
// invalidates the enumerator. We always get only the first filter from each enumerator.
hr = pGraph->EnumFilters(&pEnum);
- if (FAILED(hr)) { if(verbose)printf("SETUP: pGraph->EnumFilters() failed. \n"); return; }
+ if (FAILED(hr)) { DebugPrintOut("SETUP: pGraph->EnumFilters() failed.\n"); return; }
IBaseFilter * pFilter = NULL;
if (pEnum->Next(1, &pFilter, &cFetched) == S_OK)
count++;
}
- if(verbose)printf("SETUP: removing filter %s...\n", buffer);
+ DebugPrintOut("SETUP: removing filter %s...\n", buffer);
hr = pGraph->RemoveFilter(pFilter);
- if (FAILED(hr)) { if(verbose)printf("SETUP: pGraph->RemoveFilter() failed. \n"); return; }
- if(verbose)printf("SETUP: filter removed %s \n",buffer);
+ if (FAILED(hr)) { DebugPrintOut("SETUP: pGraph->RemoveFilter() failed.\n"); return; }
+ DebugPrintOut("SETUP: filter removed %s\n",buffer);
pFilter->Release();
pFilter = NULL;
videoDevice::~videoDevice(){
- if(setupStarted){ if(verbose)printf("\nSETUP: Disconnecting device %i\n", myID); }
+ if(setupStarted){ DebugPrintOut("\nSETUP: Disconnecting device %i\n", myID); }
else{
if(sgCallback){
sgCallback->Release();
if( (sgCallback) && (pGrabber) )
{
pGrabber->SetCallback(NULL, 1);
- if(verbose)printf("SETUP: freeing Grabber Callback\n");
+ DebugPrintOut("SETUP: freeing Grabber Callback\n");
sgCallback->Release();
//delete our pixels
if( (pControl) )
{
HR = pControl->Pause();
- if (FAILED(HR)) if(verbose)printf("ERROR - Could not pause pControl\n");
+ if (FAILED(HR)) DebugPrintOut("ERROR - Could not pause pControl\n");
HR = pControl->Stop();
- if (FAILED(HR)) if(verbose)printf("ERROR - Could not stop pControl\n");
+ if (FAILED(HR)) DebugPrintOut("ERROR - Could not stop pControl\n");
}
//Disconnect filters from capture device
if( (pVideoInputFilter) )NukeDownstream(pVideoInputFilter);
//Release and zero pointers to our filters etc
- if( (pDestFilter) ){ if(verbose)printf("SETUP: freeing Renderer \n");
+ if( (pDestFilter) ){ DebugPrintOut("SETUP: freeing Renderer\n");
(pDestFilter)->Release();
(pDestFilter) = 0;
}
- if( (pVideoInputFilter) ){ if(verbose)printf("SETUP: freeing Capture Source \n");
+ if( (pVideoInputFilter) ){ DebugPrintOut("SETUP: freeing Capture Source\n");
(pVideoInputFilter)->Release();
(pVideoInputFilter) = 0;
}
- if( (pGrabberF) ){ if(verbose)printf("SETUP: freeing Grabber Filter \n");
+ if( (pGrabberF) ){ DebugPrintOut("SETUP: freeing Grabber Filter\n");
(pGrabberF)->Release();
(pGrabberF) = 0;
}
- if( (pGrabber) ){ if(verbose)printf("SETUP: freeing Grabber \n");
+ if( (pGrabber) ){ DebugPrintOut("SETUP: freeing Grabber\n");
(pGrabber)->Release();
(pGrabber) = 0;
}
- if( (pControl) ){ if(verbose)printf("SETUP: freeing Control \n");
+ if( (pControl) ){ DebugPrintOut("SETUP: freeing Control\n");
(pControl)->Release();
(pControl) = 0;
}
- if( (pMediaEvent) ){ if(verbose)printf("SETUP: freeing Media Event \n");
+ if( (pMediaEvent) ){ DebugPrintOut("SETUP: freeing Media Event\n");
(pMediaEvent)->Release();
(pMediaEvent) = 0;
}
- if( (streamConf) ){ if(verbose)printf("SETUP: freeing Stream \n");
+ if( (streamConf) ){ DebugPrintOut("SETUP: freeing Stream\n");
(streamConf)->Release();
(streamConf) = 0;
}
- if( (pAmMediaType) ){ if(verbose)printf("SETUP: freeing Media Type \n");
+ if( (pAmMediaType) ){ DebugPrintOut("SETUP: freeing Media Type\n");
MyDeleteMediaType(pAmMediaType);
}
if((pMediaEvent)){
- if(verbose)printf("SETUP: freeing Media Event \n");
+ DebugPrintOut("SETUP: freeing Media Event\n");
(pMediaEvent)->Release();
(pMediaEvent) = 0;
}
if( (pGraph) )destroyGraph();
//Release and zero our capture graph and our main graph
- if( (pCaptureGraph) ){ if(verbose)printf("SETUP: freeing Capture Graph \n");
+ if( (pCaptureGraph) ){ DebugPrintOut("SETUP: freeing Capture Graph\n");
(pCaptureGraph)->Release();
(pCaptureGraph) = 0;
}
- if( (pGraph) ){ if(verbose)printf("SETUP: freeing Main Graph \n");
+ if( (pGraph) ){ DebugPrintOut("SETUP: freeing Main Graph\n");
(pGraph)->Release();
(pGraph) = 0;
}
delete pCaptureGraph;
delete pGraph;
- if(verbose)printf("SETUP: Device %i disconnected and freed\n\n",myID);
+ DebugPrintOut("SETUP: Device %i disconnected and freed\n\n",myID);
}
//setup a max no of device objects
for(int i=0; i<VI_MAX_CAMERAS; i++) VDList[i] = new videoDevice();
- if(verbose)printf("\n***** VIDEOINPUT LIBRARY - %2.04f - TFW07 *****\n\n",VI_VERSION);
+ DebugPrintOut("\n***** VIDEOINPUT LIBRARY - %2.04f - TFW07 *****\n\n",VI_VERSION);
//added for the pixelink firewire camera
//MEDIASUBTYPE_Y800 = (GUID)FOURCCMap(FCC('Y800'));
// ----------------------------------------------------------------------
void videoInput::setVerbose(bool _verbose){
- verbose = _verbose;
+#ifdef _DEBUG
+ gs_verbose = _verbose;
+#else
+ (void)_verbose; // Suppress 'unreferenced parameter' warning
+#endif
}
// ----------------------------------------------------------------------
bCallback = useCallback;
callbackSetCount = 1;
}else{
- printf("ERROR: setUseCallback can only be called before setup\n");
+ DebugPrintOut("ERROR: setUseCallback can only be called before setup\n");
}
}
if(VDList[deviceNumber]->pVideoInputFilter)VDList[deviceNumber]->pVideoInputFilter = NULL;
if(FAILED(hr)){
- printf("SETUP: couldn't set requested format\n");
+ DebugPrintOut("SETUP: couldn't set requested format\n");
}else{
long lValue = 0;
hr = pVideoDec->get_AvailableTVFormats(&lValue);
{
hr = pVideoDec->put_TVFormat(VDList[deviceNumber]->formatType);
if( FAILED(hr) ){
- printf("SETUP: couldn't set requested format\n");
+ DebugPrintOut("SETUP: couldn't set requested format\n");
}else{
returnVal = true;
}
//COM Library Intialization
comInit();
- if(!silent)printf("\nVIDEOINPUT SPY MODE!\n\n");
+ if(!silent) DebugPrintOut("\nVIDEOINPUT SPY MODE!\n\n");
ICreateDevEnum *pDevEnum = NULL;
if(hr == S_OK){
- if(!silent)printf("SETUP: Looking For Capture Devices\n");
+ if(!silent) DebugPrintOut("SETUP: Looking For Capture Devices\n");
IMoniker *pMoniker = NULL;
while (pEnum->Next(1, &pMoniker, NULL) == S_OK){
}
deviceNames[deviceCounter][count] = 0;
- if(!silent)printf("SETUP: %i) %s \n",deviceCounter, deviceNames[deviceCounter]);
+ if(!silent) DebugPrintOut("SETUP: %i) %s\n",deviceCounter, deviceNames[deviceCounter]);
}
pPropBag->Release();
pEnum = NULL;
}
- if(!silent)printf("SETUP: %i Device(s) found\n\n", deviceCounter);
+ if(!silent) DebugPrintOut("SETUP: %i Device(s) found\n\n", deviceCounter);
}
comUnInit();
processPixels(src, dst, width, height, flipRedAndBlue, flipImage);
success = true;
}else{
- if(verbose)printf("ERROR: GetPixels() - bufferSizes do not match!\n");
+ DebugPrintOut("ERROR: GetPixels() - bufferSizes do not match!\n");
}
}else{
- if(verbose)printf("ERROR: GetPixels() - Unable to grab frame for device %i\n", id);
+ DebugPrintOut("ERROR: GetPixels() - Unable to grab frame for device %i\n", id);
}
}
}
VDList[id]->nFramesRunning++;
if(freeze && VDList[id]->autoReconnect){
- if(verbose)printf("ERROR: Device seems frozen - attempting to reconnect\n");
+ DebugPrintOut("ERROR: Device seems frozen - attempting to reconnect\n");
if( !restartDevice(VDList[id]->myID) ){
- if(verbose)printf("ERROR: Unable to reconnect to device\n");
+ DebugPrintOut("ERROR: Unable to reconnect to device\n");
}else{
- if(verbose)printf("SUCCESS: Able to reconnect to device\n");
+ DebugPrintOut("SUCCESS: Able to reconnect to device\n");
}
}
hr = getDevice(&VD->pVideoInputFilter, deviceID, VD->wDeviceName, VD->nDeviceName);
if (FAILED(hr)){
- printf("setVideoSetting - getDevice Error\n");
+ DebugPrintOut("setVideoSetting - getDevice Error\n");
return false;
}
hr = VD->pVideoInputFilter->QueryInterface(IID_IAMVideoProcAmp, (void**)&pAMVideoProcAmp);
if(FAILED(hr)){
- printf("setVideoSetting - QueryInterface Error\n");
+ DebugPrintOut("setVideoSetting - QueryInterface Error\n");
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
return false;
char propStr[16];
getVideoPropertyAsString(Property,propStr);
- if (verbose) printf("Setting video setting %s.\n", propStr);
+ DebugPrintOut("Setting video setting %s.\n", propStr);
pAMVideoProcAmp->GetRange(Property, &min, &max, &SteppingDelta, &defaultValue, &flags);
- if (verbose) printf("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, min, max, SteppingDelta, defaultValue, flags);
+ DebugPrintOut("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, min, max, SteppingDelta, defaultValue, flags);
pAMVideoProcAmp->Get(Property, ¤tValue, &flags);
if(pAMVideoProcAmp)pAMVideoProcAmp->Release();
float halfStep = (float)stepAmnt * 0.5f;
if( mod < halfStep ) rasterValue -= mod;
else rasterValue += stepAmnt - mod;
- printf("RASTER - pctValue is %f - value is %li - step is %li - mod is %li - rasterValue is %li\n", pctValue, value, stepAmnt, mod, rasterValue);
+ DebugPrintOut("RASTER - pctValue is %f - value is %li - step is %li - mod is %li - rasterValue is %li\n", pctValue, value, stepAmnt, mod, rasterValue);
}
return setVideoSettingFilter(deviceID, Property, rasterValue, Flags, false);
hr = getDevice(&VD->pVideoInputFilter, deviceID, VD->wDeviceName, VD->nDeviceName);
if (FAILED(hr)){
- printf("setVideoSetting - getDevice Error\n");
+ DebugPrintOut("setVideoSetting - getDevice Error\n");
return false;
}
hr = VD->pVideoInputFilter->QueryInterface(IID_IAMVideoProcAmp, (void**)&pAMVideoProcAmp);
if(FAILED(hr)){
- printf("setVideoSetting - QueryInterface Error\n");
+ DebugPrintOut("setVideoSetting - QueryInterface Error\n");
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
return false;
}
- if (verbose) printf("Setting video setting %s.\n", propStr);
+ DebugPrintOut("Setting video setting %s.\n", propStr);
long CurrVal, Min, Max, SteppingDelta, Default, CapsFlags, AvailableCapsFlags = 0;
pAMVideoProcAmp->GetRange(Property, &Min, &Max, &SteppingDelta, &Default, &AvailableCapsFlags);
- if (verbose) printf("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, Min, Max, SteppingDelta, Default, AvailableCapsFlags);
+ DebugPrintOut("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, Min, Max, SteppingDelta, Default, AvailableCapsFlags);
pAMVideoProcAmp->Get(Property, &CurrVal, &CapsFlags);
- if (verbose) printf("Current value: %ld Flags %ld (%s)\n", CurrVal, CapsFlags, (CapsFlags == 1 ? "Auto" : (CapsFlags == 2 ? "Manual" : "Unknown")));
+ DebugPrintOut("Current value: %ld Flags %ld (%s)\n", CurrVal, CapsFlags, (CapsFlags == 1 ? "Auto" : (CapsFlags == 2 ? "Manual" : "Unknown")));
if (useDefaultValue) {
pAMVideoProcAmp->Set(Property, Default, VideoProcAmp_Flags_Auto);
float halfStep = (float)stepAmnt * 0.5f;
if( mod < halfStep ) rasterValue -= mod;
else rasterValue += stepAmnt - mod;
- printf("RASTER - pctValue is %f - value is %li - step is %li - mod is %li - rasterValue is %li\n", pctValue, value, stepAmnt, mod, rasterValue);
+ DebugPrintOut("RASTER - pctValue is %f - value is %li - step is %li - mod is %li - rasterValue is %li\n", pctValue, value, stepAmnt, mod, rasterValue);
}
return setVideoSettingCamera(deviceID, Property, rasterValue, Flags, false);
char propStr[16];
getCameraPropertyAsString(Property,propStr);
- if (verbose) printf("Setting video setting %s.\n", propStr);
+ DebugPrintOut("Setting video setting %s.\n", propStr);
hr = VDList[deviceID]->pVideoInputFilter->QueryInterface(IID_IAMCameraControl, (void**)&pIAMCameraControl);
if (FAILED(hr)) {
- printf("Error\n");
+ DebugPrintOut("Error\n");
return false;
}
else
{
long CurrVal, Min, Max, SteppingDelta, Default, CapsFlags, AvailableCapsFlags;
pIAMCameraControl->GetRange(Property, &Min, &Max, &SteppingDelta, &Default, &AvailableCapsFlags);
- if (verbose) printf("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, Min, Max, SteppingDelta, Default, AvailableCapsFlags);
+ DebugPrintOut("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, Min, Max, SteppingDelta, Default, AvailableCapsFlags);
pIAMCameraControl->Get(Property, &CurrVal, &CapsFlags);
- if (verbose) printf("Current value: %ld Flags %ld (%s)\n", CurrVal, CapsFlags, (CapsFlags == 1 ? "Auto" : (CapsFlags == 2 ? "Manual" : "Unknown")));
+ DebugPrintOut("Current value: %ld Flags %ld (%s)\n", CurrVal, CapsFlags, (CapsFlags == 1 ? "Auto" : (CapsFlags == 2 ? "Manual" : "Unknown")));
if (useDefaultValue) {
pIAMCameraControl->Set(Property, Default, CameraControl_Flags_Auto);
}
hr = getDevice(&VD->pVideoInputFilter, deviceID, VD->wDeviceName, VD->nDeviceName);
if (FAILED(hr)){
- printf("setVideoSetting - getDevice Error\n");
+ DebugPrintOut("setVideoSetting - getDevice Error\n");
return false;
}
hr = VD->pVideoInputFilter->QueryInterface(IID_IAMCameraControl, (void**)&pIAMCameraControl);
if(FAILED(hr)){
- printf("setVideoSetting - QueryInterface Error\n");
+ DebugPrintOut("setVideoSetting - QueryInterface Error\n");
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
return false;
char propStr[16];
getCameraPropertyAsString(Property,propStr);
- if (verbose) printf("Setting video setting %s.\n", propStr);
+ DebugPrintOut("Setting video setting %s.\n", propStr);
pIAMCameraControl->GetRange(Property, &min, &max, &SteppingDelta, &defaultValue, &flags);
- if (verbose) printf("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, min, max, SteppingDelta, defaultValue, flags);
+ DebugPrintOut("Range for video setting %s: Min:%ld Max:%ld SteppingDelta:%ld Default:%ld Flags:%ld\n", propStr, min, max, SteppingDelta, defaultValue, flags);
pIAMCameraControl->Get(Property, ¤tValue, &flags);
if(pIAMCameraControl)pIAMCameraControl->Release();
//if another library has started com as single threaded
//and we need it multi-threaded - send warning but don't fail
if( hr == RPC_E_CHANGED_MODE){
- if(verbose)printf("SETUP - COM already setup - threaded VI might not be possible\n");
+ DebugPrintOut("SETUP - COM already setup - threaded VI might not be possible\n");
}
}
if(deviceNumber>devicesFound-1)
{
- if(verbose)printf("SETUP: device[%i] not found - you have %i devices available\n", deviceNumber, devicesFound);
- if(devicesFound>=0) if(verbose)printf("SETUP: this means that the last device you can use is device[%i] \n", devicesFound-1);
+ DebugPrintOut("SETUP: device[%i] not found - you have %i devices available\n", deviceNumber, devicesFound);
+ if(devicesFound>=0) DebugPrintOut("SETUP: this means that the last device you can use is device[%i]\n", devicesFound-1);
return false;
}
if(VDList[deviceNumber]->readyToCapture)
{
- if(verbose)printf("SETUP: can't setup, device %i is currently being used\n",VDList[deviceNumber]->myID);
+ DebugPrintOut("SETUP: can't setup, device %i is currently being used\n",VDList[deviceNumber]->myID);
return false;
}
//Don't want to get stuck in a loop
if(stepX < 1 || stepY < 1) continue;
- //if(verbose)printf("min is %i %i max is %i %i - res is %i %i \n", scc.MinOutputSize.cx, scc.MinOutputSize.cy, scc.MaxOutputSize.cx, scc.MaxOutputSize.cy, stepX, stepY);
- //if(verbose)printf("min frame duration is %i max duration is %i\n", scc.MinFrameInterval, scc.MaxFrameInterval);
+ //DebugPrintOut("min is %i %i max is %i %i - res is %i %i\n", scc.MinOutputSize.cx, scc.MinOutputSize.cy, scc.MaxOutputSize.cx, scc.MaxOutputSize.cy, stepX, stepY);
+ //DebugPrintOut("min frame duration is %i max duration is %i\n", scc.MinFrameInterval, scc.MaxFrameInterval);
bool exactMatch = false;
bool exactMatchX = false;
CAPTURE_MODE = PIN_CATEGORY_CAPTURE; //Don't worry - it ends up being preview (which is faster)
callbackSetCount = 1; //make sure callback method is not changed after setup called
- if(verbose)printf("SETUP: Setting up device %i\n",deviceID);
+ DebugPrintOut("SETUP: Setting up device %i\n",deviceID);
// CREATE THE GRAPH BUILDER //
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void **)&VD->pCaptureGraph);
if (FAILED(hr)) // FAILED is a macro that tests the return value
{
- if(verbose)printf("ERROR - Could not create the Filter Graph Manager\n");
+ DebugPrintOut("ERROR - Could not create the Filter Graph Manager\n");
return hr;
}
hr = CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void**)&VD->pGraph);
if (FAILED(hr))
{
- if(verbose)printf("ERROR - Could not add the graph builder!\n");
+ DebugPrintOut("ERROR - Could not add the graph builder!\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pCaptureGraph->SetFiltergraph(VD->pGraph);
if (FAILED(hr))
{
- if(verbose)printf("ERROR - Could not set filtergraph\n");
+ DebugPrintOut("ERROR - Could not set filtergraph\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pGraph->QueryInterface(IID_IMediaControl, (void **)&VD->pControl);
if (FAILED(hr))
{
- if(verbose)printf("ERROR - Could not create the Media Control object\n");
- stopDevice(deviceID);
+ DebugPrintOut("ERROR - Could not create the Media Control object\n");
+ stopDevice(deviceID);
return hr;
}
hr = getDevice(&VD->pVideoInputFilter, deviceID, VD->wDeviceName, VD->nDeviceName);
if (SUCCEEDED(hr)){
- if(verbose)printf("SETUP: %s\n", VD->nDeviceName);
+ DebugPrintOut("SETUP: %s\n", VD->nDeviceName);
hr = VD->pGraph->AddFilter(VD->pVideoInputFilter, VD->wDeviceName);
}else{
- if(verbose)printf("ERROR - Could not find specified video device\n");
+ DebugPrintOut("ERROR - Could not find specified video device\n");
stopDevice(deviceID);
return hr;
}
IAMStreamConfig *streamConfTest = NULL;
hr = VD->pCaptureGraph->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, VD->pVideoInputFilter, IID_IAMStreamConfig, (void **)&streamConfTest);
if(FAILED(hr)){
- if(verbose)printf("SETUP: Couldn't find preview pin using SmartTee\n");
+ DebugPrintOut("SETUP: Couldn't find preview pin using SmartTee\n");
}else{
CAPTURE_MODE = PIN_CATEGORY_PREVIEW;
streamConfTest->Release();
//webcams tend not to have a crossbar so this function will also detect a webcams and not apply the crossbar
if(VD->useCrossbar)
{
- if(verbose)printf("SETUP: Checking crossbar\n");
+ DebugPrintOut("SETUP: Checking crossbar\n");
routeCrossbar(&VD->pCaptureGraph, &VD->pVideoInputFilter, VD->connection, CAPTURE_MODE);
}
//we do this because webcams don't have a preview mode
hr = VD->pCaptureGraph->FindInterface(&CAPTURE_MODE, &MEDIATYPE_Video, VD->pVideoInputFilter, IID_IAMStreamConfig, (void **)&VD->streamConf);
if(FAILED(hr)){
- if(verbose)printf("ERROR: Couldn't config the stream!\n");
+ DebugPrintOut("ERROR: Couldn't config the stream!\n");
stopDevice(deviceID);
return hr;
}
//NOW LETS DEAL WITH GETTING THE RIGHT SIZE
hr = VD->streamConf->GetFormat(&VD->pAmMediaType);
if(FAILED(hr)){
- if(verbose)printf("ERROR: Couldn't getFormat for pAmMediaType!\n");
+ DebugPrintOut("ERROR: Couldn't getFormat for pAmMediaType!\n");
stopDevice(deviceID);
return hr;
}
bool foundSize = false;
if(customSize){
- if(verbose) printf("SETUP: Default Format is set to %i by %i \n", currentWidth, currentHeight);
+ DebugPrintOut("SETUP: Default Format is set to %ix%i\n", currentWidth, currentHeight);
char guidStr[8];
// try specified format and size
getMediaSubtypeAsString(VD->tryVideoType, guidStr);
- if(verbose)printf("SETUP: trying specified format %s @ %i by %i\n", guidStr, VD->tryWidth, VD->tryHeight);
+ DebugPrintOut("SETUP: trying specified format %s @ %ix%i\n", guidStr, VD->tryWidth, VD->tryHeight);
if( setSizeAndSubtype(VD, VD->tryWidth, VD->tryHeight, VD->tryVideoType) ){
VD->setSize(VD->tryWidth, VD->tryHeight);
getMediaSubtypeAsString(mediaSubtypes[i], guidStr);
- if(verbose)printf("SETUP: trying format %s @ %i by %i\n", guidStr, VD->tryWidth, VD->tryHeight);
+ DebugPrintOut("SETUP: trying format %s @ %ix%i\n", guidStr, VD->tryWidth, VD->tryHeight);
if( setSizeAndSubtype(VD, VD->tryWidth, VD->tryHeight, mediaSubtypes[i]) ){
VD->setSize(VD->tryWidth, VD->tryHeight);
VD->videoType = mediaSubtypes[i];
//if we didn't find the requested size - lets try and find the closest matching size
if( foundSize == false ){
- if( verbose )printf("SETUP: couldn't find requested size - searching for closest matching size\n");
+ DebugPrintOut("SETUP: couldn't find requested size - searching for closest matching size\n");
int closestWidth = -1;
int closestHeight = -1;
if( closestWidth != -1 && closestHeight != -1){
getMediaSubtypeAsString(newMediaSubtype, guidStr);
- if(verbose)printf("SETUP: closest supported size is %s @ %i %i\n", guidStr, closestWidth, closestHeight);
+ DebugPrintOut("SETUP: closest supported size is %s @ %i %i\n", guidStr, closestWidth, closestHeight);
if( setSizeAndSubtype(VD, closestWidth, closestHeight, newMediaSubtype) ){
VD->setSize(closestWidth, closestHeight);
foundSize = true;
// Create the Sample Grabber.
hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,IID_IBaseFilter, (void**)&VD->pGrabberF);
if (FAILED(hr)){
- if(verbose)printf("Could not Create Sample Grabber - CoCreateInstance()\n");
+ DebugPrintOut("Could not Create Sample Grabber - CoCreateInstance()\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pGraph->AddFilter(VD->pGrabberF, L"Sample Grabber");
if (FAILED(hr)){
- if(verbose)printf("Could not add Sample Grabber - AddFilter()\n");
+ DebugPrintOut("Could not add Sample Grabber - AddFilter()\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&VD->pGrabber);
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not query SampleGrabber\n");
+ DebugPrintOut("ERROR: Could not query SampleGrabber\n");
stopDevice(deviceID);
return hr;
}
//We use SampleCB
hr = VD->pGrabber->SetCallback(VD->sgCallback, 0);
if (FAILED(hr)){
- if(verbose)printf("ERROR: problem setting callback\n");
+ DebugPrintOut("ERROR: problem setting callback\n");
stopDevice(deviceID);
return hr;
}else{
- if(verbose)printf("SETUP: Capture callback set\n");
+ DebugPrintOut("SETUP: Capture callback set\n");
}
}
VD->streamConf->Release();
VD->streamConf = NULL;
}else{
- if(verbose)printf("ERROR: connecting device - prehaps it is already being used?\n");
+ DebugPrintOut("ERROR: connecting device - prehaps it is already being used?\n");
stopDevice(deviceID);
return S_FALSE;
}
//used to give the video stream somewhere to go to.
hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)(&VD->pDestFilter));
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not create filter - NullRenderer\n");
+ DebugPrintOut("ERROR: Could not create filter - NullRenderer\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pGraph->AddFilter(VD->pDestFilter, L"NullRenderer");
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not add filter - NullRenderer\n");
+ DebugPrintOut("ERROR: Could not add filter - NullRenderer\n");
stopDevice(deviceID);
return hr;
}
hr = VD->pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, VD->pVideoInputFilter, VD->pGrabberF, VD->pDestFilter);
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not connect pins - RenderStream()\n");
+ DebugPrintOut("ERROR: Could not connect pins - RenderStream()\n");
stopDevice(deviceID);
return hr;
}
IMediaFilter *pMediaFilter = 0;
hr = VD->pGraph->QueryInterface(IID_IMediaFilter, (void**)&pMediaFilter);
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not get IID_IMediaFilter interface\n");
+ DebugPrintOut("ERROR: Could not get IID_IMediaFilter interface\n");
}else{
pMediaFilter->SetSyncSource(NULL);
pMediaFilter->Release();
hr = VD->pControl->Run();
if (FAILED(hr)){
- if(verbose)printf("ERROR: Could not start graph\n");
+ DebugPrintOut("ERROR: Could not start graph\n");
stopDevice(deviceID);
return hr;
}
}
- if(verbose)printf("SETUP: Device is setup and ready to capture.\n\n");
+ DebugPrintOut("SETUP: Device is setup and ready to capture.\n\n");
VD->readyToCapture = true;
//Release filters - seen someone else do this
bool foundDevice = false;
- if(verbose)printf("SETUP: You are not a webcam! Setting Crossbar\n");
+ DebugPrintOut("SETUP: You are not a webcam! Setting Crossbar\n");
pXBar1->Release();
IAMCrossbar *Crossbar;
hr = Crossbar->get_CrossbarPinInfo( iPin , pIndex , &pRIndex , &pType);
if( pType == conType){
- if(verbose)printf("SETUP: Found Physical Interface");
+ DebugPrintOut("SETUP: Found Physical Interface");
switch(conType){
case PhysConn_Video_Composite:
- if(verbose)printf(" - Composite\n");
+ DebugPrintOut(" - Composite\n");
break;
case PhysConn_Video_SVideo:
- if(verbose)printf(" - S-Video\n");
+ DebugPrintOut(" - S-Video\n");
break;
case PhysConn_Video_Tuner:
- if(verbose)printf(" - Tuner\n");
+ DebugPrintOut(" - Tuner\n");
break;
case PhysConn_Video_USB:
- if(verbose)printf(" - USB\n");
+ DebugPrintOut(" - USB\n");
break;
case PhysConn_Video_1394:
- if(verbose)printf(" - Firewire\n");
+ DebugPrintOut(" - Firewire\n");
break;
}
}
Crossbar->Route(pOIndex,pIndex);
}else{
- if(verbose) printf("SETUP: Didn't find specified Physical Connection type. Using Defualt. \n");
+ DebugPrintOut("SETUP: Didn't find specified Physical Connection type. Using Defualt.\n");
}
//we only free the crossbar when we close or restart the device
if(pXBar1)pXBar1 = NULL;
}else{
- if(verbose) printf("SETUP: You are a webcam or snazzy firewire cam! No Crossbar needed\n");
+ DebugPrintOut("SETUP: You are a webcam or snazzy firewire cam! No Crossbar needed\n");
return hr;
}
return hr;
}
-struct SuppressVideoInputMessages
-{
- SuppressVideoInputMessages() { videoInput::setVerbose(false); }
-};
-
-static SuppressVideoInputMessages do_it;
-
namespace cv
{
videoInput VideoCapture_DShow::g_VI;