Fail to set port using SetMulticastGroup() of IMulticastConfig to "MPEG-2 Multicast Receiver" filter
-
Hi to all, I am doing DirectShow Programming in VC++ & C#.Net. I am using "MPEG-2 Multicast Receiver" filter & using IMulticastConfig interface on it. In VC++, when I use SetMulticastGroup(ip, port) of IMulticastConfig it sets port properly to the filter. But when same thing I do in C#.Net (same code of VC++), it fails to sets different port to that filter. (every-time sets a new port. No compilation or run-time error). For C#.net, IMulticastConfig is written using IMulticastConfig of DirectX 9.0 of VC++. Following is my interface,
using System.Runtime.InteropServices; [ComImport, System.Security.SuppressUnmanagedCodeSecurity, Guid("1CB42CC8-D32C-4f73-9267-C114DA470378"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IMulticastConfig { [PreserveSig] int SetNetworkInterface([In] ulong ulNIC); [PreserveSig] int GetNetworkInterface([Out] ulong pNIC); [PreserveSig] int SetMulticastGroup([In] ulong ulIP, [In] ushort usPort); [PreserveSig] int GetMulticastGroup([Out] ulong pIP, [Out] ushort pPort); }
My code is,m_MulticastRcv] = Func.AddFilterByName(this.m_GraphBuilder, FilterCategory.LegacyAmFilterCategory, cNetworkInputFilterName); if (m_MulticastRcv == null) throw new Exception(); IMulticastConfig Inetwork = (IMulticastConfig)m_MulticastRcv; m_hResult = Inetwork.SetMulticastGroup(InetAddress("234.1.1.1"), (ushort)System.Net.IPAddress.HostToNetworkOrder((ushort)1234)); DsError.ThrowExceptionForHR(m_hResult); m_hResult = Inetwork.SetNetworkInterface(InetAddress("192.168.2.112")); DsError.ThrowExceptionForHR(m_hResult);
Thanks & Regards, Aniket A. Salunkhe