Sign in to follow this  
VanillaSnake21

DirectShow VideoWindow

Recommended Posts

Hi, Im having trouble running a video in my own window, I pinned the problem down to the call put_Owner(), it fails every time with an error VFW_E_NOT_CONNECTED im trying to run all the functions from a class, maybe thats the problem, heres some source

VideoPlayback::VideoPlayback()
{
	CoInitialize(NULL);

	CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&graphBuilder);

	if(FAILED(graphBuilder->QueryInterface(IID_IMediaControl, (void **)&mediaControl)))
		MB_INFO("Query Interface Media Control Failed");
	
	if(FAILED(graphBuilder->QueryInterface (IID_IMediaEvent, (void **)&mediaEvent)))
			MB_INFO("Query Interface Media Event Failed");

	if(FAILED(graphBuilder->QueryInterface (IID_IVideoWindow, (void **)&videoWindow)))
			MB_INFO("Query Interface Video Window Failed");

}

void VideoPlayback::SetVideoWindow(HWND * wnd)
{
	mainWindow = wnd;

	// The first call is to put_Owner, here we are telling DirectShow to use our main Window which we have the handle for 
	// (hWnd is a handle to a window and is returned when we call CreateWindow. For further info see: WinMain).
	//graphBuilder->ConnectDirect(
	HRESULT hr; 
	if(FAILED( hr = videoWindow->put_Owner((OAHWND)*wnd)))
	{
		MB_INFO("put_Owner failed");
		if(hr = VFW_E_NOT_CONNECTED)
			MB_INFO("Not Connected");
	}

	WINDOWINFO info;
	GetWindowInfo(wnd, &info);

	// DirectShow needs to know this information so it can correctly calculate where to position 
	// the video e.g. avoid drawing over the menu bar.
	if(FAILED(videoWindow->put_Windowstyle(info.dwstyle)))
		MB_INFO("put_Windowstyle failed");


	RECT clientRect;

	GetClientRect(wnd, &clientRect);

	if(FAILED(videoWindow->SetWindowPosition(clientRect.left, clientRect.top, clientRect.right, clientRect.bottom)))
		MB_INFO("SetWindowPosition failed");


	//if(FAILED(mediaEvent->SetNotifyWindow((OAHWND)wnd, WM_GRAPHNOTIFY, 0)))
	//	MB_INFO("SetNotifyWindow failed");


} 
I really need help since there are almost no good tutorials on DirectShow (by the way if anyone knows any good ones, please post them up) Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this