void TestGetValue()
        {
            PropVariant p = new PropVariant("FDSA");
            int hr = m_me.GetValue(p);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(p.GetString() == "asdf");
        }
        private void TestSetValue()
        {
            PropVariant p = new PropVariant();

            int hr = m_pStore.SetNamedValue("asdf", new PropVariant("testme"));
            MFError.ThrowExceptionForHR(hr);
            hr = m_pStore.GetNamedValue("asdf", p);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(p.GetString() == "testme");
        }
        void TestGetAt()
        {
            PropVariant var = new PropVariant();
            PropertyKey key = new PropertyKey();
            int hr = m_ps.GetAt(0, key);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(key.pID == 3);

            hr = m_ps.GetValue(key, var);
            MFError.ThrowExceptionForHR(hr);
            Debug.Assert(var.GetString() == "asdf");
        }
Beispiel #4
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: Invoke
    //  Description:  Callback for asynchronous BeginGetEvent method.
    //
    //  pAsyncResult: Pointer to the result.
    /////////////////////////////////////////////////////////////////////////
    int IMFAsyncCallback.Invoke(IMFAsyncResult pAsyncResult)
    {
        // Make sure we *never* leave this entry point with an exception
        try
        {
            int hr;
            IMFMediaEvent pEvent;
            MediaEventType meType = MediaEventType.MEUnknown;  // Event type
            PropVariant varEventData = new PropVariant();	        // Event data

            // Get the event from the event queue.
            hr = m_pMEG.EndGetEvent(pAsyncResult, out pEvent);
            MFError.ThrowExceptionForHR(hr);

            // Get the event type.
            hr = pEvent.GetType(out meType);
            MFError.ThrowExceptionForHR(hr);

            // Get the event status. If the operation that triggered the event did
            // not succeed, the status is a failure code.
            hr = pEvent.GetStatus(out m_hrStatus);
            MFError.ThrowExceptionForHR(hr);

            if (m_hrStatus == 862022) // NS_S_DRM_MONITOR_CANCELLED
            {
                m_hrStatus = MFError.MF_E_OPERATION_CANCELLED;
                m_state = Enabler.Complete;
            }

            // Get the event data.
            hr = pEvent.GetValue(varEventData);
            MFError.ThrowExceptionForHR(hr);

            // For the MEEnablerCompleted action, notify the application.
            // Otherwise, request another event.
            Debug.WriteLine(string.Format("Content enabler event: {0}", meType.ToString()));

            if (meType == MediaEventType.MEEnablerCompleted)
            {
                PostMessage(m_hwnd, WM_APP_CONTENT_ENABLER, IntPtr.Zero, IntPtr.Zero);
            }
            else
            {
                if (meType == MediaEventType.MEEnablerProgress)
                {
                    if (varEventData.GetVariantType() == PropVariant.VariantType.String)
                    {
                        Debug.WriteLine(string.Format("Progress: {0}", varEventData.GetString()));
                    }
                }
                hr = m_pMEG.BeginGetEvent(this, null);
                MFError.ThrowExceptionForHR(hr);
            }

            // Clean up.
            varEventData.Clear();
            SafeRelease(pEvent);

            return S_Ok;
        }
        catch (Exception e)
        {
            return Marshal.GetHRForException(e);
        }
    }
        void TestQueueEventParamVar()
        {
            IMFMediaEvent pEvent;
            Guid g = Guid.NewGuid();
            PropVariant p = new PropVariant();

            int hr = m_meq.QueueEventParamVar(MediaEventType.MESessionClosed, g, 0, new PropVariant("asdf"));
            MFError.ThrowExceptionForHR(hr);

            hr = m_meq.GetEvent(MFEventFlag.None, out pEvent);
            MFError.ThrowExceptionForHR(hr);

            hr = pEvent.GetValue(p);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(p.GetString() == "asdf");
        }