当前位置: 首页>>代码示例>>C#>>正文


C# IPin.EnumMediaTypes方法代码示例

本文整理汇总了C#中IPin.EnumMediaTypes方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.EnumMediaTypes方法的具体用法?C# IPin.EnumMediaTypes怎么用?C# IPin.EnumMediaTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPin的用法示例。


在下文中一共展示了IPin.EnumMediaTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMediaTypes

        /// <summary>
        /// Gets iSC's available _AMMediaTypes, without freeing pbFormat
        /// Caller should call MediaType.Free(_AMMediaType[]) when done
        /// </summary>
        public static _AMMediaType[] GetMediaTypes(IPin pin)
        {
            IEnumMediaTypes iEnum;
            pin.EnumMediaTypes(out iEnum);

            ArrayList alMTs = new ArrayList();

            IntPtr[] ptrs = new IntPtr[1];
            uint fetched;

            iEnum.Next(1, ptrs, out fetched);

            while(fetched == 1)
            {
                _AMMediaType mt = (_AMMediaType)Marshal.PtrToStructure(ptrs[0], typeof(_AMMediaType));
                alMTs.Add(mt);

                Marshal.FreeCoTaskMem(ptrs[0]);
                ptrs[0] = IntPtr.Zero;

                iEnum.Next(1, ptrs, out fetched);
            }

            _AMMediaType[] mts = new _AMMediaType[alMTs.Count];
            alMTs.CopyTo(mts);

            return mts;
        }
开发者ID:JayBeavers,项目名称:WPF-MediaKit,代码行数:32,代码来源:Pins.cs

示例2: RebuildMediaType

    protected void RebuildMediaType(IPin pPin)
    {
      if (pPin != null)
      {
        //Detection if the Video Stream is VC-1 on output pin of the splitter
        IEnumMediaTypes enumMediaTypesAudioVideo;
        int hr = pPin.EnumMediaTypes(out enumMediaTypesAudioVideo);
        AMMediaType[] mediaTypes = new AMMediaType[1];
        int typesFetched;
        PinInfo pinInfo;
        pPin.QueryPinInfo(out pinInfo);

        while (0 == enumMediaTypesAudioVideo.Next(1, mediaTypes, out typesFetched))
        {
          if (typesFetched == 0)
            break;

          if (mediaTypes[0].majorType == MediaType.Video && !pinInfo.name.ToLowerInvariant().Contains("sub"))
          {
            if (mediaTypes[0].subType == MediaSubType.VC1)
            {
              Log.Info("VideoPlayer9: found VC-1 video out pin");
              vc1Codec = true;
            }
            if (mediaTypes[0].subType == MediaSubType.H264 || mediaTypes[0].subType == MediaSubType.AVC1)
            {
              Log.Info("VideoPlayer9: found H264 video out pin");
              h264Codec = true;
            }
            if (mediaTypes[0].subType == MediaSubType.XVID || mediaTypes[0].subType == MediaSubType.xvid ||
                mediaTypes[0].subType == MediaSubType.dx50 || mediaTypes[0].subType == MediaSubType.DX50 ||
                mediaTypes[0].subType == MediaSubType.divx || mediaTypes[0].subType == MediaSubType.DIVX)
            {
              Log.Info("VideoPlayer9: found XVID video out pin");
              xvidCodec = true;
            }
            MediatypeVideo = true;
          }
          else if (mediaTypes[0].majorType == MediaType.Audio)
          {
            //Detection if the Audio Stream is AAC on output pin of the splitter
            if (mediaTypes[0].subType == MediaSubType.LATMAAC || mediaTypes[0].subType == MediaSubType.AAC)
            {
              Log.Info("VideoPlayer9: found AAC Audio out pin");
              aacCodec = true;
            }
            if (mediaTypes[0].subType == MediaSubType.LATMAACLAF)
            {
              Log.Info("VideoPlayer9: found AAC LAVF Audio out pin");
              aacCodecLav = true;
            }
            MediatypeAudio = true;
          }
          else if (mediaTypes[0].majorType == MediaType.Subtitle)
          {
            MediatypeSubtitle = true;
          }
        }
        DirectShowUtil.ReleaseComObject(enumMediaTypesAudioVideo);
        enumMediaTypesAudioVideo = null;
      }
    }
开发者ID:HeinA,项目名称:MediaPortal-1,代码行数:62,代码来源:VideoPlayerVMR9.cs

示例3: getPinMediaType

        private int getPinMediaType(IPin pPin, Guid majorType, Guid minorType, Guid formatType, ref AMMediaType mediaType)
        {
            if (pPin == null) throw new Exception("No pin");

            int hr;

            IEnumMediaTypes pEnum = null;

            hr = pPin.EnumMediaTypes(out pEnum);
            DsError.ThrowExceptionForHR(hr);
            bool found = false;
            IntPtr fetched = IntPtr.Zero;
            AMMediaType[] pMT = new AMMediaType[1];
            hr = pEnum.Next(1, pMT, fetched);
            while (hr == 0)
            {
                if ((majorType.Equals(Guid.Empty)) || (majorType.Equals(pMT[0].majorType)))
                    if ((minorType.Equals(Guid.Empty)) || (minorType.Equals(pMT[0].subType)))
                        if ((formatType.Equals(Guid.Empty)) || (formatType.Equals(pMT[0].formatType)))
                        // Match
                        {
                            found = true;
                            mediaType = pMT[0];
                            break;
                        }

                DsUtils.FreeAMMediaType(pMT[0]);

                hr = pEnum.Next(1, pMT, fetched);
            }

            // End
            Marshal.ReleaseComObject(pEnum);
            if (found)
                return 0;
            else
                return -1;
        }
开发者ID:piet5211,项目名称:remotepotato,代码行数:38,代码来源:DSTranscoderBase.cs

示例4: IsMatchingPin

		private bool IsMatchingPin(IPin pin, PinDirection direction, Guid mediaType)
		{
			PinDirection pinDirection;
			int hr = pin.QueryDirection(out pinDirection);
			DsError.ThrowExceptionForHR(hr);

			if (pinDirection != direction)
				// The pin lacks direction
				return false;

			IPin connectedPin;
			hr = pin.ConnectedTo(out connectedPin);
			if ((uint)hr != 0x80040209 /* Pin is not connected */)
				DsError.ThrowExceptionForHR(hr);

			if (connectedPin != null)
			{
				// The pin is already connected
				Marshal.ReleaseComObject(connectedPin);
				return false;
			}

			IEnumMediaTypes mediaTypesEnum;
			hr = pin.EnumMediaTypes(out mediaTypesEnum);
			DsError.ThrowExceptionForHR(hr);

			AMMediaType[] mediaTypes = new AMMediaType[1];

			while (mediaTypesEnum.Next(1, mediaTypes, IntPtr.Zero) == 0)
			{
				Guid majorType = mediaTypes[0].majorType;
				DsUtils.FreeAMMediaType(mediaTypes[0]);

				if (majorType == mediaType)
				{
					// We have found the pin we were looking for
					return true;
				}
			}

			return false;
		}
开发者ID:hpavlov,项目名称:video.directshowvideocapture,代码行数:42,代码来源:DirectShowCapture.cs

示例5: TestMediaTypes

 private static bool TestMediaTypes(IPin pin, IPin receiver)
 {
   bool ret = false;
   IEnumMediaTypes types;
   pin.EnumMediaTypes(out types);
   types.Reset();
   while (true)
   {
     AMMediaType[] mediaTypes = new AMMediaType[1];
     int typesFetched;
     int hr = types.Next(1, mediaTypes, out typesFetched);
     if (hr != 0 || typesFetched == 0)
     {
       break;
     }
     //Log.Info("Check output type: {0}, {1}", mediaTypes[0].majorType,
     //  mediaTypes[0].subType);
     if (receiver.QueryAccept(mediaTypes[0]) == 0)
     {
       //Log.Info("Accepted!");
       ret = true;
       break;
     }
   }
   ReleaseComObject(types);
   //Log.Info("-----EndofTypes");
   return ret;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:28,代码来源:DirectShowUtil.cs

示例6: TryConnect

    public static bool TryConnect(IGraphBuilder graphBuilder, string filtername, IPin outputPin, bool TryNewFilters)
    {
      int hr;
      Log.Info("----------------TryConnect-------------");
      PinInfo outputInfo;
      outputPin.QueryPinInfo(out outputInfo);
      DsUtils.FreePinInfo(outputInfo);
      //ListMediaTypes(outputPin);
      ArrayList currentfilters = GetFilters(graphBuilder);
      foreach (IBaseFilter filter in currentfilters)
      {
        if (TryConnect(graphBuilder, filtername, outputPin, filter))
        {
          ReleaseFilters(currentfilters);
          return true;
        }
      }
      ReleaseFilters(currentfilters);
      //not found, try new filter from registry
      if (TryNewFilters)
      {
        Log.Info("No preloaded filter could be connected. Trying to load new one from registry");
        IEnumMediaTypes enumTypes;
        hr = outputPin.EnumMediaTypes(out enumTypes);
        if (hr != 0)
        {
          Log.Debug("Failed: {0:x}", hr);
          return false;
        }
        Log.Debug("Got enum");
        ArrayList major = new ArrayList();
        ArrayList sub = new ArrayList();

        Log.Debug("Getting corresponding filters");
        for (;;)
        {
          AMMediaType[] mediaTypes = new AMMediaType[1];
          int typesFetched;
          hr = enumTypes.Next(1, mediaTypes, out typesFetched);
          if (hr != 0 || typesFetched == 0)
          {
            break;
          }
          major.Add(mediaTypes[0].majorType);
          sub.Add(mediaTypes[0].subType);
        }
        ReleaseComObject(enumTypes);
        Log.Debug("Found {0} media types", major.Count);
        Guid[] majorTypes = (Guid[])major.ToArray(typeof (Guid));
        Guid[] subTypes = (Guid[])sub.ToArray(typeof (Guid));
        Log.Debug("Loading filters");
        ArrayList filters = FilterHelper.GetFilters(majorTypes, subTypes, (Merit)0x00400000);
        Log.Debug("Loaded {0} filters", filters.Count);
        foreach (string name in filters)
        {
          if (!CheckFilterIsLoaded(graphBuilder, name))
          {
            Log.Debug("Loading filter: {0}", name);
            IBaseFilter f = AddFilterToGraph(graphBuilder, name);
            if (f != null)
            {
              if (TryConnect(graphBuilder, filtername, outputPin, f))
              {
                ReleaseComObject(f);
                return true;
              }
              else
              {
                graphBuilder.RemoveFilter(f);
                ReleaseComObject(f);
              }
            }
          }
          else
          {
            Log.Debug("Ignoring filter {0}. Already in graph.", name);
          }
        }
      }
      Log.Debug("TryConnect failed.");
      return outputInfo.name.StartsWith("~");
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:82,代码来源:DirectShowUtil.cs

示例7: QueryConnect

 public static bool QueryConnect(IPin pin, IPin other)
 {
   IEnumMediaTypes enumTypes;
   int hr = pin.EnumMediaTypes(out enumTypes);
   if (hr != 0 || enumTypes == null)
   {
     return false;
   }
   int count = 0;
   for (;;)
   {
     AMMediaType[] types = new AMMediaType[1];
     int fetched;
     hr = enumTypes.Next(1, types, out fetched);
     if (hr != 0 || fetched == 0)
     {
       break;
     }
     count++;
     if (other.QueryAccept(types[0]) == 0)
     {
       return true;
     }
   }
   PinInfo info;
   PinInfo infoOther;
   pin.QueryPinInfo(out info);
   DsUtils.FreePinInfo(info);
   other.QueryPinInfo(out infoOther);
   DsUtils.FreePinInfo(infoOther);
   Log.Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, count);
   return false;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:33,代码来源:DirectShowUtil.cs

示例8: IsPinSupportsMediaType

            /// <summary>
            /// 指定したピンが指定したMediaTypeをサポートするか?
            /// </summary>
            /// <param name="pin">ピン</param>
            /// <param name="major">majorType</param>
            /// <param name="sub">subType or 検証不要な場合 Guid.Empty</param>
            /// <returns>サポートしてる場合true</returns>
            public static bool IsPinSupportsMediaType(IPin pin, Guid major, Guid sub)
            {
                bool found = false;
                IEnumMediaTypes enumerator = null;
                try
                {
                    pin.EnumMediaTypes(out enumerator);
                    IntPtr pMedia = IntPtr.Zero;
                    AMMediaType media = new AMMediaType();

                    found = false;
                    enumerator.Reset();
                    while (!found && enumerator.Next(1, out pMedia, IntPtr.Zero) == S_OK)
                    {
                        if (pMedia == IntPtr.Zero) continue;
                        Marshal.PtrToStructure(pMedia, media);

                        if (media.majorType == major && (sub == Guid.Empty || media.subType != sub))
                            found = true;

                        Util.FreeMediaType(media);
                        Marshal.FreeCoTaskMem(pMedia);
                    }
                }
                finally
                {
                    if (enumerator != null)
                        Marshal.ReleaseComObject(enumerator);
                    enumerator = null;
                }
                return found;
            }
开发者ID:ttsuki,项目名称:ttsuki,代码行数:39,代码来源:GraphBase.cs

示例9: checkMediaTypes

        private static bool checkMediaTypes(IPin pin, Guid mediaType, Guid mediaSubType)
        {
            int reply = 0;

            IEnumMediaTypes enumMediaTypes = null;
            AMMediaType[] mediaTypes = new AMMediaType[1];

            reply = pin.EnumMediaTypes(out enumMediaTypes);
            DsError.ThrowExceptionForHR(reply);

            while (enumMediaTypes.Next(mediaTypes.Length, mediaTypes, IntPtr.Zero) == 0)
            {
                foreach (AMMediaType currentMediaType in mediaTypes)
                {
                    if (currentMediaType != null)
                    {
                        if (currentMediaType.majorType == mediaType &&
                            currentMediaType.subType == mediaSubType)
                        {
                            Marshal.ReleaseComObject(enumMediaTypes);
                            return (true);
                        }
                    }
                }
            }

            Marshal.ReleaseComObject(enumMediaTypes);

            return (false);
        }
开发者ID:esurharun,项目名称:TSDumper,代码行数:30,代码来源:DirectShowGraph.cs

示例10: logMediaTypes

        private void logMediaTypes(IPin pin)
        {
            IEnumMediaTypes mediaTypes = null;
            AMMediaType[] mediaType = new AMMediaType[1];

            AMMediaType connectedMediaType = new AMMediaType();
            reply = pin.ConnectionMediaType(connectedMediaType);

            reply = pin.EnumMediaTypes(out mediaTypes);
            if (reply != 0)
            {
                LogMessage("Media types cannot be determined at this time (not connected yet?)");
                return;
            }

            while (mediaTypes.Next(mediaType.Length, mediaType, IntPtr.Zero) == 0)
            {
                foreach (AMMediaType currentMediaType in mediaType)
                {
                    PinInfo pinInfo;
                    reply = pin.QueryPinInfo(out pinInfo);
                    DsError.ThrowExceptionForHR(reply);

                    string majorType = TranslateMediaMajorType(currentMediaType.majorType);
                    string subType = TranslateMediaSubType(currentMediaType.subType);

                    string connectedComment;

                    if (currentMediaType.majorType == connectedMediaType.majorType && currentMediaType.subType == connectedMediaType.subType)
                        connectedComment = "** Connected **";
                    else
                        connectedComment = string.Empty;

                    LogMessage("Media type: " +
                        majorType + " ; " +
                        subType + " " +
                        currentMediaType.fixedSizeSamples + " " +
                        currentMediaType.sampleSize + " " +
                        connectedComment);
                }
            }
        }
开发者ID:esurharun,项目名称:TSDumper,代码行数:42,代码来源:DirectShowGraph.cs

示例11: VideoIndex

        private int VideoIndex(IPin pPin)
        {
            int hr;
            int bRet = -1;
            AMMediaType[] pmt = new AMMediaType[1];
            IEnumMediaTypes ppEnum;

            // Walk the MediaTypes for the pin
            hr = pPin.EnumMediaTypes(out ppEnum);
            DsError.ThrowExceptionForHR(hr);

            try {
                do {
                    bRet++;
                    // Just read the first one
                    hr = ppEnum.Next(1, pmt, IntPtr.Zero);
                    DsError.ThrowExceptionForHR(hr);

                } while (pmt[0].majorType != MediaType.Video);
            } catch {
                bRet = -1;
            } finally {
                Marshal.ReleaseComObject(ppEnum);
            }
            DsUtils.FreeAMMediaType(pmt[0]);

            return bRet;
        }
开发者ID:i-e-b,项目名称:HLS---Smooth-Encoder,代码行数:28,代码来源:VideoCapture.cs

示例12: QueryConnect

    /// <summary>
    /// QueryConnect checks if two Pins can be connected.
    /// </summary>
    /// <param name="pin">Pin 1</param>
    /// <param name="other">Pin 2</param>
    /// <returns>True if they accept connection</returns>
    static bool QueryConnect(IPin pin, IPin other)
    {
      IEnumMediaTypes enumTypes;
      int hr = pin.EnumMediaTypes(out enumTypes);
      if (hr != 0 || enumTypes == null)
        return false;

      int count = 0;
      IntPtr ptrFetched = Marshal.AllocCoTaskMem(4);
      try
      {
        for (; ; )
        {
          AMMediaType[] types = new AMMediaType[1];
          hr = enumTypes.Next(1, types, ptrFetched);
          if (hr != 0 || Marshal.ReadInt32(ptrFetched) == 0)
            break;

          count++;
          try
          {
            if (other.QueryAccept(types[0]) == 0)
              return true;
          }
          finally
          {
            FilterGraphTools.FreeAMMediaType(types[0]);
          }
        }
        PinInfo info;
        PinInfo infoOther;
        pin.QueryPinInfo(out info);
        other.QueryPinInfo(out infoOther);
        ServiceRegistration.Get<ILogger>().Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, count);
        FilterGraphTools.FreePinInfo(info);
        FilterGraphTools.FreePinInfo(infoOther);
        return false;
      }
      finally
      {
        Marshal.FreeCoTaskMem(ptrFetched);
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:49,代码来源:GraphRebuilder.cs

示例13: Connect

        public int Connect(IPin pReceivePin, AMMediaType pmt)
        {
            Monitor.Enter(this);
            int hr = S_OK;
            pin = null;
            pintype = null;
            allocator = null;
            string id = "Unnamed pin";
            pReceivePin.QueryId(out id);
            PinInfo pi = new PinInfo();
            hr = pReceivePin.QueryPinInfo(out pi);
            if (hr == S_OK)
            {
                FilterInfo fi = new FilterInfo();
                hr = pi.filter.QueryFilterInfo(out fi);
                if (hr == S_OK)
                {
                    id += (" (" + fi.achName);
                }
                Guid guid;
                hr = pi.filter.GetClassID(out guid);
                if (hr == S_OK)
                {
                    id += (", " + guid.ToString());
                }
                id += ")";
            }
            try
            {
                AMMediaType amt = null;
                if (pmt != null)
                {
                    amt = pmt;
                }
                else
            #if false
                {
                    IEnumMediaTypes ie;
                    hr = pReceivePin.EnumMediaTypes(out ie);
                    int fetched;
                    int alloc = Marshal.SizeOf(typeof(AMMediaType));
                    IntPtr mtypePtr = Marshal.AllocCoTaskMem(alloc);
                    while (ie.Next(1, mtypePtr, out fetched) == S_OK)
                    {
                        amt = new AMMediaType();
                        Marshal.PtrToStructure(mtypePtr, amt);
                        hr = pReceivePin.QueryAccept(amt);
                        if (hr == S_OK)
                        {
                            break;
                        }
                        DsUtils.FreeAMMediaType(amt);
                        amt = null;
                    }
                    if (fetched == 0)
                    {
                        amt = null;
                    }
                    Marshal.FreeCoTaskMem(mtypePtr);
                }
                if (amt == null)
            #endif
                {
                    amt = mediatype;
                }
                hr = pReceivePin.QueryAccept(amt);
                if (hr == S_FALSE)
                {
                    log.InfoFormat("No media type for pin '{0}'", id);
                    Monitor.Exit(this);
                    return VFW_E_NO_ACCEPTABLE_TYPES;
                }

                hr = pReceivePin.ReceiveConnection(this, amt);
                if (hr == VFW_E_TYPE_NOT_ACCEPTED)
                {
                    log.InfoFormat("No connection to pin '{0}'", id);
                    Monitor.Exit(this);
                    return VFW_E_NO_ACCEPTABLE_TYPES;
                }
                DsError.ThrowExceptionForHR(hr);

                pin = pReceivePin;
                pintype = amt;
            }
            catch (Exception e)
            {
                LogUtil.ExceptionLog.ErrorFormat("Caught exception in connect ({0}): {1}{2}", id, e.Message, e.StackTrace);
                pin = null;
                pintype = null;
                allocator = null;
                Monitor.Exit(this);
                return VFW_E_NO_TRANSPORT;
            }
            Monitor.Exit(this);
            log.InfoFormat("Connected to pin '{0}'", id);
            return S_OK;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:98,代码来源:DirectShowCodec.cs

示例14: while

            int IPin.Connect(IPin pReceivePin, AMMediaType pmt)
            {
                IEnumMediaTypes emt;

                if (connectedPin != null)
                    return DsResults.E_AlreadyConnected;
                if (pReceivePin == null)
                    return E_POINTER;
                if (pReceivePin.EnumMediaTypes(out emt) == S_OK)
                {
                    var mediaTypes = new AMMediaType[1];

                    while (emt.Next(1, mediaTypes, IntPtr.Zero) == S_OK)
                        if (mediaTypes[0].majorType == MediaType.Stream && pReceivePin.ReceiveConnection(this, mediaTypes[0]) == S_OK)
                        {
                            emt = null;
                            connectedPin = pReceivePin;
                            return S_OK;
                        }
                    emt = null;
                }
                if (pmt != null && pmt.majorType != MediaType.Null && pmt.majorType != MediaType.Stream)
                    return DsResults.E_TypeNotAccepted;
                if (pReceivePin.ReceiveConnection(this, mediaType) == S_OK)
                {
                    connectedPin = pReceivePin;
                    return S_OK;
                }
                return DsResults.E_NoAcceptableTypes;
            }
开发者ID:sgraf812,项目名称:crystalmpq,代码行数:30,代码来源:MpqFileSourceFilter.cs

示例15: ListMediaTypes

 private static void ListMediaTypes(IPin pin)
 {
   IEnumMediaTypes types;
   pin.EnumMediaTypes(out types);
   types.Reset();
   while (true)
   {
     AMMediaType[] mediaTypes = new AMMediaType[1];
     int typesFetched;
     int hr = types.Next(1, mediaTypes, out typesFetched);
     if (hr != 0 || typesFetched == 0)
     {
       break;
     }
     Log.Info("Has output type: {0}, {1}", mediaTypes[0].majorType,
              mediaTypes[0].subType);
   }
   ReleaseComObject(types);
   Log.Info("-----EndofTypes");
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:20,代码来源:DirectShowUtil.cs


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