From 490d6ab7fa0f77c2a7682d34be05ace191761ef3 Mon Sep 17 00:00:00 2001 From: Justine Alexandra Roberts Tunney Date: Tue, 21 Jul 2015 18:18:29 -0400 Subject: [PATCH] Change RTP code to make sending Opus possible. --- rtp/session.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rtp/session.go b/rtp/session.go index 7028c05..fee65ea 100644 --- a/rtp/session.go +++ b/rtp/session.go @@ -84,6 +84,17 @@ func (rs *Session) Send(frame *Frame) (err error) { return } +func (rs *Session) SendRaw(data []byte, samps uint32) (err error) { + if rs == nil || rs.Sock == nil || rs.Peer == nil { + return nil + } + rs.Header.Write(rs.obuf) + rs.Header.TS += samps + rs.Header.Seq++ + _, err = rs.Sock.WriteTo(append(rs.obuf[:HeaderSize], data...), rs.Peer) + return +} + func (rs *Session) Close() { if rs == nil || rs.Sock == nil { return @@ -142,6 +153,9 @@ func receiver(sock *net.UDPConn, c chan<- *Frame, e chan<- error, r <-chan *Fram } func listenRTP(host string) (sock net.PacketConn, err error) { + if strings.Contains(host, ":") { + return net.ListenPacket("udp", host) + } for i := 0; i < rtpBindMaxAttempts; i++ { port := rtpBindPortMin + rand.Int63()%(rtpBindPortMax-rtpBindPortMin+1) saddr := net.JoinHostPort(host, strconv.FormatInt(port, 10))