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

Copy track SSRC and payload, working webrtc!

This commit is contained in:
Alexandre Iooss 2020-10-05 10:26:08 +02:00
parent e8f4cd7683
commit 2a3b79734a
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02

View File

@ -68,7 +68,6 @@ func ingestFrom(inputChannel chan srt.Packet) {
// Receive video // Receive video
go func() { go func() {
for { for {
// Listen for a single RTP Packet, we need this to determine the SSRC
inboundRTPPacket := make([]byte, 1500) // UDP MTU inboundRTPPacket := make([]byte, 1500) // UDP MTU
n, _, err := videoListener.ReadFromUDP(inboundRTPPacket) n, _, err := videoListener.ReadFromUDP(inboundRTPPacket)
if err != nil { if err != nil {
@ -79,7 +78,12 @@ func ingestFrom(inputChannel chan srt.Packet) {
panic(err) panic(err)
} }
log.Printf("[Video] %s", packet) log.Printf("[Video] %s", packet)
// Write RTP packet to all video tracks
// Adapt payload and SSRC to match destination
for _, videoTrack := range videoTracks { for _, videoTrack := range videoTracks {
packet.Header.PayloadType = videoTrack.PayloadType()
packet.Header.SSRC = videoTrack.SSRC()
if writeErr := videoTrack.WriteRTP(packet); writeErr != nil { if writeErr := videoTrack.WriteRTP(packet); writeErr != nil {
panic(err) panic(err)
} }
@ -90,7 +94,6 @@ func ingestFrom(inputChannel chan srt.Packet) {
// Receive audio // Receive audio
go func() { go func() {
for { for {
// Listen for a single RTP Packet, we need this to determine the SSRC
inboundRTPPacket := make([]byte, 1500) // UDP MTU inboundRTPPacket := make([]byte, 1500) // UDP MTU
n, _, err := audioListener.ReadFromUDP(inboundRTPPacket) n, _, err := audioListener.ReadFromUDP(inboundRTPPacket)
if err != nil { if err != nil {
@ -102,6 +105,8 @@ func ingestFrom(inputChannel chan srt.Packet) {
} }
log.Printf("[Audio] %s", packet) log.Printf("[Audio] %s", packet)
for _, audioTrack := range audioTracks { for _, audioTrack := range audioTracks {
packet.Header.PayloadType = audioTrack.PayloadType()
packet.Header.SSRC = audioTrack.SSRC()
if writeErr := audioTrack.WriteRTP(packet); writeErr != nil { if writeErr := audioTrack.WriteRTP(packet); writeErr != nil {
panic(err) panic(err)
} }