private void HookupGraphEventService(IFilterGraph pGraph)
        {
            object o;
            int    hr;

            DirectShowLib.IServiceProvider spServiceProvider = (DirectShowLib.IServiceProvider)pGraph;

            hr = spServiceProvider.QueryService(typeof(BroadcastEventService).GUID,
                                                typeof(IBroadcastEventEx).GUID,
                                                out o);

            spBroadcastEvent = o as IBroadcastEventEx;

            if (hr < 0 || spBroadcastEvent == null)
            {
                // Create the Broadcast Event Service object.
                spBroadcastEvent = new BroadcastEventService() as IBroadcastEventEx;

                IRegisterServiceProvider spRegService = (IRegisterServiceProvider)pGraph;

                // Register the Broadcast Event Service object as a service.
                hr = spRegService.RegisterService(
                    typeof(BroadcastEventService).GUID,
                    spBroadcastEvent);
            }

            DsError.ThrowExceptionForHR(hr);
        }
Ejemplo n.º 2
0
        private void RegisterService(IFilterGraph ifg)
        {
            int hr;

            // Get the registration interface from the graph
            IRegisterServiceProvider spRegService = ifg as IRegisterServiceProvider;

            // Create the Broadcast Event Service object.
            IBroadcastEvent spBroadcastEvent = new BroadcastEventService() as IBroadcastEvent;

            try
            {
                // Register the Broadcast Event Service object as a service.
                hr = spRegService.RegisterService(
                    SID_SBroadcastEventService,
                    spBroadcastEvent);
                DsError.ThrowExceptionForHR(hr);
            }
            finally
            {
                Marshal.ReleaseComObject(spBroadcastEvent);
            }
        }