Advertisement
and_cesbo

Astra. API method to change input

Jun 17th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. -- Script for Astra 5.62 and newer
  2. -- Script implements API method to switch between inputs
  3. -- Installation: Save script input /etc/astra/mod/change-input.lua
  4. -- Usage:
  5. -- 1. Create new stream
  6. -- 2. In the stream settings set "Backup Type" to "Passive Backup"
  7. -- 3. Save stream and check stream ID, you may find in the stream settings or in the URL. For example : http://server.local:8000/#/stream/server.local:8000/a018 "a018" - this is stream ID
  8. -- 4. Call API method: curl -X POST -d "{\"cmd\":\"change-input\",\"id\":\"a018\"}" http://admin:password@server.local:8000/control/
  9. -- server.local - this is server address
  10. -- 8000 - port to the Astra web interface
  11. -- a018 - stream ID
  12.  
  13. control_api["change-input"] = function(server, client, data)
  14.     local channel_data = channel_list_ID[data.id]
  15.     if not channel_data then
  16.         control_api_response(server, client, { ["change-input"] = "er" })
  17.         return nil
  18.     end
  19.  
  20.     local input_id = channel_data.active_input_id
  21.     local next_input_id = input_id + 1
  22.     if next_input_id > #channel_data.input then
  23.         next_input_id = 1
  24.     end
  25.     channel_kill_input(channel_data, input_id)
  26.     log.debug("[" .. channel_data.config.name .. "] Destroy input #" .. input_id)
  27.     channel_data.active_input_id = -1
  28.     collectgarbage()
  29.  
  30.     channel_init_input(channel_data, next_input_id)
  31.     control_api_response(server, client, { ["change-input"] = "ok" })
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement