コード例 #1
0
 public VideoInfoHeader2()
 {
     InterlaceFlags = AMInterlace.None;
     CopyProtectFlags = AMCopyProtect.None;
     ControlFlags = AMControl.None;
     BitRate = 0;
     BitErrorRate = 0;
     AvgTimePerFrame = 0;
     PictAspectRatioX = 0;
     PictAspectRatioY = 0;
     Reserved2 = 0;
     SrcRect = new DsRect();
     TargetRect = new DsRect();
     BmiHeader = new BitmapInfoHeader();
 }
コード例 #2
0
        protected HRESULT CalculateOutputRectangle(IMFMediaType pProposedType, out DsRect prcOutput)
        {
            prcOutput = null;
            HRESULT hr = S_OK;
            int srcWidth = 0, srcHeight = 0;

            MFRatio inputPAR = new MFRatio(0, 0);
            MFRatio outputPAR = new MFRatio(0, 0);
            DsRect rcOutput = new DsRect(0, 0, 0, 0);

            MFVideoArea displayArea;

            MFHelper.VideoTypeBuilder pmtProposed = null;

            // Helper object to read the media type.
            hr = MFHelper.MediaTypeBuilder.Create(pProposedType, out pmtProposed);
            if (hr.Failed) return hr;

            // Get the source's frame dimensions.
            hr = pmtProposed.GetFrameDimensions(out srcWidth, out srcHeight);
            if (hr.Failed) return hr;

            // Get the source's display area.
            hr = pmtProposed.GetVideoDisplayArea(out displayArea);
            if (hr.Failed) return hr;

            // Calculate the x,y offsets of the display area.
            int offsetX = (int)displayArea.OffsetX.GetOffset();
            int offsetY = (int)displayArea.OffsetY.GetOffset();

            // Use the display area if valid. Otherwise, use the entire frame.
            if (displayArea.Area.Width != 0 &&
                displayArea.Area.Height != 0 &&
                offsetX + displayArea.Area.Width <= (srcWidth) &&
                offsetY + displayArea.Area.Height <= (srcHeight))
            {
                rcOutput.left = offsetX;
                rcOutput.right = offsetX + displayArea.Area.Width;
                rcOutput.top = offsetY;
                rcOutput.bottom = offsetY + displayArea.Area.Height;
            }
            else
            {
                rcOutput.left = 0;
                rcOutput.top = 0;
                rcOutput.right = srcWidth;
                rcOutput.bottom = srcHeight;
            }

            // rcOutput is now either a sub-rectangle of the video frame, or the entire frame.

            // If the pixel aspect ratio of the proposed media type is different from the monitor's,
            // letterbox the video. We stretch the image rather than shrink it.

            inputPAR = pmtProposed.GetPixelAspectRatio();    // Defaults to 1:1

            outputPAR.Denominator = outputPAR.Numerator = 1; // This is an assumption of the sample.

            // Adjust to get the correct picture aspect ratio.
            prcOutput = MFHelper.CorrectAspectRatio(rcOutput, inputPAR, outputPAR);

            return NOERROR;
        }
コード例 #3
0
 public VideoInfoHeader()
 {
     BitRate = 0;
     BitErrorRate = 0;
     AvgTimePerFrame = 0;
     SrcRect = new DsRect();
     TargetRect = new DsRect();
     BmiHeader = new BitmapInfoHeader();
 }
コード例 #4
0
 protected override HRESULT OnInitInterfaces()
 {
     m_evStop.Reset();
     HRESULT hr;
     {
         hr = (HRESULT)MFHelper.DXVA2CreateDirect3DDeviceManager9(out m_DeviceResetToken, out m_DeviceManager);
         hr.Assert();
         if (hr.Succeeded)
         {
             hr = (HRESULT)m_DeviceManager.ResetDevice(Marshal.GetObjectForIUnknown(m_Device.ComPointer), m_DeviceResetToken);
             hr.Assert();
         }
         m_Caller = new Wrapper(this);
     }
     m_Renderer = new EVRRenderer();
     bool bAllocatorUsed = false;
     IMFVideoRenderer _renderer = (IMFVideoRenderer)m_Renderer.QueryInterface(typeof(IMFVideoRenderer));
     hr = (HRESULT)_renderer.InitializeRenderer(null, (IMFVideoPresenter)this);
     hr.Assert();
     bAllocatorUsed = hr.Succeeded;
     m_Renderer.FilterGraph = m_GraphBuilder;
     hr = base.OnInitInterfaces();
     if (!bAllocatorUsed && m_VideoControl != null)
     {
         IMFGetService _service = (IMFGetService)m_Renderer.QueryInterface(typeof(IMFGetService));
         IntPtr _object;
         hr = (HRESULT)_service.GetService(MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFVideoDisplayControl).GUID, out _object);
         hr.Assert();
         IMFVideoDisplayControl _display = (IMFVideoDisplayControl)Marshal.GetObjectForIUnknown(_object);
         hr = (HRESULT)_display.SetVideoWindow(m_VideoControl.Handle);
         hr.Assert();
         DsRect _rect = new DsRect(m_VideoControl.ClientRectangle);
         hr = (HRESULT)_display.SetVideoPosition(new MFVideoNormalizedRect(), _rect);
         hr.Assert();
     }
     return hr;
 }