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); }
private void TestEnum() { int hr; IEnumStreamBufferRecordingAttrib pEnum; hr = m_sbra.EnumAttributes(out pEnum); DsError.ThrowExceptionForHR(hr); Debug.Assert(pEnum != null); hr = pEnum.Reset(); DsError.ThrowExceptionForHR(hr); }