Пример #1
0
        private void NotifyError(string sErrorMessage, int hrErr)
        {
            m_pPreview.CloseDevice();

            string sErrMsg = MFError.GetErrorText(hrErr);
            string sMsg    = string.Format("{0} (HRESULT = 0x{1:x}:{2})", sErrorMessage, hrErr, sErrMsg);

            MessageBox.Show(this, sMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Пример #2
0
        private void NotifyError(string sErrorMessage, HResult hrErr)
        {
            string sErrMsg = MFError.GetErrorText(hrErr);
            string sMsg    = string.Format("{0} (HRESULT = 0x{1:x}:{2})", sErrorMessage, hrErr, sErrMsg);

            MessageBox.Show(this, sMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            StopCapture();
        }
Пример #3
0
        private void NotifyError(string sErrorMessage, int hrErr)
        {
            var    sErrMsg = MFError.GetErrorText(hrErr);
            string sMsg    = $"{sErrorMessage} (HRESULT = 0x{hrErr:x}:{sErrMsg})";

            camProcess.CloseDevice();
            NotificationRequest.Raise(new Notification {
                Content = sMsg, Title = "Error"
            });
        }
Пример #4
0
        /// <summary>
        /// Print out a debug line when hr doesn't equal S_Ok.
        /// </summary>
        /// <param name="hr">Value to check</param>
        /// <returns>The input value.</returns>
        /// <remarks>This code shows the calling routine and the error text.
        /// All the public interface methods use this to wrap their returns.
        /// </remarks>
        private static HResult CheckReturn(HResult hr)
        {
#if DEBUG
            if (hr != HResult.S_OK)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(1);

                string sName  = sf.GetMethod().Name;
                string sError = MFError.GetErrorText(hr);
                if (sError != null)
                {
                    sError = sError.Trim();
                }
                Trace(string.Format("{1} returning 0x{0:x} ({2})", hr, sName, sError));
            }
#endif
            return(hr);
        }
Пример #5
0
        public void DoSplit()
        {
            HResult hr;
            bool    bHasVideo = false;

            IMFByteStream     pStream      = null;
            IMFASFContentInfo pContentInfo = null;
            IMFASFSplitter    pSplitter    = null;

            Console.WriteLine(string.Format("Opening {0}.", m_sFileName));

            try
            {
                // Start the Media Foundation platform.
                hr = MFExtern.MFStartup(0x10070, MFStartup.Full);
                MFError.ThrowExceptionForHR(hr);

                // Open the file.
                OpenFile(m_sFileName, out pStream);

                // Read the ASF header.
                CreateContentInfo(pStream, out pContentInfo);

                // Create the ASF splitter.
                CreateASFSplitter(pContentInfo, out pSplitter);

                // Select the first video stream.
                SelectVideoStream(pContentInfo, pSplitter, out bHasVideo);

                // Parse the ASF file.
                if (bHasVideo)
                {
                    DisplayKeyFrames(pStream, pSplitter);
                }
                else
                {
                    Console.WriteLine("No video stream.");
                }
            }
            catch (Exception e)
            {
                hr = (HResult)Marshal.GetHRForException(e);
                string s = MFError.GetErrorText(hr);

                if (s == null)
                {
                    s = e.Message;
                }
                else
                {
                    s = string.Format("{0} ({1})", s, e.Message);
                }

                Console.WriteLine(string.Format("Exception 0x{0:x}: {1}", hr, s));
            }
            finally
            {
                // Clean up.
                SafeRelease(pSplitter);
                SafeRelease(pContentInfo);
                SafeRelease(pStream);
            }

            // Shut down the Media Foundation platform.
            hr = MFExtern.MFShutdown();
            MFError.ThrowExceptionForHR(hr);
        }
Пример #6
0
        void NotifyError(IntPtr hwnd, string sErrorMessage, int hrErr)
        {
            string s = string.Format("{0} (HRESULT = 0x{1:x} {2})", sErrorMessage, hrErr, MFError.GetErrorText(hrErr));

            MessageBox.Show(this, s, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Пример #7
0
        void NotifyError(string sErrorMessage, HResult hrErr)
        {
            string    s;
            const int REGDB_E_CLASSNOTREG = unchecked ((int)0x80040154);

            if (hrErr != (HResult)REGDB_E_CLASSNOTREG)
            {
                s = string.Format("{0} (HRESULT = 0x{1:x} {2})", sErrorMessage, hrErr, MFError.GetErrorText(hrErr));
            }
            else
            {
                string e;

                if (Environment.Is64BitProcess)
                {
                    e = "64";
                }
                else
                {
                    e = "32";
                }

                s = string.Format("The CLSID for that MFT is not registered for {0}bit.  Please rebuild/reregister.", e);
            }

            MessageBox.Show(this, s, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            UpdateUI(CPlayer.PlayerState.Ready);
        }
Пример #8
0
 public static string GetDescription(this HResult hr)
 {
     return(MFError.GetErrorText((int)hr));
 }