void IRecorder.Start(string filename)
        {
            IStreamBufferSink sink = this.streamBufferSink as IStreamBufferSink;

            object pRecUnk;
            //int hr = sink.CreateRecorder(filename, RecordingType.Reference, out pRecUnk);
            int hr = sink.CreateRecorder(filename, RecordingType.Content, out pRecUnk);

            if (hr >= 0)
            {
                long rtStart = 0;
                //IStreamBufferMediaSeeking mediaSeeking = this.streamBufferSource as IStreamBufferMediaSeeking;
                //if (mediaSeeking != null)
                //{
                //    // Reference time (100-nanosecond units). 100 * 10e-9 = 10e-7 = 10000000
                //    mediaSeeking.GetCurrentPosition(out rtStart);
                //}

                // Start the recording.
                this.currentRecorderControl = pRecUnk as IStreamBufferRecordControl;
                //long rtStart = -10000000; // Start 1 seconds ago.
                hr = this.currentRecorderControl.Start(ref rtStart);
                DsError.ThrowExceptionForHR(hr);

                IsPossibleRecorderStart = false;
                IsPossibleRecorderStop  = true;
            }
        }
        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);
        }
Esempio n. 3
0
        private void TestRecorder()
        {
            const string FileName = "delme.out";
            int          hr;
            object       o;
            short        c;

            File.Delete(FileName);

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

            // Make sure we really got a recorder object
            IStreamBufferRecordingAttribute i = o as IStreamBufferRecordingAttribute;

            hr = i.GetAttributeCount(0, out c);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(c != 0, "CreateRecorder");
        }