Added USER_END trigger
This commit is contained in:
parent
46615efe49
commit
93f8b01a0b
4 changed files with 23 additions and 10 deletions
|
@ -180,16 +180,16 @@ if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.
|
||||||
["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],
|
["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],
|
||||||
["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE",
|
["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE",
|
||||||
"RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],["PUSH_OUT_START","PUSH_OUT_START: before recording/pushing, allow target changes."],["RECORDING_END","RECORDING_END: after a recording finishes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW",
|
"RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],["PUSH_OUT_START","PUSH_OUT_START: before recording/pushing, allow target changes."],["RECORDING_END","RECORDING_END: after a recording finishes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW",
|
||||||
"USER_NEW: a new user connects that hasn't been allowed or denied access before"],["LIVE_BANDWIDTH","LIVE_BANDWIDTH: when the value specified as param is surpassed"]],LTSonly:!0,validate:["required"],"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();$("[name=params]").setval("").closest(".UIelement").hide();break;case "LIVE_BANDWIDTH":$("[name=appliesto]").closest(".UIelement").show();
|
"USER_NEW: a new user connects that hasn't been allowed or denied access before"],["USER_END","USER_END: a user session disconnects after receiving some media"],["LIVE_BANDWIDTH","LIVE_BANDWIDTH: when the value specified as param is surpassed"]],LTSonly:!0,validate:["required"],"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();
|
||||||
$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",
|
$("[name=params]").setval("").closest(".UIelement").hide();break;case "LIVE_BANDWIDTH":$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",
|
||||||
pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},
|
type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",
|
||||||
LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,"default":n["default"]};
|
pointer:{main:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],
|
||||||
if(!("triggers"in mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){fa();ta.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",
|
1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,"default":n["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");
|
||||||
0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){fa()})},$(this).val()*1E3)},help:"How often the table below should be updated."},
|
mist.send(function(){fa();ta.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){fa()})},
|
||||||
{label:"..or",type:"DOMfield",DOMfield:ta,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));y=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(y));var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},fa=function(){var a=mist.data.log;if(a){a.length>=
|
$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ta,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));y=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(y));var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},
|
||||||
2&&a[0][0]<a[a.length-1][0]&&a.reverse();y.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));y.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};fa();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var n={graph:"new"},w=mist.stored.get().graphs?
|
fa=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();y.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));y.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};fa();break;case "Statistics":var B=$("<span>").text("Loading..");
|
||||||
$.extend(!0,{},mist.stored.get().graphs):{},Q={};for(h in mist.data.streams)Q[h]=!0;for(h in mist.data.active_streams)Q[mist.data.active_streams[h]]=!0;var Q=Object.keys(Q).sort(),ga=[];for(h in mist.data.config.protocols)ga.push(mist.data.config.protocols[h].connector);ga.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;
|
d.append(B);var n={graph:"new"},w=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},Q={};for(h in mist.data.streams)Q[h]=!0;for(h in mist.data.active_streams)Q[mist.data.active_streams[h]]=!0;var Q=Object.keys(Q).sort(),ga=[];for(h in mist.data.config.protocols)ga.push(mist.data.config.protocols[h].connector);ga.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+
|
||||||
B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
||||||
false);b.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{msg:"This graph id has already been used. Please enter something else.",
|
false);b.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{msg:"This graph id has already been used. Please enter something else.",
|
||||||
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+
|
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+
|
||||||
'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
||||||
|
|
|
@ -5212,6 +5212,7 @@ var UI = {
|
||||||
['CONN_CLOSE', 'CONN_CLOSE: right after a connection has been closed'],
|
['CONN_CLOSE', 'CONN_CLOSE: right after a connection has been closed'],
|
||||||
['CONN_PLAY', 'CONN_PLAY: right before a stream playback of a connection'],
|
['CONN_PLAY', 'CONN_PLAY: right before a stream playback of a connection'],
|
||||||
['USER_NEW', 'USER_NEW: a new user connects that hasn\'t been allowed or denied access before'],
|
['USER_NEW', 'USER_NEW: a new user connects that hasn\'t been allowed or denied access before'],
|
||||||
|
['USER_END', 'USER_END: a user session disconnects after receiving some media'],
|
||||||
['LIVE_BANDWIDTH','LIVE_BANDWIDTH: when the value specified as param is surpassed']
|
['LIVE_BANDWIDTH','LIVE_BANDWIDTH: when the value specified as param is surpassed']
|
||||||
],
|
],
|
||||||
LTSonly: true,
|
LTSonly: true,
|
||||||
|
|
|
@ -153,6 +153,12 @@ namespace Controller {
|
||||||
trgs["USER_NEW"]["response"] = "always";
|
trgs["USER_NEW"]["response"] = "always";
|
||||||
trgs["USER_NEW"]["response_action"] = "If false, denies the session while it remains in the cache. If true, accepts the session while it remains in the cache.";
|
trgs["USER_NEW"]["response_action"] = "If false, denies the session while it remains in the cache. If true, accepts the session while it remains in the cache.";
|
||||||
|
|
||||||
|
trgs["USER_END"]["when"] = "Every time a session ends (same time it is written to the access log)";
|
||||||
|
trgs["USER_END"]["stream_specific"] = true;
|
||||||
|
trgs["USER_END"]["payload"] = "session identifier (hexadecimal string)\nstream name (string)\nconnector (string)\nconnection address (string)\nduration in seconds (integer)\nuploaded bytes total (integer)\ndownloaded bytes total (integer)\ntags (string)";
|
||||||
|
trgs["USER_END"]["response"] = "ignored";
|
||||||
|
trgs["USER_END"]["response_action"] = "None.";
|
||||||
|
|
||||||
trgs["LIVE_BANDWIDTH"]["when"] = "Every time a new live stream key frame is received";
|
trgs["LIVE_BANDWIDTH"]["when"] = "Every time a new live stream key frame is received";
|
||||||
trgs["LIVE_BANDWIDTH"]["stream_specific"] = true;
|
trgs["LIVE_BANDWIDTH"]["stream_specific"] = true;
|
||||||
trgs["LIVE_BANDWIDTH"]["payload"] = "stream name (string)\ncurrent bytes per second (integer)";
|
trgs["LIVE_BANDWIDTH"]["payload"] = "stream name (string)\ncurrent bytes per second (integer)";
|
||||||
|
|
|
@ -92,6 +92,12 @@ namespace Controller{
|
||||||
rlxAccs->setString("tags", tags, newEndPos);
|
rlxAccs->setString("tags", tags, newEndPos);
|
||||||
rlxAccs->setEndPos(newEndPos + 1);
|
rlxAccs->setEndPos(newEndPos + 1);
|
||||||
}
|
}
|
||||||
|
if (Triggers::shouldTrigger("USER_END", strm)){
|
||||||
|
std::stringstream plgen;
|
||||||
|
plgen << sessId << "\n" << strm << "\n" << conn << "\n" << host << "\n" << duration << "\n" << up << "\n" << down << "\n" << tags;
|
||||||
|
std::string payload = plgen.str();
|
||||||
|
Triggers::doTrigger("USER_END", payload, strm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Write contents to Filename
|
///\brief Write contents to Filename
|
||||||
|
|
Loading…
Add table
Reference in a new issue