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);
            }
        }