예제 #1
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: EndEnableContent
    //  Description:  Completes the enable action.
    /////////////////////////////////////////////////////////////////////////

    public HResult EndEnableContent(IMFAsyncResult pResult)
    {
        // Make sure we *never* leave this entry point with an exception
        try
        {
            Debug.WriteLine("ContentProtectionManager::EndEnableContent");

            if (pResult == null)
            {
                throw new COMException("NULL IMFAsyncResult", (int)HResult.E_POINTER);
            }

            // Release interfaces, so that we're ready to accept another call
            // to BeginEnableContent.
            SafeRelease(m_pEnabler);
            SafeRelease(m_pMEG);
            SafeRelease(m_punkState);
            SafeRelease(m_pCallback);

            m_pEnabler  = null;
            m_pMEG      = null;
            m_pCallback = null;
            m_punkState = null;

            return(m_hrStatus);
        }
        catch (Exception e)
        {
            return((HResult)Marshal.GetHRForException(e));
        }
    }
예제 #2
0
 public unsafe void BeginWrite(byte[] bRef, int offset, uint count, IMFAsyncCallback callback, object?context = default)
 {
     fixed(void *ptr = &bRef[offset])
     {
         BeginWrite((IntPtr)ptr, count, callback, context != null ? Marshal.GetIUnknownForObject(context) : IntPtr.Zero);
     }
 }
예제 #3
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFBeginCreateFile(
     [In] MFFileAccessMode AccessMode,
     [In] MFFileOpenMode OpenMode,
     [In] MFFileFlags fFlags,
     [In, MarshalAs(UnmanagedType.LPWStr)] string pwszFilePath,
     [In] IMFAsyncCallback pCallback,
     [In][MarshalAs(UnmanagedType.IUnknown)] object pState,
     [MarshalAs(UnmanagedType.IUnknown)] out object ppCancelCookie);
예제 #4
0
    public HResult BeginGetEvent(IMFAsyncCallback pCallback, object o)
    {
        HResult hr;

        hr = m_events.BeginGetEvent(pCallback, o);

        return(hr);
    }
예제 #5
0
        public HResult BeginGetEvent(IMFAsyncCallback pCallback, object punkState)
        {
            HResult hr = HResult.S_OK;

            hr = CheckShutdown();
            if (MFError.Succeeded(hr))
            {
                hr = _spEventQueue.BeginGetEvent(pCallback, punkState);
            }
            return(hr);
        }
            public int BeginWrite(IntPtr pb, int cb, IMFAsyncCallback pCallback, object pUnkState)
            {
                mWebServer.sendRawData(pb, cb);

                AsyncWriteData lAsyncWriteData = new AsyncWriteData()
                {
                    cb = cb, pCallback = pCallback, punkState = pUnkState
                };

                ThreadPool.QueueUserWorkItem(lAsyncWriteData.execute);

                return(0);
            }
예제 #7
0
    public void Dispose()
    {
        Debug.WriteLine("ContentProtectionManager::Dispose");
        SafeRelease(m_pEnabler);
        SafeRelease(m_pMEG);
        SafeRelease(m_pCallback);
        SafeRelease(m_punkState);

        m_pEnabler  = null;
        m_pMEG      = null;
        m_pCallback = null;
        m_punkState = null;
    }
예제 #8
0
        public HResult BeginCreateObject(
            IMFByteStream pByteStream,
            string pwszURL,
            MFResolution dwFlags,
            IPropertyStore pProps,             // Can be NULL.
            out object ppIUnknownCancelCookie, // Can be NULL.
            IMFAsyncCallback pCallback,
            object punkState                   // Can be NULL
            )
        {
            // Make sure we *never* leave this entry point with an exception
            try
            {
                HResult hr;
                m_Log.WriteLine("BeginCreateObject");

                ppIUnknownCancelCookie = null; // We don't return a cancellation cookie.

                if ((pByteStream == null) || (pwszURL == null) || (pCallback == null))
                {
                    throw new COMException("bad stream, url, or callback", (int)HResult.E_INVALIDARG);
                }

                IMFAsyncResult pResult = null;

                WavSource pSource = new WavSource();

                pSource.Open(pByteStream);

                hr = MFExtern.MFCreateAsyncResult(pSource as IMFMediaSource, pCallback, punkState, out pResult);
                MFError.ThrowExceptionForHR(hr);

                hr = MFExtern.MFInvokeCallback(pResult);
                MFError.ThrowExceptionForHR(hr);

                if (pResult != null)
                {
                    Marshal.ReleaseComObject(pResult);
                }
                return(HResult.S_OK);
            }
            catch (Exception e)
            {
                ppIUnknownCancelCookie = null;
                return((HResult)Marshal.GetHRForException(e));
            }
        }
예제 #9
0
    public HResult BeginCreateObject(string pwszURL,
                                     MFResolution dwFlags,
                                     IPropertyStore pProps,
                                     out object ppIUnknownCancelCookie,
                                     IMFAsyncCallback pCallback,
                                     object pUnkState)
    {
        // The constructor launches an async connect to the url.
        IcyScheme ice = new IcyScheme(pwszURL);

        IMFAsyncResult pResult;
        MFError        hrthrowonerror = MFExtern.MFCreateAsyncResult(
            ice, pCallback, pUnkState, out pResult);

        ppIUnknownCancelCookie = ice;

        hrthrowonerror = MFExtern.MFInvokeCallback(pResult);

        return(HResult.S_OK);
    }
예제 #10
0
    public HResult BeginRead(
        IntPtr pb, int cb, IMFAsyncCallback pCallback, object pUnkState)
    {
        // For reasons beyond my understanding, sometime we are asked to
        // return bytes at negative offsets.  In these cases, we change
        // the number of bytes requested to 0, which results in EndRead
        // returning 0 bytes.
        if (m_Position < 0)
        {
            cb = 0;
        }

        // This handles the case where SetCurrentPosition was called to
        // rewind the stream.
        if (m_Position == 0)
        {
            m_PositionReal = 0;
            m_SinceLast    = 0;
        }

        // Since BeginRead is async, caller could call GetCurrentPosition
        // while the read is running.  Spec says they get the new value.
        m_Position += cb;

        IMFAsyncResult pResult;
        ReadParams     rp = new ReadParams(pb, cb);

        HResult hr = MFExtern.MFCreateAsyncResult(
            rp, pCallback, pUnkState, out pResult);

        // If 2 BeginReads are called consecutively, might the Workqueue
        // run them concurrently?  I don't know, but that would be bad.
        if (MFError.Succeeded(hr))
        {
            hr = MFExtern.MFPutWorkItem(
                (int)MFASYNC_WORKQUEUE_TYPE.StandardWorkqueue,
                this, pResult);
        }

        return(hr);
    }
예제 #11
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: BeginEnableContent
    //  Description:  Called by the PMP session to start the enable action.
    /////////////////////////////////////////////////////////////////////////

    public HResult BeginEnableContent(
        IMFActivate pEnablerActivate,
        IMFTopology pTopo,
        IMFAsyncCallback pCallback,
        object punkState
        )
    {
        // Make sure we *never* leave this entry point with an exception
        try
        {
            Debug.WriteLine("ContentProtectionManager::BeginEnableContent");

            if (m_pEnabler != null)
            {
                throw new COMException("A previous call is still pending", (int)HResult.E_FAIL);
            }

            HResult hr;

            // Save so we can create an async result later
            m_pCallback = pCallback;
            m_punkState = punkState;

            // Create the enabler from the IMFActivate pointer.
            object o;
            hr = pEnablerActivate.ActivateObject(typeof(IMFContentEnabler).GUID, out o);
            MFError.ThrowExceptionForHR(hr);
            m_pEnabler = o as IMFContentEnabler;

            // Notify the application. The application will call DoEnable from the app thread.
            m_state = Enabler.Ready; // Reset the state.
            PostMessage(m_hwnd, WM_APP_CONTENT_ENABLER, IntPtr.Zero, IntPtr.Zero);

            return(HResult.S_OK);
        }
        catch (Exception e)
        {
            return((HResult)Marshal.GetHRForException(e));
        }
    }
예제 #12
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: BeginEnableContent
    //  Description:  Called by the PMP session to start the enable action.
    /////////////////////////////////////////////////////////////////////////
    public int BeginEnableContent(
        IMFActivate pEnablerActivate,
        IMFTopology pTopo,
        IMFAsyncCallback pCallback,
        object punkState
        )
    {
        // Make sure we *never* leave this entry point with an exception
        try
        {
            Debug.WriteLine("ContentProtectionManager::BeginEnableContent");

            if (m_pEnabler != null)
            {
                throw new COMException("A previous call is still pending", E_Fail);
            }

            int hr;

            // Save so we can create an async result later
            m_pCallback = pCallback;
            m_punkState = punkState;

            // Create the enabler from the IMFActivate pointer.
            object o;
            hr = pEnablerActivate.ActivateObject(typeof(IMFContentEnabler).GUID, out o);
            MFError.ThrowExceptionForHR(hr);
            m_pEnabler = o as IMFContentEnabler;

            // Notify the application. The application will call DoEnable from the app thread.
            m_state = Enabler.Ready; // Reset the state.
            PostMessage(m_hwnd, WM_APP_CONTENT_ENABLER, IntPtr.Zero, IntPtr.Zero);

            return S_Ok;
        }
        catch (Exception e)
        {
            return Marshal.GetHRForException(e);
        }
    }
            public int BeginWrite(IntPtr pb, int cb, IMFAsyncCallback pCallback, object pUnkState)
            {
                ++h;

                //if(++h == 10)
                //{
                //    Thread.Sleep(2000);
                //}
                //else
                {
                    mWebServer.sendRawData(pb, cb);
                }

                AsyncWriteData lAsyncWriteData = new AsyncWriteData()
                {
                    cb = cb, pCallback = pCallback, punkState = pUnkState
                };

                ThreadPool.QueueUserWorkItem(lAsyncWriteData.execute);

                return(0);
            }
 public int BeginRead(IntPtr pb, int cb, IMFAsyncCallback pCallback, object pUnkState)
 {
     throw new NotImplementedException();
 }
예제 #15
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFCreateAsyncResult(
     [MarshalAs(UnmanagedType.IUnknown)] object punkObject,
     IMFAsyncCallback pCallback,
     [MarshalAs(UnmanagedType.IUnknown)] object punkState,
     out IMFAsyncResult ppAsyncResult
     );
예제 #16
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFBeginUnregisterWorkQueueWithMMCSS(
     int dwWorkQueueId,
     [In] IMFAsyncCallback pDoneCallback,
     [In][MarshalAs(UnmanagedType.IUnknown)] object pDoneState);
예제 #17
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFBeginRegisterWorkQueueWithMMCSS(
     int dwWorkQueueId,
     [In, MarshalAs(UnmanagedType.LPWStr)] string wszClass,
     int dwTaskId,
     [In] IMFAsyncCallback pDoneCallback,
     [In][MarshalAs(UnmanagedType.IUnknown)] object pDoneState);
예제 #18
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFScheduleWorkItem(
     IMFAsyncCallback pCallback,
     [MarshalAs(UnmanagedType.IUnknown)] object pState,
     long Timeout,
     long pKey);
예제 #19
0
파일: Externs.cs 프로젝트: gitter-badger/GS
 public static extern void MFPutWorkItem(
     int dwQueue,
     IMFAsyncCallback pCallback,
     [MarshalAs(UnmanagedType.IUnknown)] object pState);
예제 #20
0
        public int BeginCreateObject(
            IMFByteStream pByteStream,
            string pwszURL,
            MFResolution dwFlags,
            IPropertyStore pProps,              // Can be NULL.
            out object ppIUnknownCancelCookie,  // Can be NULL.
            IMFAsyncCallback pCallback,
            object punkState                  // Can be NULL
        )
        {
            // Make sure we *never* leave this entry point with an exception
            try
            {
                int hr;
                m_Log.WriteLine("BeginCreateObject");

                ppIUnknownCancelCookie = null; // We don't return a cancellation cookie.

                if ((pByteStream == null) || (pwszURL == null) || (pCallback == null))
                {
                    throw new COMException("bad stream, url, or callback", E_InvalidArgument);
                }

                IMFAsyncResult pResult = null;

                WavSource pSource = new WavSource();

                pSource.Open(pByteStream);

                hr = MFExtern.MFCreateAsyncResult(pSource as IMFMediaSource, pCallback, punkState, out pResult);
                MFError.ThrowExceptionForHR(hr);

                hr = MFExtern.MFInvokeCallback(pResult);
                MFError.ThrowExceptionForHR(hr);

                if (pResult != null)
                {
                    Marshal.ReleaseComObject(pResult);
                }
                return S_Ok;
            }
            catch (Exception e)
            {
                ppIUnknownCancelCookie = null;
                return Marshal.GetHRForException(e);
            }
        }
예제 #21
0
        //-------------------------------------------------------------------
        // Name: Finalize
        // Description: Starts the async finalize operation.
        //-------------------------------------------------------------------
        public void Finalize(IMFAsyncCallback pCallback, object punkState)
        {
            int hr;
            lock (this)
            {
                ValidateOperation(CAsyncOperation.StreamOperation.OpFinalize);

                if (m_pFinalizeResult != null)
                {
                    throw new COMException("The operation is already pending.", MFError.MF_E_INVALIDREQUEST);
                }

                // Create and store the async result object.
                hr = MFExtern.MFCreateAsyncResult(null, pCallback, punkState, out m_pFinalizeResult);
                MFError.ThrowExceptionForHR(hr);

                m_state = State.Finalized;
                QueueAsyncOperation(CAsyncOperation.StreamOperation.OpFinalize);
            }
        }
예제 #22
0
 public HResult BeginWrite(IntPtr pb,
                           int cb, IMFAsyncCallback pCallback, object pUnkState)
 {
     throw new NotImplementedException();
 }
예제 #23
0
    public void Dispose()
    {
        Debug.WriteLine("ContentProtectionManager::Dispose");
        SafeRelease(m_pEnabler);
        SafeRelease(m_pMEG);
        SafeRelease(m_pCallback);
        SafeRelease(m_punkState);

        m_pEnabler = null;
        m_pMEG = null;
        m_pCallback = null;
        m_punkState = null;
    }
예제 #24
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: EndEnableContent
    //  Description:  Completes the enable action.
    /////////////////////////////////////////////////////////////////////////
    public int EndEnableContent(IMFAsyncResult pResult)
    {
        // Make sure we *never* leave this entry point with an exception
        try
        {
            Debug.WriteLine("ContentProtectionManager::EndEnableContent");

            if (pResult == null)
            {
                throw new COMException("NULL IMFAsyncResult", E_Pointer);
            }

            // Release interfaces, so that we're ready to accept another call
            // to BeginEnableContent.
            SafeRelease(m_pEnabler);
            SafeRelease(m_pMEG);
            SafeRelease(m_punkState);
            SafeRelease(m_pCallback);

            m_pEnabler = null;
            m_pMEG = null;
            m_pCallback = null;
            m_punkState = null;

            return m_hrStatus;
        }
        catch (Exception e)
        {
            return Marshal.GetHRForException(e);
        }
    }
예제 #25
0
        //-------------------------------------------------------------------
        // Name: BeginFinalize
        // Description: Starts the asynchronous finalize operation.
        //
        // Note: We use the Finalize operation to write the RIFF headers.
        //-------------------------------------------------------------------
        public int BeginFinalize(
            IMFAsyncCallback pCallback,
            object punkState)
        {
            // Make sure we *never* leave this entry point with an exception
            try
            {
                TRACE("CWavSink::BeginFinalize");

                lock (this)
                {
                    CheckShutdown();

                    // Tell the stream to finalize.
                    m_pStream.Finalize(pCallback, punkState);
                }
                return S_Ok;
            }
            catch (Exception e)
            {
                return Marshal.GetHRForException(e);
            }
        }
예제 #26
0
        // All of the IMFMediaEventGenerator methods do the following:
        // 1. Check for shutdown status.
        // 2. Call the event generator helper object.
        public int BeginGetEvent(IMFAsyncCallback pCallback, object punkState)
        {
            // Make sure we *never* leave this entry point with an exception
            try
            {
                int hr;
                m_Log.WriteLine("-BeginGetEvent");

                lock (this)
                {
                    CheckShutdown();
                    hr = m_pEventQueue.BeginGetEvent(pCallback, punkState);
                    MFError.ThrowExceptionForHR(hr);
                }
                return S_Ok;
            }
            catch (Exception e)
            {
                return Marshal.GetHRForException(e);
            }
        }