Skip to content

Commit

Permalink
增加流媒体服务器健康检测并重新格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
chatop committed Nov 28, 2020
1 parent 88a6142 commit 3dc6f20
Show file tree
Hide file tree
Showing 169 changed files with 699 additions and 25,797 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified CommonFunctions/.DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions CommonFunctions/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class Common

//在线播放用户列表
public static List<PlayerSession> PlayerSessions = new List<PlayerSession>();
public static object MediaServerLock = new object();
public static object CameraSessionLock = new object();
public static object SipDeviceListLock = new object();
public static object CameraInstanceListLock = new object();
Expand All @@ -49,9 +50,9 @@ static Common()
{
KillSelf();
}

//清理ffmpeg进程
Process[] processes = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(FFmpegBinPath));
Process[] processes = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(FFmpegBinPath));
if (processes != null && processes.Length > 0)
{
foreach (var process in processes)
Expand Down
37 changes: 36 additions & 1 deletion CommonFunctions/CommonFunctions.xml

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

3 changes: 3 additions & 0 deletions CommonFunctions/DBStructs/CameraInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace CommonFunctions.DBStructs
{
/// <summary>
/// 音视频设备的注册实例结构,与数据库中Camera表一致是Camera表的字段映射
/// </summary>
[Table(Name = "Camera")]
[Index("cmr_cameraid", "CameraId", true)]
[Index("cmr_cameraname", "CameraName", false)]
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/DBStructs/ClientOnOffLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public enum OnOff
Off,
}

/// <summary>
/// 设备上线下线的记录,实际作用有点鸡肋,打算将来移除掉
/// </summary>
[Serializable]
[Table(Name = "ClientLogOnOff")]
[Index("clof_ipaddress", "IpAddress", false)]
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/DBStructs/DvrDayTimeRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace CommonFunctions.DBStructs
{
/// <summary>
/// 录制计划详细计划的结构,是数据库DvrDayTimeRange表的字段映射
/// </summary>
[Serializable]
[Table(Name = "DvrDayTimeRange")]
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/DBStructs/RecordFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace CommonFunctions.DBStructs
{
/// <summary>
/// 录制文件的记录结构,是数据库RecordFile表的字段映射
/// </summary>
[Table(Name = "RecordFile")]
[Index("rf_cameraid", "CameraId", false)]
[Index("rf_cameraname", "CameraName", false)]
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/DBStructs/StreamDvrPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public enum OverStepPlan
DeleteFile,
}

/// <summary>
/// 录制计划,是数据库StreamDvrPlan表的字段映射
/// </summary>
[Table(Name = "StreamDvrPlan")]
[Index("uk_dvrPlan_MId", "MediaServerId", false)]
[Index("uk_dvrPlan_CId", "CameraId", false)]
Expand Down
2 changes: 1 addition & 1 deletion CommonFunctions/ManageStructs/AllowKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace CommonFunctions.ManageStructs
{
/// <summary>
/// allowkey管理类
/// allowkey管理类,暂时没有启用
/// </summary>
[Serializable]
public class AllowKey
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/ManageStructs/CameraSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public enum ClientType
Livecast,
}

/// <summary>
/// 在线音视频设备的结构
/// </summary>
[Serializable]
public class CameraSession
{
Expand Down
3 changes: 3 additions & 0 deletions CommonFunctions/ManageStructs/CutMergeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public enum TaskStatus
Closed,
}

/// <summary>
/// 裁剪合并任务的结构
/// </summary>
[Serializable]
public class CutMergeTask
{
Expand Down
9 changes: 6 additions & 3 deletions CommonFunctions/ManageStructs/ZLMediaKitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class ZLMediaKitConfig_General
private bool? _rtmp_demand;
private bool? _ts_demand;
private bool? _fmp4_demand;


/// <summary>
/// 自动静音
Expand Down Expand Up @@ -405,6 +405,7 @@ public class ZLMediaKitConfig_Hook
/// 录制 hls ts 切片完成事件
/// </summary>
public string? On_Record_TS => _on_record_ts;

/// <summary>
/// rtsp鉴权事件,此事件中比对rtsp的用户名密码
/// </summary>
Expand Down Expand Up @@ -731,9 +732,11 @@ public ushort? Sslport
public class ZLMediaKitConfig_Rtp
{
private int? _audioMtuSize;
// private int? _clearCount;

// private int? _clearCount;
private ulong? _cycleMS;
// private int? _maxRtpCount;

// private int? _maxRtpCount;
private int? _videoMtuSize;

/// <summary>
Expand Down
23 changes: 22 additions & 1 deletion CommonFunctions/MediaServerControl/MediaServerInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading;
using CommonFunctions.DBStructs;
using CommonFunctions.ManageStructs;
using CommonFunctions.WebApiStructs.Request;
using CommonFunctions.WebApiStructs.Response;
using LibSystemInfo;
using JsonHelper = LibGB28181SipGate.JsonHelper;
Expand Down Expand Up @@ -59,6 +58,8 @@ public string Secret
/// </summary>
public bool IsRunning => GetIsRunning(out _);

public bool Health => GetHealth();

/// <summary>
/// 获取运行时长(秒)
/// </summary>
Expand Down Expand Up @@ -211,6 +212,26 @@ public MediaServerInstance(string ipaddress, ushort webApiPort, ushort mediaServ
})).Start();
}


private bool GetHealth()
{
try
{
string innerUrl = "http://" + _ipaddress + ":" + _webApiPort + "/Health";
var httpRet = NetHelper.HttpGetRequest(innerUrl, null, "utf-8", 1000);
if (!string.IsNullOrEmpty(httpRet) && httpRet.Equals("ok"))
{
return true;
}

return false;
}
catch
{
return false;
}
}

public bool GetIsRunning(out ResponseStruct rs)
{
rs = new ResponseStruct()
Expand Down
Loading

0 comments on commit 3dc6f20

Please sign in to comment.