コード例 #1
0
        /// <summary>
        ///  Populate the internal InnerList with sources/physical connectors
        ///  found on the crossbars. Each instance of this class is limited
        ///  to video only or audio only sources ( specified by the isVideoDevice
        ///  parameter on the constructor) so we check each source before adding
        ///  it to the list.
        /// </summary>
        protected ArrayList FindCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
        {
            ArrayList sources = new ArrayList();
            int errorCode;
            int numOutPins;
            int numInPins;
            errorCode = crossbar.get_PinCounts(out numOutPins, out numInPins);
            if (errorCode < 0)
            {
                Marshal.ThrowExceptionForHR(errorCode);
            }

            // We loop through every combination of output and input pin
            // to see which combinations match.

            // Loop through output pins
            for (int cOut = 0; cOut < numOutPins; cOut++)
            {
                // Loop through input pins
                for (int cIn = 0; cIn < numInPins; cIn++)
                {
                    // Can this combination be routed?
                    errorCode = crossbar.CanRoute(cOut, cIn);
                    if (errorCode == 0)
                    {
                        // Yes, this can be routed
                        int relatedPin;
                        PhysicalConnectorType connectorType;
                        errorCode = crossbar.get_CrossbarPinInfo(true, cIn, out relatedPin, out connectorType);
                        if (errorCode < 0)
                        {
                            Marshal.ThrowExceptionForHR(errorCode);
                        }

                        // Is this the correct type?, If so add to the InnerList
                        CrossbarSource source = new CrossbarSource(crossbar, cOut, cIn, connectorType);
                        if (connectorType < PhysicalConnectorType.Audio_Tuner)
                        {
                            if (isVideoDevice)
                            {
                                sources.Add(source);
                            }
                            else
                            {
                                sources.Add(source);
                            }
                        }
                    }
                }
            }

            // Some silly drivers (*cough* Nvidia *cough*) add crossbars
            // with no real choices. Every input can only be routed to
            // one output. Loop through every Source and see if there
            // at least one other Source with the same output pin.
            int refIndex = 0;
            while (refIndex < sources.Count)
            {
                bool found = false;
                CrossbarSource refSource = (CrossbarSource)sources[refIndex];
                for (int c = 0; c < sources.Count; c++)
                {
                    CrossbarSource source = (CrossbarSource)sources[c];
                    if ((refSource.OutputPin == source.OutputPin) && (refIndex != c))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    refIndex++;
                }
                else
                {
                    sources.RemoveAt(refIndex);
                }
            }
            return sources;
        }
コード例 #2
0
        /// <summary>
        ///  Populate the internal InnerList with sources/physical connectors
        ///  found on the crossbars. Each instance of this class is limited
        ///  to video only or audio only sources ( specified by the isVideoDevice
        ///  parameter on the constructor) so we check each source before adding
        ///  it to the list.
        /// </summary>
        protected ArrayList FindCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
        {
            ArrayList sources = new ArrayList();
            int       errorCode;
            int       numOutPins;
            int       numInPins;

            errorCode = crossbar.get_PinCounts(out numOutPins, out numInPins);
            if (errorCode < 0)
            {
                Marshal.ThrowExceptionForHR(errorCode);
            }

            // We loop through every combination of output and input pin
            // to see which combinations match.

            // Loop through output pins
            for (int cOut = 0; cOut < numOutPins; cOut++)
            {
                // Loop through input pins
                for (int cIn = 0; cIn < numInPins; cIn++)
                {
                    // Can this combination be routed?
                    errorCode = crossbar.CanRoute(cOut, cIn);
                    if (errorCode == 0)
                    {
                        // Yes, this can be routed
                        int relatedPin;
                        PhysicalConnectorType connectorType;
                        errorCode = crossbar.get_CrossbarPinInfo(true, cIn, out relatedPin, out connectorType);
                        if (errorCode < 0)
                        {
                            Marshal.ThrowExceptionForHR(errorCode);
                        }

                        // Is this the correct type?, If so add to the InnerList
                        CrossbarSource source = new CrossbarSource(crossbar, cOut, cIn, connectorType);
                        if (connectorType < PhysicalConnectorType.Audio_Tuner)
                        {
                            if (isVideoDevice)
                            {
                                sources.Add(source);
                            }
                            else
                            {
                                sources.Add(source);
                            }
                        }
                    }
                }
            }

            // Some silly drivers (*cough* Nvidia *cough*) add crossbars
            // with no real choices. Every input can only be routed to
            // one output. Loop through every Source and see if there
            // at least one other Source with the same output pin.
            int refIndex = 0;

            while (refIndex < sources.Count)
            {
                bool           found     = false;
                CrossbarSource refSource = (CrossbarSource)sources[refIndex];
                for (int c = 0; c < sources.Count; c++)
                {
                    CrossbarSource source = (CrossbarSource)sources[c];
                    if ((refSource.OutputPin == source.OutputPin) && (refIndex != c))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    refIndex++;
                }
                else
                {
                    sources.RemoveAt(refIndex);
                }
            }
            return(sources);
        }
コード例 #3
0
        /// <summary> Populate the collection by looking for commonly implemented property pages. </summary>
        protected void AddFromGraph(ICaptureGraphBuilder2 graphBuilder, IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter, IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, SourceCollection videoSources, SourceCollection audioSources)
        {
            object filter = null;
            Guid   capture;
            Guid   interleaved;
            Guid   gUID;
            int    hr;

            Trace.Assert(graphBuilder != null);
            // 1. the video capture filter
            AddIfSupported(videoDeviceFilter, "Video Capture Device");

            // 2. the video capture pin
            capture     = PinCategory.Capture;
            interleaved = MediaType.Interleaved;
            gUID        = typeof(IAMStreamConfig).GUID;
            hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
            if (hr != 0)
            {
                interleaved = MediaType.Video;
                hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
                if (hr != 0)
                {
                    filter = null;
                }
            }
            AddIfSupported(filter, "Video Capture Pin");

            // 3. the video preview pin
            capture     = PinCategory.Preview;
            interleaved = MediaType.Interleaved;
            gUID        = typeof(IAMStreamConfig).GUID;
            hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
            if (hr != 0)
            {
                interleaved = MediaType.Video;
                hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
                if (hr != 0)
                {
                    filter = null;
                }
            }
            AddIfSupported(filter, "Video Preview Pin");

            // 4. the video crossbar(s)
            ArrayList crossbars = new ArrayList();
            int       num       = 1;

            for (int c = 0; c < videoSources.Count; c++)
            {
                CrossbarSource source = videoSources[c] as CrossbarSource;
                if (source != null && crossbars.IndexOf(source.Crossbar) < 0)
                {
                    crossbars.Add(source.Crossbar);
                    if (AddIfSupported(source.Crossbar, "Video Crossbar " + (num == 1 ? "" : num.ToString())))
                    {
                        num++;
                    }
                }
            }
            crossbars.Clear();

            // 5. the video compressor
            AddIfSupported(videoCompressorFilter, "Video Compressor");

            // 6. the video TV tuner
            capture     = PinCategory.Capture;
            interleaved = MediaType.Interleaved;
            gUID        = typeof(IAMTVTuner).GUID;
            hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
            if (hr != 0)
            {
                interleaved = MediaType.Video;
                hr          = graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out filter);
                if (hr != 0)
                {
                    filter = null;
                }
            }
            AddIfSupported(filter, "TV Tuner");

            // 7. the video compressor (VFW)
            IAMVfwCompressDialogs compressDialog = videoCompressorFilter as IAMVfwCompressDialogs;

            if (compressDialog != null)
            {
                VfwCompressorPropertyPage page = new VfwCompressorPropertyPage("Video Compressor", compressDialog);
                base.InnerList.Add(page);
            }

            // 8. the audio capture filter
            AddIfSupported(audioDeviceFilter, "Audio Capture Device");

            // 9. the audio capture pin
            capture     = PinCategory.Capture;
            interleaved = MediaType.Audio;
            gUID        = typeof(IAMStreamConfig).GUID;
            hr          = graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out filter);
            if (hr != 0)
            {
                filter = null;
            }
            AddIfSupported(filter, "Audio Capture Pin");

            // 9. the audio preview pin
            capture     = PinCategory.Preview;
            interleaved = MediaType.Audio;
            gUID        = typeof(IAMStreamConfig).GUID;
            hr          = graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out filter);
            if (hr != 0)
            {
                filter = null;
            }
            AddIfSupported(filter, "Audio Preview Pin");

            // 10. the audio crossbar(s)
            num = 1;
            for (int c = 0; c < audioSources.Count; c++)
            {
                CrossbarSource source = audioSources[c] as CrossbarSource;
                if (source != null && crossbars.IndexOf(source.Crossbar) < 0)
                {
                    crossbars.Add(source.Crossbar);
                    if (AddIfSupported(source.Crossbar, "Audio Crossbar " + (num == 1 ? "" : num.ToString())))
                    {
                        num++;
                    }
                }
            }
            crossbars.Clear();

            // 11. the audio compressor
            AddIfSupported(audioCompressorFilter, "Audio Compressor");
        }