Skip to content

Commit

Permalink
针对手动推流后又被自动断下来的问题进行处理,数据库中Camera.Activated=false时CameraAutoKeeper将不再对…
Browse files Browse the repository at this point in the history
…此类设备进行自动推拉流自动结束推拉流进行控制
  • Loading branch information
chatop committed Nov 27, 2020
1 parent d390bee commit a4e986b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion StreamNodeWebApi/AutoTasker/CameraAutoKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ private static void keeperCamera()
liveCamera(cit);
}

if (cit != null && (cit.EnableLive == false || cit.Activated == false)
if (cit != null && (cit.EnableLive == false || cit.Activated == true) //为了自己可控的进行推流与断流控制,这边只处理cit.Activated为true的情况
//手动推流的情况下,可以将数据库Activated设置了False来解决推上去后又断下来的问题
) //停止摄像头,如果activated为False,就一定要停止
{
stopCamera(cit);
Expand Down
56 changes: 56 additions & 0 deletions StreamNodeWebApi/AutoTasker/MediaKeeperCheckKeepAlive.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Threading;
using CommonFunctions;
using CommonFunctions.ManageStructs;

namespace StreamNodeWebApi.AutoTasker
{
/// <summary>
/// 未完成
/// </summary>
public class MediaKeeperCheckKeepAlive
{
private void KeepAlive()
{
while (true)
{
lock (Common.MediaServerList)
{
for (int i = Common.MediaServerList.Count - 1; i <= 0; i--)
{
var ret = Common.MediaServerList[i].GetIsRunning(out ResponseStruct rs);
if (ret == true && rs.Code == ErrorNumber.None)
{
Common.MediaServerList[i].KeepAlive = DateTime.Now;
Common.MediaServerList[i].UpdateTime = DateTime.Now;
}

if ((DateTime.Now - Common.MediaServerList[i].KeepAlive).TotalMinutes > 20)
{

Common.MediaServerList[i] = null;
}
}
Common.RemoveNull(Common.MediaServerList);
}


Thread.Sleep(10000);
}
}
public MediaKeeperCheckKeepAlive()
{
new Thread(new ThreadStart(delegate
{
try
{
KeepAlive();
}
catch (Exception ex)
{
//
}
})).Start();
}
}
}
1 change: 1 addition & 0 deletions StreamNodeWebApi/Controllers/WebHookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public WebHookController(IHttpContextAccessor httpContextAccessor)
[AuthVerify]
public bool OnSipDeviceRegister(ReqAddCameraInstance req)
{

ResponseStruct rs;
var ret = MediaServerApis.AddSipDeviceToDB(req, out rs);
if (rs.Code != ErrorNumber.None)
Expand Down

0 comments on commit a4e986b

Please sign in to comment.