vmem to SlimDX
Posted: 01 Apr 2010 00:20
Hi everybody.
I am trying to get video to be rendered to SlimDX surface (or Direct3D surface for that matter), and always I get stopped on lock problems. I tried to write to Bitmap, Direct3D.Texture, Surface... but it seams impossible to get video in anything that can be called from managed DirectX ( C# ).
This is how I create arguments for libvlc_core:
now, I copied all of this from this forum, for which I'm thankful, but it appears that I don't understand locks. Here is how I do it:
Which leaves one more problem - what to put to dolock and unlock functions?
I tried few things:
I tried to unlock surfaces in cases that they were locked, but I only managed to get one or few calls to dolock functions, and no unlock whatsoever. I tried this with different objects, but couldn't do anything. Any thoughts? Every help would be appreciated...
Thanks
I am trying to get video to be rendered to SlimDX surface (or Direct3D surface for that matter), and always I get stopped on lock problems. I tried to write to Bitmap, Direct3D.Texture, Surface... but it seams impossible to get video in anything that can be called from managed DirectX ( C# ).
This is how I create arguments for libvlc_core:
Code: Select all
string [] args = new string[] {
"-I", "dummy", "--ignore-config",
@"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins",
"--vout", "vmem",
"--vmem-width", vWidth.ToString(),
"--vmem-height", vHeight.ToString(),
"--vmem-pitch", (vWidth * 4).ToString(),
"--vmem-chroma", "RV32",
"--vmem-lock", my_dolock_str,
"--vmem-unlock", my_unlock_str,
"--vmem-data", my_ptr_str
};
Code: Select all
public static DelegateLocker delegate_dolock = new DelegateLocker(dolock);
public static DelegateUnlocker delegate_unlock = new DelegateUnlocker(unlock);
public static DelegatePtr delegate_ptr = new DelegatePtr(get_ptr);
string my_dolock_str = Marshal.GetFunctionPointerForDelegate(delegate_dolock).ToInt32().ToString();
string my_unlock_str = Marshal.GetFunctionPointerForDelegate(delegate_unlock).ToInt32().ToString();
string my_ptr_str = Marshal.GetFunctionPointerForDelegate(delegate_ptr).ToInt32().ToString();
I tried few things:
Code: Select all
public static IntPtr dolock(IntPtr ctx) {
return ctx;
}
public static IntPtr dolock(IntPtr ctx) {
DataRectangle data = mySurface.LockRectangle(LockFlags.None);
return data.Data.DataPointer;
}
public static IntPtr dolock(IntPtr ctx) {
Surface surf = Surface.FromPointer(ctx);
DataRectangle data = surf.LockRectangle(LockFlags.None);
return data.Data.DataPointer;
}
Thanks