This commit is contained in:
hehaoyang 2024-01-25 18:38:39 +08:00
parent 98d0761a19
commit b3f5b23a49
13 changed files with 232 additions and 148 deletions

View File

@ -8,13 +8,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Debug|x86.ActiveCfg = Debug|x86
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Debug|x86.Build.0 = Debug|x86
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Release|Any CPU.Build.0 = Release|Any CPU
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Release|x86.ActiveCfg = Release|x86
{4B2B07A3-B601-414A-9B90-E5228C3E55AD}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -7,6 +7,7 @@
<Nullable>disable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<ItemGroup>
@ -18,13 +19,14 @@
<Compile Remove="Utils\._JsonUtils.cs" />
<Compile Remove="Utils\._LiteDBUtils.cs" />
<Compile Remove="Utils\._LogUtils.cs" />
<Compile Remove="Utils\._ProcessUtils.cs" />
<Compile Remove="Utils\._SQLiteUtils.cs" />
<Compile Remove="Utils\._TaskUtils.cs" />
<Compile Remove="Utils\._UdpClientUtils.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LiteDB.Async" Version="0.1.7" />
<PackageReference Include="LiteDB" Version="5.0.17" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@ -1,23 +1,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Net;
using HxServer.Utils;
using System.Data.SqlTypes;
using Newtonsoft.Json;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Data;
using System.Reflection;
using System.IO;
using System.Threading.Channels;
using System.Xml.Linq;
using HxServer.Utils;
using LiteDB;
using LiteDB.Async;
using Newtonsoft.Json;
namespace HxServer.Peripheral
{
@ -51,7 +34,7 @@ namespace HxServer.Peripheral
public DateTime StartTime { get; set; }
[JsonProperty(PropertyName = "end_time")]
public DateTime EndTime { get; set; }
public DateTime? EndTime { get; set; }
[JsonProperty(PropertyName = "duration")]
public int Duration { get; set; }
@ -61,88 +44,102 @@ namespace HxServer.Peripheral
[JsonProperty(PropertyName = "path")]
public string Path { get; set; }
public static HxVideoRecord Build(Dictionary<string, object> dictionary)
{
return new()
{
Channel = Convert.ToInt32(dictionary["channel"]),
StartTime = Convert.ToDateTime(dictionary["start_time"]),
EndTime = string.IsNullOrEmpty(dictionary["end_time"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(dictionary["end_time"]),
Duration = Convert.ToInt32(dictionary["duration"]),
Name = dictionary["name"].ToString(),
Path = dictionary["path"].ToString()
};
}
}
public class DataBase
{
private const string filename = "HxNvr.DataBase.db";
private static LiteDatabase Database { get; set; }
// 打开数据库 (如果不存在则创建)
private static LiteDatabaseAsync database { get; set; } = new(@"HxNvr.DataBase.db");
//private static SQLiteCommand InsertLogCommand = new("INSERT INTO [Log] ([timestamp], [type], [index], [message], [data]) VALUES (@timestamp, @type, @index, @message, @data); SELECT LAST_INSERT_ROWID();");
private static ConnectionString ConnectionString => new() { Filename = "HxNvr.DataBase.db", Connection = ConnectionType.Shared, };
public static void Initialization()
{
var collection = database.GetCollection<HxSetting>("Settings");
var array = collection.FindAllAsync().Result;
if (array.Count() == 0)
Database = new(ConnectionString);
var collection = Database.GetCollection<HxSetting>("Settings");
var array = collection.FindAll();
if (!array.Any())
{
collection.InsertAsync(new HxSetting() { Name = "code", Value = "TVIS" });
collection.InsertAsync(new HxSetting() { Name = "recording_split_time", Value = "10" });
collection.InsertAsync(new HxSetting() { Name = "recording_reserver_time", Value = "15" });
collection.InsertAsync(new HxSetting() { Name = "drive_threshold", Value = "10" });
collection.InsertAsync(new HxSetting() { Name = "is_cleanup_enabled", Value = "1" });
collection.InsertAsync(new HxSetting() { Name = "is_cleanup_forced_for_reserve_time", Value = "0" });
collection.InsertAsync(new HxSetting() { Name = "disks", Value = "/home/hehaoyang/harddisk1;D://" });
collection.InsertAsync(new HxSetting() { Name = "channel_00", Value = "0;通道 01;Bsm;teweishi.oicp.net;554;1;15;1;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_01", Value = "1;通道 02;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_02", Value = "2;通道 03;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_03", Value = "3;通道 04;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_04", Value = "4;通道 05;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_05", Value = "5;通道 06;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_06", Value = "6;通道 07;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_07", Value = "7;通道 08;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_08", Value = "8;通道 09;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_09", Value = "9;通道 10;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_10", Value = "10;通道 11;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_11", Value = "11;通道 12;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_12", Value = "12;通道 13;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_13", Value = "13;通道 14;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_14", Value = "14;通道 15;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertAsync(new HxSetting() { Name = "channel_15", Value = "15;通道 16;Bsm;192.168.10.101;554;1;15;0;1;0" });
collection.InsertBulk(new List<HxSetting>()
{
new() { Name = "code", Value = "TVIS" },
new() { Name = "recording_split_time", Value = "10" },
new() { Name = "recording_reserver_time", Value = "15" },
new() { Name = "drive_threshold", Value = "10" },
new() { Name = "is_cleanup_enabled", Value = "1" },
new() { Name = "is_cleanup_forced_for_reserve_time", Value = "0" },
new() { Name = "disks", Value = "/home/hehaoyang/harddisk1;/root;D:/" },
new() { Name = "channel_00", Value = "0;通道 01;AHV;127.0.0.1;8554;0;1;1" },
new() { Name = "channel_01", Value = "1;通道 02;AHV;127.0.0.1;8554;1;1;1" },
new() { Name = "channel_02", Value = "2;通道 03;AHV;127.0.0.1;8554;2;1;1" },
new() { Name = "channel_03", Value = "3;通道 04;AHV;127.0.0.1;8554;3;1;1" },
new() { Name = "channel_04", Value = "4;通道 05;Bsm;192.168.10.105;554;0;0;1" },
new() { Name = "channel_05", Value = "5;通道 06;Bsm;192.168.10.106;554;0;0;1" },
new() { Name = "channel_06", Value = "6;通道 07;Bsm;192.168.10.107;554;0;0;1" },
new() { Name = "channel_07", Value = "7;通道 08;Bsm;192.168.10.108;554;0;0;1" },
new() { Name = "channel_08", Value = "8;通道 09;Bsm;192.168.10.109;554;0;0;1" },
new() { Name = "channel_09", Value = "9;通道 10;Bsm;192.168.10.110;554;0;0;1" },
new() { Name = "channel_10", Value = "10;通道 11;Bsm;192.168.10.111;554;0;0;1" },
new() { Name = "channel_11", Value = "11;通道 12;Bsm;192.168.10.112;554;0;0;1" },
new() { Name = "channel_12", Value = "12;通道 13;Bsm;192.168.10.113;554;0;0;1" },
new() { Name = "channel_13", Value = "13;通道 14;Bsm;192.168.10.114;554;0;0;1" },
new() { Name = "channel_14", Value = "14;通道 15;Bsm;192.168.10.115;554;0;0;1" },
new() { Name = "channel_15", Value = "15;通道 16;Bsm;192.168.10.116;554;0;0;1" }
});
}
}
public static Dictionary<string, string> ReadSettings()
{
Dictionary<string, string> keyValuePairs = [];
/* 打开表 */
var collection = database.GetCollection<HxSetting>("Settings");
var collection = Database.GetCollection<HxSetting>("Settings");
var array = collection.FindAllAsync().Result;
var array = collection.FindAll();
/* 查询所有数据 */
foreach (var c in array)
keyValuePairs.Add(c.Name, c.Value);
DebugTrace.WriteLine(nameof(DataBase), $"读取设置信息");
return keyValuePairs;
}
public static async void WriteLogger(DateTime timestamp, int type, int index, string message, string data)
public static void WriteLogger(DateTime timestamp, int type, int index, string message, string data)
{
/* 打开表 */
var collection = database.GetCollection<HxLog>("Log");
var collection = Database.GetCollection<HxLog>("Log");
/* 插入数据 */
await collection.InsertAsync(new HxLog() { Timestamp = timestamp, Type = type, Index = index, Message = message, Data = data });
var res = collection.Insert(new HxLog() { Timestamp = timestamp, Type = type, Index = index, Message = message, Data = data });
DebugTrace.WriteLine(nameof(DataBase), $"写入日志数据: {message} {data}");
}
public static List<HxVideoRecord> QueryFirstRecord()
{
List<HxVideoRecord> records = [];
/* 打开表 */
var collection = database.GetCollection<HxVideoRecord>("Records");
var collection = Database.GetCollection<HxVideoRecord>("Records");
var record = collection.FindOneAsync(x=> !string.IsNullOrEmpty(x.Name)).Result;
var record = collection.FindOne(x => !string.IsNullOrEmpty(x.Name));
if (record != null)
records.Add(record);
DebugTrace.WriteLine(nameof(DataBase), $"查询第一条录像记录: res = {(records.Count == 0 ? "NULL" : records[0].Name)}");
return records;
}
@ -150,28 +147,50 @@ namespace HxServer.Peripheral
{
List<HxVideoRecord> records = [];
///* 打开表 */
//var collection = LiteDBUtils.GetCollection<HxVideoRecord>(filename, "Records");
try
{
var collection = Database.GetCollection<HxVideoRecord>("Records");
var result = collection.Find(x => x.StartTime.Date.CompareTo(date.Date) == 0);
if (result == null)
records = result.ToList();
}
catch { }
//records = collection.Find(x => x.StartTime.Date.CompareTo(date.Date) == 0).ToList();
DebugTrace.WriteLine(nameof(DataBase), $"查询录像日志记录: res = {records.Count}");
return records;
}
public static void ReplaceRecord(int channel, DateTime start_time, DateTime end_time, int duration, string name, string path)
public static void ReplaceRecord(HxVideoRecord record)
{
///* 打开表 */
//var collection = LiteDBUtils.GetCollection<HxVideoRecord>(filename, "Records");
var collection = Database.GetCollection<HxVideoRecord>("Records");
//collection.Update(new HxVideoRecord() { Channel = channel, StartTime = start_time, EndTime = end_time, Duration = duration, Name = name, Path = path });
var _record = collection.FindOne(x => x.Name == record.Name);
if (_record == null)
{
collection.Insert(record);
DebugTrace.WriteLine(nameof(DataBase), $"插入录像日志记录: {record.Name}");
}
else
{
_record.EndTime = record.EndTime;
_record.Duration = record.Duration;
collection.Update(_record);
DebugTrace.WriteLine(nameof(DataBase), $"更新录像日志记录: {record.Name}");
}
}
public static void DeleteRecordByPath(string path)
{
///* 打开表 */
//var collection = LiteDBUtils.GetCollection<HxVideoRecord>(filename, "Records");
var collection = Database.GetCollection<HxVideoRecord>("Records");
//var record = collection.DeleteMany(x => x.Path == path);
int res = collection.DeleteMany(x => x.Path == path);
DebugTrace.WriteLine(nameof(DataBase), $"删除录像日志记录, {path}" + (res == 0 ? "删除失败" : "删除成功"));
}
}
}

View File

@ -75,12 +75,12 @@ public class MonitorServer
var buffer = UdpClient.EndReceive(ar, ref point);
TaskUtils.Run(Process, buffer, point);
TaskUtils.Run(UdpDataProcess, buffer, point);
UdpClient.BeginReceive(RequestCallback, null);
}
private static void Process(byte[] buffer, IPEndPoint point)
private static void UdpDataProcess(byte[] buffer, IPEndPoint point)
{
if (buffer.Length > 0)
{
@ -94,9 +94,6 @@ public class MonitorServer
switch (model.ActionType)
{
case 0:
if (dictionary == null)
return;
UpdateAppInfos(dictionary["name"].ToString(), dictionary["version"].ToString(), point);
break;
@ -113,51 +110,43 @@ public class MonitorServer
break;
case 4:
if (dictionary == null)
return;
{
DataBase.WriteLogger(Convert.ToDateTime(dictionary["timestamp"]),
Convert.ToInt32(dictionary["type"]),
Convert.ToInt32(dictionary["index"]),
dictionary["message"].ToString(),
dictionary["data"].ToString());
}
break;
case 5:
if (dictionary == null || dictionary.Count == 0)
{
if (dictionary.Count == 0)
{
UdpClient.Send(point, new Model(5, DataBase.QueryFirstRecord()));
}
else
{
if (dictionary.ContainsKey("date"))
UdpClient.Send(point, new Model(5, DataBase.QueryRecord(Convert.ToDateTime(dictionary["date"].ToString()))));
if (dictionary.TryGetValue("date", out object value))
UdpClient.Send(point, new Model(5, DataBase.QueryRecord(Convert.ToDateTime(value.ToString()))));
else
UdpClient.Send(point, new Model(5, DataBase.QueryRecord(Convert.ToDateTime(dictionary["start_date"].ToString()))));
}
}
break;
case 6:
if (dictionary == null)
return;
DataBase.ReplaceRecord(Convert.ToInt32(dictionary["channel"]),
Convert.ToDateTime(dictionary["start_time"]),
Convert.ToDateTime(dictionary["end_time"]),
Convert.ToInt32(dictionary["duration"]),
dictionary["name"].ToString(),
dictionary["path"].ToString());
DataBase.ReplaceRecord(HxVideoRecord.Build(dictionary));
break;
case 7:
if (dictionary == null)
return;
if (dictionary.ContainsKey("path"))
DataBase.DeleteRecordByPath(dictionary["path"].ToString());
{
if (dictionary.TryGetValue("path", out object value))
DataBase.DeleteRecordByPath(value.ToString());
//else if (dictionary.ContainsKey("date"))
// DataBase.DeleteRecord("date", dictionary["date"].ToString());
}
break;
}
}
@ -190,7 +179,23 @@ public class MonitorServer
{
if (DateTime.Now - app.DateTime >= TimeSpan.FromSeconds(10))
{
Console.WriteLine($"{app.Name} Reboot");
var process = Process.GetProcessesByName(app.Name);
/* 若进程不存在, 启动进程 */
if (process.Length == 0)
{
Process.Start(app.Path);
}
//else
//{
// process[0].Kill();
// Process.Start(app.Path);
// DebugTrace.WriteLine(nameof(DataBase), $"超过10s为收到心跳数据, 重启 {app.Name} 软件");
//}
app.DateTime = DateTime.Now;
}
});
}

View File

@ -12,8 +12,7 @@ Console.WriteLine($"Hello, World!");
DataBase.Initialization();
/* 服务启动 */
//MonitorServer.Initialization(AppInfo.Set("HxNvr", ""));
MonitorServer.Initialization();
MonitorServer.Initialization(AppInfo.Set("HxNvr", "D:\\App\\HxNvr\\HxNvr.exe"));
MonitorServer.Startup();
while (true) ;

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HxServer.Utils
{
public class DebugTrace
{
public static void WriteLine(string title, string message)
{
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | {title} | {message}");
}
}
}

View File

@ -17,7 +17,7 @@ public class JsonUtils
return JsonConvert.SerializeObject(value);
}
public static Dictionary<string, object>? ToDictionary(object? message)
public static Dictionary<string, object> ToDictionary(object? message)
{
var json = message?.ToString();

View File

@ -1,19 +0,0 @@
using LiteDB;
using LiteDB.Async;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HxServer.Utils
{
public static class LiteDBUtils
{
public static ILiteCollection<T> GetCollection<T>(LiteDatabase database, string name, BsonAutoId autoId = BsonAutoId.ObjectId)
{
/* 获取集合(相当于表) */
return database.GetCollection<T>(name);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace HxServer.Utils;
@ -12,32 +13,42 @@ public class LogUtils
public static void AppendLog(string message)
{
Console.WriteLine(message);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "log.log"), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
var data = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {message}";
Console.WriteLine(data);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "log.log"), data);
}
public static void AppendLog(string filename, string message)
{
Console.WriteLine(message);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
var data = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {message}";
Console.WriteLine(data);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), data);
}
public static void AppendError(string message)
{
var data = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {message}";
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.WriteLine(data);
Console.ForegroundColor = ConsoleColor.White;
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "error.log"), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "error.log"), data);
}
public static void AppendError(string filename, string message)
{
var data = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {message}";
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.WriteLine(data);
Console.ForegroundColor = ConsoleColor.White;
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), data);
}

View File

@ -30,8 +30,9 @@ void HxDevice::startup(QJsonObject object)
auto type = array[2].toUpper();
auto address = array[3];
auto port = array[4].toInt();
auto enable = QVariant(array[7]).toBool();
auto record = QVariant(array[8]).toBool();
auto _channel = array[5].toInt();
auto enable = QVariant(array[6]).toBool();
auto record = QVariant(array[7]).toBool();
if (enable && record)
{
@ -43,6 +44,8 @@ void HxDevice::startup(QJsonObject object)
rtspurl = QString("rtsp://%1:%2/stander/livestream/0/%3").arg(address).arg(port).arg(!secondary ? 0 : 1);
else if (type == "BSM")
rtspurl = QString("rtsp://%1:%2/%3").arg(address).arg(port).arg(!secondary ? 11 : 12);
else if (type == "AHV")
rtspurl = QString("rtsp://%1:%2/dev/video%3").arg(address).arg(port).arg(_channel);
/* 创建 视频读取线程 */
HxTask::run(this, &HxDevice::frame_read_process, 5000, uuid);
@ -66,7 +69,8 @@ void HxDevice::frame_read_process()
// av_dict_set(&avdic, "audio_buffer_size","30", 0);
av_dict_set(&avdic, "stimeout", "500000", 0);
av_dict_set(&avdic, "max_delay", "500000", 0);
av_dict_set(&avdic, "rtsp_transport", "tcp", 0);
av_dict_set(&avdic, "rtsp_transport", "+udp+tcp", 0);
// av_dict_set(&avdic, "rtsp_transport", "tcp", 0);
avformat_network_init();

Binary file not shown.

38
HxVideoCaptor/external/rtsp-server.c vendored Normal file
View File

@ -0,0 +1,38 @@
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
GMainLoop* loop;
GstRTSPServer* server;
GstRTSPMountPoints* mounts;
gst_init(NULL, NULL);
loop = g_main_loop_new(NULL, FALSE);
server = gst_rtsp_server_new();
gst_rtsp_server_set_service(server, "8554");
mounts = gst_rtsp_server_get_mount_points(server);
for (int i = 0; i < 4; i++)
{
char device[1024] = { 0 }, launch[2048] = { 0 };
sprintf(device, "/dev/video%d", i);
sprintf(launch, "( v4l2src device=%s ! videoconvert ! video/x-raw, format=NV12, width=1280, height=720, framerate=25/1 ! videoparse width=1280 height=720 format=nv12 ! clockoverlay time-format=\"%%Y-%%m-%%d %%H:%%M:%%S\"! queue ! mpph264enc ! rtph264pay name=pay0 pt=96 )", device);
GstRTSPMediaFactory* factory = gst_rtsp_media_factory_new();
gst_rtsp_media_factory_set_launch(factory, launch);
gst_rtsp_media_factory_set_shared(factory, TRUE);
gst_rtsp_mount_points_add_factory(mounts, device, factory);
g_print(" listern => rtsp://localhost:8554%s\r\n", device);
}
g_object_unref(mounts);
gst_rtsp_server_attach(server, NULL);
g_main_loop_run(loop);
return 0;
}

View File

@ -14,6 +14,9 @@ int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
/* 设置最大线程个数 */
QThreadPool::globalInstance()->setMaxThreadCount(100);
/* UDP广播 初始化 */
HxBroadcast::initialization(BROADCAST_PORT);
QObject::connect(HxBroadcast::context(), &HxBroadcast::receive_event, [=](QByteArray data) { broadcast_receive_event(data); });