Exemplo n.º 1
0
        // Get output stream from capture handler
        private Stream GetStream(CaptureHandler handler, string outputFolder, string outputFormat, int index)
        {
            if (!Directory.Exists(outputFolder))
            {
                throw new ArgumentException("Output directory doesn't exist.");
            }
            var time = DateTime.Now;
            var file =
                $"{time.Day}-{time.Month}-{time.Year}_{time.Hour}-{time.Minute}-{time.Second}_{handler.Device.GetFileName()}";
            var path = Path.Combine(outputFolder, file.WithExtension(outputFormat));

            while (File.Exists(path))
            {
                path = Path.Combine(outputFolder, $"{file}_{index++}".WithExtension(outputFormat));
            }
            return(AudioFormats[outputFormat](path, handler.Format, handler.Format.BitRate()));
        }
Exemplo n.º 2
0
 public void StartCapture(IEnumerable <string> devices, string outputFolder, string outputFormat, int clipLength,
                          Action finished)
 {
     _outputFolder = outputFolder;
     _outputFormat = outputFormat;
     _clipLength   = clipLength;
     SendStatus("Starting...");
     Task.Run(() => {
         foreach (var id in devices)
         {
             var device  = _devices.GetDevice(id);
             var handler = new CaptureHandler(device, _clipLength);
             _handlers.Add(handler);
             handler.OnFailure += OnFailure;
             handler.Activate();
         }
         Main.Dispatcher?.BeginInvoke(DispatcherPriority.Normal, finished);
     });
 }