server: split OnFrame into OnPacketRTP and OnPacketRTCP

This commit is contained in:
aler9
2021-10-30 16:03:08 +02:00
committed by Alessandro Ros
parent 62bd19f770
commit 472430f900
8 changed files with 111 additions and 56 deletions

View File

@@ -124,14 +124,25 @@ func (sh *serverHandler) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*bas
}, nil
}
// called after receiving a frame.
func (sh *serverHandler) OnFrame(ctx *gortsplib.ServerHandlerOnFrameCtx) {
// called after receiving a RTP packet.
func (sh *serverHandler) OnPacketRTP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx) {
sh.mutex.Lock()
defer sh.mutex.Unlock()
// if we are the publisher, route frames to readers
// if we are the publisher, route packet to readers
if ctx.Session == sh.publisher {
sh.stream.WriteFrame(ctx.TrackID, ctx.StreamType, ctx.Payload)
sh.stream.WriteFrame(ctx.TrackID, gortsplib.StreamTypeRTP, ctx.Payload)
}
}
// called after receiving a RTCP packet.
func (sh *serverHandler) OnPacketRTCP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx) {
sh.mutex.Lock()
defer sh.mutex.Unlock()
// if we are the publisher, route packet to readers
if ctx.Session == sh.publisher {
sh.stream.WriteFrame(ctx.TrackID, gortsplib.StreamTypeRTCP, ctx.Payload)
}
}