示例#1
0
        private IWMWriterAdvanced GetWriterAdvanced(IBaseFilter asfWriter)
        {
            int hr;
            IWMWriterAdvanced pWriterAdvanced = null;

            // I don't understand why we can't just QueryInterface for a IWMWriterAdvanced, but
            // we just can't.  So, we use an IServiceProvider
            DirectShowLib.IServiceProvider pProvider = asfWriter as DirectShowLib.IServiceProvider;

            if (pProvider != null)
            {
                object opro;

                hr = pProvider.QueryService(typeof(IWMWriterAdvanced2).GUID, typeof(IWMWriterAdvanced2).GUID, out opro);
                WMError.ThrowExceptionForHR(hr);

                pWriterAdvanced = opro as IWMWriterAdvanced;
                if (pWriterAdvanced == null)
                {
                    throw new Exception("Can't get IWMWriterAdvanced");
                }
            }

            return(pWriterAdvanced);
        }
        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);
        }
        private void TestQuery()
        {
            int    hr;
            object o;

            hr = m_isp.QueryService(typeof(foo2).GUID, typeof(IAMGraphBuilderCallback).GUID, out o);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(o == m_f);
        }