/// <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); }
/// <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."); } } } }