Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env /usr/local/bin/astra_5
- logfile = "/var/log/astra_5.log"
- os.remove(logfile)
- log.set({ filename = logfile })
- pidfile("/var/run/astra_5.pid")
- ntv3 = newcamd({ name = 'ntv3', host = '127.0.0.1', port = 50003, user = 'user1', pass = 'pass1', key = '0102030405060708091011121314', cas_data = '040600'})
- ntv4 = newcamd({ name = 'ntv4', host = '127.0.0.1', port = 50004, user = 'user1', pass = 'pass1', key = '0102030405060708091011121314', cas_data = '040600'})
- channels = {
- { name = "Bober", input = {"dvb://ntv_11862_5#pnr=1501&cam=ntv3"}, output = {"udp://192.168.2.25@239.0.100.60#sync"}},
- { name = "Dom zhivotnye", input = {"dvb://ntv_11862_5#pnr=1502&cam=ntv3"}, output = {"udp://192.168.2.25@239.0.100.62#sync"}},
- { name = "Extreme sports", input = {"dvb://ntv_11862_5#pnr=1507&cam=ntv4"}, output = {"udp://192.168.2.25@239.0.100.63#sync"}},
- { name = "Nat Geo Wild", input = {"dvb://ntv_11862_5#pnr=1510&cam=ntv3"}, output = {"udp://192.168.2.25@239.0.100.64#sync"}},
- { name = "Psihologia 21", input = {"dvb://ntv_11862_5#pnr=1504&cam=ntv3"}, output = {"udp://192.168.2.25@239.0.100.65#sync"}},
- }
- -- declare
- _an = {}
- local hostname = utils.hostname()
- local content = ""
- local _t = 10 -- timer start signal
- function send_monitor(content)
- http_request({
- host = "127.0.0.1",
- path = "/?mod=tvstat",
- method = "POST",
- content = content,
- port = 80,
- headers = {
- "User-Agent: Astra v." .. astra.version,
- "Host: " .. hostname,
- "Content-Type: application/x-www-form-urlencoded",
- "Content-Length: " .. #content,
- "Connection: close",
- },
- callback = function(s,r)
- --dump_table(r)
- end
- })
- end
- -- settings tuner
- local tune_conf = { name = "ntv_11862_5", adapter = 5, type = "S2", frequency = 11862, lnb_sharing = false, polarization = "R", symbolrate = 27500, lof1 = 10750, lof2 = 10750, slof = 10750, modulation = "PSK8",
- callback = function(data)
- --dump_table(data)
- _t = _t + 1
- if(_t == 15)then
- bitrate = "calc"
- snr = data.signal * 100 / 65535
- if(snr>100)then
- snr = 99
- end
- if(data.status == 31)then
- lock = 1
- else
- lock = 0
- end
- content = "type=dvb&stream=ntv_11862_5&adapter=5&server=" .. hostname .. "&lock=" .. lock .. "&bitrate=" .. bitrate .. "&snr=" .. snr .. "&ber=" .. data.ber .. "&unc=" .. data.unc
- send_monitor(content)
- --log.info(content)
- _t = 0
- end
- end
- }
- ntv_11862_5 = dvb_input(tune_conf)
- for q,item in pairs(channels)do
- local output = item.output[1]
- make_channel(item)
- _an[q] = {i = {}, a = {}, t = 20}
- _an[q].i = udp_input(parse_url(item.output[1]))
- _an[q].a = analyze({
- upstream = _an[q].i:stream(),
- name = "_" .. item.name,
- callback = function(data)
- --dump_table(data)
- if(data.total and ((_an[q].t==30) or (data.total.cc_errors > 5 or data.total.pes_errors > 5
- or data.total.scrambled or data.on_air==false or data.total.bitrate<50)))then
- local scram = 0
- local onair = 0
- if(data.total.scrambled==true) then
- scram = 1
- end
- if(data.on_air==true) then
- onair = 1
- end
- content = "type=channel&server=" .. hostname .. "&adapter=" .. tune_conf.adapter .. "&channel=" .. item.name .. "&output=" .. output .. "&stream=" .. tune_conf.name .. "&scrambled=" .. scram .. "&bitrate=" .. data.total.bitrate .. "&cc_error=" .. data.total.cc_errors .. "&pes_error=" .. data.total.pes_errors .. "&ready=" .. onair
- send_monitor(content)
- _an[q].t = 0
- end
- _an[q].t = _an[q].t + 1
- end
- })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement