void Load(IMediaPropertyBag impb, string s1, string s2)
        {
            int    hr;
            object o = s2;

            hr = impb.Write("INFO/" + s1, ref o);
            DsError.ThrowExceptionForHR(hr);
        }
        private void TestSave()
        {
            int               hr;
            object            o1, o2;
            IMediaPropertyBag pb = (IMediaPropertyBag) new MediaPropertyBag();

            hr = m_pPersist2.Save(pb, false, false);
            DsError.ThrowExceptionForHR(hr);

            hr = pb.EnumProperty(0, out o1, out o2);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(TrimNull((string)o2) == Author, "Save");
        }
        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);
        }