C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2009, 09:32 PM   #1
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,924
Problem with settgin a callback under directshow

1>..\Include\CDirectShowCamera.cpp(224) : error C3867: 'CDirectShowCamera::BufferCB': function call missing argument list; use '&CDirectShowCamera::BufferCB' to create a pointer to member
Code:
this->pGrabber->SetCallback(this->BufferCB , 1);
 
keep returning errors, here is the callback function, which is implimented as a member function

Code:
HRESULT CDirectShowCamera::BufferCB(double SampleTime , BYTE* pImage , long BufferLen){ 
 // snip irrelevant guts
   return S_OK;
 } 
 
except if I add the ampersand it gives this error

Code:
 this->pGrabber->SetCallback(&CDirectShowCamera::BufferCB , 1);
1>..\Include\CDirectShowCamera.cpp(224) : error C2664: 'ISampleGrabber::SetCallback' : cannot convert parameter 1 from 'HRESULT (__thiscall CDirectShowCamera::* )(double,BYTE *,long)' to 'ISampleGrabberCB *'


which makes even less sense. Obviously I need to be able to call this callback function, but I need it to know what instance of CDIrectShowCamera it is handling, so that it can add the sampels to the appropriate buffer. There will be more than one instance of the class operating simultaneously. I know im probably missing somethign realyl obvious.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is online now   Reply With Quote
Old 06-23-2009, 09:44 PM   #2
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
Join Date: Jul 2003
Location: Banks of the River Styx
Posts: 891
Never worked with these, but: "You can't convert a member-function pointer to a ISampleGrabberCB *" -- is what that error says... where are you getting lost?

Seems to me you should derive from ISampleGrabberCB, and implement that interface, instantiate it, and pass the instance. The derived class could hold whatever data you needed it to, such as a pointer to your CDIrectShowCamera. No different than predicates to C++'s standard functions, such as sort(), really.
__________________
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Cactus_Hugger is offline   Reply With Quote
Old 06-23-2009, 10:10 PM   #3
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,922
Right, assuming you've derived the class from ISampleGrabberCB and overloaded the BufferCB or SampleCB functions, you'll just need to pass a pointer to the object itself, ie:

Code:
this->pGrabber->SetCallback(this, 1);
Sebastiani is offline   Reply With Quote
Old 06-23-2009, 10:24 PM   #4
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,924
I tried making a derived class but the compiler pukes because there is no appropriate constructor type in the base class, and when I tried overloading the constructor it puked again saying constructors are not allowed a return type, which didnt make sense since the constructor had no return type. I think im starting to see why pointers to member functions are not used very often.

I'm rethinking my strategy to possibly avoid pointers to member functions. It late and I think im messing up on implimenting the ISampleGrabberCB interface, so ill get soem sleep adn try again tomorrow.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is online now   Reply With Quote
Old 06-23-2009, 10:38 PM   #5
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,922
>> I tried making a derived class but the compiler pukes because there is no appropriate constructor type in the base class, and when I tried overloading the constructor it puked again

Well, you can't override a constructor. Can you post a compilable example?

Last edited by Sebastiani; 06-23-2009 at 10:40 PM.
Sebastiani is offline   Reply With Quote
Old 06-24-2009, 05:22 AM   #6
C++ Witch
 
laserlight's Avatar
 
Join Date: Oct 2003
Location: Singapore
Posts: 10,352
Quote:
Originally Posted by abachler
I tried making a derived class but the compiler pukes because there is no appropriate constructor type in the base class
If I understand this particular hurdle correctly, you could invoke the appropriate base class constructor in the derived class constructor's initialisation list.
__________________
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar

Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
laserlight is offline   Reply With Quote
Old 06-24-2009, 11:32 AM   #7
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,924
Quote:
Originally Posted by Sebastiani View Post
>> I tried making a derived class but the compiler pukes because there is no appropriate constructor type in the base class, and when I tried overloading the constructor it puked again

Well, you can't override a constructor. Can you post a compilable example?
The last compilable example I have doesnt have any of this code in it. It's using the GetCurrentBuffer() method, which I want to improve so that I get every image, with no duplicates. All im trying to do is add the callback so I can buffer each sample and then ill rewrite the CDirectShowCamera::GetCurrentImage() member function to retrieve images from the buffer instead of from GetCurrentBuffer(). This is the relevant code from the constructor function in the last compilable version,

Code:
  this->pGrabber->SetCallback(NULL , 1);
  this->pGrabber->SetBufferSamples(TRUE);

  this->Stage = 17;
  hr = this->pControl->Run();
  if(FAILED(hr)) return;

  this->Stage = 0xffffffff;
  this->Initialized = TRUE;
  return; 
I cant post the whole class as its quite lengthy, this is actually the last thing it does before running the graph
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WS_POPUP, continuation of old problem blurrymadness Windows Programming 1 04-20-2007 06:54 PM
Laptop Problem Boomba Tech Board 1 03-07-2006 06:24 PM
Sorting problem.. well actually more of a string problem fatdunky C Programming 5 11-07-2005 11:34 PM
searching problem DaMenge C Programming 9 09-12-2005 01:04 AM
half ADT (nested struct) problem... CyC|OpS C Programming 1 10-26-2002 08:37 AM


All times are GMT -6. The time now is 05:56 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22