Skip to content

Commit

Permalink
fix and update
Browse files Browse the repository at this point in the history
  • Loading branch information
chatop2020 committed Dec 6, 2023
1 parent 43b29d5 commit 0bcbd49
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 12 deletions.
3 changes: 2 additions & 1 deletion AKStreamWeb/Config/AKStreamWeb.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"ForwardUnmanagedRtmpRtspRtcStream": false,
"LocalizationKingBaseDb": false,
"ForwardUrlIn": "http://",
"ForwardUrlOut": "http://"
"ForwardUrlOut": "http://",
"ForwardUrlOnRecord": "http://"
}
11 changes: 10 additions & 1 deletion AKStreamWeb/Misc/AKStreamWebConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class AKStreamWebConfig
private bool _forwardUnmanagedRtmpRtspRtcStream = true;
private string? _forwardUrlIn = "";
private string? _forwardUrlOut = "";
private string? _forwardUrlOnRecord = "";


/// <summary>
Expand Down Expand Up @@ -178,6 +179,14 @@ public string ForwardUrlOut
get => _forwardUrlOut;
set => _forwardUrlOut = value;
}


/// <summary>
/// 有录制消息的时候的转发
/// </summary>
public string ForwardUrlOnRecord
{
get => _forwardUrlOnRecord;
set => _forwardUrlOnRecord = value;
}
}
}
78 changes: 68 additions & 10 deletions AKStreamWeb/Services/WebHookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public static class WebHookService
private delegate void ForwardPushInfo(ReqForWebHookOnStreamChange msg,string url);
private delegate void ForwardDestoryInfo(ReqForWebHookOnFlowReport msg,string url);

private delegate void ForwardOnRecordInfo(ReqForWebHookOnRecordMP4 msg, string url);

private static void ForwardPush(ReqForWebHookOnStreamChange msg, string url)
{
NetHelper.HttpPostRequest(url, null, JsonHelper.ToJson(msg));
Expand All @@ -32,6 +34,11 @@ private static void ForwardDestory(ReqForWebHookOnFlowReport msg, string url)
{
NetHelper.HttpPostRequest(url, null, JsonHelper.ToJson(msg));
}

private static void ForwardRecord(ReqForWebHookOnRecordMP4 msg, string url)
{
NetHelper.HttpPostRequest(url, null, JsonHelper.ToJson(msg));
}


/// <summary>
Expand Down Expand Up @@ -178,6 +185,17 @@ public static ResToWebHookOnRecordMP4 OnRecordMp4(ReqForWebHookOnRecordMP4 req)

if (videoChannel == null)
{
if ((!string.IsNullOrEmpty(Common.AkStreamWebConfig.ForwardUrlOut)) &&
(UtilsHelper.IsUrl(Common.AkStreamWebConfig.ForwardUrlOut)) &&
(Common.AkStreamWebConfig.ForwardUnmanagedRtmpRtspRtcStream) )
{
GCommon.Logger.Info(
$"[{Common.LoggerHead}]->转发录制信息->{Common.AkStreamWebConfig.ForwardUrlOnRecord}->{JsonHelper.ToJson(req)}");

Action<ReqForWebHookOnRecordMP4,string> action = ForwardRecord;
action.BeginInvoke(req,Common.AkStreamWebConfig.ForwardUrlOnRecord,null,null);
}

return new ResToWebHookOnRecordMP4()
{
Code = 0,
Expand Down Expand Up @@ -940,11 +958,22 @@ public static ResToWebHookOnPlay OnPlay(ReqForWebHookOnPlay req)

if (videoChannel == null)
{
return new ResToWebHookOnPlay()
if (Common.AkStreamWebConfig.ForwardUnmanagedRtmpRtspRtcStream)
{
Code = -1,
Msg = "feild",
};
return new ResToWebHookOnPlay()
{
Code = 0,
Msg = "success",
};
}
else
{
return new ResToWebHookOnPlay()
{
Code = -1,
Msg = "feild",
};
}
}


Expand Down Expand Up @@ -1057,13 +1086,42 @@ public static ResToWebHookOnPublish OnPublish(ReqForWebHookOnPublish req)
.First();
if (videoChannel == null)
{
return new ResToWebHookOnPublish()
if (Common.AkStreamWebConfig.ForwardUnmanagedRtmpRtspRtcStream)
{
Code = -1,
Enable_Hls = false,
Enable_Mp4 = false,
Msg = "failed",
};

ResToWebHookOnPublish result = new ResToWebHookOnPublish();
result.Code = 0;
result.Msg = "success";
result.Enable_Hls = true;
result.Enable_Mp4 = false;
result.Enable_Hls_Fmp4 = true;
result.Enable_Rtsp = true;
result.Enable_Rtmp = true;
result.Enable_Ts = true;
result.Enable_Fmp4 = true;
result.Hls_Demand = true;
result.Rtsp_Demand = false;
result.Rtmp_Demand = false;
result.Ts_Demand = true;
result.Fmp4_Demand = true;
result.Enable_Audio = true;
result.Add_Mute_Audio = true;
result.Mp4_Save_Path = "";
result.Mp4_As_Player = false;
result.Hls_Save_Path = "";
result.Auto_Close = false;
return result;
}
else
{
return new ResToWebHookOnPublish()
{
Code = -1,
Enable_Hls = false,
Enable_Mp4 = false,
Msg = "failed",
};
}
}

if (videoChannel.Enabled == false || videoChannel.MediaServerId.Contains("unknown_server"))
Expand Down

0 comments on commit 0bcbd49

Please sign in to comment.