Пример #1
0
 public int GetCurFile(out string pszFileName, AMMediaType pmt)
 {
     pszFileName = m_sFileName;
     if (pmt != null)
     {
         pmt.Set(Pins[0].CurrentMediaType);
     }
     return(NOERROR);
 }
 public override HRESULT GetMediaType(int iPosition, ref AMMediaType pmt)
 {
     if (iPosition == 0)
     {
         pmt.Set(_pmt);
         return(NOERROR);
     }
     return(VFW_S_NO_MORE_ITEMS);
 }
Пример #3
0
 public override HRESULT GetMediaType(int iPosition, ref AMMediaType pmt)
 {
     if (iPosition < 0)
     {
         return(E_INVALIDARG);
     }
     if (iPosition > 0)
     {
         return(VFW_S_NO_MORE_ITEMS);
     }
     pmt.Set(m_mt);
     return(NOERROR);
 }
Пример #4
0
        public int GetMediaType(int iPosition, ref AMMediaType pMediaType)
        {
            if (iPosition < 0)
            {
                return(E_INVALIDARG);
            }
            VideoStreamConfigCaps _caps;

            GetDefaultCaps(0, out _caps);

            int nWidth  = 0;
            int nHeight = 0;

            if (iPosition == 0)
            {
                if (Pins.Count > 0 && Pins[0].CurrentMediaType.majorType == MediaType.Video)
                {
                    pMediaType.Set(Pins[0].CurrentMediaType);
                    return(NOERROR);
                }
                nWidth  = _caps.InputSize.Width;
                nHeight = _caps.InputSize.Height;
            }
            else
            {
                iPosition--;
                nWidth  = _caps.MinOutputSize.Width + _caps.OutputGranularityX * iPosition;
                nHeight = _caps.MinOutputSize.Height + _caps.OutputGranularityY * iPosition;
                if (nWidth > _caps.MaxOutputSize.Width || nHeight > _caps.MaxOutputSize.Height)
                {
                    return(VFW_S_NO_MORE_ITEMS);
                }
            }

            pMediaType.majorType  = DirectShow.MediaType.Video;
            pMediaType.formatType = DirectShow.FormatType.VideoInfo;

            VideoInfoHeader vih = new VideoInfoHeader();

            vih.AvgTimePerFrame       = m_nAvgTimePerFrame;
            vih.BmiHeader.Compression = BI_RGB;
            vih.BmiHeader.BitCount    = (short)m_nBitCount;
            vih.BmiHeader.Width       = nWidth;
            vih.BmiHeader.Height      = nHeight;
            vih.BmiHeader.Planes      = 1;
            vih.BmiHeader.ImageSize   = vih.BmiHeader.Width * Math.Abs(vih.BmiHeader.Height) * vih.BmiHeader.BitCount / 8;

            if (vih.BmiHeader.BitCount == 32)
            {
                pMediaType.subType = DirectShow.MediaSubType.RGB32;
            }
            if (vih.BmiHeader.BitCount == 24)
            {
                pMediaType.subType = DirectShow.MediaSubType.RGB24;
            }
            AMMediaType.SetFormat(ref pMediaType, ref vih);
            pMediaType.fixedSizeSamples = true;
            pMediaType.sampleSize       = vih.BmiHeader.ImageSize;

            return(NOERROR);
        }
Пример #5
0
 public override HRESULT GetMediaType(int iPosition, ref AMMediaType pmt)
 {
     pmt.Set(this.pmt);
     return(NOERROR);
 }