/// <summary> /// /// </summary> /// <param name="dsDevice"></param> /// <returns></returns> static public string[] GetCameraCapability(DsDevice dsDevice) { int hr; IFilterGraph2 filterGraph = new FilterGraph() as IFilterGraph2; IBaseFilter capFilter = null; IPin pPin = null; string[] listVideoInfo; try { // add the video input device hr = filterGraph.AddSourceFilterForMoniker(dsDevice.Mon, null, "Source Filter", out capFilter); DsError.ThrowExceptionForHR(hr); pPin = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0); //listResolution = GetResolutionsAvailable( pPin ).ToList(); listVideoInfo = GetResolutionsAvailable(pPin); } finally { Marshal.ReleaseComObject(pPin); pPin = null; } return(listVideoInfo); }
public void TestGetData() { int hr; IBaseFilter ibf = (IBaseFilter) new StreamBufferSink(); IPin iPin = DsFindPin.ByDirection(ibf, PinDirection.Input, 0); m_isbdc = (IStreamBufferDataCounters)iPin; try { SBEPinData pPinData; pPinData.cDataBytes = 33; pPinData.cTimestamps = 43; hr = m_isbdc.GetData(out pPinData); DsError.ThrowExceptionForHR(hr); Debug.Assert(pPinData.cDataBytes == 0, "GetData"); Debug.Assert(pPinData.cTimestamps == 0, "GetData2"); } finally { Marshal.ReleaseComObject(ibf); Marshal.ReleaseComObject(iPin); } }
/// <summary> /// Initializes a new instance of the <see cref="Hauppauge"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> public Hauppauge(IBaseFilter tunerFilter) { IPin pin = DsFindPin.ByDirection(tunerFilter, PinDirection.Input, 0); if (pin != null) { _propertySet = pin as IKsPropertySet; if (_propertySet != null) { KSPropertySupport supported; _propertySet.QuerySupported(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, out supported); if ((supported & KSPropertySupport.Set) != 0) { Log.Log.Debug("Hauppauge: DVB-S card found!"); _isHauppauge = true; _ptrDiseqc = Marshal.AllocCoTaskMem(1024); _tempValue = Marshal.AllocCoTaskMem(1024); _tempInstance = Marshal.AllocCoTaskMem(1024); } else { Log.Log.Debug("Hauppauge: DVB-S card NOT found!"); _isHauppauge = false; Dispose(); } } } else { Log.Log.Info("Hauppauge: tuner pin not found!"); } }
/// <summary> /// Initializes a new instance of the <see cref="GenericBDAS"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> public GenericBDAS(IBaseFilter tunerFilter) { _TunerDevice = (IBDA_Topology)tunerFilter; //check if the BDA driver supports DiSEqC IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport"); if (pin != null) { _propertySet = pin as IKsPropertySet; if (_propertySet != null) { KSPropertySupport supported; _propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Set) != 0) { Log.Log.Debug(FormatMessage("DiSEqC capable card found!")); _isGenericBDAS = true; } } } else { Log.Log.Info(FormatMessage("tuner pin not found!")); } }
internal TBSDVBS2Handler(IBaseFilter tunerFilter, Tuner tuner) { if (!tuner.Name.ToUpperInvariant().Contains("TBS")) { return; } IPin pin = DsFindPin.ByDirection(tunerFilter, PinDirection.Input, 0); if (pin != null) { propertySet = pin as IKsPropertySet; if (propertySet != null) { KSPropertySupport supported; reply = propertySet.QuerySupported(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, out supported); if (reply == 0) { dvbs2Capable = (supported & KSPropertySupport.Get) == KSPropertySupport.Get || (supported & KSPropertySupport.Set) == KSPropertySupport.Set; if (dvbs2Capable) { useSet = (supported & KSPropertySupport.Set) == KSPropertySupport.Set; useGet = !useSet; } } } } }
private static IEnumMediaTypes GetEnumMediaTypes() { IBaseFilter filter; int hr; IPin pRet = null; DsDevice [] capDevices; // Get the collection of video devices capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); if (capDevices.Length == 0) { throw new Exception("No video capture devices found!"); } DsDevice dev = capDevices[0]; string s; dev.Mon.GetDisplayName(null, null, out s); filter = Marshal.BindToMoniker(s) as IBaseFilter; pRet = DsFindPin.ByDirection(filter, PinDirection.Output, 0); IEnumMediaTypes enumMediaTypes; hr = pRet.EnumMediaTypes(out enumMediaTypes); DsError.ThrowExceptionForHR(hr); return(enumMediaTypes); }
/// <summary> /// Connecte le LAV Splitter Source et le renderer vidéo en créant le LAV Video Decoder. /// </summary> /// <param name="graph">Le graphe.</param> /// <param name="parserOutputVideoPin">Le pin de sortie vidéo</param> /// <param name="videoRendererInputPin">Le pin d'entrée du Renderer.</param> internal static void ConnectLAVSplitterAndRendererWithLAVDecoder(IGraphBuilder graph, IPin parserOutputVideoPin, IPin videoRendererInputPin) { Type filterType = null; IBaseFilter externalFilter = null; var lavVideoDecoder = LAVFilters[LAVFilterObject.VideoDecoder]; CreateFilter(DxMediaPlayer.LAVVideo, lavVideoDecoder.CLSID, lavVideoDecoder.Name, ref filterType, ref externalFilter); int hr = graph.AddFilter(externalFilter, lavVideoDecoder.Name); DsError.ThrowExceptionForHR(hr); IPin externalDecoderInputPin = DsFindPin.ByDirection(externalFilter, PinDirection.Input, 0); hr = graph.ConnectDirect(parserOutputVideoPin, externalDecoderInputPin, null); DsError.ThrowExceptionForHR(hr); IPin externalDecoderOutputPin = DsFindPin.ByDirection(externalFilter, PinDirection.Output, 0); hr = graph.ConnectDirect(externalDecoderOutputPin, videoRendererInputPin, null); DsError.ThrowExceptionForHR(hr); SafeRelease(externalDecoderInputPin); SafeRelease(externalDecoderOutputPin); }
/// <summary> /// Connects pins of graph /// </summary> private void GraphBuilding_ConnectPins() { // Pins used in graph IPin pinSourceCapture = null; IPin pinSampleGrabberInput = null; int hr = 0; try { // Collect pins pinSourceCapture = DsFindPin.ByDirection(DX.CaptureFilter, PinDirection.Output, 0); pinSampleGrabberInput = DsFindPin.ByDirection(DX.SampleGrabberFilter, PinDirection.Input, 0); hr = DX.FilterGraph.Connect(pinSourceCapture, pinSampleGrabberInput); DsError.ThrowExceptionForHR(hr); } catch { throw; } finally { SafeReleaseComObject(pinSourceCapture); pinSourceCapture = null; SafeReleaseComObject(pinSampleGrabberInput); pinSampleGrabberInput = null; } }
/// <summary> /// Gets available resolutions (which are appropriate for us) for capture filter. /// </summary> /// <param name="captureFilter">Capture filter for asking for resolution list.</param> private static ResolutionList GetResolutionsAvailable(IBaseFilter captureFilter) { ResolutionList resolution_list = null; IPin pRaw = null; try { pRaw = DsFindPin.ByDirection(captureFilter, PinDirection.Output, 0); //pRaw = DsFindPin.ByCategory(captureFilter, PinCategory.Capture, 0); //pRaw = DsFindPin.ByCategory(filter, PinCategory.Preview, 0); resolution_list = GetResolutionsAvailable(pRaw); } catch { throw; //resolution_list = new ResolutionList(); //resolution_list.Add(new Resolution(640, 480)); } finally { SafeReleaseComObject(pRaw); pRaw = null; } return(resolution_list); }
/// <summary> /// adds the TsFileSink filter to the graph /// </summary> /// <returns></returns> private bool AddTsFileSink() { if (!CheckThreadId()) { return(false); } Log.Log.WriteFile("analog:AddTsFileSink"); _tsFileSink = (IBaseFilter) new MpFileWriter(); int hr = _graphBuilder.AddFilter(_tsFileSink, "TsFileSink"); if (hr != 0) { Log.Log.WriteFile("analog:AddTsFileSink returns:0x{0:X}", hr); throw new TvException("Unable to add TsFileSink"); } Log.Log.WriteFile("analog:connect muxer->tsfilesink"); IPin pin = DsFindPin.ByDirection(_encoder.MultiplexerFilter, PinDirection.Output, 0); if (!FilterGraphTools.ConnectPin(_graphBuilder, pin, _tsFileSink, 0)) { Log.Log.WriteFile("analog:unable to connect muxer->tsfilesink"); throw new TvException("Unable to connect pins"); } Release.ComObject("mpegmux pinin", pin); if (_capture.SupportsTeletext) { Log.Log.WriteFile("analog:connect wst/vbi codec->tsfilesink"); if (!FilterGraphTools.ConnectPin(_graphBuilder, _teletext.WST_VBI_Pin, _tsFileSink, 1)) { Log.Log.WriteFile("analog:unable to connect wst/vbi->tsfilesink"); throw new TvException("Unable to connect pins"); } } return(true); }
private void BuildGraph() { int hr = 0; graphBuilder = (IFilterGraph2) new FilterGraph(); vmr = (IBaseFilter) new VideoMixingRenderer(); hr = graphBuilder.AddFilter(vmr, "VMR"); DsError.ThrowExceptionForHR(hr); hr = (vmr as IVMRFilterConfig).SetNumberOfStreams(1); DsError.ThrowExceptionForHR(hr); IPin pinIn = DsFindPin.ByDirection(vmr, PinDirection.Input, 0); streamControl = (IVMRVideoStreamControl)pinIn; hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null); DsError.ThrowExceptionForHR(hr); rot = new DsROTEntry(graphBuilder); // Run the graph to really connect VMR pins. // This sample doesn't work if the graph has not been run at least one time hr = (graphBuilder as IMediaControl).Run(); DsError.ThrowExceptionForHR(hr); }
private int getDeviceID(IBaseFilter tunerFilter) { IKsPin pKsPin = DsFindPin.ByDirection(tunerFilter, PinDirection.Output, 0) as IKsPin; if (pKsPin != null) { IntPtr raw; reply = pKsPin.KsQueryMediums(out raw); DsError.ThrowExceptionForHR(reply); try { RegPinMedium rpm; IntPtr addr = new IntPtr(raw.ToInt32() + 8); rpm = (RegPinMedium)Marshal.PtrToStructure(addr, typeof(RegPinMedium)); return((int)rpm.dw1); } finally { if (IntPtr.Zero != raw) { Marshal.FreeCoTaskMem(raw); } } } return(-1); }
private void Configure() { // In order to lock a profile, you have to have at least one stream // connected to the sink. I connect a video thru the DVVideoEnc into // the StreamBufferSink. int hr; IBaseFilter pFilter; IBaseFilter pRender = (IBaseFilter) new VideoRendererDefault(); ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); m_FilterGraph = (IFilterGraph2) new FilterGraph(); DsROTEntry ds = new DsROTEntry(m_FilterGraph); hr = icgb.SetFiltergraph(m_FilterGraph); DsError.ThrowExceptionForHR(hr); DsDevice [] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); hr = m_FilterGraph.AddSourceFilterForMoniker(devs[0].Mon, null, devs[0].Name, out pFilter); DsError.ThrowExceptionForHR(hr); hr = m_FilterGraph.AddFilter(pRender, "renderererer"); DsError.ThrowExceptionForHR(hr); hr = icgb.RenderStream(null, null, pFilter, null, pRender); DsError.ThrowExceptionForHR(hr); m_pin = DsFindPin.ByDirection(pRender, PinDirection.Input, 0); m_igs = (IAMGraphStreams)m_FilterGraph; Marshal.ReleaseComObject(pFilter); Marshal.ReleaseComObject(icgb); Marshal.ReleaseComObject(pRender); }
public void SetupVideoStream(IFilterGraph2 builder, IBaseFilter capfiler, IBaseFilter renderer, Control target) { //串接後面的Filters 的 Pins //目前不做畫面擷取所以也不需要用SmartTee來分流 IPin pin_out = null; IPin pin_in = null; //==== Streaming Circuit ==== try { //Win7開始預設最好是使用 VideoMixingRenderer7,當然能用VideoMixingRenderer9更好 //原始的VideoRenderer吃不到顯卡的特殊能力 //renderer = (IBaseFilter)new VideoMixingRenderer9(); SetupRenderWindow((IVMRFilterConfig9)renderer, target); builder.AddFilter(renderer, "Video Mixing Renderer 9"); pin_in = DsFindPin.ByDirection(renderer, PinDirection.Input, 0); //裝好Filter以後,在Capture Device找出對應的pin腳然後接上去... //就像焊接電路一樣的觀念 pin_out = DsFindPin.ByCategory(capfiler, PinCategory.Capture, 0); builder.Connect(pin_out, pin_in); } finally { //todo: 這邊應該弄Dispose不應該直接叫 Marshal if (null != pin_out) { Marshal.ReleaseComObject(pin_out); } if (null != pin_in) { Marshal.ReleaseComObject(pin_in); } } }
/// <summary> /// Gets the ICodecAPI interface for whichever pin is in use for the current codec /// </summary> /// <returns>a reference to the ICodecAPI on the current pin</returns> private ICodecAPI GetCodecAPI() { string pinName; if (_currentVideoSettings.CodecType == VideoCodecType.H264) { pinName = "H264"; } else { throw new NotImplementedException("GetCodecAPI not implemented for codectype " + _currentVideoSettings.CodecType.ToString()); } IPin pin = DsFindPin.ByName(_captureFilter, pinName); if (pin == null) { throw new Exception(pinName + " pin not found on MangoCapture filter."); } ICodecAPI codecAPI = (ICodecAPI)pin; if (codecAPI == null) { throw new Exception("ICodecAPI interface not found on pin " + pinName); } return(codecAPI); }
/// <summary> /// Initializes a new instance of the <see cref="ViXSATSC"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> public ViXSATSC(IBaseFilter tunerFilter) { IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport"); if (pin != null) { _propertySet = tunerFilter as IKsPropertySet; if (_propertySet != null) { KSPropertySupport supported; _propertySet.QuerySupported(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Set) != 0) { Log.Log.Debug("ViXS ATSC: DVB-S card found!"); _tempValue = Marshal.AllocCoTaskMem(1024); _isViXSATSC = true; } else { Log.Log.Debug("ViXS ATSC: card NOT found!"); _isViXSATSC = false; } } } else { Log.Log.Info("ViXS ATSC: could not find MPEG2 Transport pin!"); } }
protected virtual void SetupAudio() { int hr; IEnumFilters enumFilters; hr = _graph.EnumFilters(out enumFilters); DsError.ThrowExceptionForHR(hr); IBaseFilter[] filters = new IBaseFilter[1]; IntPtr fetched = new IntPtr(); while (enumFilters.Next(1, filters, fetched) == 0) { IBaseFilter filter = filters[0] as IBaseFilter; IPin unconnectedPin = DsFindPin.ByConnectionStatus((IBaseFilter)filter, PinConnectedStatus.Unconnected, 0); if (unconnectedPin != null) { PinDirection direction; hr = unconnectedPin.QueryDirection(out direction); DsError.ThrowExceptionForHR(hr); if (direction == PinDirection.Output) { hr = _graph.Render(unconnectedPin); DsError.ThrowExceptionForHR(hr); SetupSampleGrabber(); } } } }
public IBaseFilter GetVideo() { IBaseFilter baseDevice; var filterGraph = new FilterGraph() as IFilterGraph2; filterGraph.AddSourceFilterForMoniker(selectedDevice.Mon, null, selectedDevice.Name, out baseDevice); IPin pin = DsFindPin.ByCategory(baseDevice, PinCategory.Capture, 0); var streamConfig = pin as IAMStreamConfig; AMMediaType media; int iC = 0, iS = 0; streamConfig.GetNumberOfCapabilities(out iC, out iS); IntPtr ptr = Marshal.AllocCoTaskMem(iS); for (int i = 0; i < iC; i++) { streamConfig.GetStreamCaps(i, out media, ptr); VideoInfoHeader v; v = new VideoInfoHeader(); Marshal.PtrToStructure(media.formatPtr, v); } Guid iid = typeof(IBaseFilter).GUID; object source; selectedDevice.Mon.BindToObject(null, null, ref iid, out source); return((IBaseFilter)source); }
/// <summary> /// Connects the last filter in the audio chain to the audio volume filter (if AddAudioVolumeFilter has been called), and then /// to the audio renderer /// </summary> /// <remarks> /// First call AddAudioRenderer() /// </remarks> /// <param name="audioOutPin">the audio output pin</param> /// <param name="useIntelligentConnect">true to use intelligent connect, false to not</param> protected void ConnectToAudio(IPin audioOutPin, bool useIntelligentConnect) { IPin connectToRenderPin; if (_audioVolumeFilter != null) { IPin avfIn = DsFindPin.ByName(_audioVolumeFilter, _audioVolumeFilterIn); ConnectFilters(audioOutPin, avfIn, useIntelligentConnect); connectToRenderPin = DsFindPin.ByName(_audioVolumeFilter, _audioVolumeFilterOut); } else { connectToRenderPin = audioOutPin; } IPin renderInputPin = null; try { renderInputPin = DsFindPin.ByDirection(_audioRender, PinDirection.Input, 0); if (renderInputPin != null) { FilterGraphTools.ConnectFilters(_graphBuilder, connectToRenderPin, renderInputPin, useIntelligentConnect); } } finally { ReleaseComObject(renderInputPin); } }
private void Config() { int hr; IBaseFilter pFilter; ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); m_fg = (IFilterGraph2) new FilterGraph(); DsROTEntry rot = new DsROTEntry(m_fg); hr = icgb.SetFiltergraph(m_fg); DsError.ThrowExceptionForHR(hr); m_mo = (IMixerOCX) new OverlayMixer(); TestAdvise(); hr = m_fg.AddFilter((IBaseFilter)m_mo, null); DsError.ThrowExceptionForHR(hr); hr = m_fg.AddSourceFilter(@"foo.avi", null, out pFilter); DsError.ThrowExceptionForHR(hr); IPin iPin = DsFindPin.ByDirection(pFilter, PinDirection.Output, 0); hr = icgb.RenderStream(null, null, iPin, null, (IBaseFilter)m_mo); DsError.ThrowExceptionForHR(hr); hr = ((IMediaControl)m_fg).Run(); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// Initializes a new instance of the <see cref="Twinhan"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> public Twinhan(IBaseFilter tunerFilter) { _ptrPmt = Marshal.AllocCoTaskMem(8192); _ptrDwBytesReturned = Marshal.AllocCoTaskMem(4); // int32 _thbdaBuf = Marshal.AllocCoTaskMem(8192); _ptrOutBuffer = Marshal.AllocCoTaskMem(8192); _ptrOutBuffer2 = Marshal.AllocCoTaskMem(8192); _ptrDiseqc = Marshal.AllocCoTaskMem(8192); _ptrMMIBuffer = Marshal.AllocCoTaskMem(8192); _captureFilter = tunerFilter; _initialized = false; _camPresent = false; _isTwinHanCard = false; if (_captureFilter != null) { IPin pin = DsFindPin.ByDirection(_captureFilter, PinDirection.Input, 0); propertySet = pin as IKsPropertySet; _isTwinHanCard = IsTwinhan; if (_isTwinHanCard) { _camPresent = IsCamPresent(); Log.Log.WriteFile("Twinhan: CAM detected:{0}", _camPresent); } } _initialized = true; }
/// <summary> /// Initializes a new instance of the <see cref="GenericATSC"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> public GenericATSC(IBaseFilter tunerFilter) { IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport"); if (pin != null) { _propertySet = pin as IKsPropertySet; if (_propertySet != null) { KSPropertySupport supported; _propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Set) != 0) { Log.Log.Debug("GenericATSC: QAM capable card found!"); _isGenericATSC = true; _tempValue = Marshal.AllocCoTaskMem(1024); _tempInstance = Marshal.AllocCoTaskMem(1024); } else { Log.Log.Debug("GenericATSC: QAM card NOT found!"); _isGenericATSC = false; } } } else { Log.Log.Info("GenericATSC: tuner pin not found!"); } }
private void SetPinVideoImageSize(string pinName) { int hr; IPin pin = DsFindPin.ByDirection(_videoEncoder, PinDirection.Output, 0); if (pin != null) { AppLogger.Message("VideoCaptureDevice: found output pin"); } // get video stream interfaces AppLogger.Message("VideoCaptureDevice:get Video stream control interface (IAMStreamConfig)"); IAMStreamConfig streamConfig = (IAMStreamConfig)pin; AMMediaType media; hr = streamConfig.GetFormat(out media); DsError.ThrowExceptionForHR(hr); VideoInfoHeader v = new VideoInfoHeader(); v.BmiHeader = new BitmapInfoHeader(); v.BmiHeader.Width = 320; v.BmiHeader.Height = 240; media.formatPtr = Marshal.AllocCoTaskMem(1024); Marshal.StructureToPtr(v, media.formatPtr, true); hr = streamConfig.SetFormat(media); DsError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(media); }
void BuildGraph() { int hr; IBaseFilter ppFilter; DsDevice [] devs; IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder; m_ROT = new DsROTEntry(graphBuilder); IFilterGraph2 ifg2 = graphBuilder as IFilterGraph2; devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); DsDevice dev = devs[0]; hr = ifg2.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out ppFilter); DsError.ThrowExceptionForHR(hr); m_idf = ppFilter as IAMDroppedFrames; IPin IPinOut = DsFindPin.ByDirection(ppFilter, PinDirection.Output, 0); hr = ifg2.Render(IPinOut); DsError.ThrowExceptionForHR(hr); m_imc = graphBuilder as IMediaControl; hr = m_imc.Run(); DsError.ThrowExceptionForHR(hr); }
private void Config() { parser = (IDvbSiParser) new DvbSiParser(); graph = new BdaGraph(); graph.InitializeGraph(); /* * // The second pin go to the Mpeg-2 Tables and Sections filter * IPin demuxPin = DsFindPin.ByDirection(graph.mpeg2Demux, PinDirection.Output, 1); * pidMapper = (IMPEG2PIDMap)demuxPin; */ int hr = 0; int regCookie; object mpeg2DataControl; IPin mpegPin = DsFindPin.ByDirection(graph.bdaSecTab, PinDirection.Input, 0); hr = (graph.networkProvider as IBDA_TIF_REGISTRATION).RegisterTIFEx(mpegPin, out regCookie, out mpeg2DataControl); DsError.ThrowExceptionForHR(hr); pidMapper = (IMPEG2PIDMap)mpeg2DataControl; graph.MakeTuneRequest(); graph.RunGraph(); }
/// <summary> /// Adds video source filter to the filter graph. /// </summary> private void AddFilter_Source() { CaptureFilter = null; int hr = FilterGraph.AddSourceFilterForMoniker(_CameraMoniker, null, "Source Filter", out CaptureFilter); DsError.ThrowExceptionForHR(hr); // Pins used in graph IPin pinSourceCapture = null; try { pinSourceCapture = DsFindPin.ByDirection(CaptureFilter, PinDirection.Output, 0); SetSourceParams(pinSourceCapture, _FrameSize); } catch { throw; } finally { SafeReleaseComObject(pinSourceCapture); } return; }
protected override void ConnectFilters() { int hr; m_form.Invoke((MethodInvoker) delegate() { try { AddElecardAVCDecoder(); IPin pinUdpOut = DsFindPin.ByName(m_UdpFilter, "Out"); IPin pinDecoderXInput = DsFindPin.ByName(m_ElecardAVCDecoderFilter, "XForm In"); IPin pinDecoderXOutput = DsFindPin.ByName(m_ElecardAVCDecoderFilter, "XForm Out"); hr = m_graphBuilder.Connect(pinUdpOut, pinDecoderXInput); DsError.ThrowExceptionForHR(hr); hr = m_graphBuilder.Render((DirectShowLib.IPin)pinDecoderXOutput); SetVideoWindow(); pCallback(10, "start"); return; } catch (Exception err) { } }); }
public SRM314(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest) { InitializeNetworkSink(); _currentVideoSettings = new VideoSettings(); _crossbar = AddFilterByName(FilterCategory.AMKSCrossbar, "Sensoray 314 Crossbar"); _captureFilter = AddFilterByName(FilterCategory.AMKSCapture, "Sensoray 314 A/V Capture"); //instantiate BDA VES and get reference to capture pin _ves = AddFilterByName(FilterCategory.WDMStreamingEncoderDevices, "Sensoray 314 BDA MPEG VES Encoder"); _vesCapturePin = DsFindPin.ByName(_ves, "Capture"); //instantiate frame rate filter and get control interface _frameRateFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "FC Frame Rate Filter"); _frameRate = (IFCFrameRateAPI)_frameRateFilter; SetInputAndSystem(); _frameRate.set_InputFramerate(15.0); ChangeProfile(CurrentProfile); ConnectFilters(_crossbar, "0: Video Decoder Out", _captureFilter, "Analog Video In", false); ConnectFilters(_captureFilter, "Analog ITU Video", _ves, "Analog ITU Video", false); // ConnectFilterToNetMux(_ves, "Capture", "Input 01"); ConnectFilters(_ves, "Capture", _frameRateFilter, "Input", false); ConnectFilterToNetMux(_frameRateFilter, "Output", "Input 01"); ConnectNetMuxToNetSnk(); }
public static bool RenderPin(IGraphBuilder graphBuilder, IBaseFilter source, string pinName) { int hr = 0; if (graphBuilder == null) { throw new ArgumentNullException("graphBuilder"); } if (source == null) { throw new ArgumentNullException("source"); } IPin pin = DsFindPin.ByName(source, pinName); if (pin != null) { hr = graphBuilder.Render(pin); Marshal.ReleaseComObject(pin); return(hr >= 0); } return(false); }
protected override void SetStructure(Guid guidPropSet, uint propId, Type structureType, object structValue) { Guid propertyGuid = guidPropSet; IPin pin = DsFindPin.ByDirection(captureFilter, PinDirection.Input, 0); if (pin == null) { return; } IKsPropertySet propertySet = pin as IKsPropertySet; if (propertySet == null) { throw new ApplicationException("Twinhan: SetStructure() properySet=null"); return; } int iSize = Marshal.SizeOf(structureType); //throw new ApplicationException("Twinhan: size:{0}", iSize); IntPtr pDataReturned = Marshal.AllocCoTaskMem(iSize); Marshal.StructureToPtr(structValue, pDataReturned, true); int hr = propertySet.RemoteSet(ref propertyGuid, propId, IntPtr.Zero, 0, pDataReturned, (uint)Marshal.SizeOf(structureType)); if (hr != 0) { // throw new ApplicationException("Twinhan: SetStructure() failed 0x{0:X}", hr); } else { //throw new ApplicationException("Twinhan: SetStructure() returned ok 0x{0:X}", hr); } Marshal.FreeCoTaskMem(pDataReturned); }