コード例 #1
0
    protected void CreateSession()
    {
        TRACE("CPlayer::CreateSession");

        HResult       hr;
        IMFAttributes pAttributes;
        IMFActivate   pEnablerActivate;

        // Close the old session, if any.
        CloseSession();

        // Create a new attribute store.
        hr = MFExtern.MFCreateAttributes(out pAttributes, 1);
        MFError.ThrowExceptionForHR(hr);

        // Create the content protection manager.
        m_pContentProtectionManager = new ContentProtectionManager(m_hwndEvent);

        // Set the MF_SESSION_CONTENT_PROTECTION_MANAGER attribute with a pointer
        // to the content protection manager.
        hr = pAttributes.SetUnknown(
            MFAttributesClsid.MF_SESSION_CONTENT_PROTECTION_MANAGER,
            m_pContentProtectionManager
            );
        MFError.ThrowExceptionForHR(hr);

        // Create the PMP media session.
        try
        {
            hr = MFExtern.MFCreatePMPMediaSession(
                MFPMPSessionCreationFlags.None,
                pAttributes,
                out m_pSession,
                out pEnablerActivate
                );
            MFError.ThrowExceptionForHR(hr);
        }
        catch
        {
            // TODO:

            // If MFCreatePMPMediaSession fails it might return an IMFActivate pointer.
            // This indicates that a trusted binary failed to load in the protected process.
            // An application can use the IMFActivate pointer to create an enabler object, which
            // provides revocation and renewal information for the component that failed to
            // load.

            // This sample does not demonstrate that feature. Instead, we simply treat this
            // case as a playback failure.
            throw;
        }

        hr = m_pSession.BeginGetEvent(this, null);
        MFError.ThrowExceptionForHR(hr);

        SafeRelease(pAttributes);
        SafeRelease(pEnablerActivate);
    }
コード例 #2
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: GetContentProtectionManager
    //  Description:  Returns the content protection manager object.
    //
    //  This is a helper object for handling IMFContentEnabler operations.
    /////////////////////////////////////////////////////////////////////////
    public HResult GetContentProtectionManager(out ContentProtectionManager ppManager)
    {
        HResult hr;

        ppManager = m_pContentProtectionManager;

        if (m_pContentProtectionManager == null)
        {
            hr = unchecked ((HResult)0x80004005); // Session wasn't created yet. No helper object;
        }
        else
        {
            hr = 0;
        }

        return(hr);
    }
コード例 #3
0
ファイル: Player.cs プロジェクト: GoshaDE/SuperMFLib
    public CPlayer(IntPtr hVideo, IntPtr hEvent)
    {
        TRACE(("CPlayer::CPlayer"));

        Debug.Assert(hVideo != IntPtr.Zero);
        Debug.Assert(hEvent != IntPtr.Zero);

        int hr;

        m_pSession = null;
        m_pSource = null;
        m_pVideoDisplay = null;
        m_hwndVideo = hVideo;
        m_hwndEvent = hEvent;
        m_state = PlayerState.Ready;
        m_pContentProtectionManager = null;

        m_hCloseEvent = new AutoResetEvent(false);

        hr = MFExtern.MFStartup(0x10070, MFStartup.Full);
        MFError.ThrowExceptionForHR(hr);
    }
コード例 #4
0
ファイル: Player.cs プロジェクト: GoshaDE/SuperMFLib
    ///////////////////////////////////////////////////////////////////////
    //  Name: GetContentProtectionManager
    //  Description:  Returns the content protection manager object.
    //
    //  This is a helper object for handling IMFContentEnabler operations.
    /////////////////////////////////////////////////////////////////////////
    public int GetContentProtectionManager(out ContentProtectionManager ppManager)
    {
        int hr;

        ppManager = m_pContentProtectionManager;

        if (m_pContentProtectionManager == null)
        {
            hr = unchecked((int)0x80004005); // Session wasn't created yet. No helper object;
        }
        else
        {
            hr = 0;
        }

        return hr;
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: GoshaDE/SuperMFLib
    protected void CreateSession()
    {
        TRACE("CPlayer::CreateSession");

        int hr;
        IMFAttributes pAttributes;
        IMFActivate pEnablerActivate;

        // Close the old session, if any.
        CloseSession();

        // Create a new attribute store.
        hr = MFExtern.MFCreateAttributes(out pAttributes, 1);
        MFError.ThrowExceptionForHR(hr);

        // Create the content protection manager.
        m_pContentProtectionManager = new ContentProtectionManager(m_hwndEvent);

        // Set the MF_SESSION_CONTENT_PROTECTION_MANAGER attribute with a pointer
        // to the content protection manager.
        hr = pAttributes.SetUnknown(
            MFAttributesClsid.MF_SESSION_CONTENT_PROTECTION_MANAGER,
            m_pContentProtectionManager
            );
        MFError.ThrowExceptionForHR(hr);

        // Create the PMP media session.
        try
        {
            hr = MFExtern.MFCreatePMPMediaSession(
                MFPMPSessionCreationFlags.None,
                pAttributes,
                out m_pSession,
                out pEnablerActivate
                );
            MFError.ThrowExceptionForHR(hr);
        }
        catch
        {
            // TODO:

            // If MFCreatePMPMediaSession fails it might return an IMFActivate pointer.
            // This indicates that a trusted binary failed to load in the protected process.
            // An application can use the IMFActivate pointer to create an enabler object, which
            // provides revocation and renewal information for the component that failed to
            // load.

            // This sample does not demonstrate that feature. Instead, we simply treat this
            // case as a playback failure.
            throw;
        }

        hr = m_pSession.BeginGetEvent(this, null);
        MFError.ThrowExceptionForHR(hr);

        SafeRelease(pAttributes);
        SafeRelease(pEnablerActivate);
    }
コード例 #6
0
ファイル: Player.cs プロジェクト: GoshaDE/SuperMFLib
    public int Shutdown()
    {
        TRACE("CPlayer::ShutDown");

        int hr = S_Ok;

        try
        {
            if (m_pContentProtectionManager != null)
            {
                m_pContentProtectionManager.Dispose();
                m_pContentProtectionManager = null;
            }

            if (m_hCloseEvent != null)
            {
                // Close the session
                CloseSession();

                // Shutdown the Media Foundation platform
                hr = MFExtern.MFShutdown();
                MFError.ThrowExceptionForHR(hr);

                m_hCloseEvent.Close();
                m_hCloseEvent = null;
            }
        }
        catch (Exception ce)
        {
            hr = Marshal.GetHRForException(ce);
        }

        return hr;
    }