コード例 #1
0
        protected ArrayList findCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
        {
            int       num;
            int       num2;
            ArrayList list      = new ArrayList();
            int       errorCode = crossbar.get_PinCounts(out num, out num2);

            if (errorCode < 0)
            {
                Marshal.ThrowExceptionForHR(errorCode);
            }
            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num2; j++)
                {
                    if (crossbar.CanRoute(i, j) == 0)
                    {
                        int num6;
                        PhysicalConnectorType type;
                        errorCode = crossbar.get_CrossbarPinInfo(true, j, out num6, out type);
                        if (errorCode < 0)
                        {
                            Marshal.ThrowExceptionForHR(errorCode);
                        }
                        CrossbarSource source = new CrossbarSource(crossbar, i, j, type);
                        if (type < PhysicalConnectorType.Audio_Tuner)
                        {
                            if (isVideoDevice)
                            {
                                list.Add(source);
                            }
                            else if (!isVideoDevice)
                            {
                                list.Add(source);
                            }
                        }
                    }
                }
            }
            int index = 0;

            while (index < list.Count)
            {
                bool           flag    = false;
                CrossbarSource source2 = (CrossbarSource)list[index];
                for (int k = 0; k < list.Count; k++)
                {
                    CrossbarSource source3 = (CrossbarSource)list[k];
                    if ((source2.OutputPin == source3.OutputPin) && (index != k))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    index++;
                }
                else
                {
                    list.RemoveAt(index);
                }
            }
            return(list);
        }
コード例 #2
0
        protected void addFromGraph(ICaptureGraphBuilder2 graphBuilder, IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter, IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, SourceCollection videoSources, SourceCollection audioSources)
        {
            object ppint = null;

            Trace.Assert(graphBuilder != null);
            this.addIfSupported(videoDeviceFilter, "Video Capture Device");
            Guid capture     = PinCategory.Capture;
            Guid interleaved = MediaType.Interleaved;
            Guid gUID        = typeof(IAMStreamConfig).GUID;

            if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
            {
                interleaved = MediaType.Video;
                if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
                {
                    ppint = null;
                }
            }
            this.addIfSupported(ppint, "Video Capture Pin");
            capture     = PinCategory.Preview;
            interleaved = MediaType.Interleaved;
            gUID        = typeof(IAMStreamConfig).GUID;
            if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
            {
                interleaved = MediaType.Video;
                if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
                {
                    ppint = null;
                }
            }
            this.addIfSupported(ppint, "Video Preview Pin");
            ArrayList list = new ArrayList();
            int       num  = 1;

            for (int i = 0; i < videoSources.Count; i++)
            {
                CrossbarSource source = videoSources[i] as CrossbarSource;
                if ((source != null) && (list.IndexOf(source.Crossbar) < 0))
                {
                    list.Add(source.Crossbar);
                    if (this.addIfSupported(source.Crossbar, "Video Crossbar " + ((num == 1) ? "" : num.ToString())))
                    {
                        num++;
                    }
                }
            }
            list.Clear();
            this.addIfSupported(videoCompressorFilter, "Video Compressor");
            capture     = PinCategory.Capture;
            interleaved = MediaType.Interleaved;
            gUID        = typeof(IAMTVTuner).GUID;
            if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
            {
                interleaved = MediaType.Video;
                if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0)
                {
                    ppint = null;
                }
            }
            this.addIfSupported(ppint, "TV Tuner");
            IAMVfwCompressDialogs compressDialogs = videoCompressorFilter as IAMVfwCompressDialogs;

            if (compressDialogs != null)
            {
                VfwCompressorPropertyPage page = new VfwCompressorPropertyPage("Video Compressor", compressDialogs);
                base.InnerList.Add(page);
            }
            this.addIfSupported(audioDeviceFilter, "Audio Capture Device");
            capture     = PinCategory.Capture;
            interleaved = MediaType.Audio;
            gUID        = typeof(IAMStreamConfig).GUID;
            if (graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out ppint) != 0)
            {
                ppint = null;
            }
            this.addIfSupported(ppint, "Audio Capture Pin");
            capture     = PinCategory.Preview;
            interleaved = MediaType.Audio;
            gUID        = typeof(IAMStreamConfig).GUID;
            if (graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out ppint) != 0)
            {
                ppint = null;
            }
            this.addIfSupported(ppint, "Audio Preview Pin");
            num = 1;
            for (int j = 0; j < audioSources.Count; j++)
            {
                CrossbarSource source2 = audioSources[j] as CrossbarSource;
                if ((source2 != null) && (list.IndexOf(source2.Crossbar) < 0))
                {
                    list.Add(source2.Crossbar);
                    if (this.addIfSupported(source2.Crossbar, "Audio Crossbar " + ((num == 1) ? "" : num.ToString())))
                    {
                        num++;
                    }
                }
            }
            list.Clear();
            this.addIfSupported(audioCompressorFilter, "Audio Compressor");
        }