In the following code, when we added the "rotator" code, we discovered that then lovely DirectShow in C# code imported from CodeProject [1] needed a tweak. The RenderStream method _should_ allow nulls for the first two arguments to indicate "don't care"*. When the original code (as [in] ref Guid) was tried, nothing we could come up with would pass the compiler (or the run-time marshaller). We tried passing 0, Guid.Empty, null, a Guid initialized to null, and IntPtr.Zero; all failed. We eventually decided to flip the bozo-bit and mark the method as unsafe and pass the first two arguments as Guid*. This _seems_ to work fine in use, but I'm always leery of such shenanigans in .Net.
And opinions on what I _should_ have done? Marc [1] http://www.codeproject.com/cs/media/directshownet.asp [2] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/ directX/htm/icapturegraphbuilder2renderstream.asp [ComVisible(true), ComImport, Guid("93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D"), InterfaceType( ComInterfaceType.InterfaceIsIUnknown )] public interface ICaptureGraphBuilder2 { // ... methods of renown and interest elided [PreserveSig] unsafe int RenderStream( [In] Guid* pCategory, // was [in] ref Guid pCategory, [In] Guid* pType, // was [in] ref Guid pType, [In, MarshalAs(UnmanagedType.IUnknown)] object pSource, [In] IBaseFilter pfCompressor, [In] IBaseFilter pfRenderer ); // ... more methods of renown and interest elided }; Guid CaptureId = PinCategory.Capture; Guid VideoId = MediaType.Video; unsafe { Result(m_CaptureGraph.RenderStream( &CaptureId, &VideoId, m_CaptureDevice, m_BaseGrabFilter, m_RotatorFilter)); if (arg_WithRotator) { Result(m_CaptureGraph.RenderStream(null, &VideoId, m_RotatorFilter, null, m_VideoMixingRenderer9)); } else { Result(m_CaptureGraph.RenderStream(null, &VideoId, m_BaseGrabFilter, null, m_VideoMixingRenderer9)); } } =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
