title: Create a custom class for this directshow system, cant figure out how
body: <p>I'm trying to learn directshow, and computer vision with opencv. But to keep the code cleaner I want to "put away" (create a class) the directshow code that I've borrowed from the internet. 
  The code is: 
  <a href="http://alax.info/trac/public/browser/trunk/Utilities/SetLifeCamStudioResolutionSample/SetLifeCamStudioResolutionSample.cpp" rel="nofollow">http://alax.info/trac/public/browser/trunk/Utilities/SetLifeCamStudioResolutionSample/SetLifeCamStudioResolutionSample.cpp</a></p>
  
  <p>Okay. so in my vc++ project, I create a new class. I call it "directshowclass", I have directshowclass.h &amp; .cpp.</p>
  
  <p>The problem I have is that I cant figure out how to take care of all parts in the code.</p>
  
  <p>Everything in _tmain() I put in one function. that one is okay.</p>
  
  <p>But what do I do with:</p>
  
  <pre><code>CComPtr&lt;IPin&gt; GetPin(IBaseFilter* pBaseFilter, SIZE_T nIndex = 0)
  {
      ....
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>#pragma region Formerly located in qedit.h in Windows SDK, now obsoleted and defined within project
  
  struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
  ISampleGrabberCB : IUnknown
  {
      //
      // Raw methods provided by interface
      //
  
        virtual HRESULT __stdcall SampleCB (double SampleTime,struct IMediaSample * pSample ) = 0;
        virtual HRESULT __stdcall BufferCB double SampleTime,unsigned char * pBuffer, long BufferLen ) = 0;
  };
  
  struct __declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
  ISampleGrabber : IUnknown
  {
      //
      // Raw methods provided by interface
      //
  
        virtual HRESULT __stdcall SetOneShot (
          long OneShot ) = 0;
        virtual HRESULT __stdcall SetMediaType (
          struct _AMMediaType * pType ) = 0;
        virtual HRESULT __stdcall GetConnectedMediaType (
          struct _AMMediaType * pType ) = 0;
        virtual HRESULT __stdcall SetBufferSamples (
          long BufferThem ) = 0;
        virtual HRESULT __stdcall GetCurrentBuffer (
          /*[in,out]*/ long * pBufferSize,
          /*[out]*/ long * pBuffer ) = 0;
        virtual HRESULT __stdcall GetCurrentSample (
          /*[out,retval]*/ struct IMediaSample * * ppSample ) = 0;
        virtual HRESULT __stdcall SetCallback (
          struct ISampleGrabberCB * pCallback,
          long WhichMethodToCallback ) = 0;
  };
  
  struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
  SampleGrabber;
      // [ default ] interface ISampleGrabber
  
  #pragma endregion
  
  #undef ATLENSURE_SUCCEEDED
  #define ATLENSURE_SUCCEEDED(x) { HRESULT __a = (x); if(FAILED(__a)) { _tprintf(_T("Error 0x%08x in line %d\n"), __a, __LINE__); AtlThrow(__a); } }
  </code></pre>
  
  <p>How do I declare them in the .h file? and also .cpp file.</p>