Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions Halovision/VisionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ private void LoadSettings()
cmbDevices.Text = xmlSettings.DocumentElement.SelectSingleNode("//Camera").InnerText;
}

if (xmlSettings.DocumentElement.SelectSingleNode("//DeviceIP") != null)
if (xmlSettings.DocumentElement.SelectSingleNode("//DeviceURL") != null)
{
txtDeviceIP.Text = xmlSettings.DocumentElement.SelectSingleNode("//DeviceIP").InnerText;
txtDeviceURL.Text = xmlSettings.DocumentElement.SelectSingleNode("//DeviceURL").InnerText;
}

if (xmlSettings.DocumentElement.SelectSingleNode("//RecordVideo") != null && xmlSettings.DocumentElement.SelectSingleNode("//RecordVideo").InnerText == "1")
Expand Down Expand Up @@ -236,13 +236,13 @@ private void cmbDevices_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbDevices.Text == "lucidcode Halovision Device")
{
txtDeviceIP.Enabled = true;
lblDeviceIP.Enabled = true;
txtDeviceURL.Enabled = true;
lblDeviceURL.Enabled = true;
}
else
{
txtDeviceIP.Enabled = false;
lblDeviceIP.Enabled = false;
txtDeviceURL.Enabled = false;
lblDeviceURL.Enabled = false;
}

if (loadingDevices) { return; }
Expand Down Expand Up @@ -282,43 +282,58 @@ private void ConnectHalovisionDevice()
try
{
Core.Initialize();

if (txtDeviceURL.Text.Contains("://"))
{
libvlc = new LibVLC(enableDebugLogs: true);
libvlc.SetLogFile(m_strPath + "vlc.log");

using (Media media = new Media(libvlc, txtDeviceURL.Text, FromType.FromLocation))
{
player = new MediaPlayer(media);
player.Hwnd = pbDisplay.Handle;
player.Play();
}
return;
}

libvlc = new LibVLC(enableDebugLogs: false, "--rtsp-tcp");

// Use TCP messaging.
videoChannel = new TcpMessagingSystemFactory().CreateDuplexOutputChannel("tcp://" + txtDeviceIP.Text + ":8093/");
videoChannel = new TcpMessagingSystemFactory().CreateDuplexOutputChannel("tcp://" + txtDeviceURL.Text + ":8093/");
videoChannel.ResponseMessageReceived += OnResponseMessageReceived;

// Use unique name for the pipe.
string aVideoPipeName = Guid.NewGuid().ToString();

// Open pipe that will be read by VLC.
videoPipe = new NamedPipeServerStream(@"\" + aVideoPipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 65528);
ManualResetEvent aVlcConnectedPipe = new ManualResetEvent(false);
ManualResetEvent vlcConnectedPipe = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(x =>
{
videoPipe.WaitForConnection();

// Indicate VLC has connected the pipe.
aVlcConnectedPipe.Set();
vlcConnectedPipe.Set();
});

// VLC connects the pipe and starts playing.
using (Media aMedia = new Media(libvlc, @"stream://\\\.\pipe\" + aVideoPipeName, FromType.FromLocation))
using (Media media = new Media(libvlc, @"stream://\\\.\pipe\" + aVideoPipeName, FromType.FromLocation))
{
// Setup VLC so that it can process raw h264 data
aMedia.AddOption(":demux=H264");
media.AddOption(":demux=H264");

player = new MediaPlayer(aMedia);
player = new MediaPlayer(media);
player.Hwnd = pbDisplay.Handle;

// Note: This will connect the pipe and read the video.
player.Play();
}

// Wait until VLC connects the pipe so that it is ready to receive the stream.
if (!aVlcConnectedPipe.WaitOne(5000))
if (!vlcConnectedPipe.WaitOne(5000))
{
throw new TimeoutException($"VLC did not open connection with {txtDeviceIP.Text}.");
throw new TimeoutException($"VLC did not open connection with {txtDeviceURL.Text}.");
}

// Open connection with service running on Raspberry.
Expand Down Expand Up @@ -674,7 +689,7 @@ private void SaveSettings()
defaultSettings += "<Plugin>";
defaultSettings += "<Algorithm>" + cmbAlgorithm.Text + "</Algorithm>";
defaultSettings += "<Camera>" + cmbDevices.Text + "</Camera>";
defaultSettings += "<DeviceIP>" + txtDeviceIP.Text + "</DeviceIP>";
defaultSettings += "<DeviceURL>" + txtDeviceURL.Text + "</DeviceURL>";
defaultSettings += "<PixelThreshold>" + cmbPixelThreshold.Text + "</PixelThreshold>";
defaultSettings += "<PixelsInARow>" + cmbPixelsInARow.Text + "</PixelsInARow>";
defaultSettings += "<FrameThreshold>" + cmbFrameThreshold.Text + "</FrameThreshold>";
Expand Down Expand Up @@ -742,7 +757,7 @@ private void chkTCMP_CheckedChanged(object sender, EventArgs e)
SaveSettings();
}

private void txtDeviceIP_TextChanged(object sender, EventArgs e)
private void txtDeviceURL_TextChanged(object sender, EventArgs e)
{
SaveSettings();
}
Expand Down
40 changes: 20 additions & 20 deletions Halovision/VisionForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Halovision/VisionForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACW
DQAAAk1TRnQBSQFMAwEBAAGQAQEBkAEBAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
DQAAAk1TRnQBSQFMAwEBAAGYAQEBmAEBAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
ARwDAAEBAQABGAUAAbABKBIAXf//ABgABv8B6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6AHX
Expand Down
8 changes: 4 additions & 4 deletions Installer/Lucid Scribe Halovision.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -10596,15 +10596,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe Halovision"
"ProductCode" = "8:{60FBE49C-525A-47C8-BB5C-6BF5D113D350}"
"PackageCode" = "8:{C63F763A-A2CE-4A38-9148-F8781B2D7954}"
"ProductCode" = "8:{C9AEFE59-99D9-423A-A27F-74531C589BBF}"
"PackageCode" = "8:{9C719105-AE8B-47D5-AAB8-5BF9BD2262FC}"
"UpgradeCode" = "8:{CAAB2187-AD23-435C-A3DB-568744247625}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.7"
"ProductVersion" = "8:1.0.8"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucidcode.com/Contact"
Expand Down Expand Up @@ -11128,7 +11128,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_B4AF1D2EA1D64556B1C67844FD932129"
{
"SourcePath" = "8:..\\Halovision\\obj\\Debug\\lucidcode.LucidScribe.Plugin.Halovision.dll"
"SourcePath" = "8:..\\Halovision\\obj\\x86\\Release\\lucidcode.LucidScribe.Plugin.Halovision.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_491A001224CF4D699EA475B2FB5F2890"
Expand Down