public void StopRecordingTest()
        {
            FFmpegHandler handler      = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            string        ffmpegDevice = GetDefaultDevice();

            if (ffmpegDevice == "" || ffmpegDevice == null)
            {
                Assert.Fail("Failed to get a default device check NAudioHandler");
            }

            handler.beginRecording(ffmpegDevice);
            Thread.Sleep(2000);
            if (handler.RunningProcess.HasExited)
            {
                Assert.Fail("Process did not successfuly start");
            }
            Thread.Sleep(1000);
            handler.stopRecording();
            Thread.Sleep(2000);
            if (handler.RunningProcess != null)
            {
                handler.RunningProcess.Kill();
                Assert.Fail("Proccess did not stop");
            }
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------
        /// <summary>
        /// Recording loop, called in main loop. Called by timer to start every hour on the hour.
        /// </summary>
        public async void record(Object obj = null)
        {
            int count = 0;

            while (!recordStop)
            {
                Console.WriteLine("\n\n\n");
                Console.WriteLine("----------------  " + ++count + "  -------------------");
                StatusMessage = "Creating new recording at " + DateTime.Now + "...";
                LogWriter.Write("Creating new recording at " + DateTime.Now + "...");
                Console.WriteLine("\n\n\n");
                String localFileName = "";
                timeLeft = (uint)setRecordingTime();
                //timeLeft = 5; // ### ADD BACK IN ON RELEASE

                // Get the bitrate through authStation, in case it has been updated.
                var  handler   = new BroadcastLoggerHandler();
                bool succeeded = handler.authStation(stationId, authCode);
                if (succeeded)
                {
                    bitRate = handler.BitRate;
                }
                else
                {
                    StatusMessage = handler.ErrorMessage + "\nBacklogging record.";
                    LogWriter.Write("Backlogging record");
                }

                localFileName = new FFmpegHandler("ffmpeg", "ffmpeg.exe")
                                .beginRecording(audioDevice, timeLeft, bitRate);
                storage.AddToQueue(stationId, localFileName);
                await Task.Delay((int)timeLeft * 1000);
            }
        }
        private string GetDefaultDevice()
        {
            FFmpegHandler handler  = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            NAudioHandler nHandler = new NAudioHandler();

            string[] devices       = new string[0];
            string   defaultDevice = nHandler.getDefaultDevice().ToString();
            string   ffmpegDevice  = string.Empty;

            handler.getInputDevices((string[] s) =>
            {
                devices = s;
            });
            Thread.Sleep(3000);
            foreach (string s in devices)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (i == s.Length - 1 && s[i] == defaultDevice[i])
                    {
                        ffmpegDevice = s;
                        break;
                    }
                    if (s[1] != defaultDevice[1])
                    {
                        continue;
                    }
                }
            }
            return(ffmpegDevice);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor to create the logging user interface.
        /// </summary>
        /// <param name="devices">A list of devices to be shown in the dropdown box</param>
        /// <param name="selectedDevice">The selected device from the previous page.</param>
        /// <param name="recording">A parameter used for recovery, to start recording automatically pass in true</param>
        /// <param name="authCode">The authcode to be used for recording. </param>
        public Logger(string[] devices, string selectedDevice, bool recording, String authCode)
        {
            InitializeComponent();
            authCodeLabel.Content = "Enter auth code for " + Manager.Instance.StationId + ":";
            authCodeTextBox.Text  = authCode;
            updateDevices(devices, selectedDevice);
            this.selectedDevice_ = selectedDevice;
            ffh = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            initalizeMeter();
            Manager.Instance.setDevice(selectedDevice_);

            // Get status update messages from Manager
            Manager.Instance.StatusUpdate += ((e) =>
            {
                this.Dispatcher.Invoke((Action)(() => {
                    statusLabel.Content = e;
                }));
            });
            // Notify when Manager finishes handling queue.
            Manager.Instance.RecordingStopped += (() => {
                this.Dispatcher.Invoke((Action)(() => {
                    progressBar.IsIndeterminate = false;
                    startStopButton.IsEnabled = true;
                }));
            });
            //Begin recording if the previous session was still recording.
            if (recording == true)
            {
                beginRecording(null, null);
                startStopButton.SetStop();
            }
        }
 public void NoExecutable()
 {
     try
     {
         string        deviceName = string.Empty;
         FFmpegHandler handler    = new FFmpegHandler("ffmpeg", deviceName);
         Assert.Fail("Exception should of been thrown");
     }
     catch (ArgumentException ex)
     {
     }
 }
        public void FileName()
        {
            FFmpegHandler handler       = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            string        defaultDevice = GetDefaultDevice();
            string        file          = handler.beginRecording(defaultDevice, 1);

            Thread.Sleep(5000);
            if (!File.Exists(file))
            {
                Assert.Fail("File was not created");
            }
            File.Delete(file);
        }
        public void TimedRecording()
        {
            FFmpegHandler handler       = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            string        defaultDevice = GetDefaultDevice();
            string        fileName      = handler.beginRecording(defaultDevice, 2);

            Console.WriteLine(fileName);
            Thread.Sleep(5000);
            if (!File.Exists(fileName))
            {
                Assert.Fail("Failed to create the file");
            }
        }
 public void InvalidInitializationFile()
 {
     try
     {
         FFmpegHandler handler = new FFmpegHandler("ffmpeg", "InvalidFileName");
         Assert.Fail("Expected an exception");
     }catch (System.ArgumentException) {
         //Expected exception
     }
     catch (Exception)
     {
         Assert.Fail("Did not catch the right exception");
     }
 }
        public void FinishedRecording()
        {
            FFmpegHandler handler = new FFmpegHandler("ffmpeg", "ffmpeg.exe");

            handler.FinishedRecording += (o, args) =>
            {
                if (args.FileName == null)
                {
                    Assert.Fail();
                }
            };
            handler.beginRecording(GetDefaultDevice(), 1);
            Thread.Sleep(5000);
        }
 public void InvalidInitializationSubDirectory()
 {
     try
     {
         FFmpegHandler handler = new FFmpegHandler("InvalidSubDirectory", "ffmpeg.exe");
         Assert.Fail("Expected an excpetion");
     }
     catch (System.ArgumentException)
     {
         //Expected expcetion
     }
     catch (Exception)
     {
         Assert.Fail("Did not catch the right exception");
     }
 }
        public void Cleanup()
        {
            FFmpegHandler handler      = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            string        ffmpegDevice = GetDefaultDevice();

            if (ffmpegDevice == "" || ffmpegDevice == null)
            {
                Assert.Fail("Failed to get a default device check NAudioHandler");
            }
            handler.beginRecording(ffmpegDevice, 1);
            Thread.Sleep(5000);
            if (handler.RunningProcess != null)
            {
                handler.RunningProcess.Kill();
                Assert.Fail("Procces was not stopped");
            }
        }
 public void ProperInitialization()
 {
     FFmpegHandler handler = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
 }
Exemplo n.º 13
0
        private void FFmpegGetDevices()
        {
            FFmpegHandler handler = new FFmpegHandler("ffmpeg", "ffmpeg.exe");

            handler.getInputDevices(updateDevices);
        }