Following a very short server application to allow to receive a stream sending by gstreamer, and create a cumulus publication with (to be readen by RTMFP clients with NetStream::play of course):
socket = cumulus:createUDPSocket()
function socket:onReception(data, address)
-- consider just video and audio packets
if data:byte(1) ~= 0x09 and data:byte(1) ~= 0x08 then return end
-- compute time
local time = data:byte(5)*65536+data:byte(6)*256+data:byte(7)
if not starttime or starttime>time then starttime = time end
time = time-starttime
if not lasttime or time<lasttime then
-- start or restart publication
if testpublication then testpublication:close() end
testpublication = cumulus:publish("file")
if not testpublication then error("already published") end
end
lasttime = time
-- publish
if data:byte(1)==0x09 then
testpublication:pushVideoPacket(time, data,11) -- offset 11
else
testpublication:pushAudioPacket(time, data,11) -- offset 11
end
testpublication:flush()
end
if err then error(err) else NOTE("Starting UDP socket on 6666 port") end