62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using TBF.BenchControl.Network.Telnet;
|
|
|
|
namespace TBF.BenchControl.Network.Camera.CLP1611
|
|
{
|
|
public class LiveStreamOp : IOperation
|
|
{
|
|
readonly Camera camera;
|
|
readonly Telnet.TelnetClient telnet;
|
|
readonly string command;
|
|
|
|
bool liveStreamCommandSent;
|
|
|
|
Process vlcProcess;
|
|
|
|
/// <summary>
|
|
/// Events: Event.None or Event.Error
|
|
/// </summary>
|
|
/// <param name="camera">CLP1611.Camera reference</param>
|
|
public LiveStreamOp(Camera camera, Telnet.TelnetClient telnet, string command)
|
|
{
|
|
this.camera = camera;
|
|
this.telnet = telnet;
|
|
this.command = command;
|
|
}
|
|
|
|
|
|
public void Start()
|
|
{
|
|
liveStreamCommandSent = false;
|
|
}
|
|
|
|
public Event Run()
|
|
{
|
|
if (!liveStreamCommandSent)
|
|
{
|
|
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
|
{
|
|
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
|
|
liveStreamCommandSent = true;
|
|
}
|
|
|
|
vlcProcess = new Process();
|
|
vlcProcess.StartInfo = new ProcessStartInfo(System.IO.Path.Combine(camera.CameraCfg.VlcExePath, "vlc.exe"));
|
|
vlcProcess.StartInfo.Arguments = string.Format("rtsp://{0}:8554/", camera.IPAddress);
|
|
vlcProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
|
|
vlcProcess.Start();
|
|
}
|
|
return Event.None;
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
if (liveStreamCommandSent)
|
|
{
|
|
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
|
}
|
|
}
|
|
}
|
|
}
|