add auth endpoint for on_publish

This commit is contained in:
dreamer 2021-05-11 20:44:42 +02:00
parent a2ad5e3d8c
commit e9bb401170
3 changed files with 30 additions and 0 deletions

View File

@ -11,4 +11,8 @@ app:get("/", function(self)
return handlers.Roothandler(self) return handlers.Roothandler(self)
end) end)
app:post("/auth", function(self)
return handlers.Authhandler(self)
end)
return app return app

View File

@ -0,0 +1,24 @@
local autoload = require("lapis.util").autoload
local function Authhandler(self)
local name = self.params.name
local password = self.params.password
print(name)
print(password)
local endpoints = {
puik='something',
wstd='something',
buzz='something'
}
if endpoints[name] == password then
return {status = 201}
else
return {status = 404}
end
end
return Authhandler

View File

@ -15,6 +15,8 @@ rtmp {
application stream { application stream {
live on; live on;
on_publish http://localhost:${{PORT}}/auth;
#relays the incoming video to low quality streams on this server, audio-only version and to a different server #relays the incoming video to low quality streams on this server, audio-only version and to a different server
exec ffmpeg -i rtmp://localhost:1935/stream/$name exec ffmpeg -i rtmp://localhost:1935/stream/$name
-c:a copy -c:v copy -f flv rtmp://localhost/hls/$name_hi; -c:a copy -c:v copy -f flv rtmp://localhost/hls/$name_hi;