Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

DirectX Video

jbbatts77jbbatts77 Member Posts: 4
Hello All,

I'm fairly new to DiretX but have spent some time in it the last few months. I'm currently streaming video using DiretX and I really need to flip the image on the X or Y axis. I'm setting up my graph and video window with the code below (sorry, i know it's long):

Type srvType = Type.GetTypeFromCLSID(Clsid.FilterGraph);
if (srvType != null)
{
graphObj = Activator.CreateInstance(srvType);

graph = (IGraphBuilder)graphObj;

IBindCtx bindCtx = null;
IMoniker moniker = null;

int n = 0;

if (DXWin32.CreateBindCtx(0, out bindCtx) == 0)
{
if (DXWin32.MkParseDisplayName(bindCtx, CameraID, ref n, out moniker) == 0)
{
Guid filterId = typeof(IBaseFilter).GUID;
moniker.BindToObject(null, null, ref filterId, out sourceObj);

Marshal.ReleaseComObject(moniker);
moniker = null;
}
Marshal.ReleaseComObject(bindCtx);
bindCtx = null;
}

if (sourceObj != null)
{
sourceBase = (IBaseFilter)sourceObj;

srvType = Type.GetTypeFromCLSID(Clsid.SampleGrabber);

grabberObj = Activator.CreateInstance(srvType);
sg = (ISampleGrabber)grabberObj;
grabberBase = (IBaseFilter)grabberObj;

graph.AddFilter(sourceBase, "source");
graph.AddFilter(grabberBase, "grabber");

AMMediaType mt = new AMMediaType();
mt.majorType = MediaType.Video;
mt.subType = MediaSubType.RGB24;
sg.SetMediaType(mt);

if (graph.Connect(DXTools.GetOutPin(sourceBase, 0), DXTools.GetInPin(grabberBase, 0)) >= 0)
{
if (sg.GetConnectedMediaType(mt) == 0)
{
VideoInfoHeader vih = (VideoInfoHeader)Marshal.PtrToStructure(mt.formatPtr, typeof(VideoInfoHeader));
grabber.Width = vih.BmiHeader.Width;
grabber.Height = vih.BmiHeader.Height;
}

graph.Render(DXTools.GetOutPin(grabberBase, 0));

sg.SetBufferSamples(false);
sg.SetOneShot(false);
sg.SetCallback(grabber, 1);


win = (IVideoWindow)graphObj;

win.put_Owner(this.Parent.Handle);
win.put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN);
win.put_Visible(DsHlp.OATRUE);
win.put_AutoShow(0);

ResizeWindow();

mc = (IMediaControl)graphObj;

mc.Run();
}
}
}

can somebody please point me in the right direction. I'm assuming i need to add some sort of new filter. I have found a few samples online but most require a third part component.

Any help would be greatly appreciated.

Thanks,
Bryan


Sign In or Register to comment.