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

Use external configuration to setup multicasts

This commit is contained in:
Yohann D'ANELLO
2020-09-29 22:40:49 +02:00
parent 2920b6883c
commit 5fa492547b
4 changed files with 62 additions and 15 deletions

View File

@ -53,16 +53,18 @@ func Serve(cfg *Options) {
buff := make([]byte, 2048)
n, err := s.Read(buff, 10000)
multicast.SendPacket("demo", buff[:n])
if err != nil {
log.Println("Error occurred while reading SRT socket:", err)
break
}
if n == 0 {
// End of stream
multicast.CloseConnection("demo")
break
}
multicast.SendPacket("demo", buff[:n])
// Unmarshal the incoming packet
packet := &rtp.Packet{}
if err = packet.Unmarshal(buff[:n]); err != nil {
@ -81,10 +83,11 @@ func Serve(cfg *Options) {
break
}
multicast.SendPacket("demo", buff[:n])
log.Printf("Received %d bytes", n)
packet := &rtp.Packet{}
multicast.SendPacket("demo", buff[:n])
if err := packet.Unmarshal(buff[:n]); err != nil {
panic(err)
}