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.
            const string FileName = "delme.out";

            int         hr;
            IBaseFilter pFilter;
            object      o;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            StreamBufferSink      sbk  = new StreamBufferSink();

            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            DsROTEntry ds = new DsROTEntry(m_FilterGraph);

            hr = icgb.SetFiltergraph(m_FilterGraph);
            DsError.ThrowExceptionForHR(hr);

            hr = m_FilterGraph.AddFilter((IBaseFilter)sbk, "StreamBufferSink");
            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);

            DVVideoEnc  dve         = new DVVideoEnc();
            IBaseFilter ibfVideoEnc = (IBaseFilter)dve;

            hr = m_FilterGraph.AddFilter(ibfVideoEnc, "dvenc");
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, pFilter, ibfVideoEnc, (IBaseFilter)sbk);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(pFilter);
            Marshal.ReleaseComObject(icgb);

            IStreamBufferSink isbc = (IStreamBufferSink)sbk;

            hr = isbc.LockProfile("delme.prf");
            DsError.ThrowExceptionForHR(hr);

            File.Delete(FileName);

            hr = isbc.CreateRecorder("delme.out", RecordingType.Content, out o);
            DsError.ThrowExceptionForHR(hr);

            // Make sure we really got a recorder object
            IStreamBufferRecordingAttribute sbra = (IStreamBufferRecordingAttribute)o;

            hr = sbra.EnumAttributes(out m_sbra);
            DsError.ThrowExceptionForHR(hr);
        }
Ejemplo n.º 2
0
        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;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            StreamBufferSink      sbk  = new StreamBufferSink();

            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            DsROTEntry ds = new DsROTEntry(m_FilterGraph);

            hr = icgb.SetFiltergraph(m_FilterGraph);
            DsError.ThrowExceptionForHR(hr);

            hr = m_FilterGraph.AddFilter((IBaseFilter)sbk, "StreamBufferSink");
            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);

            DVVideoEnc  dve         = new DVVideoEnc();
            IBaseFilter ibfVideoEnc = (IBaseFilter)dve;

            hr = m_FilterGraph.AddFilter(ibfVideoEnc, "dvenc");
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, pFilter, ibfVideoEnc, (IBaseFilter)sbk);
            DsError.ThrowExceptionForHR(hr);

            m_isbc = (IStreamBufferSink)sbk;
            hr     = m_isbc.LockProfile(null);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(pFilter);
            Marshal.ReleaseComObject(icgb);
        }
Ejemplo n.º 3
0
        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;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            StreamBufferSink      sbk  = new StreamBufferSink();

            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            DsROTEntry ds = new DsROTEntry(m_FilterGraph);

            hr = icgb.SetFiltergraph(m_FilterGraph);
            DsError.ThrowExceptionForHR(hr);

            hr = m_FilterGraph.AddFilter((IBaseFilter)sbk, "StreamBufferSink");
            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);

            DVVideoEnc  dve         = new DVVideoEnc();
            IBaseFilter ibfVideoEnc = (IBaseFilter)dve;

            hr = m_FilterGraph.AddFilter(ibfVideoEnc, "dvenc");
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, pFilter, ibfVideoEnc, (IBaseFilter)sbk);
            DsError.ThrowExceptionForHR(hr);

            IStreamBufferSink isbc = (IStreamBufferSink)sbk;

            hr = isbc.LockProfile(null);
            DsError.ThrowExceptionForHR(hr);

            IPin i = DsFindPin.ByDirection((IBaseFilter)sbk, PinDirection.Input, 0);

            ((IMediaControl)m_FilterGraph).Run();
            // --------------------------
            IBaseFilter streamBuffer = null;

            m_FilterGraph2 = (IFilterGraph2) new FilterGraph();
            DsROTEntry ds2 = new DsROTEntry(m_FilterGraph2);

            streamBuffer = (IBaseFilter) new StreamBufferSource();

            hr = m_FilterGraph2.AddFilter(streamBuffer, "Stream buffer sink");
            DsError.ThrowExceptionForHR(hr);

            IStreamBufferSource sbsrc = (IStreamBufferSource)streamBuffer;

            hr = sbsrc.SetStreamSink(isbc);
            DsError.ThrowExceptionForHR(hr);

            IPin i2 = DsFindPin.ByDirection((IBaseFilter)streamBuffer, PinDirection.Output, 0);

            ((IMediaControl)m_FilterGraph2).Run();

            m_sbms = (IStreamBufferMediaSeeking2)sbsrc;
            // --------------------------

            Marshal.ReleaseComObject(pFilter);
            Marshal.ReleaseComObject(icgb);
        }