Example #1
0
        /// <summary>
        /// Attaches this graph to a source graph
        /// </summary>
        /// <param name="source">source sub graph to get data from</param>
        public void SetSource(ISourceSubGraph source)
        {
            Debug.WriteLine("DefaultRenderer.SetSource: " + source.GetType().ToString());

            List <DetailPinInfo> pins = null;

            try
            {
                input = (IBaseFilter)source.Controller.InsertSourceFilter(source.Output, this.graph);

                pins = input.EnumPinsDetails();

                foreach (DetailPinInfo i in pins)
                {
                    int hr = this.captureGraph.RenderStream(null, null, i.Pin, null, null);
                    Debug.WriteLine("DefaultRenderer rendered stream; HRESULT = " + hr.ToString("x"));
                }
            }
            finally
            {
                if (pins != null)
                {
                    pins.Release();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Determines what streams are available on the Net Demux.
        /// Creates channels in the GMF Bridge controller accordingly.
        /// Then, creates the GMF Bridge Sink, and connects the streams to their respective pins.
        /// </summary>
        private void RenderNetDemux()
        {
            List <DetailPinInfo> pins = null;

            try
            {
                //fetch all pins on this filter
                pins = netDemux.EnumPinsDetails();

                //create list of pins we care about
                List <IPin> demuxPins = new List <IPin>();

                //get output pins of type video or audio
                foreach (DetailPinInfo i in pins)
                {
                    if (i.Info.dir == PinDirection.Output)
                    {
                        if (i.Type.majorType == MediaType.Video)
                        {
                            controller.AddStream(1, eFormatType.eAny, 1);
                            demuxPins.Add(i.Pin);
                        }
                        else if (i.Type.majorType == MediaType.Audio)
                        {
                            controller.AddStream(0, eFormatType.eAny, 1);
                            demuxPins.Add(i.Pin);
                        }
                    }
                }

                //create GMF Sink
                output = (IBaseFilter)controller.InsertSinkFilter(graph);
                //connect Demux to GMF Sink
                for (int i = 0; i < demuxPins.Count; i++)
                {
                    IPin sinkPin;
                    int  hr = output.FindPin("Input " + (i + 1).ToString(), out sinkPin);
                    if (hr == 0)
                    {
                        FilterGraphTools.ConnectFilters(graph, demuxPins[i], sinkPin, false);
                        Marshal.ReleaseComObject(sinkPin);
                    }
                }
            }
            catch (Exception ex)
            {
                Release(output);
                output = null;
                throw ex;
            }
            finally
            {
                if (pins != null)
                {
                    pins.Release();
                }
            }
        }
Example #3
0
        /// <summary>
        /// Attach this graph to a source
        /// </summary>
        /// <param name="source">the source sub graph</param>
        public void SetSource(ISourceSubGraph source)
        {
            Debug.WriteLine("LTNetworkSink.SetSource: " + source.GetType().ToString());

            List <DetailPinInfo> pins = null;

            try
            {
                netMux = (IBaseFilter) new LMNetMuxClass();
                graph.AddFilter(netMux, @"LEAD Network Multiplexer (2.0)");
                lmNetMux            = (LMNetMux)netMux;
                lmNetMux.LiveSource = this.LiveSource;
                Debug.WriteLine(String.Format("LiveSource={0}", lmNetMux.LiveSource));

                lmNetMux.MaxQueueDuration = this.MaxQueueDuration;
                netSnk = (IBaseFilter) new LMNetSnkClass();
                graph.AddFilter(netSnk, "LEAD Network Sink (2.0)");

                InitializeNetworkSink();

                input = (IBaseFilter)source.Controller.InsertSourceFilter(source.Output, this.graph);

                pins = input.EnumPinsDetails();

                int muxInputNumber = 1;
                foreach (DetailPinInfo i in pins)
                {
                    IPin muxPin = null;
                    try
                    {
                        muxPin = DsFindPin.ByName(netMux, "Input " + muxInputNumber.ToString("D2"));
                        FilterGraphTools.ConnectFilters(this.graph, i.Pin, muxPin, false);
                    }
                    finally
                    {
                        if (muxPin != null)
                        {
                            muxPin.Release();
                        }
                    }
                    muxInputNumber++;
                }

                FilterGraphTools.ConnectFilters(this.graph, netMux, "Output 01", netSnk, "Input", false);
            }
            finally
            {
                if (pins != null)
                {
                    pins.Release();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Finds a pin on the selected filter
        /// </summary>
        /// <param name="filter">filter to search</param>
        /// <param name="direction">direction the pin is in</param>
        /// <param name="major">major media type</param>
        /// <param name="sub">sub media type</param>
        /// <returns>matching IPin. Caller must release</returns>
        private IPin FindPinWithMediaType(IBaseFilter filter, PinDirection direction, Guid major, Guid sub)
        {
            List <DetailPinInfo> details = null;
            IPin preConnectedTo          = null;

            try
            {
                details = filter.EnumPinsDetails();
                foreach (DetailPinInfo pin in details)
                {
                    if ((pin.Info.dir == direction) && (pin.Type != null))
                    {
                        if ((pin.Type.majorType == major) && (pin.Type.subType == sub))
                        {
                            //check if the pin we found matching is already connected
                            if (pin.Pin.ConnectedTo(out preConnectedTo) == 0)
                            {
                                if (preConnectedTo != null)
                                {
                                    preConnectedTo.Release();
                                    preConnectedTo = null;
                                    continue;
                                }
                            }

                            //make sure that releasing the details doesn't release the IPin
                            IPin toReturn = pin.Pin;
                            pin.Pin = null;
                            return(toReturn);
                        }
                    }
                }

                throw new Exception("No pin found with major=" + major.ToString() + " and sub=" + sub.ToString() + ", or pin already connected!");
            }
            finally
            {
                details.Release();
            }
        }
Example #5
0
        /// <summary>
        /// Sets the source for this graph
        /// </summary>
        /// <param name="source">source sub graph</param>
        public void SetSource(ISourceSubGraph source)
        {
            Debug.WriteLine("OggWriter.SetSource: " + source.GetType().ToString());

            List <DetailPinInfo> pins = null;

            try
            {
                input = (IBaseFilter)source.Controller.InsertSourceFilter(source.Output, this.graph);

                pins = input.EnumPinsDetails();

                int oggStreamCounter = 0;

                foreach (DetailPinInfo i in pins)
                {
                    if (i.Info.dir == PinDirection.Output)
                    {
                        IPin destPin = DsFindPin.ByName(oggMux, "Stream " + oggStreamCounter.ToString());
                        if (destPin != null)
                        {
                            FilterGraphTools.ConnectFilters(this.graph, i.Pin, destPin, false);
                            Release(destPin);
                            oggStreamCounter++;
                        }
                    }
                }

                FilterGraphTools.ConnectFilters(this.graph, oggMux, "Ogg Stream", fileWriter, "in", false);
            }
            finally
            {
                if (pins != null)
                {
                    pins.Release();
                }
            }
        }