示例#1
0
        /// <summary>
        /// This method returns the time of the graphs
        /// <see cref="IReferenceClock"/>.
        /// </summary>
        /// <returns>The <see cref="Int64"/> value of the
        /// <see cref="IReferenceClock"/>.</returns>
        public long GetCurrentTime(out int dropped)
        {
            dropped = 0;
            long start = 0;
            long time  = -1;

            if (this.referenceClock != null)
            {
                int hr = this.referenceClock.GetTime(out time);
                DsError.ThrowExceptionForHR(hr);
            }

            IAMDroppedFrames droppedFrames = this.videoStreamConfig as IAMDroppedFrames;

            if (droppedFrames != null)
            {
                int hr = droppedFrames.GetNumDropped(out dropped);
                DsError.ThrowExceptionForHR(hr);
            }

            IGraphConfig graphConfig = this.graphBuilder as IGraphConfig;

            if (graphConfig != null)
            {
                graphConfig.GetStartTime(out start);
            }

            return(time - start);
        }
        void BuildGraph()
        {
            int         hr;
            IBaseFilter ppFilter;

            DsDevice []   devs;
            IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder;

            m_ROT = new DsROTEntry(graphBuilder);
            IFilterGraph2 ifg2 = graphBuilder as IFilterGraph2;

            devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            DsDevice dev = devs[0];

            hr = ifg2.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out ppFilter);
            DsError.ThrowExceptionForHR(hr);

            m_idf = ppFilter as IAMDroppedFrames;

            IPin IPinOut = DsFindPin.ByDirection(ppFilter, PinDirection.Output, 0);

            hr = ifg2.Render(IPinOut);
            DsError.ThrowExceptionForHR(hr);

            m_imc = graphBuilder as IMediaControl;
            hr    = m_imc.Run();
            DsError.ThrowExceptionForHR(hr);
        }
        public void Reset(bool full)
        {
            /*
             * NOTE:
             * Interfaces obtained with a cast (as) should not be released with Marshal.ReleaseComObject.
             */

            if (mediaControl != null)
            {
                mediaControl.StopWhenReady();
                mediaControl = null;
            }

            if (full && rot != null)
            {
                rot.Dispose();
                rot = null;
            }

            DsUtils.FreeAMMediaType(videoType);

            Util.DisposeObject(ref mpeg2Enc);

            if (previewRenderer != null)
            {
                IVideoWindow window = graph as IVideoWindow;
                window.put_Owner(IntPtr.Zero);
                window.put_Visible(OABool.False);
            }

            if (videoInput != null)
            {
                Util.NukeDownstream(graph, videoInput);
            }

            if (audioInput != null)
            {
                Util.NukeDownstream(graph, audioInput);
            }

            audioNullRenderer  = null;
            videoNullRenderer  = null;
            audioGrabber       = null;
            videoGrabber       = null;
            audioSampleGrabber = null;
            videoSampleGrabber = null;
            droppedFrames      = null;
            previewRenderer    = null;
            smartTee           = null;

            if (full)
            {
                Util.ReleaseComObject(ref videoInput);
                Util.ReleaseComObject(ref audioInput);
                Util.ReleaseComObject(ref graph);
                Util.ReleaseComObject(ref captureGraph);
            }

            if (dvdRecorder != null)
            {
                bool res = dvdRecorder.Stop();
                if (!res)
                {
                    Trace.WriteLine("VideoRecorder.Stop() failed");

                    Util.CheckRecorderDevices(dvdRecorder);
                }

                for (int i = 0; i < dvdRecorder.Devices.Count; i++)
                {
                    if (dvdRecorder.GetDeviceError(i).Facility == PrimoSoftware.DVDBuilder.ErrorFacility.Success)
                    {
                        dvdRecorder.Devices[i].NotifyOSFileSystemChanged();
                    }
                    dvdRecorder.Devices[i].Dispose();
                }
            }

            Util.DisposeObject(ref dvdRecorder);
        }
示例#4
0
        public void Reset(bool full)
        {
            /*
             * NOTE:
             * Interfaces obtained with a cast (as) should not be released with Marshal.ReleaseComObject.
             */

            if (mediaControl != null)
            {
                mediaControl.StopWhenReady();
                mediaControl = null;
            }

            if (full && rot != null)
            {
                rot.Dispose();
                rot = null;
            }

            DsUtils.FreeAMMediaType(videoType);
            DsUtils.FreeAMMediaType(audioType);

            if (transcoder != null)
            {
                transcoder.Flush();
                transcoder.Close();
                Util.DisposeObject(ref transcoder);
            }

            if (previewRenderer != null)
            {
                IVideoWindow window = graph as IVideoWindow;
                window.put_Owner(IntPtr.Zero);
                window.put_Visible(OABool.False);
            }

            if (videoInput != null)
            {
                Util.NukeDownstream(graph, videoInput);
            }

            if (audioInput != null)
            {
                Util.NukeDownstream(graph, audioInput);
            }

            audioNullRenderer  = null;
            videoNullRenderer  = null;
            audioGrabber       = null;
            videoGrabber       = null;
            audioSampleGrabber = null;
            videoSampleGrabber = null;
            droppedFrames      = null;
            previewRenderer    = null;
            smartTee           = null;

            if (full)
            {
                Util.ReleaseComObject(ref videoInput);
                Util.ReleaseComObject(ref audioInput);
                Util.ReleaseComObject(ref graph);
                Util.ReleaseComObject(ref captureGraph);
            }
        }