1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-28 08:52:35 +02:00

Fix messaging hang by output

This commit is contained in:
Alexandre Iooss
2020-10-18 15:13:13 +02:00
parent 09a3422d06
commit 37d944621b
3 changed files with 19 additions and 23 deletions

View File

@ -21,12 +21,12 @@ func handleStreamer(socket *srtgo.SrtSocket, streams map[string]*stream.Stream,
st := stream.New()
streams[name] = st
// Create a new buffer
// UDP packet cannot be larger than MTU (1500)
buff := make([]byte, 1500)
// Read RTP packets forever and send them to the WebRTC Client
for {
// Create a new buffer
// UDP packet cannot be larger than MTU (1500)
buff := make([]byte, 1500)
// 5s timeout
n, err := socket.Read(buff, 5000)
if err != nil {
@ -41,11 +41,8 @@ func handleStreamer(socket *srtgo.SrtSocket, streams map[string]*stream.Stream,
}
// Send raw data to other streams
// Copy data in another buffer to ensure that the data would not be overwritten
// FIXME: might be unnecessary
data := make([]byte, n)
copy(data, buff[:n])
st.Broadcast <- data
buff = buff[:n]
st.Broadcast <- buff
}
// Close stream