Integrating a DirectX Video Stream?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
codwarrior
Posts: 7
Joined: Tue Feb 10, 2004 10:00 am

Integrating a DirectX Video Stream?

Post by codwarrior »

Hi,

I am trying to integrate a video stream from a framegrabber in Irrlicht. So far, I managed to redirect the DirectX graph to the Irrlicht window. But now, the live stream overwrites all Irrlicht-rendered objects. I wonder now how to combine the video stream and the Irrlicht elements so that i can place e.g. IGUIButtons or something above the stream. Has anyone tried something similar?

Or another thought: is it possible to direct the output rendered by Irrlicht, say, to a DirectX graph, a file or anything?

Thanks in advance...
bappy
Posts: 63
Joined: Fri Dec 12, 2003 10:49 am
Location: france
Contact:

Post by bappy »

here is what i making, i can have a video played in irrlicht window with directx show, but for a namespace probleme , i had to recompile the source of irr and rename the class IUnknown to IUknown1

.h:

#include "CDefine.h"
#include <DShow.h>


#pragma comment(lib, "Strmiids.lib")

class CVIDEOPLAYER
{
IGraphBuilder *pGB;
IMediaControl *pMC;
IVideoWindow *pVW;
IMediaEventEx *pME;
IMediaSeeking *pMS;

bool Loop;

public:
CVIDEOPLAYER();
~CVIDEOPLAYER();
void Init(wchar_t *File,int x,int y,int width,int height,bool loop=0);
void Play();
void Pause();
void Stop();
void Remove();
void Update();
bool IsFinish();
};

.cpp:

#include "CVideoPlayer.h"


CVIDEOPLAYER::CVIDEOPLAYER()
{
pGB=NULL;
pMC=NULL;
pVW=NULL;
pME=NULL;
pMS=NULL;
Loop=0;
}

CVIDEOPLAYER::~CVIDEOPLAYER()
{
Remove();
}

void
CVIDEOPLAYER::Init(wchar_t *File,int x,int y,int width,int height,bool loop)
{
HWND g_hwnd=GetHwnd();
Loop=loop;
CoInitialize(NULL);
//This creates the filter graph manager
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGB);

//Query COM interface
pGB->QueryInterface(IID_IMediaControl, (void **)&pMC);
pGB->QueryInterface(IID_IVideoWindow, (void **)&pVW);
pGB->QueryInterface(IID_IMediaEvent, (void **)&pME);
pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS);

pGB->RenderFile(File,NULL);
//Set the parents window
pVW->put_Owner((OAHWND)g_hwnd);

//Sets the child window
pVW->put_WindowStyle(WS_CHILD|WS_CLIPSIBLINGS);

/*//here we create a RECT in which to draw the child window on
RECT vwrect;

//get the size of the Parent
GetClientRect(g_hwnd,&vwrect);
*/
//Set the Child to this position
pVW->SetWindowPosition(x,y,width,height);
SetForegroundWindow(g_hwnd);
SetCursor( NULL );
}

void
CVIDEOPLAYER::Play()
{
if(pMC)
pMC->Run();
}

void
CVIDEOPLAYER::Pause()
{
if(pMC)
pMC->Pause();
}

void
CVIDEOPLAYER::Stop()
{
if(pMC)
pMC->Stop();
}

bool
CVIDEOPLAYER::IsFinish()
{
if(pME)
{
long evCode,Param1, Param2;
pME->GetEvent(&evCode, &Param1,&Param2, 0);
pME->FreeEventParams(evCode, Param1, Param2);
if (evCode == EC_COMPLETE)
return true;
}
return false;
}

void
CVIDEOPLAYER::Update()
{
if(Loop)
if(IsFinish())
{
LONGLONG pos=0;
pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning ,
NULL, AM_SEEKING_NoPositioning);
}
}

void
CVIDEOPLAYER::Remove()
{
if(pMC)
{
pMC->Stop();
pMC->Release();
pMC=NULL;
}
if(pGB)
{
pGB->Release();
pGB=NULL;
}
if(pVW)
{
pVW->put_Visible(OAFALSE);
pVW->put_Owner(NULL);
pVW->Release();
pVW=NULL;
}
if(pME)
{
pME->Release();
pME=NULL;
}
if(pMS)
{
pMS->Release();
pMS=NULL;
}

}
-----------------------------
Sans danger, pas de gloire...
http;//bappy.free.fr
-----------------------------
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Re: Integrating a DirectX Video Stream?

Post by rt »

codwarrior wrote:I am trying to integrate a video stream from a framegrabber in Irrlicht. So far, I managed to redirect the DirectX graph to the Irrlicht window. But now, the live stream overwrites all Irrlicht-rendered objects. I wonder now how to combine the video stream and the Irrlicht elements so that i can place e.g. IGUIButtons or something above the stream. Has anyone tried something similar?
If you want to have control over the z-order of your movies you could try writing the movie data to a texture, and have that texture mapped onto a billboard. Or perhaps render the gui after you render the movie object? Did you check out the AVI player code in the tutorial forum?
codwarrior
Posts: 7
Joined: Tue Feb 10, 2004 10:00 am

Post by codwarrior »

Thank you all for your kind help, both are very promising solutions, but I need more time in order to understand fully.

Another question that arose: Where is Irrlicht's output buffer, i.e. the "image" that has been rendered and which is about to be given to the video HW?

Thanks again...
Post Reply