Exemplo n.º 1
0
        /// <summary>
        /// BufferCB callback
        /// </summary>
        /// <remarks>COULD BE EXECUTED FROM FOREIGN THREAD.</remarks>
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
        {
            try
            {
                // Note that we depend on only being called once per call to Click.  Otherwise
                // a second call can overwrite the previous image.
                if (BufferLen == Math.Abs(m_videoBitCount / 8 * m_videoWidth) * m_videoHeight)
                {
                }

                if (m_bWantOneFrame)
                {
                    m_bWantOneFrame = false;
                    if (m_ipBuffer != IntPtr.Zero)
                    {
                    }

                    // Save the buffer
                    NativeMethodes.CopyMemory(m_ipBuffer, pBuffer, BufferLen);

                    // Picture is ready.
                    m_PictureReady.Set();
                }
            }
            catch { }

            return(0);
        }
Exemplo n.º 2
0
 int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
 {
     if (this.m_bWantOneFrame)
     {
         this.m_bWantOneFrame = false;
         NativeMethodes.CopyMemory(this.m_ipBuffer, pBuffer, BufferLen);
         this.m_PictureReady.Set();
     }
     return(0);
 }
Exemplo n.º 3
0
 private void ApplyDirectShowLogFile()
 {
     if (this.DX.FilterGraph != null)
     {
         this.CloseDirectShowLogFile();
         if (!string.IsNullOrEmpty(this._DirectShowLogFilepath))
         {
             this._DirectShowLogHandle = NativeMethodes.CreateFile(this._DirectShowLogFilepath, FileAccess.Write, FileShare.Read, IntPtr.Zero, FileMode.OpenOrCreate, FileAttributes.Normal, IntPtr.Zero);
             if ((this._DirectShowLogHandle.ToInt32() == -1) || (this._DirectShowLogHandle == IntPtr.Zero))
             {
                 this._DirectShowLogHandle = IntPtr.Zero;
                 throw new Exception("Can't open log file for writing: " + this._DirectShowLogFilepath);
             }
             NativeMethodes.SetFilePointerEx(this._DirectShowLogHandle, 0L, IntPtr.Zero, 2);
             this.DX.FilterGraph.SetLogFile(this._DirectShowLogHandle);
         }
     }
 }
Exemplo n.º 4
0
        internal static void _DisplayPropertyPage(object filter_or_pin, IntPtr hwndOwner)
        {
            if (filter_or_pin != null)
            {
                DirectShowLib.ISpecifyPropertyPages o = filter_or_pin as DirectShowLib.ISpecifyPropertyPages;
                if (o == null)
                {
                    IAMVfwCompressDialogs dialogs = filter_or_pin as IAMVfwCompressDialogs;
                    if (dialogs != null)
                    {
                        /*    DsError.ThrowExceptionForHR(dialogs.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero));*/
                    }
                }
                else
                {
                    DsCAUUID scauuid;
                    string   lpszCaption = string.Empty;
                    if (filter_or_pin is IBaseFilter)
                    {
                        FilterInfo  info;
                        IBaseFilter filter = filter_or_pin as IBaseFilter;
//                         DsError.ThrowExceptionForHR(filter.QueryFilterInfo(out info));
//                         lpszCaption = info.achName;
//                         if (info.pGraph != null)
//                         {
//                             Marshal.ReleaseComObject(info.pGraph);
//                         }
                    }
                    else if (filter_or_pin is IPin)
                    {
                        PinInfo info2;
                        IPin    pin = filter_or_pin as IPin;
                        /* DsError.ThrowExceptionForHR(pin.QueryPinInfo(out info2));*/
                        /* lpszCaption = info2.name;*/
                    }
                    DsError.ThrowExceptionForHR(o.GetPages(out scauuid));
                    object ppUnk = filter_or_pin;
                    DsError.ThrowExceptionForHR(NativeMethodes.OleCreatePropertyFrame(hwndOwner, 0, 0, lpszCaption, 1, ref ppUnk, scauuid.cElems, scauuid.pElems, 0, 0, IntPtr.Zero));
                    Marshal.FreeCoTaskMem(scauuid.pElems);
                    Marshal.ReleaseComObject(o);
                }
            }
        }
Exemplo n.º 5
0
 private void CloseDirectShowLogFile()
 {
     try
     {
         if (this.DX.FilterGraph != null)
         {
             this.DX.FilterGraph.SetLogFile(IntPtr.Zero);
         }
         NativeMethodes.CloseHandle(this._DirectShowLogHandle);
     }
     catch
     {
         throw;
     }
     finally
     {
         this._DirectShowLogHandle = IntPtr.Zero;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// BufferCB callback
        /// </summary>
        /// <remarks>COULD BE EXECUTED FROM FOREIGN THREAD.</remarks>
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
        {
            // Note that we depend on only being called once per call to Click.  Otherwise
            // a second call can overwrite the previous image.
            Debug.Assert(BufferLen == Math.Abs(m_videoBitCount / 8 * m_videoWidth) * m_videoHeight, "Incorrect buffer length");

            if (m_bWantOneFrame)
            {
                m_bWantOneFrame = false;
                Debug.Assert(m_ipBuffer != IntPtr.Zero, "Unitialized buffer");

                // Save the buffer
                NativeMethodes.CopyMemory(m_ipBuffer, pBuffer, BufferLen);

                // Picture is ready.
                m_PictureReady.Set();
            }

            return(0);
        }
Exemplo n.º 7
0
        private void SetMixerSettings()
        {
            VMR9AlphaBitmap bitmap;

            if (!this._bMixerEnabled)
            {
                if (this._bMixerImageWasUsed)
                {
                    DsError.ThrowExceptionForHR(this.DX.MixerBitmap.GetAlphaBitmapParameters(out bitmap));
                    bitmap.dwFlags = VMR9AlphaBitmapFlags.Disable;
                    DsError.ThrowExceptionForHR(this.DX.MixerBitmap.UpdateAlphaBitmapParameters(ref bitmap));
                }
            }
            else if (this._OverlayBitmap != null)
            {
                Graphics graphics = Graphics.FromImage(this._OverlayBitmap);
                IntPtr   hdc      = graphics.GetHdc();
                IntPtr   ptr2     = NativeMethodes.CreateCompatibleDC(hdc);
                IntPtr   hbitmap  = this._OverlayBitmap.GetHbitmap();
                NativeMethodes.SelectObject(ptr2, hbitmap);
                bitmap = new VMR9AlphaBitmap {
                    dwFlags      = VMR9AlphaBitmapFlags.FilterMode | VMR9AlphaBitmapFlags.SrcColorKey | VMR9AlphaBitmapFlags.hDC,
                    hdc          = ptr2,
                    rSrc         = new DsRect(0, 0, this._OverlayBitmap.Size.Width, this._OverlayBitmap.Size.Height),
                    rDest        = new NormalizedRect(0f, 0f, 1f, 1f),
                    clrSrcKey    = ColorTranslator.ToWin32(this._GDIColorKey),
                    dwFilterMode = VMRMixerPrefs.PointFiltering,
                    fAlpha       = this._GDIAlphaValue
                };
                DsError.ThrowExceptionForHR(this.DX.MixerBitmap.SetAlphaBitmap(ref bitmap));
                NativeMethodes.DeleteObject(hbitmap);
                NativeMethodes.DeleteDC(ptr2);
                graphics.ReleaseHdc(hdc);
                graphics.Dispose();
                this._bMixerImageWasUsed = true;
            }
        }