示例#1
0
        private void StartStream(string URL, string hostname)
        {
            Repeater?.Start();
            Debugging.DebugLog(Debugging.DebugLevel.Info, "Starting Camera Sttram" + ID);

            Debugging.DebugLog(Debugging.DebugLevel.Debug1, "Executing: " +
                               Console.GetValue(Variables.V_encoder_path).Value + " " +
                               String.Format(Console.GetValue(string.Format(Variables.V_camera_stream_args, ID)).Value, URL, string.Format("{0}:{1}/camera.ogg", hostname, port)));

            encoderProcess = new Process();
            encoderProcess.StartInfo.FileName               = Console.GetValue(Variables.V_encoder_path).Value;
            encoderProcess.StartInfo.Arguments              = String.Format(Console.GetValue(string.Format(Variables.V_camera_stream_args, ID)).Value, URL, string.Format("{0}:{1}/camera.ogg", hostname, port));
            encoderProcess.StartInfo.CreateNoWindow         = true;
            encoderProcess.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            encoderProcess.StartInfo.UseShellExecute        = false;
            encoderProcess.StartInfo.RedirectStandardInput  = true;
            encoderProcess.StartInfo.RedirectStandardError  = true;
            encoderProcess.StartInfo.RedirectStandardOutput = true;

            encoderProcess.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
                Debugging.DebugLog(Debugging.DebugLevel.Debug3, e.Data);
            };
            encoderProcess.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => {
                Debugging.DebugLog(Debugging.DebugLevel.Debug3, e.Data);
            };

            encoderProcess.Start();
            encoderProcess.BeginErrorReadLine();
            encoderProcess.BeginOutputReadLine();
        }
示例#2
0
        private void StartStream(string URL, string filename)
        {
            Debugging.DebugLog(Debugging.DebugLevel.Info, "Starting Camera " + ID);

            if (!new DirectoryInfo(GetDirectory(filename)).Exists)
            {
                new DirectoryInfo(GetDirectory(filename)).Create();
            }

            Debugging.DebugLog(Debugging.DebugLevel.Debug1, "Executing: " + Console.GetValue(Variables.V_encoder_path).Value + " " + String.Format(Console.GetValue(Variables.V_encoder_stream_args).Value, URL, filename));

            StreamSaveThread = new Process();
            StreamSaveThread.StartInfo.FileName               = Console.GetValue(Variables.V_encoder_path).Value;
            StreamSaveThread.StartInfo.Arguments              = String.Format(Console.GetValue(Variables.V_encoder_save_args).Value, URL, filename);
            StreamSaveThread.StartInfo.CreateNoWindow         = true;
            StreamSaveThread.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            StreamSaveThread.StartInfo.UseShellExecute        = false;
            StreamSaveThread.StartInfo.RedirectStandardInput  = true;
            StreamSaveThread.StartInfo.RedirectStandardError  = true;
            StreamSaveThread.StartInfo.RedirectStandardOutput = true;

            StreamSaveThread.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
                Debugging.DebugLog(Debugging.DebugLevel.Debug3, e.Data);
            };
            StreamSaveThread.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => {
                Debugging.DebugLog(Debugging.DebugLevel.Debug3, e.Data);
            };

            StreamSaveThread.Start();
            StreamSaveThread.BeginErrorReadLine();
            StreamSaveThread.BeginOutputReadLine();
        }
示例#3
0
        private void DoDiskCleanup()
        {
            //Count is protected from having non numurical values so if this fails look elsewhere
            int             count = int.Parse(Console.GetValue(Variables.V_camera_count).Value);
            List <FileInfo> list  = new List <FileInfo>();

            for (int id = 0; id < count; id++)
            {
                list.AddRange(new DirectoryInfo(string.Format(Console.GetValue(Variables.V_camera_save_path).Value, id)).GetFiles());
            }
            if (list.Count == 0)
            {
                Debugging.DebugLog(Debugging.DebugLevel.Message, "No files to remove!");
                return;
            }

            FileInfo oldest = list.OrderBy(f => f.CreationTime).First();

            Debugging.DebugLog(Debugging.DebugLevel.Message, "Removing file due to disk limit reached: {0}", oldest.Name);

            //oldest.Delete();
        }
示例#4
0
        private void StartStream()
        {
            string filename = string.Format(Console.GetValue(Variables.V_camera_save_path).Value, ID) +
                              DateTime.Now.ToString(Console.GetValue(string.Format(Variables.V_camera_save_format, ID)).Value);

            Debugging.DebugLog(Debugging.DebugLevel.Info, "Starting Camera " + ID);
            //We need to make sure the stream task is started also so we can pull the data from it
            ConsoleResponseBoolean variable = Console.GetOnOff(string.Format(Variables.V_camera_stream_enabled, ID));

            if (variable.State == ConsoleCommandState.Failure)
            {
                throw new LogicException(string.Format("{0} is not a boolean variable!", Variables.V_camera_stream_enabled));
            }
            if (!variable.Value)
            {
                Console.SetValue(string.Format(Variables.V_camera_stream_enabled, ID), "True");
            }


            try { stream?.Close(); } catch { };

            File.Delete(filename);
            stream = File.OpenWrite(filename);

            Program.CameraManager.GetGamera(ID)
            .StreamTask.Repeater.AddStream(
                new StreamClient(stream, (data, offset, length) => {
                try { stream.Write(data, offset, length);

                      /*      string s = ASCIIEncoding.ASCII.GetString(data, 0, data.Length);
                       *    var sb = new StringBuilder();
                       *    int i = 0;
                       *
                       *    sb.Append(" Capture Pattern: ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append("         Version: ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append("     Header Type: ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append("Granule Position: ")
                       *         .Append(BitConverter.ToUInt64(new byte[] { data[6],  data[7],  data[8], data[9], data[10], data[11], data[12], data[13] }, 0)).Append("\n");
                       *
                       *    sb.Append("Granule Position: ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append("Bitstream Number: ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append(" Page Seq Number: ")
                       *        .Append(data[i++].ToString("X2")).Append(" ") // 18
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *    sb.Append("        Checksum: ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append(" ")
                       *        .Append(data[i++].ToString("X2")).Append("\n");
                       *
                       *
                       *    sb.Append("\n");
                       *    Console.Write(sb.ToString());*/

                      return(true); } catch { }
                return(false);
            })
                );

            NextSegment = DateTime.Now.AddMinutes(30);
            NextFlush   = DateTime.Now.AddMinutes(1);
        }