mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 06:46:42 +08:00
update doc
This commit is contained in:
@@ -61,13 +61,13 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP frames from the source
|
||||
// read RTP packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// write RTP frames
|
||||
// write RTP packets
|
||||
err = conn.WriteFrame(0, gortsplib.StreamTypeRTP, buf[:n])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -57,13 +57,13 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP frames from the source
|
||||
// read RTP packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
// write RTP frames
|
||||
// write RTP packets
|
||||
err = conn.WriteFrame(0, gortsplib.StreamTypeRTP, buf[:n])
|
||||
if err != nil {
|
||||
break
|
||||
|
@@ -49,13 +49,13 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP frames from the source
|
||||
// read RTP packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// write RTP frames
|
||||
// write RTP packets
|
||||
err = conn.WriteFrame(0, gortsplib.StreamTypeRTP, buf[:n])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -37,10 +37,10 @@ func main() {
|
||||
// instantiate a RTP/H264 decoder
|
||||
dec := rtph264.NewDecoder()
|
||||
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
|
||||
if streamType == gortsplib.StreamTypeRTP && trackID == h264Track {
|
||||
// convert RTP frames into H264 NALUs
|
||||
// convert RTP packets into H264 NALUs
|
||||
nalus, _, err := dec.Decode(payload)
|
||||
if err != nil {
|
||||
return
|
||||
|
@@ -29,7 +29,7 @@ func main() {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
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))
|
||||
})
|
||||
|
@@ -51,7 +51,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
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))
|
||||
})
|
||||
|
@@ -22,7 +22,7 @@ func main() {
|
||||
defer conn.Close()
|
||||
|
||||
for {
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
|
@@ -77,7 +77,7 @@ func main() {
|
||||
})
|
||||
mux.SetPCRPID(256)
|
||||
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
|
||||
if trackID != h264TrackID {
|
||||
return
|
||||
@@ -94,7 +94,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// convert RTP frames into H264 NALUs
|
||||
// convert RTP packets into H264 NALUs
|
||||
nalus, pts, err := dec.DecodeRTP(&pkt)
|
||||
if err != nil {
|
||||
return
|
||||
|
@@ -17,7 +17,7 @@ func main() {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// read RTP frames
|
||||
// read RTP packets
|
||||
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))
|
||||
})
|
||||
|
@@ -53,7 +53,7 @@ func New(receiverSSRC *uint32, clockRate int) *RTCPReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessFrame extracts the needed data from RTP or RTCP frames.
|
||||
// ProcessFrame extracts the needed data from RTP or RTCP packets.
|
||||
func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, payload []byte) {
|
||||
rr.mutex.Lock()
|
||||
defer rr.mutex.Unlock()
|
||||
@@ -115,8 +115,8 @@ func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, p
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// we can afford to unmarshal all RTCP frames
|
||||
// since they are sent with a frequency much lower than the one of RTP frames
|
||||
// we can afford to unmarshal all RTCP packets
|
||||
// since they are sent with a frequency much lower than the one of RTP packets
|
||||
frames, err := rtcp.Unmarshal(payload)
|
||||
if err == nil {
|
||||
for _, frame := range frames {
|
||||
|
@@ -32,7 +32,7 @@ func New(clockRate int) *RTCPSender {
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessFrame extracts the needed data from RTP or RTCP frames.
|
||||
// ProcessFrame extracts the needed data from RTP or RTCP packets.
|
||||
func (rs *RTCPSender) ProcessFrame(ts time.Time, streamType base.StreamType, payload []byte) {
|
||||
rs.mutex.Lock()
|
||||
defer rs.mutex.Unlock()
|
||||
|
@@ -512,7 +512,7 @@ func (sc *ServerConn) handleRequestOuter(req *base.Request) error {
|
||||
sc.tcpFrameBuffer = multibuffer.New(uint64(sc.s.ReadBufferCount), uint64(sc.s.ReadBufferSize))
|
||||
} else {
|
||||
// when playing, tcpFrameBuffer is only used to receive RTCP receiver reports,
|
||||
// that are much smaller than RTP frames and are sent at a fixed interval
|
||||
// that are much smaller than RTP packets and are sent at a fixed interval
|
||||
// (about 2 frames every 10 secs).
|
||||
// decrease RAM consumption by allocating less buffers.
|
||||
sc.tcpFrameBuffer = multibuffer.New(8, uint64(sc.s.ReadBufferSize))
|
||||
|
@@ -836,7 +836,7 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base
|
||||
if *ss.setuppedProtocol == base.StreamProtocolUDP {
|
||||
if *ss.setuppedDelivery == base.StreamDeliveryUnicast {
|
||||
for trackID, track := range ss.setuppedTracks {
|
||||
// readers can send RTCP frames
|
||||
// readers can send RTCP packets
|
||||
sc.s.udpRTCPListener.addClient(ss.ip(), track.udpRTCPPort, ss, trackID, false)
|
||||
|
||||
// open the firewall by sending packets to the counterpart
|
||||
|
Reference in New Issue
Block a user