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

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

            for (int x = 0; x < ipin; x++)
            {
                for (int y = 0; y < opin; y++)
                {
                    hr = m_ixbar.CanRoute(y, x);
                    if (hr == 0)
                    {
                        // If we can route, try it
                        hr = m_ixbar.Route(y, x);
                        Debug.Assert(hr == 0);
                    }
                    else if (hr == 1)
                    {
                        // If we can't route, we should get S_FALSE
                        hr = m_ixbar.Route(y, x);
                        Debug.Assert(hr == 1);
                    }
                    else
                    {
                        DsError.ThrowExceptionForHR(hr);
                    }
                }
            }
        }
Ejemplo n.º 2
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.º 3
0
        private void SetCurrentCrossbarInput(IAMCrossbar crossbar, VideoInput videoInput)
        {
            if (videoInput.Type == PhysicalConnectorType.Default || crossbar.get_PinCounts(out int outputPinCount, out int inputPinCount) != 0)
            {
                return;
            }
            int num  = -1;
            int num2 = -1;
            int pinIndexRelated;
            PhysicalConnectorType physicalType;

            for (int i = 0; i < outputPinCount; i++)
            {
                if (crossbar.get_CrossbarPinInfo(isInputPin: false, i, out pinIndexRelated, out physicalType) == 0 && physicalType == PhysicalConnectorType.VideoDecoder)
                {
                    num = i;
                    break;
                }
            }
            for (int j = 0; j < inputPinCount; j++)
            {
                if (crossbar.get_CrossbarPinInfo(isInputPin: true, j, out pinIndexRelated, out physicalType) == 0 && physicalType == videoInput.Type && j == videoInput.Index)
                {
                    num2 = j;
                    break;
                }
            }
            if (num2 != -1 && num != -1 && crossbar.CanRoute(num, num2) == 0)
            {
                crossbar.Route(num, num2);
            }
        }
Ejemplo n.º 4
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.º 5
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));
            }
        }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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 );
        }
        // 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.º 17
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.");
                    }
                }
            }
        }