diff --git a/examples/client-read-h264/main.go b/examples/client-read-h264/main.go index 78f0db83..b1ec1dda 100644 --- a/examples/client-read-h264/main.go +++ b/examples/client-read-h264/main.go @@ -20,7 +20,7 @@ func main() { } defer conn.Close() - // check whether there's a H264 track + // find the H264 track h264Track := func() int { for i, track := range conn.Tracks() { if track.IsH264() { @@ -34,14 +34,14 @@ func main() { } fmt.Printf("H264 track is number %d\n", h264Track+1) - // instantiate a decoder + // instantiate a RTP/H264 decoder dec := rtph264.NewDecoder() // read RTP frames - err = conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) { + err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { if trackID == h264Track { // convert RTP frames into H264 NALUs - nalus, _, err := dec.Decode(buf) + nalus, _, err := dec.Decode(payload) if err != nil { return } diff --git a/examples/client-read-options/main.go b/examples/client-read-options/main.go index 7634ab54..131d56d4 100644 --- a/examples/client-read-options/main.go +++ b/examples/client-read-options/main.go @@ -30,8 +30,8 @@ func main() { defer conn.Close() // read RTP frames - err = conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) { - fmt.Printf("frame from track %d, type %v, size %d\n", trackID, typ, len(buf)) + err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { + fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) }) panic(err) } diff --git a/examples/client-read-partial/main.go b/examples/client-read-partial/main.go index b9c8c3db..a0e8cc99 100644 --- a/examples/client-read-partial/main.go +++ b/examples/client-read-partial/main.go @@ -52,8 +52,8 @@ func main() { } // read RTP frames - err = conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) { - fmt.Printf("frame from track %d, type %v, size %d\n", trackID, typ, len(buf)) + err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { + fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) }) panic(err) } diff --git a/examples/client-read-pause/main.go b/examples/client-read-pause/main.go index d5427317..b9809419 100644 --- a/examples/client-read-pause/main.go +++ b/examples/client-read-pause/main.go @@ -26,8 +26,8 @@ func main() { done := make(chan struct{}) go func() { defer close(done) - conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) { - fmt.Printf("frame from track %d, type %v, size %d\n", trackID, typ, len(buf)) + conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { + fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) }) }() diff --git a/examples/client-read/main.go b/examples/client-read/main.go index f3dbc907..fafe5763 100644 --- a/examples/client-read/main.go +++ b/examples/client-read/main.go @@ -18,8 +18,8 @@ func main() { defer conn.Close() // read RTP frames - err = conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) { - fmt.Printf("frame from track %d, type %v, size %d\n", trackID, typ, len(buf)) + err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { + fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) }) panic(err) } diff --git a/pkg/rtcpreceiver/rtcpreceiver.go b/pkg/rtcpreceiver/rtcpreceiver.go index 6d3349d8..e49ba690 100644 --- a/pkg/rtcpreceiver/rtcpreceiver.go +++ b/pkg/rtcpreceiver/rtcpreceiver.go @@ -48,15 +48,15 @@ func New(receiverSSRC *uint32, clockRate int) *RTCPReceiver { } // ProcessFrame extracts the needed data from RTP or RTCP frames. -func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, buf []byte) { +func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, payload []byte) { rr.mutex.Lock() defer rr.mutex.Unlock() if streamType == base.StreamTypeRTP { // do not parse the entire packet, extract only the fields we need - if len(buf) >= 8 { - sequenceNumber := uint16(buf[2])<<8 | uint16(buf[3]) - rtpTime := uint32(buf[4])<<24 | uint32(buf[5])<<16 | uint32(buf[6])<<8 | uint32(buf[7]) + if len(payload) >= 8 { + sequenceNumber := uint16(payload[2])<<8 | uint16(payload[3]) + rtpTime := uint32(payload[4])<<24 | uint32(payload[5])<<16 | uint32(payload[6])<<8 | uint32(payload[7]) // first frame if !rr.firstRTPReceived { @@ -111,7 +111,7 @@ func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, b } else { // we can afford to unmarshal all RTCP frames // since they are sent with a frequency much lower than the one of RTP frames - frames, err := rtcp.Unmarshal(buf) + frames, err := rtcp.Unmarshal(payload) if err == nil { for _, frame := range frames { if sr, ok := (frame).(*rtcp.SenderReport); ok { diff --git a/pkg/rtcpsender/rtcpsender.go b/pkg/rtcpsender/rtcpsender.go index bab5e537..d71b97dc 100644 --- a/pkg/rtcpsender/rtcpsender.go +++ b/pkg/rtcpsender/rtcpsender.go @@ -33,13 +33,13 @@ func New(clockRate int) *RTCPSender { } // ProcessFrame extracts the needed data from RTP or RTCP frames. -func (rs *RTCPSender) ProcessFrame(ts time.Time, streamType base.StreamType, buf []byte) { +func (rs *RTCPSender) ProcessFrame(ts time.Time, streamType base.StreamType, payload []byte) { rs.mutex.Lock() defer rs.mutex.Unlock() if streamType == base.StreamTypeRTP { pkt := rtp.Packet{} - err := pkt.Unmarshal(buf) + err := pkt.Unmarshal(payload) if err == nil { if !rs.firstRTPReceived { rs.firstRTPReceived = true