Skip to content

Commit ba8ba96

Browse files
committed
supporting drop publisher via control module
1 parent 6057362 commit ba8ba96

File tree

6 files changed

+60
-17
lines changed

6 files changed

+60
-17
lines changed

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"rtmp_server_timeout":15000,
66
"rtmp_server_url":"http://localhost/stat.xml",
77
"rtmp_server_stream_url":"rtmp://localhost/live/",
8+
"rtmp_server_control_url":"http://localhost/control",
89
"language":"en",
910
"template":"default",
1011
"version":"1.0.0"

language/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"viewers":"Viewers",
1717
"time":"Time",
1818
"play":"Play",
19+
"drop":"Drop",
1920
"playing":"Playing",
2021
"close":"Close"
21-
}
22+
}

public/js/events.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
function drop_publisher(app_name, stream_name) {
2+
var control_server = $("#control_server").val() + "/drop/publisher?app=" + app_name + "&name=" + stream_name;
3+
console.log('drop: ' + stream_name + ' from URL:' + control_server);
4+
5+
var jqxhr = $.get(control_server, function (data, status) {
6+
console.log('Status: ' + status + ' Data: ' + data);
7+
});
8+
9+
}
10+
11+
function dropStreamEvent() {
12+
13+
$(".drop_stream").click(function () {
14+
var stream_name = $(this).attr('data-stream-name');
15+
16+
$("#stream_drop_popup").modal('show');
17+
18+
$("#modal-btn-yes").on("click", function () {
19+
drop_publisher("live", stream_name);
20+
$("#stream_drop_popup").modal('hide');
21+
});
22+
23+
$("#modal-btn-no").on("click", function () {
24+
$("#stream_drop_popup").modal('hide');
25+
});
26+
});
27+
}
28+
129
function playStreamEvent() {
230

331
var $player;
@@ -27,4 +55,4 @@ function playStreamEvent() {
2755
})
2856

2957

30-
}
58+
}

public/js/model.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function setLiveStream(data)
4848

4949
var table = "";
5050
var language_play = $("#language_play").val();
51-
51+
var language_drop = $("#language_drop").val();
5252
$.each(data, function (index,channel) {
5353

5454

@@ -61,16 +61,14 @@ function setLiveStream(data)
6161
var viewers = "<td class='text-center'><b>"+numeral(channel.nclients[0]).format('0,0')+"<b/></td>";
6262
var resolution = "<td class='text-center'>"+channel.meta[0].video[0].width[0] + " X " + channel.meta[0].video[0].height[0]+"</td>";
6363
var play = "<td><button class='btn btn-default play_stream' data-stream-name='"+channel.name[0]+"' data-toggle='modal' data-target='#stream_popup'><i class='glyphicon glyphicon-play'></i> "+language_play+"</button></td>";
64-
65-
table = table + "<tr>"+name+resolution+bw_in+bw_out+bytes_in+bytes_out+viewers+time+play+"</tr>";
64+
var drop = "<td><button class='btn btn-default drop_stream' data-stream-name='"+channel.name[0]+"'><i class='glyphicon glyphicon-stop'></i> "+language_drop+"</button></td>";
65+
table = table + "<tr>"+name+resolution+bw_in+bw_out+bytes_in+bytes_out+viewers+time+play+drop+"</tr>";
6666

6767
});
6868

6969

7070
$("#live_stream").html(table);
7171

7272
playStreamEvent();
73-
73+
dropStreamEvent();
7474
}
75-
76-

server.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ app.get('/',function(req,res){
2828
title: config.site_title,
2929
language: language,
3030
version:config.version,
31-
stream_server:config.rtmp_server_stream_url
31+
stream_server:config.rtmp_server_stream_url,
32+
control_server:config.rtmp_server_control_url
3233
});
3334
});
3435

@@ -100,10 +101,3 @@ setInterval(function(){
100101
});
101102

102103
},config.rtmp_server_refresh);
103-
104-
105-
106-
107-
108-
109-

template/default.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<a class="navbar-brand" id="uptime"></a>
2323
<div id="show_live"></div>
2424
</div>
25-
</div>
25+
</div>
2626
</div>
2727
<div class="container">
2828

@@ -105,6 +105,7 @@ <h1 style="font-size: 20px" id="total_bandwidth_out">0</h1>
105105
<th class="text-center"><i class='glyphicon glyphicon-user' style='color: #73afff;'></i> {{language.viewers}} </th>
106106
<th class="text-center"><i class='glyphicon glyphicon-time' style='color: #73afff;'></i> {{language.time}}</th>
107107
<th class="text-center"><i class='glyphicon glyphicon-time' style='color: #73afff;'></i> {{language.play}}</th>
108+
<th class="text-center"><i class='glyphicon glyphicon-time' style='color: #73afff;'></i> {{language.drop}}</th>
108109
</tr>
109110
</thead>
110111
<tbody id="live_stream">
@@ -128,6 +129,25 @@ <h1 style="font-size: 20px" id="total_bandwidth_out">0</h1>
128129

129130
<input type="hidden" value="{{language.play}}" id="language_play">
130131
<input type="hidden" value="{{stream_server}}" id="stream_server">
132+
<input type="hidden" value="{{language.drop}}" id="language_drop">
133+
<input type="hidden" value="{{control_server}}" id="control_server">
134+
135+
<div id="stream_drop_popup" class="modal fade" role="dialog">
136+
<div class="modal-dialog modal-sm">
137+
<div class="modal-content">
138+
<div class="modal-header">
139+
<h4 class="modal-title">{{language.drop}} <span id="channel_name"></span></h4>
140+
</div>
141+
<div class="modal-body">
142+
143+
</div>
144+
<div class="modal-footer">
145+
<button type="button" class="btn btn-default" id="modal-btn-yes">Yes</button>
146+
<button type="button" class="btn btn-primary" id="modal-btn-no">No</button>
147+
</div>
148+
</div>
149+
</div>
150+
</div>
131151

132152
<div id="stream_popup" class="modal fade" role="dialog">
133153
<div class="modal-dialog">
@@ -151,6 +171,7 @@ <h4 class="modal-title">{{language.playing}} <span id="channel_name"></span></h4
151171
<script src="js/library/numeral.js"></script>
152172
<script src="js/library/player.min.js"></script>
153173
<script src="js/bootstrap.js"></script>
174+
<script src="js/confirm-bootstrap.js"></script>
154175
<script src="js/socket.js"></script>
155176
<script src="js/message.js"></script>
156177
<script src="js/helper.js"></script>

0 commit comments

Comments
 (0)