Ejemplo n.º 1
0
        void TestPinCounts()
        {
            int hr;
            int opin, ipin;

            hr = m_ixbar.get_PinCounts(out opin, out ipin);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(opin > 0, "PinCount output");
            Debug.Assert(ipin > 0, "PinCount input");
        }
Ejemplo n.º 2
0
        public void ChangeVideoInputSource(PhysicalConnectorType inputType)
        {
            if (crossbar != null)
            {
                int numOutputPins;
                int numInputPins;
                int hr = crossbar.get_PinCounts(out numOutputPins, out numInputPins);
                DsError.ThrowExceptionForHR(hr);

                int outputPin = -1;
                //get the video output pin
                for (int i = 0; i < numOutputPins; i++)
                {
                    int relatedPin;
                    PhysicalConnectorType physicalType;
                    hr = crossbar.get_CrossbarPinInfo(false, i, out relatedPin, out physicalType);
                    DsError.ThrowExceptionForHR(hr);

                    //VideoDecoder
                    //AudioDecoder
                    if (physicalType == PhysicalConnectorType.Video_VideoDecoder)
                    {
                        outputPin = i;
                        break;
                    }
                }

                int inputPin = -1;
                for (int i = 0; i < numInputPins; i++)
                {
                    int relatedPin;
                    PhysicalConnectorType physicalType;
                    hr = crossbar.get_CrossbarPinInfo(true, i, out relatedPin, out physicalType);
                    DsError.ThrowExceptionForHR(hr);

                    if (physicalType == inputType)
                    {
                        inputPin = i;
                        break;
                    }
                }

                if (outputPin != -1 && inputPin != -1)
                {
                    hr = crossbar.Route(outputPin, inputPin);

                    videoInputDeviceSource = inputType;

                    DsError.ThrowExceptionForHR(hr);
                }
            }
        }
Ejemplo n.º 3
0
        // Token: 0x06000045 RID: 69 RVA: 0x00003694 File Offset: 0x00001894
        private void SetCurrentCrossbarInput(IAMCrossbar crossbar, VideoInput videoInput)
        {
            int num;
            int num2;

            if (videoInput.Type != PhysicalConnectorType.Default && crossbar.get_PinCounts(out num, out num2) == 0)
            {
                int num3 = -1;
                int num4 = -1;
                for (int i = 0; i < num; i++)
                {
                    int num5;
                    PhysicalConnectorType physicalConnectorType;
                    if (crossbar.get_CrossbarPinInfo(false, i, out num5, out physicalConnectorType) == 0 && physicalConnectorType == PhysicalConnectorType.VideoDecoder)
                    {
                        num3 = i;
                        break;
                    }
                }
                for (int j = 0; j < num2; j++)
                {
                    int num5;
                    PhysicalConnectorType physicalConnectorType;
                    if (crossbar.get_CrossbarPinInfo(true, j, out num5, out physicalConnectorType) == 0 && physicalConnectorType == videoInput.Type && j == videoInput.Index)
                    {
                        num4 = j;
                        break;
                    }
                }
                if (num4 != -1 && num3 != -1 && crossbar.CanRoute(num3, num4) == 0)
                {
                    crossbar.Route(num3, num4);
                }
            }
        }
Ejemplo n.º 4
0
        // Token: 0x06000044 RID: 68 RVA: 0x00003620 File Offset: 0x00001820
        private VideoInput GetCurrentCrossbarInput(IAMCrossbar crossbar)
        {
            VideoInput result = VideoInput.Default1;
            int        num;
            int        num2;

            if (crossbar.get_PinCounts(out num, out num2) == 0)
            {
                int num3 = -1;
                for (int i = 0; i < num; i++)
                {
                    int num4;
                    PhysicalConnectorType physicalConnectorType;
                    if (crossbar.get_CrossbarPinInfo(false, i, out num4, out physicalConnectorType) == 0 && physicalConnectorType == PhysicalConnectorType.VideoDecoder)
                    {
                        num3 = i;
                        break;
                    }
                }
                int num5;
                if (num3 != -1 && crossbar.get_IsRoutedTo(num3, out num5) == 0)
                {
                    int num4;
                    PhysicalConnectorType type;
                    int num6 = crossbar.get_CrossbarPinInfo(true, num5, out num4, out type);
                    result = new VideoInput(num5, type);
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        private int FindVideoDecoderOutputPin(IAMCrossbar crossbar)
        {
            int rv = -1;

            int outputPinsCount;
            int inputPinsCount;
            int hr = crossbar.get_PinCounts(out outputPinsCount, out inputPinsCount);

            DsError.ThrowExceptionForHR(hr);

            for (int i = 0; i < outputPinsCount; i++)
            {
                int relatedIndex;
                PhysicalConnectorType connectorType;
                hr = crossbar.get_CrossbarPinInfo(false, i, out relatedIndex, out connectorType);
                if (hr == 0)
                {
                    int inputPinIndex;
                    crossbar.get_IsRoutedTo(i, out inputPinIndex);

                    Trace.WriteLine(string.Format("Crossbar Output Pin {0}: '{1}' routed to pin {2}", i, GetPhysicalPinName(connectorType), inputPinIndex));
                    if (connectorType == PhysicalConnectorType.Video_VideoDecoder)
                    {
                        rv = i;
                    }
                }
            }

            return(rv);
        }
Ejemplo n.º 6
0
        private static Camera_NET.VideoInput GetCrossbarInput(IAMCrossbar crossbar)
        {
            int num;
            int num2;

            Camera_NET.VideoInput input = Camera_NET.VideoInput.Default;
            if (crossbar.get_PinCounts(out num2, out num) == 0)
            {
                int num4;
                int num6;
                int outputPinIndex = -1;
                for (int i = 0; i < num2; i++)
                {
                    PhysicalConnectorType type;
                    if ((crossbar.get_CrossbarPinInfo(false, i, out num4, out type) == 0) && (type == PhysicalConnectorType.Video_VideoDecoder))
                    {
                        outputPinIndex = i;
                        break;
                    }
                }
                if ((outputPinIndex != -1) && (crossbar.get_IsRoutedTo(outputPinIndex, out num6) == 0))
                {
                    PhysicalConnectorType type2;
                    crossbar.get_CrossbarPinInfo(true, num6, out num4, out type2);
                    input = new Camera_NET.VideoInput(num6, type2);
                }
            }
            return(input);
        }
Ejemplo n.º 7
0
        //protected override void ConfigureVMR9InWindowlessMode(int numberOfStream)
        //{
        //    int hr = 0;
        //    IVMRFilterConfig9 filterConfig = this.videoRenderer as IVMRFilterConfig9;

        //    // Configure VMR-9 in Windowsless mode
        //    hr = filterConfig.SetRenderingMode(VMR9Mode.Windowless);
        //    DsError.ThrowExceptionForHR(hr);

        //    // With 1 input stream
        //    hr = filterConfig.SetNumberOfStreams(numberOfStream);
        //    DsError.ThrowExceptionForHR(hr);

        //    IVMRWindowlessControl9 windowlessControl = this.videoRenderer as IVMRWindowlessControl9;

        //    // The main form is hosting the VMR-9
        //    hr = windowlessControl.SetVideoClippingWindow(this.hostingControl.Handle);
        //    DsError.ThrowExceptionForHR(hr);

        //    // Keep the aspect-ratio OK
        //    //hr = windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
        //    hr = windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.None);
        //    DsError.ThrowExceptionForHR(hr);

        //    // Init the VMR-9 with default size values
        //    OnResizeMoveHandler(null, null);

        //    // Add Windows Messages handlers
        //    AddHandlers();
        //}

        public int FindCrossbarPin(IAMCrossbar pXBar, PhysicalConnectorType PhysicalType,
                                   PinDirection Dir, out int pIndex)
        {
            pIndex = -1;
            bool bInput = (Dir == PinDirection.Input ? true : false);

            // Find out how many pins the crossbar has.
            int cOut, cIn;
            int hr = pXBar.get_PinCounts(out cOut, out cIn);

            if (hr < 0)
            {
                return(hr);
            }
            // Enumerate pins and look for a matching pin.
            int count = (bInput ? cIn : cOut);

            for (int i = 0; i < count; i++)
            {
                int iRelated = 0;
                PhysicalConnectorType ThisPhysicalType = 0;
                hr = pXBar.get_CrossbarPinInfo(bInput, i, out iRelated, out ThisPhysicalType);
                if (hr >= 0 && ThisPhysicalType == PhysicalType)
                {
                    // Found a match, return the index.
                    pIndex = i;
                    return(0);
                }
            }
            // Did not find a matching pin.
            return(-1);
        }
Ejemplo n.º 8
0
        private void SetCurrentCrossbarInput(IAMCrossbar crossbar, VideoInput videoInput)
        {
            if (videoInput.Type != PhysicalConnectorType.Default)
            {
                int inPinsCount, outPinsCount;


                if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
                {
                    int videoOutputPinIndex = -1;
                    int videoInputPinIndex  = -1;
                    int pinIndexRelated;
                    PhysicalConnectorType type;


                    for (int i = 0; i < outPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(false, i, out pinIndexRelated, out type) != 0)
                        {
                            continue;
                        }

                        if (type == PhysicalConnectorType.VideoDecoder)
                        {
                            videoOutputPinIndex = i;
                            break;
                        }
                    }


                    for (int i = 0; i < inPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(true, i, out pinIndexRelated, out type) != 0)
                        {
                            continue;
                        }

                        if ((type == videoInput.Type) && (i == videoInput.Index))
                        {
                            videoInputPinIndex = i;
                            break;
                        }
                    }


                    if ((videoInputPinIndex != -1) && (videoOutputPinIndex != -1) &&
                        (crossbar.CanRoute(videoOutputPinIndex, videoInputPinIndex) == 0))
                    {
                        crossbar.Route(videoOutputPinIndex, videoInputPinIndex);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        // Does not AddRef the returned *Pin
        private int GetCrossbarPinAtIndex(IAMCrossbar crossbar, int pinIndex, bool isInputPin, out IPin pin)
        {
            pin = null;

            if (crossbar == null)
            {
                return(-1);
            }

            int cntInPins, cntOutPins;

            if (crossbar.get_PinCounts(out cntOutPins, out cntInPins) != 0)
            {
                return(unchecked ((int)0x80004005));               //E_FAIL;
            }
            int trueIndex = isInputPin ? pinIndex : pinIndex + cntInPins;

            IBaseFilter filter = crossbar as IBaseFilter;

            if (filter != null)
            {
                IEnumPins enumPins = null;
                if (filter.EnumPins(out enumPins) == 0)
                {
                    int     i    = 0;
                    IPin [] pins = new IPin[1];
                    //22 int n;
                    //22 while(enumPins.Next(1, pins, out n) == 0)
                    while (enumPins.Next(1, pins, IntPtr.Zero) == 0)
                    {
                        //pP.Release();
                        if (i == trueIndex)
                        {
                            pin = pins[0];
                            break;
                        }
                        Marshal.ReleaseComObject(pins[0]);
                        i++;
                    }
                    Marshal.ReleaseComObject(enumPins);
                }
                //pFilter.Release();
            }

            return(pin != null ? 0 : unchecked ((int)0x80004005));           //E_FAIL;
        }
Ejemplo n.º 10
0
        private VideoInput GetCurrentCrossbarInput(IAMCrossbar crossbar)
        {
            VideoInput videoInput = VideoInput.Default;

            int inPinsCount, outPinsCount;


            if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
            {
                int videoOutputPinIndex = -1;
                int pinIndexRelated;
                PhysicalConnectorType type;


                for (int i = 0; i < outPinsCount; i++)
                {
                    if (crossbar.get_CrossbarPinInfo(false, i, out pinIndexRelated, out type) != 0)
                    {
                        continue;
                    }

                    if (type == PhysicalConnectorType.VideoDecoder)
                    {
                        videoOutputPinIndex = i;
                        break;
                    }
                }

                if (videoOutputPinIndex != -1)
                {
                    int videoInputPinIndex;


                    if (crossbar.get_IsRoutedTo(videoOutputPinIndex, out videoInputPinIndex) == 0)
                    {
                        PhysicalConnectorType inputType;

                        crossbar.get_CrossbarPinInfo(true, videoInputPinIndex, out pinIndexRelated, out inputType);

                        videoInput = new VideoInput(videoInputPinIndex, inputType);
                    }
                }
            }

            return(videoInput);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets type of input connected to video output of the crossbar.
        /// </summary>
        /// <param name="crossbar">The crossbar of device.</param>
        /// <returns>Video input of device</returns>
        /// <seealso cref="CrossbarAvailable"/>
        public static VideoInput GetCrossbarInput(IAMCrossbar crossbar)
        {
            VideoInput videoInput = VideoInput.Default;

            int inPinsCount, outPinsCount;

            // gen number of pins in the crossbar
            if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
            {
                int videoOutputPinIndex = -1;
                int pinIndexRelated;
                PhysicalConnectorType type;

                // find index of the video output pin
                for (int i = 0; i < outPinsCount; i++)
                {
                    if (crossbar.get_CrossbarPinInfo(false, i, out pinIndexRelated, out type) != 0)
                    {
                        continue;
                    }

                    if (type == PhysicalConnectorType.Video_VideoDecoder)
                    {
                        videoOutputPinIndex = i;
                        break;
                    }
                }

                if (videoOutputPinIndex != -1)
                {
                    int videoInputPinIndex;

                    // get index of the input pin connected to the output
                    if (crossbar.get_IsRoutedTo(videoOutputPinIndex, out videoInputPinIndex) == 0)
                    {
                        PhysicalConnectorType inputType;

                        crossbar.get_CrossbarPinInfo(true, videoInputPinIndex, out pinIndexRelated, out inputType);

                        videoInput = new VideoInput(videoInputPinIndex, inputType);
                    }
                }
            }

            return(videoInput);
        }
Ejemplo n.º 12
0
        private VideoInput[] ColletCrossbarVideoInputs(IAMCrossbar crossbar)
        {
            lock ( cacheCrossbarVideoInputs )
            {
                if (cacheCrossbarVideoInputs.ContainsKey(deviceMoniker))
                {
                    return(cacheCrossbarVideoInputs[deviceMoniker]);
                }

                List <VideoInput> videoInputsList = new List <VideoInput>( );

                if (crossbar != null)
                {
                    int inPinsCount, outPinsCount;


                    if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
                    {
                        for (int i = 0; i < inPinsCount; i++)
                        {
                            int pinIndexRelated;
                            PhysicalConnectorType type;

                            if (crossbar.get_CrossbarPinInfo(true, i, out pinIndexRelated, out type) != 0)
                            {
                                continue;
                            }

                            if (type < PhysicalConnectorType.AudioTuner)
                            {
                                videoInputsList.Add(new VideoInput(i, type));
                            }
                        }
                    }
                }

                VideoInput[] videoInputs = new VideoInput[videoInputsList.Count];
                videoInputsList.CopyTo(videoInputs);

                cacheCrossbarVideoInputs.Add(deviceMoniker, videoInputs);

                return(videoInputs);
            }
        }
Ejemplo n.º 13
0
        // Token: 0x06000043 RID: 67 RVA: 0x00003554 File Offset: 0x00001754
        private VideoInput[] ColletCrossbarVideoInputs(IAMCrossbar crossbar)
        {
            Dictionary <string, VideoInput[]> obj = VideoCaptureDevice.cacheCrossbarVideoInputs1;

            VideoInput[] result;
            lock (obj)
            {
                if (VideoCaptureDevice.cacheCrossbarVideoInputs1.ContainsKey(this.deviceMoniker1))
                {
                    result = VideoCaptureDevice.cacheCrossbarVideoInputs1[this.deviceMoniker1];
                }
                else
                {
                    List <VideoInput> list = new List <VideoInput>();
                    int num;
                    int num2;
                    if (crossbar != null && crossbar.get_PinCounts(out num, out num2) == 0)
                    {
                        for (int i = 0; i < num2; i++)
                        {
                            int num3;
                            PhysicalConnectorType physicalConnectorType;
                            if (crossbar.get_CrossbarPinInfo(true, i, out num3, out physicalConnectorType) == 0 && physicalConnectorType < PhysicalConnectorType.AudioTuner)
                            {
                                list.Add(new VideoInput(i, physicalConnectorType));
                            }
                        }
                    }
                    VideoInput[] array = new VideoInput[list.Count];
                    list.CopyTo(array);
                    VideoCaptureDevice.cacheCrossbarVideoInputs1.Add(this.deviceMoniker1, array);
                    result = array;
                }
            }
            return(result);
        }
Ejemplo n.º 14
0
        public int FindCrossbarPin(DirectShowLib.PhysicalConnectorType PhysicalType, bool bInput)
        {
            int hr;

            int cOut, cIn;

            hr = _amCrossbar.get_PinCounts(out cOut, out cIn);
            DsError.ThrowExceptionForHR(hr);
            // Enumerate pins and look for a matching pin.
            int count = (bInput ? cIn : cOut);

            for (int i = 0; i < count; i++)
            {
                int iRelated = 0;
                DirectShowLib.PhysicalConnectorType ThisPhysicalType = 0;
                hr = _amCrossbar.get_CrossbarPinInfo(bInput, i, out iRelated, out ThisPhysicalType);
                DsError.ThrowExceptionForHR(hr);
                if (ThisPhysicalType == (DirectShowLib.PhysicalConnectorType)PhysicalType)
                {
                    return(i);
                }
            }
            return(-1);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Sets type of input connected to video output of the crossbar.
        /// </summary>
        /// <param name="crossbar">The crossbar of device.</param>
        /// <param name="videoInput">Video input of device.</param>
        /// <seealso cref="CrossbarAvailable"/>
        private static void SetCrossbarInput(IAMCrossbar crossbar, VideoInput videoInput)
        {
            if (videoInput.Type != VideoInput.PhysicalConnectorType_Default &&
                videoInput.Index != -1)
            {
                int inPinsCount, outPinsCount;

                // gen number of pins in the crossbar
                if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
                {
                    int videoOutputPinIndex = -1;
                    int videoInputPinIndex = -1;
                    int pinIndexRelated;
                    PhysicalConnectorType type;

                    // find index of the video output pin
                    for (int i = 0; i < outPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(false, i, out pinIndexRelated, out type) != 0)
                            continue;

                        if (type == PhysicalConnectorType.Video_VideoDecoder)
                        {
                            videoOutputPinIndex = i;
                            break;
                        }
                    }

                    // find index of the required input pin
                    for (int i = 0; i < inPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(true, i, out pinIndexRelated, out type) != 0)
                            continue;

                        if ((type == videoInput.Type) && (i == videoInput.Index))
                        {
                            videoInputPinIndex = i;
                            break;
                        }
                    }

                    // try connecting pins
                    if ((videoInputPinIndex != -1) && (videoOutputPinIndex != -1))
                    {
                        if (crossbar.CanRoute(videoOutputPinIndex, videoInputPinIndex) == 0)
                        {
                            int hr = crossbar.Route(videoOutputPinIndex, videoInputPinIndex);
                            DsError.ThrowExceptionForHR(hr);
                        }
                        else
                        {
                            throw new Exception("Can't route from selected VideoInput to VideoDecoder.");
                        }
                    }
                    else
                    {
                        throw new Exception("Can't find routing pins.");
                    }

                }
            }
        }
Ejemplo n.º 16
0
        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(DsDevice dev, AMMediaType media)
        {
            int hr;

            ISampleGrabber        sampGrabber = null;
            IBaseFilter           capFilter   = null;
            ICaptureGraphBuilder2 capGraph    = null;

            // Get the graphbuilder object
            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            m_mediaCtrl   = m_FilterGraph as IMediaControl;
            try
            {
                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

                /*
                 * // check for crossbar
                 * var capDevices2 = DsDevice.GetDevicesOfCat(FilterCategory.AMKSCrossbar);
                 * if (capDevices2.Length > 0)
                 * {
                 *
                 *  IBaseFilter cross;
                 *  hr = m_FilterGraph.AddSourceFilterForMoniker(capDevices2[0].Mon, null, "crossbar", out cross);
                 *  ISpecifyPropertyPages pProp = cross as ISpecifyPropertyPages;
                 *
                 *  //Get the name of the filter from the FilterInfo struct
                 *  FilterInfo filterInfo;
                 *  hr = cross.QueryFilterInfo(out filterInfo);
                 *  DsError.ThrowExceptionForHR(hr);
                 *
                 *  // Get the propertypages from the property bag
                 *  DsCAUUID caGUID;
                 *  hr = pProp.GetPages(out caGUID);
                 *  DsError.ThrowExceptionForHR(hr);
                 *
                 *  //Create and display the OlePropertyFrame
                 *  object oDevice = (object)cross;
                 *  hr = NativeMethods.OleCreatePropertyFrame(IntPtr.Zero, 0, 0, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero);
                 *  DsError.ThrowExceptionForHR(hr);
                 *
                 *  Marshal.ReleaseComObject(oDevice);
                 *
                 *  //IAMCrossbar crossbar2 = cross as IAMCrossbar;
                 *  //int inputPinCount, outputPinCount;
                 *  //crossbar2.get_PinCounts(out inputPinCount, out outputPinCount);
                 *  //crossbar2.Route(0, (int)PhysicalConnectorType.Video_Composite);
                 *  cross = null;
                 * }*/

                // Get the SampleGrabber interface
                sampGrabber = (ISampleGrabber) new SampleGrabber();

                // Start building the graph
                hr = capGraph.SetFiltergraph(m_FilterGraph);
                DsError.ThrowExceptionForHR(hr);

                // Add the video device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
                DsError.ThrowExceptionForHR(hr);

                // add video crossbar
                // thanks to Andrew Fernie - this is to get tv tuner cards working
                IAMCrossbar crossbar = null;
                object      o;

                hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMCrossbar).GUID, out o);
                if (hr >= 0)
                {
                    crossbar = (IAMCrossbar)o;
                    int oPin, iPin;
                    int ovLink, ivLink;
                    ovLink = ivLink = 0;

                    crossbar.get_PinCounts(out oPin, out iPin);
                    int pIdxRel;
                    PhysicalConnectorType tp;
                    for (int i = 0; i < iPin; i++)
                    {
                        crossbar.get_CrossbarPinInfo(true, i, out pIdxRel, out tp);
                        if (tp == PhysicalConnectorType.Video_Composite)
                        {
                            ivLink = i;
                        }
                    }

                    for (int i = 0; i < oPin; i++)
                    {
                        crossbar.get_CrossbarPinInfo(false, i, out pIdxRel, out tp);
                        if (tp == PhysicalConnectorType.Video_VideoDecoder)
                        {
                            ovLink = i;
                        }
                    }

                    try
                    {
                        crossbar.Route(ovLink, ivLink);
                        o = null;
                    }

                    catch
                    {
                        throw new Exception("Failed to get IAMCrossbar");
                    }
                }

                //add AVI Decompressor
                IBaseFilter pAVIDecompressor = (IBaseFilter) new AVIDec();
                hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor");
                DsError.ThrowExceptionForHR(hr);

                //
                IBaseFilter baseGrabFlt = (IBaseFilter)sampGrabber;
                ConfigureSampleGrabber(sampGrabber);

                // Add the frame grabber to the graph
                hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
                DsError.ThrowExceptionForHR(hr);

                SetConfigParms(capGraph, capFilter, media);

                hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, pAVIDecompressor, baseGrabFlt);
                if (hr < 0)
                {
                    hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt);
                }

                DsError.ThrowExceptionForHR(hr);

                SaveSizeInfo(sampGrabber);
            }
            finally
            {
                if (capFilter != null)
                {
                    Marshal.ReleaseComObject(capFilter);
                    capFilter = null;
                }
                if (sampGrabber != null)
                {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (capGraph != null)
                {
                    Marshal.ReleaseComObject(capGraph);
                    capGraph = null;
                }
            }
        }
Ejemplo n.º 17
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 hr;
			int numOutPins;
			int numInPins;
			hr = crossbar.get_PinCounts( out numOutPins, out numInPins );
			if ( hr < 0 )
				Marshal.ThrowExceptionForHR( hr );

			// 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?
					hr = crossbar.CanRoute( cOut, cIn );
					if ( hr == 0 )
					{
						// Yes, this can be routed
						int relatedInputPin;
						PhysicalConnectorType connectorType;
						hr = crossbar.get_CrossbarPinInfo( true, cIn, out relatedInputPin, out connectorType );
						if ( hr < 0 )
							Marshal.ThrowExceptionForHR( hr );

						// Add it to the list
						CrossbarSource source = new CrossbarSource( crossbar, cOut, cIn, relatedInputPin, connectorType );
						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 s = (CrossbarSource) sources[c];
					if ( ( refSource.OutputPin == s.OutputPin ) && ( refIndex != c ) )
					{
						found = true;
						break;
					}
				}
				if ( found )
					refIndex++;
				else
					sources.RemoveAt( refIndex );
			}

			// Some of the video input pins have related audio pins 
			// that should be connected at the same time. We noted the pin number
			// in the CrossbarSource.RelatedInputPin. Now that we have all
			// the sources, lookup the CrossbarSource object associated with
			// that pin
			foreach ( CrossbarSource source in sources )
			{
				if ( source.RelatedInputPin != -1 )
				{
					foreach( CrossbarSource related in sources )
					{
						if ( source.RelatedInputPin == related.InputPin )
							source.RelatedInputSource = related;
					}
				}
			}

			// Remove any sources that are not of the correct type
			for (int c=0; c<sources.Count; c++)
			{
				if ( ((CrossbarSource)sources[c]).ConnectorType < PhysicalConnectorType.Audio_Tuner )
				{
					if ( !isVideoDevice )
					{
						sources.RemoveAt( c );
						c--;
					}
				}
				else
				{
					if ( isVideoDevice )
					{
						sources.RemoveAt( c );
						c--;
					}
				}
			}
    	    return( sources );
		}
Ejemplo n.º 18
0
        public static void LoadCrossbarSources(IAMCrossbar crossbar, ComboBox cbxCrossbarInput)
        {
            int connectedInputPin = -1;
            int videoDecoderOutPinIndex = FindVideoDecoderOutputPin(crossbar, out connectedInputPin);
            cbxCrossbarInput.Enabled = videoDecoderOutPinIndex != -1;

            Trace.WriteLine(string.Format("Loading crossbar dropdown on {0}\r\nVideo decoder output pin is {1} which is routed to pin {2}.",
                GetParentFormName(cbxCrossbarInput), videoDecoderOutPinIndex, connectedInputPin));

            int outputPinsCount;
            int inputPinsCount;
            int hr = crossbar.get_PinCounts(out outputPinsCount, out inputPinsCount);
            DsError.ThrowExceptionForHR(hr);

            for (int i = 0; i < inputPinsCount; i++)
            {
                int relatedIndex;
                PhysicalConnectorType connectorType;
                hr = crossbar.get_CrossbarPinInfo(true, i, out relatedIndex, out connectorType);
                if (hr == 0)
                {
                    Trace.WriteLine(string.Format("Crossbar Input Pin {0}: {1}", i, GetPhysicalPinName(connectorType)));

                    if (IsVideoPin(connectorType))
                    {
                        int addedIdnex = cbxCrossbarInput.Items.Add(
                            new CrossbarPinEntry()
                            {
                                PinIndex = i,
                                PinName = GetPhysicalPinName(connectorType)
                            }
                        );

                        if (connectedInputPin == i)
                            cbxCrossbarInput.SelectedIndex = addedIdnex;
                    }
                }
            }

            cbxCrossbarInput.Enabled = true;
        }
Ejemplo n.º 19
0
        public static string DumpCrossbar(IAMCrossbar iCB)
        {
            string ret = "\r\nCrossbar\r\n";

            if(iCB != null)
            {
                ArrayList pins = GetPins((IBaseFilter)iCB);
                ArrayList inputPins = GetPins(pins, _PinDirection.PINDIR_INPUT);
                ArrayList outputPins = GetPins(pins, _PinDirection.PINDIR_OUTPUT);

                int inPins, outPins;
                iCB.get_PinCounts(out outPins, out inPins);

                ret += "\tInput Pins...\r\n";
                for(int inIndex = 0; inIndex < inPins; inIndex++)
                {
                    int related, type;
                    iCB.get_CrossbarPinInfo(true, inIndex, out related, out type);

                    ret += string.Format(CultureInfo.CurrentCulture, "\t{0}, Related input pin: {1}\r\n", 
                        Pin.Name((IPin)inputPins[inIndex]), related);
                }

                ret += "\r\n\tOutput Pins...";
                for(int outIndex = 0; outIndex < outPins; outIndex++)
                {
                    int related, type, routed;
                    iCB.get_CrossbarPinInfo(false, outIndex, out related, out type);
                    iCB.get_IsRoutedTo(outIndex, out routed);

                    ret += string.Format(CultureInfo.CurrentCulture, 
                        "\r\n\t{0}, Related output pin: {1}, Routed input pin: {2}" + 
                        Environment.NewLine, Pin.Name((IPin)outputPins[outIndex]), related, routed);

                    ret += "\tSwitching Matrix (which input pins this output pin can accept): ";

                    for(int inIndex = 0; inIndex < inPins; inIndex++)
                    {
                        ret += string.Format(CultureInfo.CurrentCulture, "{0}-{1}", inIndex, 
                            (iCB.CanRoute(outIndex, inIndex) == 0) ? "Yes " : "No ");
                    }
                }
            }

            return ret;
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        // This function is called recursively, every time a new crossbar is
        // entered as we search upstream.
        //
        // Return values:
        //
        //   0 - Returned on final exit after recursive search if at least
        //       one routing is possible
        //   1 - Normal return indicating we've reached the end of a
        //       recursive search, so save the current path
        //  -1 - Unable to route anything
        private int BuildRoutingList(IPin startingInputPin, Routing routing, int depth)
        {
            if (startingInputPin == null || routing == null)
            {
                return(-1);                // E_POINTER;
            }
            // If the pin isn't connected, then it's a terminal pin
            IPin startingOutputPin = null;
            int  hr = startingInputPin.ConnectedTo(out startingOutputPin);

            if (hr != 0)
            {
                return((depth == 0) ? -1 : 1);
            }

            // It is connected, so now find out if the filter supports IAMCrossbar
            PinInfo pinInfo;

            if (startingOutputPin.QueryPinInfo(out pinInfo) == 0)
            {
                //ASSERT (pinInfo.dir == PINDIR_OUTPUT);

                IAMCrossbar crossbar = pinInfo.filter as IAMCrossbar;
                if (crossbar != null)
                {
                    int inputs, outputs, inputIndex, outputIndex;
                    int inputIndexRelated, outputIndexRelated;
                    PhysicalConnectorType inputPhysicalType, outputPhysicalType;

                    hr = crossbar.get_PinCounts(out outputs, out inputs);

                    // for all output pins
                    for (outputIndex = 0; outputIndex < outputs; outputIndex++)
                    {
                        hr = crossbar.get_CrossbarPinInfo(false, outputIndex, out outputIndexRelated, out outputPhysicalType);

                        // for all input pins
                        for (inputIndex = 0; inputIndex < inputs; inputIndex++)
                        {
                            hr = crossbar.get_CrossbarPinInfo(true, inputIndex, out inputIndexRelated, out inputPhysicalType);

                            // Can we route it?
                            if (crossbar.CanRoute(outputIndex, inputIndex) == 0)
                            {
                                IPin pPin = null;
                                hr = GetCrossbarPinAtIndex(crossbar, inputIndex, true, out pPin);

                                // We've found a route through this crossbar
                                // so save our state before recusively searching
                                // again.
                                Routing routingNext = new Routing();
                                // doubly linked list
                                routingNext.rightRouting = routing;
                                routing.leftRouting      = routingNext;

                                routing.crossbar           = crossbar;
                                routing.inputIndex         = inputIndex;
                                routing.outputIndex        = outputIndex;
                                routing.inputIndexRelated  = inputIndexRelated;
                                routing.outputIndexRelated = outputIndexRelated;
                                routing.inputPhysicalType  = inputPhysicalType;
                                routing.outputPhysicalType = outputPhysicalType;
                                routing.depth     = depth;
                                routing.inputName = this.pinNameByPhysicalConnectorType[inputPhysicalType] as string;

                                hr = BuildRoutingList(pPin, routingNext, depth + 1);
                                if (hr == 1)
                                {
                                    routing.leftRouting = null;
                                    SaveRouting(routing, inputPhysicalType >= PhysicalConnectorType.Audio_Tuner);
                                }
                            }                     // if we can route
                        }                         // for all input pins
                    }
                    //pXbar.Release();
                }
                else
                {
                    // The filter doesn't support IAMCrossbar, so this
                    // is a terminal pin
                    DsUtils.FreePinInfo(pinInfo);
                    Marshal.ReleaseComObject(startingOutputPin);

                    return((depth == 0) ? -1 : 1);
                }

                DsUtils.FreePinInfo(pinInfo);
            }
            Marshal.ReleaseComObject(startingOutputPin);

            return(0);
        }
Ejemplo n.º 22
0
        private static void SetCrossbarInput(IAMCrossbar crossbar, Camera_NET.VideoInput videoInput)
        {
            int num;
            int num2;

            if (((videoInput.Type != Camera_NET.VideoInput.PhysicalConnectorType_Default) && (videoInput.Index != -1)) && (crossbar.get_PinCounts(out num2, out num) == 0))
            {
                int num5;
                PhysicalConnectorType type;
                int outputPinIndex = -1;
                int inputPinIndex  = -1;
                for (int i = 0; i < num2; i++)
                {
                    if ((crossbar.get_CrossbarPinInfo(false, i, out num5, out type) == 0) && (type == PhysicalConnectorType.Video_VideoDecoder))
                    {
                        outputPinIndex = i;
                        break;
                    }
                }
                for (int j = 0; j < num; j++)
                {
                    if (((crossbar.get_CrossbarPinInfo(true, j, out num5, out type) == 0) && (type == videoInput.Type)) && (j == videoInput.Index))
                    {
                        inputPinIndex = j;
                        break;
                    }
                }
                if ((inputPinIndex == -1) || (outputPinIndex == -1))
                {
                    throw new Exception("Can't find routing pins.");
                }
                if (crossbar.CanRoute(outputPinIndex, inputPinIndex) != 0)
                {
                    throw new Exception("Can't route from selected VideoInput to VideoDecoder.");
                }
                DsError.ThrowExceptionForHR(crossbar.Route(outputPinIndex, inputPinIndex));
            }
        }
        // Get type of input connected to video output of the crossbar
        private VideoInput GetCurrentCrossbarInput( IAMCrossbar crossbar )
        {
            VideoInput videoInput = VideoInput.Default;

            int inPinsCount, outPinsCount;

            // gen number of pins in the crossbar
            if ( crossbar.get_PinCounts( out outPinsCount, out inPinsCount ) == 0 )
            {
                int videoOutputPinIndex = -1;
                int pinIndexRelated;
                PhysicalConnectorType type;

                // find index of the video output pin
                for ( int i = 0; i < outPinsCount; i++ )
                {
                    if ( crossbar.get_CrossbarPinInfo( false, i, out pinIndexRelated, out type ) != 0 )
                        continue;

                    if ( type == PhysicalConnectorType.VideoDecoder )
                    {
                        videoOutputPinIndex = i;
                        break;
                    }
                }

                if ( videoOutputPinIndex != -1 )
                {
                    int videoInputPinIndex;

                    // get index of the input pin connected to the output
                    if ( crossbar.get_IsRoutedTo( videoOutputPinIndex, out videoInputPinIndex ) == 0 )
                    {
                        PhysicalConnectorType inputType;

                        crossbar.get_CrossbarPinInfo( true, videoInputPinIndex, out pinIndexRelated, out inputType );

                        videoInput = new VideoInput( videoInputPinIndex, inputType );
                    }
                }
            }

            return videoInput;
        }
Ejemplo n.º 24
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 hr;
            int numOutPins;
            int numInPins;
            hr = crossbar.get_PinCounts( out numOutPins, out numInPins );
            if ( hr < 0 )
                Marshal.ThrowExceptionForHR( hr );

            // 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?
                    hr = crossbar.CanRoute( cOut, cIn );
                    if ( hr == 0 )
                    {
                        // Yes, this can be routed
                        int relatedPin;
                        PhysicalConnectorType connectorType;
                        hr = crossbar.get_CrossbarPinInfo( true, cIn, out relatedPin, out connectorType );
                        if ( hr < 0 )
                            Marshal.ThrowExceptionForHR( hr );

                        // 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
                            if ( !isVideoDevice )
                                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 s = (CrossbarSource) sources[c];
                    if ( ( refSource.OutputPin == s.OutputPin ) && ( refIndex != c ) )
                    {
                        found = true;
                        break;
                    }
                }
                if ( found )
                    refIndex++;
                else
                    sources.RemoveAt( refIndex );
            }

            return( sources );
        }
Ejemplo n.º 25
0
        // Does not AddRef the returned *Pin
        private int GetCrossbarPinAtIndex(IAMCrossbar crossbar, int pinIndex, bool isInputPin, out IPin pin)
        {
            pin = null;

            if (crossbar == null)
                return -1;

            int cntInPins, cntOutPins;
            if (crossbar.get_PinCounts(out cntOutPins, out cntInPins) != 0)
                return unchecked((int)0x80004005); //E_FAIL;

            int trueIndex = isInputPin ? pinIndex : pinIndex + cntInPins;

            IBaseFilter filter = crossbar as IBaseFilter;
            if (filter != null)
            {
                IEnumPins enumPins = null;
                if (filter.EnumPins(out enumPins) == 0)
                {
                    int i = 0;
                    IPin [] pins = new IPin[1];
                    //22 int n;
                    //22 while(enumPins.Next(1, pins, out n) == 0)
                    while (enumPins.Next(1, pins, IntPtr.Zero) == 0)
                    {
                        //pP.Release();
                        if (i == trueIndex)
                        {
                            pin = pins[0];
                            break;
                        }
                        Marshal.ReleaseComObject(pins[0]);
                        i++;
                    }
                    Marshal.ReleaseComObject(enumPins);
                }
                //pFilter.Release();
            }

            return pin != null ? 0 : unchecked((int)0x80004005); //E_FAIL;
        }
Ejemplo n.º 26
0
 protected ArrayList findCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
 {
     int num2;
     int num3;
     ArrayList list = new ArrayList();
     int errorCode = crossbar.get_PinCounts(out num2, out num3);
     if (errorCode < 0)
     {
         Marshal.ThrowExceptionForHR(errorCode);
     }
     for (int i = 0; i < num2; i++)
     {
         for (int j = 0; j < num3; 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;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Checks the capabilities
        /// </summary>
        private void CheckCapabilities()
        {
            IAMCrossbar crossBarFilter = _filterCrossBar as IAMCrossbar;

            if (crossBarFilter != null)
            {
                int outputs, inputs;
                crossBarFilter.get_PinCounts(out outputs, out inputs);
                _videoOutPinIndex        = -1;
                _audioOutPinIndex        = -1;
                _videoPinMap             = new Dictionary <AnalogChannel.VideoInputType, int>();
                _audioPinMap             = new Dictionary <AnalogChannel.AudioInputType, int>();
                _videoPinRelatedAudioMap = new Dictionary <AnalogChannel.VideoInputType, int>();
                int relatedPinIndex;
                PhysicalConnectorType connectorType;
                for (int i = 0; i < outputs; ++i)
                {
                    crossBarFilter.get_CrossbarPinInfo(false, i, out relatedPinIndex, out connectorType);
                    if (connectorType == PhysicalConnectorType.Video_VideoDecoder)
                    {
                        _videoOutPinIndex = i;
                    }
                    if (connectorType == PhysicalConnectorType.Audio_AudioDecoder)
                    {
                        _audioOutPinIndex = i;
                    }
                }

                int audioLine    = 0;
                int audioSPDIF   = 0;
                int audioAux     = 0;
                int videoCvbsNr  = 0;
                int videoSvhsNr  = 0;
                int videoYrYbYNr = 0;
                int videoRgbNr   = 0;
                int videoHdmiNr  = 0;
                for (int i = 0; i < inputs; ++i)
                {
                    crossBarFilter.get_CrossbarPinInfo(true, i, out relatedPinIndex, out connectorType);
                    Log.Log.Write(" crossbar pin:{0} type:{1}", i, connectorType);
                    switch (connectorType)
                    {
                    case PhysicalConnectorType.Audio_Tuner:
                        _audioPinMap.Add(AnalogChannel.AudioInputType.Tuner, i);
                        break;

                    case PhysicalConnectorType.Video_Tuner:
                        _videoPinMap.Add(AnalogChannel.VideoInputType.Tuner, i);
                        _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.Tuner, relatedPinIndex);
                        break;

                    case PhysicalConnectorType.Audio_Line:
                        audioLine++;
                        switch (audioLine)
                        {
                        case 1:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.LineInput1, i);
                            break;

                        case 2:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.LineInput2, i);
                            break;

                        case 3:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.LineInput3, i);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Audio_SPDIFDigital:
                        audioSPDIF++;
                        switch (audioSPDIF)
                        {
                        case 1:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.SPDIFInput1, i);
                            break;

                        case 2:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.SPDIFInput2, i);
                            break;

                        case 3:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.SPDIFInput3, i);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Audio_AUX:
                        audioAux++;
                        switch (audioAux)
                        {
                        case 1:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.AUXInput1, i);
                            break;

                        case 2:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.AUXInput2, i);
                            break;

                        case 3:
                            _audioPinMap.Add(AnalogChannel.AudioInputType.AUXInput3, i);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Video_Composite:
                        videoCvbsNr++;
                        switch (videoCvbsNr)
                        {
                        case 1:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.VideoInput1, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.VideoInput1, relatedPinIndex);
                            break;

                        case 2:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.VideoInput2, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.VideoInput2, relatedPinIndex);
                            break;

                        case 3:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.VideoInput3, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.VideoInput3, relatedPinIndex);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Video_SVideo:
                        videoSvhsNr++;
                        switch (videoSvhsNr)
                        {
                        case 1:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.SvhsInput1, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.SvhsInput1, relatedPinIndex);
                            break;

                        case 2:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.SvhsInput2, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.SvhsInput2, relatedPinIndex);
                            break;

                        case 3:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.VideoInput3, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.VideoInput3, relatedPinIndex);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Video_RGB:
                        videoRgbNr++;
                        switch (videoRgbNr)
                        {
                        case 1:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.RgbInput1, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.RgbInput1, relatedPinIndex);
                            break;

                        case 2:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.RgbInput2, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.RgbInput2, relatedPinIndex);
                            break;

                        case 3:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.SvhsInput3, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.SvhsInput3, relatedPinIndex);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Video_YRYBY:
                        videoYrYbYNr++;
                        switch (videoYrYbYNr)
                        {
                        case 1:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.YRYBYInput1, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.YRYBYInput1, relatedPinIndex);
                            break;

                        case 2:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.YRYBYInput2, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.YRYBYInput2, relatedPinIndex);
                            break;

                        case 3:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.YRYBYInput3, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.YRYBYInput3, relatedPinIndex);
                            break;
                        }
                        break;

                    case PhysicalConnectorType.Video_SerialDigital:
                        videoHdmiNr++;
                        switch (videoHdmiNr)
                        {
                        case 1:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.HdmiInput1, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.HdmiInput1, relatedPinIndex);
                            break;

                        case 2:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.HdmiInput2, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.HdmiInput2, relatedPinIndex);
                            break;

                        case 3:
                            _videoPinMap.Add(AnalogChannel.VideoInputType.HdmiInput3, i);
                            _videoPinRelatedAudioMap.Add(AnalogChannel.VideoInputType.HdmiInput3, relatedPinIndex);
                            break;
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Sets type of input connected to video output of the crossbar.
        /// </summary>
        /// <param name="crossbar">The crossbar of device.</param>
        /// <param name="videoInput">Video input of device.</param>
        /// <seealso cref="CrossbarAvailable"/>
        public static void SetCrossbarInput(IAMCrossbar crossbar, VideoInput videoInput)
        {
            if (videoInput.Type != VideoInput.PhysicalConnectorType_Default &&
                videoInput.Index != -1)
            {
                int inPinsCount, outPinsCount;

                // gen number of pins in the crossbar
                if (crossbar.get_PinCounts(out outPinsCount, out inPinsCount) == 0)
                {
                    int videoOutputPinIndex = -1;
                    int videoInputPinIndex  = -1;
                    int pinIndexRelated;
                    PhysicalConnectorType type;

                    // find index of the video output pin
                    for (int i = 0; i < outPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(false, i, out pinIndexRelated, out type) != 0)
                        {
                            continue;
                        }

                        if (type == PhysicalConnectorType.Video_VideoDecoder)
                        {
                            videoOutputPinIndex = i;
                            break;
                        }
                    }

                    // find index of the required input pin
                    for (int i = 0; i < inPinsCount; i++)
                    {
                        if (crossbar.get_CrossbarPinInfo(true, i, out pinIndexRelated, out type) != 0)
                        {
                            continue;
                        }

                        if ((type == videoInput.Type) && (i == videoInput.Index))
                        {
                            videoInputPinIndex = i;
                            break;
                        }
                    }

                    // try connecting pins
                    if ((videoInputPinIndex != -1) && (videoOutputPinIndex != -1))
                    {
                        if (crossbar.CanRoute(videoOutputPinIndex, videoInputPinIndex) == 0)
                        {
                            int hr = crossbar.Route(videoOutputPinIndex, videoInputPinIndex);
                            DsError.ThrowExceptionForHR(hr);
                        }
                        else
                        {
                            throw new Exception("Can't route from selected VideoInput to VideoDecoder.");
                        }
                    }
                    else
                    {
                        throw new Exception("Can't find routing pins.");
                    }
                }
            }
        }
Ejemplo n.º 29
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       hr;
            int       numOutPins;
            int       numInPins;

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

            // 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?
                    hr = crossbar.CanRoute(cOut, cIn);
                    if (hr == 0)
                    {
                        // Yes, this can be routed
                        int relatedInputPin;
                        PhysicalConnectorType connectorType;
                        hr = crossbar.get_CrossbarPinInfo(true, cIn, out relatedInputPin, out connectorType);
                        if (hr < 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }

                        // Add it to the list
                        CrossbarSource source = new CrossbarSource(crossbar, cOut, cIn, relatedInputPin, connectorType);
                        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 s = (CrossbarSource)sources[c];
                    if ((refSource.OutputPin == s.OutputPin) && (refIndex != c))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    refIndex++;
                }
                else
                {
                    sources.RemoveAt(refIndex);
                }
            }

            // Some of the video input pins have related audio pins
            // that should be connected at the same time. We noted the pin number
            // in the CrossbarSource.RelatedInputPin. Now that we have all
            // the sources, lookup the CrossbarSource object associated with
            // that pin
            foreach (CrossbarSource source in sources)
            {
                if (source.RelatedInputPin != -1)
                {
                    foreach (CrossbarSource related in sources)
                    {
                        if (source.RelatedInputPin == related.InputPin)
                        {
                            source.RelatedInputSource = related;
                        }
                    }
                }
            }

            // Remove any sources that are not of the correct type
            for (int c = 0; c < sources.Count; c++)
            {
                if (((CrossbarSource)sources[c]).ConnectorType < PhysicalConnectorType.Audio_Tuner)
                {
                    if (!isVideoDevice)
                    {
                        sources.RemoveAt(c);
                        c--;
                    }
                }
                else
                {
                    if (isVideoDevice)
                    {
                        sources.RemoveAt(c);
                        c--;
                    }
                }
            }



            return(sources);
        }
Ejemplo n.º 30
0
        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(DsDevice dev, AMMediaType media)
        {
            int hr;

            ISampleGrabber        sampGrabber = null;
            IBaseFilter           capFilter   = null;
            ICaptureGraphBuilder2 capGraph    = null;

            // Get the graphbuilder object
            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            m_mediaCtrl   = m_FilterGraph as IMediaControl;
            try
            {
                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

                // Get the SampleGrabber interface
                sampGrabber = (ISampleGrabber) new SampleGrabber();

                // Start building the graph
                hr = capGraph.SetFiltergraph(m_FilterGraph);
                DsError.ThrowExceptionForHR(hr);

                // Add the video device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
                DsError.ThrowExceptionForHR(hr);

                // add video crossbar
                // thanks to Andrew Fernie - this is to get tv tuner cards working
                IAMCrossbar crossbar = null;
                object      o;

                hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMCrossbar).GUID, out o);
                if (hr >= 0)
                {
                    crossbar = (IAMCrossbar)o;
                    int oPin, iPin;
                    int ovLink, ivLink;
                    ovLink = ivLink = 0;

                    crossbar.get_PinCounts(out oPin, out iPin);
                    int pIdxRel;
                    PhysicalConnectorType tp;
                    for (int i = 0; i < iPin; i++)
                    {
                        crossbar.get_CrossbarPinInfo(true, i, out pIdxRel, out tp);
                        if (tp == PhysicalConnectorType.Video_Composite)
                        {
                            ivLink = i;
                        }
                    }

                    for (int i = 0; i < oPin; i++)
                    {
                        crossbar.get_CrossbarPinInfo(false, i, out pIdxRel, out tp);
                        if (tp == PhysicalConnectorType.Video_VideoDecoder)
                        {
                            ovLink = i;
                        }
                    }

                    try
                    {
                        crossbar.Route(ovLink, ivLink);
                        o = null;
                    }

                    catch
                    {
                        throw new Exception("Failed to get IAMCrossbar");
                    }
                }

                //add AVI Decompressor
                IBaseFilter pAVIDecompressor = (IBaseFilter) new AVIDec();
                hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor");
                DsError.ThrowExceptionForHR(hr);

                //
                IBaseFilter baseGrabFlt = (IBaseFilter)sampGrabber;
                ConfigureSampleGrabber(sampGrabber);

                // Add the frame grabber to the graph
                hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
                DsError.ThrowExceptionForHR(hr);

                SetConfigParms(capGraph, capFilter, media);

                hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, pAVIDecompressor, baseGrabFlt);
                if (hr < 0)
                {
                    hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt);
                }

                DsError.ThrowExceptionForHR(hr);

                SaveSizeInfo(sampGrabber);
            }
            finally
            {
                if (capFilter != null)
                {
                    Marshal.ReleaseComObject(capFilter);
                    capFilter = null;
                }
                if (sampGrabber != null)
                {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (capGraph != null)
                {
                    Marshal.ReleaseComObject(capGraph);
                    capGraph = null;
                }
            }
        }
Ejemplo n.º 31
0
        // Token: 0x0600036E RID: 878 RVA: 0x00014454 File Offset: 0x00012654
        protected ArrayList findCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
        {
            ArrayList arrayList = new ArrayList();
            int       num2;
            int       num3;
            int       num  = crossbar.get_PinCounts(out num2, out num3);
            int       num4 = 0;

            checked
            {
                int num5 = num2 - 1;
                for (int i = num4; i <= num5; i++)
                {
                    int num6 = 0;
                    int num7 = num3 - 1;
                    for (int j = num6; j <= num7; j++)
                    {
                        num = crossbar.CanRoute(i, j);
                        if (num == 0)
                        {
                            int num8;
                            PhysicalConnectorType physicalConnectorType;
                            num = crossbar.get_CrossbarPinInfo(true, j, out num8, out physicalConnectorType);
                            CrossbarSource value = new CrossbarSource(crossbar, i, j, physicalConnectorType);
                            if (physicalConnectorType < PhysicalConnectorType.Audio_Tuner)
                            {
                                if (isVideoDevice)
                                {
                                    arrayList.Add(value);
                                }
                                else if (!isVideoDevice)
                                {
                                    arrayList.Add(value);
                                }
                            }
                        }
                    }
                }
                int k = 0;
                while (k < arrayList.Count)
                {
                    bool           flag           = false;
                    CrossbarSource crossbarSource = (CrossbarSource)arrayList[k];
                    int            num9           = 0;
                    int            num10          = arrayList.Count - 1;
                    for (int l = num9; l <= num10; l++)
                    {
                        CrossbarSource crossbarSource2 = (CrossbarSource)arrayList[l];
                        if (crossbarSource.OutputPin == crossbarSource2.OutputPin && k != l)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        k++;
                    }
                    else
                    {
                        arrayList.RemoveAt(k);
                    }
                }
                return(arrayList);
            }
        }
Ejemplo n.º 32
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       hr;
            int       numOutPins;
            int       numInPins;

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

            // 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?
                    hr = crossbar.CanRoute(cOut, cIn);
                    if (hr == 0)
                    {
                        // Yes, this can be routed
                        int relatedPin;
                        PhysicalConnectorType connectorType;
                        hr = crossbar.get_CrossbarPinInfo(true, cIn, out relatedPin, out connectorType);
                        if (hr < 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }

                        // 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
                            if (!isVideoDevice)
                            {
                                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 s = (CrossbarSource)sources[c];
                    if ((refSource.OutputPin == s.OutputPin) && (refIndex != c))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    refIndex++;
                }
                else
                {
                    sources.RemoveAt(refIndex);
                }
            }

            return(sources);
        }
        private static int FindVideoDecoderOutputPin(IAMCrossbar crossbar)
        {
            int rv = -1;

            int outputPinsCount;
            int inputPinsCount;
            int hr = crossbar.get_PinCounts(out outputPinsCount, out inputPinsCount);
            DsError.ThrowExceptionForHR(hr);

            for (int i = 0; i < outputPinsCount; i++)
            {
                int relatedIndex;
                PhysicalConnectorType connectorType;
                hr = crossbar.get_CrossbarPinInfo(false, i, out relatedIndex, out connectorType);
                if (hr == 0)
                {
                    int inputPinIndex;
                    crossbar.get_IsRoutedTo(i, out inputPinIndex);

                    Trace.WriteLine(string.Format("Crossbar Output Pin {0}: '{1}' routed to pin {2}", i, GetPhysicalPinName(connectorType), inputPinIndex));
                    if (connectorType == PhysicalConnectorType.Video_VideoDecoder)
                        rv = i;
                }
            }

            return rv;
        }
        // Collect all video inputs of the specified crossbar
        private VideoInput[] ColletCrossbarVideoInputs( IAMCrossbar crossbar )
        {
            lock ( cacheCrossbarVideoInputs )
            {
                if ( cacheCrossbarVideoInputs.ContainsKey( deviceMoniker ) )
                {
                    return cacheCrossbarVideoInputs[deviceMoniker];
                }

                List<VideoInput> videoInputsList = new List<VideoInput>( );

                if ( crossbar != null )
                {
                    int inPinsCount, outPinsCount;

                    // gen number of pins in the crossbar
                    if ( crossbar.get_PinCounts( out outPinsCount, out inPinsCount ) == 0 )
                    {
                        // collect all video inputs
                        for ( int i = 0; i < inPinsCount; i++ )
                        {
                            int pinIndexRelated;
                            PhysicalConnectorType type;

                            if ( crossbar.get_CrossbarPinInfo( true, i, out pinIndexRelated, out type ) != 0 )
                                continue;

                            if ( type < PhysicalConnectorType.AudioTuner )
                            {
                                videoInputsList.Add( new VideoInput( i, type ) );
                            }
                        }
                    }
                }

                VideoInput[] videoInputs = new VideoInput[videoInputsList.Count];
                videoInputsList.CopyTo( videoInputs );

                cacheCrossbarVideoInputs.Add( deviceMoniker, videoInputs );

                return videoInputs;
            }
        }
Ejemplo n.º 35
0
        void AdjustCrossbarPin()
        {
            IAMCrossbar crossbar = null;
            object      o        = null;
            int         hr;

            hr = captureGraphBuilder.FindInterface(
                PinCategory.Capture, MediaType.Video, sourceFilter, typeof(IAMCrossbar).GUID, out o);

            if (hr >= 0)
            {
                crossbar = (IAMCrossbar)o;

                int numOutPin, numInPin;
                int nOutputAudioLink, nInputAudioLink, nOutputVideoLink, nInputVideoLink;
                nOutputAudioLink = nInputAudioLink = nOutputVideoLink = nInputVideoLink = -1;
                crossbar.get_PinCounts(out numOutPin, out numInPin);
                int pIdxRel;
                PhysicalConnectorType pct;
                for (int i = 0; i < numInPin; i++)
                {
                    crossbar.get_CrossbarPinInfo(true, i, out pIdxRel, out pct);

                    Log.log(pct.ToString());

                    //if (pct == PhysicalConnectorType.Audio_Tuner) nInputAudioLink = i;
                    if (pct == PhysicalConnectorType.Video_Composite)
                    {
                        nInputVideoLink = i;
                    }
                    if (nInputAudioLink != -1 && nInputVideoLink != -1)
                    {
                        break;
                    }
                }
                for (int i = 0; i < numOutPin; i++)
                {
                    crossbar.get_CrossbarPinInfo(false, i, out pIdxRel, out pct);
                    Log.log(pct.ToString());

                    //if (pct == PhysicalConnectorType.Audio_AudioDecoder) nOutputAudioLink = i;
                    if (pct == PhysicalConnectorType.Video_VideoDecoder)
                    {
                        nOutputVideoLink = i;
                    }
                    if (nOutputAudioLink != -1 && nOutputVideoLink != 1)
                    {
                        break;
                    }
                }

                try
                {
                    if (crossbar.Route(nOutputVideoLink, nInputVideoLink) >= 0)
                    {
                        o = null;
                    }
                    else
                    {
                        o = null;
                    }
                }
                catch
                {
                    o = null;
                }
            }
        }
        // Set type of input connected to video output of the crossbar
        private void SetCurrentCrossbarInput( IAMCrossbar crossbar, VideoInput videoInput )
        {
            if ( videoInput.Type != PhysicalConnectorType.Default )
            {
                int inPinsCount, outPinsCount;

                // gen number of pins in the crossbar
                if ( crossbar.get_PinCounts( out outPinsCount, out inPinsCount ) == 0 )
                {
                    int videoOutputPinIndex = -1;
                    int videoInputPinIndex = -1;
                    int pinIndexRelated;
                    PhysicalConnectorType type;

                    // find index of the video output pin
                    for ( int i = 0; i < outPinsCount; i++ )
                    {
                        if ( crossbar.get_CrossbarPinInfo( false, i, out pinIndexRelated, out type ) != 0 )
                            continue;

                        if ( type == PhysicalConnectorType.VideoDecoder )
                        {
                            videoOutputPinIndex = i;
                            break;
                        }
                    }

                    // find index of the required input pin
                    for ( int i = 0; i < inPinsCount; i++ )
                    {
                        if ( crossbar.get_CrossbarPinInfo( true, i, out pinIndexRelated, out type ) != 0 )
                            continue;

                        if ( ( type == videoInput.Type ) && ( i == videoInput.Index ) )
                        {
                            videoInputPinIndex = i;
                            break;
                        }
                    }

                    // try connecting pins
                    if ( ( videoInputPinIndex != -1 ) && ( videoOutputPinIndex != -1 ) &&
                         ( crossbar.CanRoute( videoOutputPinIndex, videoInputPinIndex ) == 0 ) )
                    {
                        crossbar.Route( videoOutputPinIndex, videoInputPinIndex );
                    }
                }
            }
        }
Ejemplo n.º 37
0
        //protected override void ConfigureVMR9InWindowlessMode(int numberOfStream)
        //{
        //    int hr = 0;
        //    IVMRFilterConfig9 filterConfig = this.videoRenderer as IVMRFilterConfig9;
        //    // Configure VMR-9 in Windowsless mode
        //    hr = filterConfig.SetRenderingMode(VMR9Mode.Windowless);
        //    DsError.ThrowExceptionForHR(hr);
        //    // With 1 input stream
        //    hr = filterConfig.SetNumberOfStreams(numberOfStream);
        //    DsError.ThrowExceptionForHR(hr);
        //    IVMRWindowlessControl9 windowlessControl = this.videoRenderer as IVMRWindowlessControl9;
        //    // The main form is hosting the VMR-9
        //    hr = windowlessControl.SetVideoClippingWindow(this.hostingControl.Handle);
        //    DsError.ThrowExceptionForHR(hr);
        //    // Keep the aspect-ratio OK
        //    //hr = windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
        //    hr = windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.None);
        //    DsError.ThrowExceptionForHR(hr);
        //    // Init the VMR-9 with default size values
        //    OnResizeMoveHandler(null, null);
        //    // Add Windows Messages handlers
        //    AddHandlers();
        //}
        public int FindCrossbarPin(IAMCrossbar pXBar, PhysicalConnectorType PhysicalType,
            PinDirection Dir, out int pIndex)
        {
            pIndex = -1;
            bool bInput = (Dir == PinDirection.Input ? true : false);

            // Find out how many pins the crossbar has.
            int cOut, cIn;
            int hr = pXBar.get_PinCounts(out cOut, out cIn);
            if (hr < 0) return hr;
            // Enumerate pins and look for a matching pin.
            int count = (bInput ? cIn : cOut);
            for (int i = 0; i < count; i++)
            {
                int iRelated = 0;
                PhysicalConnectorType ThisPhysicalType = 0;
                hr = pXBar.get_CrossbarPinInfo(bInput, i, out iRelated, out ThisPhysicalType);
                if (hr >= 0 && ThisPhysicalType == PhysicalType)
                {
                    // Found a match, return the index.
                    pIndex = i;
                    return 0;
                }
            }
            // Did not find a matching pin.
            return -1;
        }