Skip to content

Commit

Permalink
remove workaround for pion/rtp < 1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Aug 1, 2023
1 parent 66aa844 commit 7b2e4d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 1 addition & 24 deletions client_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gortsplib

import (
"fmt"
"io"
"time"

"github.com/pion/rtcp"
Expand All @@ -15,28 +14,6 @@ import (
"github.com/bluenviron/gortsplib/v3/pkg/rtpreorderer"
)

// workaround until this gets tagged:
// https://github.com/pion/rtp/pull/234
func rtpPacketMarshalToSafe(p *rtp.Packet, buf []byte) (n int, err error) {
n, err = p.Header.MarshalTo(buf)
if err != nil {
return 0, err
}

// Make sure the buffer is large enough to hold the packet.
if n+len(p.Payload)+int(p.PaddingSize) > len(buf) {
return 0, io.ErrShortBuffer
}

m := copy(buf[n:], p.Payload)

if p.Header.Padding {
buf[n+m+int(p.PaddingSize-1)] = p.PaddingSize
}

return n + m + int(p.PaddingSize), nil
}

type clientFormat struct {
c *Client
cm *clientMedia
Expand Down Expand Up @@ -103,7 +80,7 @@ func (ct *clientFormat) stop() {

func (ct *clientFormat) writePacketRTPWithNTP(pkt *rtp.Packet, ntp time.Time) error {
byts := make([]byte, udpMaxPayloadSize)
n, err := rtpPacketMarshalToSafe(pkt, byts)
n, err := pkt.MarshalTo(byts)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion server_stream_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (sm *serverStreamMedia) allocateMulticastHandler(s *Server) error {

func (sm *serverStreamMedia) WritePacketRTPWithNTP(ss *ServerStream, pkt *rtp.Packet, ntp time.Time) {
byts := make([]byte, udpMaxPayloadSize)
n, err := rtpPacketMarshalToSafe(pkt, byts)
n, err := pkt.MarshalTo(byts)
if err != nil {
return
}
Expand Down

0 comments on commit 7b2e4d9

Please sign in to comment.