Sample Grabber

This topic is 4437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Because my attempt with the VMR failed, I have decided to use a Sample Grabber to get a video rendered in my game. I am having some trouble though. I am using the SampleCB Callback and I have to get the the sample displayed onto a texture. I however don't really know how to do this, so can anyone help me? I tried doing the following, but it didn't work:
public int SampleCB(double SampleTime, IMediaSample pSample)
{
IntPtr pBuffer;
pSample.GetPointer(out pBuffer);

int scan0 = (int)pBuffer;
scan0 += (height - 1) * stride;
Bitmap bmp = new Bitmap(width, height, -stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)scan0);
Surface surf = new Surface(this.device, bmp, Pool.Default);

{
lock(this)
{
this.device.StretchRectangle(surf,
new Rectangle(0, 0, surf.Description.Width, surf.Description.Height),
this.secondary.GetSurfaceLevel(0),
new Rectangle(0, 0, 640, 480),
TextureFilter.None);

}
}
else
{
lock (this) {
this.device.StretchRectangle(surf,
new Rectangle(0, 0, surf.Description.Width,                   surf.Description.Height),
this.primary.GetSurfaceLevel(0),
new Rectangle(0, 0, 640, 480),
TextureFilter.None);

}
}

surf.Dispose();
bmp.Dispose();

Marshal.ReleaseComObject(pSample);
return 0;
}


A note about the "readBuffer" variable, it just allows me to write to the texture not currently being drawn on screen, so it sort of acts like a buffer. Thanks in advance.

• 10
• 11
• 22
• 11
• 15