Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DirectShow in C++?

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
Hi,

I have a problem with DirectShow, in running through Microsoft's basic Video Control tutorials.

These are my global declerations, which I have checked, and are sure they are right:

static const UUID CLSID_MSVIDCTL = {0xB0EDF162, 0x910A, 0x11D2, {0xB6, 0x32, 0x00, 0xC0, 0x4F, 0x79, 0x49, 0x8E}};
static const UUID CLSID_SystemTuningSpaces = {0x164EDA5, 0x6A8F, 0x11D1, {0x9A, 0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};

This is my actual code:

HRESULT hr = S_OK;

hr = CoInitialize(NULL);

CComPtr<ITuningSpaceContainer> pTuningSpaceContainer;

hr = CoCreateInstance(CLSID_SystemTuningSpaces, NULL, CLSCTX_INPROC_SERVER, __uuidof(ITuningSpaceContainer), (void **) &pTuningSpaceContainer);

CComPtr<IMSVidCtl> pVidCtl;

hr = CoCreateInstance(CLSID_MSVIDCTL, NULL, CLSCTX_INPROC_SERVER, __uuidof(IMSVidCtl), (void **) &pVidCtl);


It fails on every CoCreateInstance to create one. I get the error message that hr = 0x80040154 Class not registered.

I'm sure I've registered everything I need, anything I might have overlooked?

Thanks,
Dan
 
Did you include Library you need (I mean in tool ->option->project...) Included fles from DirectXSDK in VC++ should be at the first place so check it. Look at piece of my code. It's working, maybe it will help you.

CVMR_Capture::CVMR_Capture(void)
{

CoInitialize(NULL);


m_pGB = NULL; //pointers to my interfaces
m_pMC = NULL;
m_pME = NULL;
m_pWC = NULL;
m_pDF =NULL;







CapGraphBuilder = NULL;
StreamConfig = NULL;
VFWDialogs = NULL;




}
HRESULT CVMR_Capture::Init(int iDeviceID, HWND hWnd, int iWidth, int iHeight, int element_tablicy)
{
HRESULT hr;

if(CapGraphBuilder) return true;

hr=CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2,(void **) &CapGraphBuilder);


if(FAILED(hr)) return false;
}

Good Luck!

Bartek
 
Thanks for the reply.

I have a few problems with you code. By the way, all the correct libraries and includes have been set in VS.

Firstly, in lines such as:
m_pMC = NULL;
You don't state what type of object you want it to be? So my code fails, requiring a type.

I have included <uuids.h> which includes the reference to CLSID_CaptureGraphBuilder2, yet it can't find it unless I explicity declare it as a global variable in my code.

Likewise for IID_ICaptureGraphBuilder2.

Also, where do you call these functions?

Thanks, Dan
 
This is begin of my *.h file. Of course it's not all but you can see what I mean writing m_pGB etc...

#if !defined(AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_)
#define AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_

#define MAX 10

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include <atlbase.h>
#include <dshow.h>
#include <d3d9.h>
#include <vmr9.h>
class CVMR_Capture
{
public:
CVMR_Capture();

virtual ~CVMR_Capture(void);


protected:


IGraphBuilder *m_pGB ;
IMediaControl *m_pMC;

IMediaEventEx *m_pME ;
IMediaEvent *pME ;


IVMRWindowlessControl *m_pWC;
.
.
.
etc.....

So now choose from menu Project->your projet settings->Linker and you will see additional Library Directories. Put here the path to your Lib file from DX SDK. Then i Linker->Input->Additional Dependecies put:
strmiids.lib quartz.lib strmbasd.lib winmm.lib msacm32.lib olepro32.lib
and Ignore Specific Library:libcd libcmtd
Then in Resources->General->Additional Include Directories I have smth like this:
"$(IntDir)";"D:\!Projekty!\BaseClasses"

where BaseClasses are the compiled and build files form DX SDK.
I spent a lot of time doing this and trying to run all this stuff but I've done, so I hope my tip will be helpfull. In case of some problems write an answer to my post

Best

Bartek
 
This is begin of my *.h file. Of course it's not all but you can see what I mean writing m_pGB etc...

#if !defined(AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_)
#define AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_

#define MAX 10

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include <atlbase.h>
#include <dshow.h>
#include <d3d9.h>
#include <vmr9.h>
class CVMR_Capture
{
public:
CVMR_Capture();

virtual ~CVMR_Capture(void);


protected:


IGraphBuilder *m_pGB ;
IMediaControl *m_pMC;

IMediaEventEx *m_pME ;
IMediaEvent *pME ;


IVMRWindowlessControl *m_pWC;
.
.
.
etc.....

So now choose from menu Project->your projet settings->Linker and you will see additional Library Directories. Put here the path to your Lib file from DX SDK. Then i Linker->Input->Additional Dependecies put:
strmiids.lib quartz.lib strmbasd.lib winmm.lib msacm32.lib olepro32.lib
and Ignore Specific Library:libcd libcmtd
Then in Resources->General->Additional Include Directories I have smth like this:
"$(IntDir)";"D:\!Projekty!\BaseClasses"

where BaseClasses are the compiled and build files form DX SDK.
I spent a lot of time doing this and trying to run all this stuff but I've done, so I hope my tip will be helpfull. In case of some problems write an answer to my post.
All of this function is a part of my project which is responsible to reading Data from my framegrabber.

Best

Bartek
 
Thanks a lot for your help.

The problem you have highlighted seems to be from the strmbasd.lib and strmbase.lib which are not currently available.

I set about trying to compile the BaseClasses but ran into another problem.

The BaseClasses won't compile because VS cannot open strmiids.lib.

I have set all the correct paths for includes and libs under (options -> projects -> VC++ Directories).

There is no linker folder though in the property pages.

I have c/c++, librarian, resources, etc...

Where do I define the path to strmiids.lib, I have tried everything I can think of.

Thanks, again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top