• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DirectShow.AMMediaType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DirectShow.AMMediaType的典型用法代码示例。如果您正苦于以下问题:C# AMMediaType类的具体用法?C# AMMediaType怎么用?C# AMMediaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AMMediaType类属于DirectShow命名空间,在下文中一共展示了AMMediaType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CheckMediaType

 public int CheckMediaType(AMMediaType pmt)
 {
     if (pmt == null) return E_POINTER;
     if (pmt.formatPtr == IntPtr.Zero) return VFW_E_INVALIDMEDIATYPE;
     if (pmt.majorType != MediaType.Video)
     {
         return VFW_E_INVALIDMEDIATYPE;
     }
     if (
             pmt.subType != MediaSubType.RGB24
         &&  pmt.subType != MediaSubType.RGB32
         &&  pmt.subType != MediaSubType.ARGB32
         )
     {
         return VFW_E_INVALIDMEDIATYPE;
     }
     BitmapInfoHeader _bmi = pmt;
     if (_bmi == null)
     {
         return E_UNEXPECTED;
     }
     if (_bmi.Compression != BI_RGB)
     {
         return VFW_E_TYPE_NOT_ACCEPTED;
     }
     if (_bmi.BitCount != 24 && _bmi.BitCount != 32)
     {
         return VFW_E_TYPE_NOT_ACCEPTED;
     }
     VideoStreamConfigCaps _caps;
     GetDefaultCaps(0, out _caps);
     if (
             _bmi.Width < _caps.MinOutputSize.Width
         || _bmi.Width > _caps.MaxOutputSize.Width
         )
     {
         return VFW_E_INVALIDMEDIATYPE;
     }
     long _rate = 0;
     {
         VideoInfoHeader _pvi = pmt;
         if (_pvi != null)
         {
             _rate = _pvi.AvgTimePerFrame;
         }
     }
     {
         VideoInfoHeader2 _pvi = pmt;
         if (_pvi != null)
         {
             _rate = _pvi.AvgTimePerFrame;
         }
     }
     if (_rate < _caps.MinFrameInterval || _rate > _caps.MaxFrameInterval)
     {
         return VFW_E_INVALIDMEDIATYPE;
     }
     return NOERROR;
 }
开发者ID:Norman0406,项目名称:KinectCamV2,代码行数:59,代码来源:VirtualCam.cs


示例2: Load

 public int Load(string pszFileName, AMMediaType pmt)
 {
   if (_sourceStream != null)
     return E_UNEXPECTED;
   _fileName = pszFileName;
   _sourceStream = new FileStream(pszFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
   _streamCreated = true;
   return NOERROR;
 }
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:9,代码来源:NetStreamSourceFilter.cs


示例3: TryGetType

 /// <summary>
 /// Tries to create a matching <see cref="AMMediaType"/> for the given <paramref name="streamInfo"/>.
 /// </summary>
 /// <param name="streamInfo">stream</param>
 /// <param name="mediaType">media type</param>
 /// <returns><c>true</c> if successful</returns>
 public static bool TryGetType(InputstreamInfo streamInfo, out AMMediaType mediaType)
 {
   Func<InputstreamInfo, AMMediaType> mediaTypeFn;
   if (TYPE_MAPPINGS.TryGetValue(streamInfo.CodecInternalName, out mediaTypeFn) || TYPE_MAPPINGS.TryGetValue(streamInfo.CodecName, out mediaTypeFn))
   {
     mediaType = mediaTypeFn(streamInfo);
     return true;
   }
   mediaType = null;
   return false;
 }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:17,代码来源:MediaTypeBuilder.cs


示例4: CheckMediaType

        public int CheckMediaType(AMMediaType pmt)
        {
            if (pmt == null) return E_POINTER;
            if (pmt.formatPtr == IntPtr.Zero) return VFW_E_INVALIDMEDIATYPE;
            if (pmt.majorType != MediaType.Video)
            {
                return VFW_E_INVALIDMEDIATYPE;
            }
            if (
                pmt.subType != MediaSubType.RGB24
                && pmt.subType != MediaSubType.RGB32
                && pmt.subType != MediaSubType.ARGB32
                )
            {
                return VFW_E_INVALIDMEDIATYPE;
            }
            BitmapInfoHeader bmi = pmt;
            if (bmi.Compression != BI_RGB)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
            if (bmi.BitCount != 24 && bmi.BitCount != 32)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
            VideoStreamConfigCaps caps;
            GetDefaultCaps(0, out caps);
            if (
                bmi.Width < caps.MinOutputSize.Width
                || bmi.Width > caps.MaxOutputSize.Width
                )
            {
                return VFW_E_INVALIDMEDIATYPE;
            }

            var rate = 0L;
            VideoInfoHeader pvi = pmt;
            if (pvi != null)
            {
                rate = pvi.AvgTimePerFrame;
            }
            VideoInfoHeader2 pvi2 = pmt;
            if (pvi2 != null)
            {
                rate = pvi2.AvgTimePerFrame;
            }

            if (rate < caps.MinFrameInterval || rate > caps.MaxFrameInterval)
            {
                return VFW_E_INVALIDMEDIATYPE;
            }
            return NOERROR;
        }
开发者ID:NickVanderPyle,项目名称:KinectCamForConference,代码行数:53,代码来源:VirtualCamFilter.cs


示例5: H264_AnnexB

    /// <summary>
    /// AnnexB formatted h264 bitstream
    /// </summary>
    /// <param name="streamInfo"></param>
    /// <returns></returns>
    public static AMMediaType H264_AnnexB(InputstreamInfo streamInfo)
    {
      int width = (int)streamInfo.Width;
      int height = (int)streamInfo.Height;

      if (streamInfo.ExtraData.Length > 0)
      {
        var codecData = new H264CodecData(streamInfo.ExtraData);

        SPSUnit spsUnit = new SPSUnit(codecData.SPS);
        width = spsUnit.Width();
        height = spsUnit.Height();
      }

      VideoInfoHeader2 vi = new VideoInfoHeader2();
      vi.SrcRect.right = width;
      vi.SrcRect.bottom = height;
      vi.TargetRect.right = width;
      vi.TargetRect.bottom = height;

      int hcf = HCF(width, height);
      vi.PictAspectRatioX = width / hcf;
      vi.PictAspectRatioY = height / hcf;

      vi.BmiHeader.Width = width;
      vi.BmiHeader.Height = height;
      vi.BmiHeader.Planes = 1;
      vi.BmiHeader.Compression = FOURCC_H264;

      AMMediaType amt = new AMMediaType();
      amt.majorType = MediaType.Video;
      amt.subType = MediaSubType.H264;
      amt.temporalCompression = true;
      amt.fixedSizeSamples = false;
      amt.sampleSize = 1;
      amt.SetFormat(vi);
      return amt;
    }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:43,代码来源:MediaTypeBuilder.cs


示例6: ImageOverFilter

        public ImageOverFilter()
            : base("CSharp Image Overlay Filter")
        {
            vid.DSplugin = true;

            AllocConsole();
            IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
            SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
            FileStream fileStream = new FileStream(safeFileHandle, FileAccess.Write);
            Encoding encoding = System.Text.Encoding.GetEncoding(MY_CODE_PAGE);
            StreamWriter standardOutput = new StreamWriter(fileStream, encoding);
            standardOutput.AutoFlush = true;
            Console.SetOut(standardOutput);
            Console.WriteLine("This text you can see in console window.");

            AMMediaType pmt = new AMMediaType() { majorType = MediaType.Video, subType = MediaSubType.YUY2, formatType = MediaType.Video, formatPtr = IntPtr.Zero };
            SetMediaType(PinDirection.Input, pmt);
            pmt.Free();

            pmt = new AMMediaType() { majorType = MediaType.Video, subType = MediaSubType.RGB24, formatType = MediaType.Video, formatPtr = IntPtr.Zero };
            SetMediaType(PinDirection.Output, pmt);
            pmt.Free();
        }
开发者ID:hzeera,项目名称:MissionPlanner,代码行数:23,代码来源:ImageOverFilter.cs


示例7: SetFormat

 public static void SetFormat(ref AMMediaType mt, IntPtr pFormat, int nSize)
 {
     AllocFormat(ref mt, nSize);
     if (mt != null && pFormat != IntPtr.Zero)
     {
         COMHelper.API.CopyMemory(mt.formatPtr, pFormat, mt.formatSize);
     }
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:8,代码来源:DirectShow.cs


示例8: Free

 public static void Free(ref AMMediaType mt)
 {
     if (mt != null)
     {
         FreeFormat(ref mt);
         if (mt.unkPtr != IntPtr.Zero)
         {
             Marshal.Release(mt.unkPtr);
             mt.unkPtr = IntPtr.Zero;
         }
     }
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:12,代码来源:DirectShow.cs


示例9: AllocFormat

 public static void AllocFormat(ref AMMediaType mt, int nSize)
 {
     FreeFormat(ref mt);
     if (mt != null && nSize > 0)
     {
         mt.formatPtr = Marshal.AllocCoTaskMem(nSize);
         mt.formatSize = nSize;
     }
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:9,代码来源:DirectShow.cs


示例10: CheckMediaType

    public override int CheckMediaType(AMMediaType pmt)
    {
      lock (m_Lock)
      {
        // The given mediatype as acceptable when the major type is Stream, no subtype and no specific format
        if (pmt.majorType == MediaType.Stream && pmt.subType == MediaSubType.Null && pmt.formatType == FormatType.None)
          return NOERROR;

        return E_FAIL;
      }
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:11,代码来源:NetStreamSourceFilter.cs


示例11: Copy

        public static void Copy(AMMediaType mt, ref AMMediaType _dest)
        {
            if (((object)_dest) == null)
            {
                _dest = new AMMediaType();
            }
            else
            {
                Free(ref _dest);
            }

            _dest.majorType = mt.majorType;
            _dest.subType = mt.subType;
            _dest.fixedSizeSamples = mt.fixedSizeSamples;
            _dest.temporalCompression = mt.temporalCompression;
            _dest.sampleSize = mt.sampleSize;
            _dest.formatType = mt.formatType;
            _dest.unkPtr = mt.unkPtr;
            _dest.formatPtr = IntPtr.Zero;
            _dest.formatSize = mt.formatSize;
            if (_dest.unkPtr != IntPtr.Zero)
            {
                Marshal.AddRef(_dest.unkPtr);
            }
            if (_dest.formatSize > 0)
            {
                _dest.formatPtr = Marshal.AllocCoTaskMem(_dest.formatSize);
                COMHelper.API.CopyMemory(_dest.formatPtr, mt.formatPtr, _dest.formatSize);
            }
        }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:30,代码来源:DirectShow.cs


示例12: SetMediaType

        public int SetMediaType(AMMediaType pMediaType)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            SetMediaTypeProc _Proc = GetProcDelegate<SetMediaTypeProc>(14);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pMediaType
                        );
        }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:13,代码来源:DirectShow.cs


示例13: ConnectionMediaType

        public int ConnectionMediaType(AMMediaType pmt)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            ConnectionMediaTypeProc _Proc = GetProcDelegate<ConnectionMediaTypeProc>(7);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pmt
                        );
        }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:13,代码来源:DirectShow.cs


示例14: FreeFormat

 public static void FreeFormat(ref AMMediaType mt)
 {
     if (mt != null)
     {
         if (mt.formatPtr != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(mt.formatPtr);
             mt.formatPtr = IntPtr.Zero;
         }
         mt.formatSize = 0;
     }
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:12,代码来源:DirectShow.cs


示例15: AreEquals

 public static bool AreEquals(AMMediaType _src, AMMediaType _dst)
 {
     if ((_dst.majorType != _src.majorType))
     {
         return false;
     }
     if (_src.subType != _dst.subType)
     {
         return false;
     }
     if (_src.formatType != _dst.formatType)
     {
         return false;
     }
     if (_src.formatSize != _dst.formatSize)
     {
         return false;
     }
     if (_src.formatSize > 0)
     {
         byte[] _source = new byte[_src.formatSize];
         byte[] _dest = new byte[_src.formatSize];
         Marshal.Copy(_src.formatPtr, _source, 0, _source.Length);
         Marshal.Copy(_dst.formatPtr, _dest, 0, _dest.Length);
         for (int i = 0; i < _source.Length; i++)
         {
             if (_dest[i] != _source[i]) return false;
         }
     }
     return true;
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:31,代码来源:DirectShow.cs


示例16: OnReceive

        /*
        public override int OnReceive(ref IMediaSampleImpl _sample)
        {
            Console.WriteLine("OnReceive ");

            Output.Deliver(ref _sample);

            return S_OK;
        }
        */
        public override int GetMediaType(int iPosition, ref AMMediaType pMediaType)
        {
            Console.WriteLine("GetMediaType");
            if (iPosition > 0) return VFW_S_NO_MORE_ITEMS;
            if (pMediaType == null) return E_INVALIDARG;
            if (!Input.IsConnected) return VFW_E_NOT_CONNECTED;

            AMMediaType.Copy(Input.CurrentMediaType, ref pMediaType);

            VideoInfoHeader vhi = new VideoInfoHeader();
            Marshal.PtrToStructure(pMediaType.formatPtr, vhi);
            vhi.BmiHeader.Compression = 0;
            vhi.BmiHeader.BitCount = 24;
            vhi.BmiHeader.ImageSize = vhi.BmiHeader.Width * vhi.BmiHeader.Height * 3;
            pMediaType.formatPtr = Marshal.AllocCoTaskMem(pMediaType.formatSize);
            Marshal.StructureToPtr(vhi, pMediaType.formatPtr, false);

            pMediaType.majorType = MediaType.Video;
            pMediaType.subType = MediaSubType.RGB24;
            pMediaType.formatType = FormatType.VideoInfo;
            pMediaType.sampleSize = vhi.BmiHeader.ImageSize;

            return NOERROR;
        }
开发者ID:hzeera,项目名称:MissionPlanner,代码行数:34,代码来源:ImageOverFilter.cs


示例17: CheckTransform

        public override int CheckTransform(AMMediaType mtIn, AMMediaType mtOut)
        {
            Console.WriteLine("CheckTransform");
            if (mtIn.subType == MediaSubType.YUY2 && mtOut.subType == MediaSubType.RGB24)
            {
                return NOERROR;
            }

            return VFW_E_INVALIDMEDIATYPE;

            //return AMMediaType.AreEquals(mtIn, mtOut) ? NOERROR : VFW_E_INVALIDMEDIATYPE;
        }
开发者ID:hzeera,项目名称:MissionPlanner,代码行数:12,代码来源:ImageOverFilter.cs


示例18: CheckInputType

        public override int CheckInputType(AMMediaType pmt)
        {
            Console.WriteLine("CheckInputType");

            if (pmt.majorType != MediaType.Video)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
            if (pmt.subType != MediaSubType.YUY2)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
            if (pmt.formatType != FormatType.VideoInfo)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
            if (pmt.formatPtr == IntPtr.Zero)
            {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }

            vid.Show();

            return NOERROR;
        }
开发者ID:hzeera,项目名称:MissionPlanner,代码行数:25,代码来源:ImageOverFilter.cs


示例19: GetMediaType

    public override int GetMediaType(int iPosition, ref AMMediaType pMediaType)
    {
      lock (m_Lock)
      {
        if (iPosition < 0)
        {
          return E_INVALIDARG;
        }
        if (iPosition > 0)
        {
          return VFW_S_NO_MORE_ITEMS;
        }
        if (_sourceStream == null)
        {
          return E_UNEXPECTED;
        }
        // Set our MediaType requirements
        pMediaType.majorType = MediaType.Stream;
        pMediaType.subType = MediaSubType.Null;
        pMediaType.formatType = FormatType.None;
        pMediaType.temporalCompression = false;
        pMediaType.fixedSizeSamples = false;
        pMediaType.sampleSize = 0;

        return NOERROR;
      }
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:27,代码来源:NetStreamSourceFilter.cs


示例20: AMMediaType

 public AMMediaType(AMMediaType mt)
     : this()
 {
     Set(mt);
 }
开发者ID:se7ensoft,项目名称:MissionPlanner,代码行数:5,代码来源:DirectShow.cs



注:本文中的DirectShow.AMMediaType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DirectShowLib.AMMediaType类代码示例发布时间:2022-05-24
下一篇:
C# Client.RmsChannel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap