public ConfigDialog(VCROptions _options) { this.options = _options; InitializeComponent(); fps.ValueChanged += new EventHandler(updateHelp); period.ValueChanged += new EventHandler(updateHelp); CompressorMoniker[] cm = DirectShowUtil.EnumCompressors(); compressors.DataSource = cm; if (options.compressor != null) { string curName = options.compressor.name; for (int i = 0; i < cm.Length; i++) { if (cm[i].name == curName) { compressors.SelectedIndex = i; } } } fps.Value = options.fps; period.Value = options.period; }
/// <summary> /// Create a new recorder with the given setting. /// </summary> public Recorder(Rectangle rect, VCROptions config) { drawer = new QuarterViewDrawer(World.world, MainWindow.mainWindow.directDraw, rect); // register timer World.world.clock.registerRepeated(new ClockHandler(capture), TimeLength.fromMinutes(config.period)); // create BitmapWriter component and configure it writer = (IBitmapWriter) new CVideoRecorder(); writer.Init(rect.Width, rect.Height, config.fps); // create DirectShow graph builder ICaptureGraphBuilder2 builder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2Cls(); // create AVIMux and file writer component IBaseFilter pMux; IFileSinkFilter unused; builder.SetOutputFileName(ref MEDIASUBTYPE_Avi, "test.avi", out pMux, out unused); builder.GetFiltergraph(out graph); // add BitmapWriter as the source component graph.AddFilter((IBaseFilter)writer, "source"); // if the compressor is specified, add it IBaseFilter compressor = config.compressor.bind(); graph.AddFilter(compressor, "compressor"); // connect components builder.RenderStream(IntPtr.Zero, IntPtr.Zero, writer, compressor, pMux); mediaControl = (IMediaControl)graph; // explicitly release local objects // Marshal.ReleaseComObject(builder); // Marshal.ReleaseComObject(pMux); // Marshal.ReleaseComObject(unused); // Marshal.ReleaseComObject(compressor); }