Ejemplo n.º 1
0
        protected void Dispose(bool disp)
        {
            var settings = m_VideoPresenter as IEVRPresenterSettings;

            if (settings != null)
            {
                settings.RegisterCallback(null);
            }

            COMUtil.TryFinalRelease(ref m_VideoPresenter);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new EVR video presenter
        /// </summary>
        /// <returns></returns>
        public static EvrPresenter CreateNew()
        {
            //            object comObject;
            //            int hr;



            /* Our exception var we use to hold the exception
             * until we need to throw it (after clean up) */
            //           Exception exception = null;

            /* A COM object we query form our native library */
            //          IClassFactory factory = null;

            /* Create our 'helper' class */
            var evrPresenter            = new EvrPresenter();
            IMFVideoPresenter presenter = null;

            try
            {
                var path      = System.IO.Path.GetDirectoryName(new Uri(typeof(EvrPresenter).Assembly.CodeBase).LocalPath);
                var dlltoload = System.IO.Path.Combine(path, IntPtr.Size == 8 ? @"EvrPresenter64.dll" : @"EvrPresenter32.dll");
                presenter = COMUtil.CreateFromDll <IMFVideoPresenter>(dlltoload, EVR_PRESENTER_CLSID);

                int count;
                var settings = presenter as IEVRPresenterSettings;
                DsError.ThrowExceptionForHR(settings.RegisterCallback(evrPresenter));
                DsError.ThrowExceptionForHR(settings.GetBufferCount(out count));
                DsError.ThrowExceptionForHR(settings.SetBufferCount(PRESENTER_BUFFER_COUNT));

                /* Populate the IMFVideoPresenter */
                evrPresenter.VideoPresenter = presenter;
            }
            catch (Exception ex)
            {
                COMUtil.TryFinalRelease(ref presenter);
                throw new WPFMediaKitException("Could not create EnhancedVideoRenderer", ex);
            }

            return(evrPresenter);

            //         /* Call the DLL export to create the class factory */

            /*       if(ProcessBits == 32)
             *             hr = DllGetClassObject32(EVR_PRESENTER_CLSID, IUNKNOWN_GUID, out comObject);
             *         else if(ProcessBits == 64)
             *             hr = DllGetClassObject64(EVR_PRESENTER_CLSID, IUNKNOWN_GUID, out comObject);
             *         else
             *         {
             *             exception = new Exception(string.Format("{0} bit processes are unsupported", ProcessBits));
             *             goto bottom;
             *         }
             */
            /* Check if our call to our DLL failed */

            /*          if(hr != 0 || comObject == null)
             *          {
             *              exception = new COMException("Could not create a new class factory.", hr);
             *              goto bottom;
             *          }
             */
            /* Cast the COM object that was returned to a COM interface type */

            /*          factory = comObject as IClassFactory;
             *
             *          if(factory == null)
             *          {
             *              exception = new Exception("Could not QueryInterface for the IClassFactory interface");
             *              goto bottom;
             *          }
             *
             *          /* Get the GUID of the IMFVideoPresenter */
            //          Guid guidVideoPresenter = typeof(IMFVideoPresenter).GUID;

            /* Creates a new instance of the IMFVideoPresenter */
            //          factory.CreateInstance(null, ref guidVideoPresenter, out comObject);

            /* QueryInterface for the IMFVideoPresenter */
            //           var presenter = comObject as IMFVideoPresenter;

            /* QueryInterface for our callback registration interface */

            /*            var registerCb = comObject as IEVRPresenterRegisterCallback;
             *          if(registerCb == null)
             *          {
             *              exception = new Exception("Could not QueryInterface for IEVRPresenterRegisterCallback");
             *              goto bottom;
             *          }
             */
            /* Register the callback to the 'helper' class we created */
            //            registerCb.RegisterCallback(evrPresenter);

            /* Populate the IMFVideoPresenter */
            //            evrPresenter.VideoPresenter = presenter;

            //            bottom:

            //          if(factory != null)
            //              Marshal.FinalReleaseComObject(factory);

            /*            if(exception != null)
             *              throw exception;
             *
             *          return evrPresenter;*/
        }