private void TestLoad() { int hr; hr = m_pPersist.Load(m_impb, null); DsError.ThrowExceptionForHR(hr); hr = m_pPersist.Load(m_impb, this); DsError.ThrowExceptionForHR(hr); }
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 mux; IFileSinkFilter ifsf; EventCode ec; ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); IFilterGraph2 filterGraph = (IFilterGraph2) new FilterGraph(); DsROTEntry ds = new DsROTEntry(filterGraph); hr = icgb.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); hr = filterGraph.AddSourceFilter("foo.avi", "foo", out pFilter); DsError.ThrowExceptionForHR(hr); hr = icgb.SetOutputFileName(MediaSubType.Avi, FileName, out mux, out ifsf); DsError.ThrowExceptionForHR(hr); hr = icgb.RenderStream(null, null, pFilter, null, mux); DsError.ThrowExceptionForHR(hr); IMediaPropertyBag impb = (IMediaPropertyBag) new MediaPropertyBag(); Load(impb, "IART", Author); Load(impb, "ICOP", Copyright); Load(impb, "INAM", Title); IPersistMediaPropertyBag pPersist = (IPersistMediaPropertyBag)mux; hr = pPersist.Load(impb, null); DsError.ThrowExceptionForHR(hr); ((IMediaControl)filterGraph).Run(); ((IMediaEvent)filterGraph).WaitForCompletion(-1, out ec); ((IMediaControl)filterGraph).Stop(); Marshal.ReleaseComObject(pFilter); Marshal.ReleaseComObject(mux); Marshal.ReleaseComObject(filterGraph); Marshal.ReleaseComObject(ifsf); Marshal.ReleaseComObject(impb); Marshal.ReleaseComObject(icgb); }
private void Configure() { int hr; IBaseFilter pFilter; IBaseFilter mux; IFileSinkFilter ifsf; ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); IFilterGraph2 filterGraph = (IFilterGraph2) new FilterGraph(); DsROTEntry ds = new DsROTEntry(filterGraph); hr = icgb.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); hr = filterGraph.AddSourceFilter("foo.avi", "foo", out pFilter); DsError.ThrowExceptionForHR(hr); hr = icgb.SetOutputFileName(MediaSubType.Avi, FileName, out mux, out ifsf); DsError.ThrowExceptionForHR(hr); hr = icgb.RenderStream(null, null, pFilter, null, mux); DsError.ThrowExceptionForHR(hr); m_impb = (IMediaPropertyBag) new MediaPropertyBag(); Load(m_impb, "IART", Author); Load(m_impb, "ICOP", Copyright); Load(m_impb, "INAM", Title); IPersistMediaPropertyBag pPersist = (IPersistMediaPropertyBag)mux; hr = pPersist.Load(m_impb, null); DsError.ThrowExceptionForHR(hr); Marshal.ReleaseComObject(pFilter); Marshal.ReleaseComObject(mux); Marshal.ReleaseComObject(filterGraph); Marshal.ReleaseComObject(ifsf); Marshal.ReleaseComObject(icgb); }