1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 18:32:19 +00:00

🐛 Copy SRT data in another buffer before sending it in the forwarding package to avoid overwriting issues

This commit is contained in:
Yohann D'ANELLO 2020-10-01 18:54:35 +02:00
parent ee1f1e331b
commit e74213fefa

View File

@ -84,7 +84,10 @@ func Serve(cfg *Options, forwardingChannel chan Packet) {
// log.Printf("Received %d bytes", n)
// Send raw packet to other streams
forwardingChannel <- Packet{StreamName: "demo", PacketType: "sendData", Data: buff[:n]}
// Copy data in another buffer to ensure that the data would not be overwritten
data := make([]byte, n)
copy(data, buff[:n])
forwardingChannel <- Packet{StreamName: "demo", PacketType: "sendData", Data: data}
// TODO: Send to WebRTC
// See https://github.com/ebml-go/webm/blob/master/reader.go