mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 07:36:57 +08:00
move format processors into dedicated folder
This commit is contained in:
48
internal/formatprocessor/processor.go
Normal file
48
internal/formatprocessor/processor.go
Normal file
@@ -0,0 +1,48 @@
|
||||
// Package formatprocessor contains code to cleanup and normalize streams.
|
||||
package formatprocessor
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
|
||||
"github.com/aler9/gortsplib/v2/pkg/format"
|
||||
)
|
||||
|
||||
// Data is the elementary data unit routed across the server.
|
||||
type Data interface {
|
||||
GetRTPPackets() []*rtp.Packet
|
||||
GetNTP() time.Time
|
||||
}
|
||||
|
||||
// Processor allows to cleanup and normalize streams.
|
||||
type Processor interface {
|
||||
// cleanups and normalizes a data unit.
|
||||
Process(Data, bool) error
|
||||
}
|
||||
|
||||
// New allocates a Processor.
|
||||
func New(forma format.Format, generateRTPPackets bool) (Processor, error) {
|
||||
switch forma := forma.(type) {
|
||||
case *format.H264:
|
||||
return newH264(forma, generateRTPPackets)
|
||||
|
||||
case *format.H265:
|
||||
return newH265(forma, generateRTPPackets)
|
||||
|
||||
case *format.VP8:
|
||||
return newVP8(forma, generateRTPPackets)
|
||||
|
||||
case *format.VP9:
|
||||
return newVP9(forma, generateRTPPackets)
|
||||
|
||||
case *format.MPEG4Audio:
|
||||
return newMPEG4Audio(forma, generateRTPPackets)
|
||||
|
||||
case *format.Opus:
|
||||
return newOpus(forma, generateRTPPackets)
|
||||
|
||||
default:
|
||||
return newGeneric(forma, generateRTPPackets)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user