mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Stream units now share the same struct, with a specialized payload.
47 lines
978 B
Go
47 lines
978 B
Go
package codecprocessor
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bluenviron/gortsplib/v5/pkg/format"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/logger"
|
|
"github.com/bluenviron/mediamtx/internal/unit"
|
|
)
|
|
|
|
type generic struct {
|
|
RTPMaxPayloadSize int
|
|
Format format.Format
|
|
GenerateRTPPackets bool
|
|
Parent logger.Writer
|
|
}
|
|
|
|
func (t *generic) initialize() error {
|
|
if t.GenerateRTPPackets {
|
|
return fmt.Errorf("we don't know how to generate RTP packets of format %T", t.Format)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (t *generic) ProcessUnit(_ *unit.Unit) error {
|
|
return fmt.Errorf("using a generic unit without RTP is not supported")
|
|
}
|
|
|
|
func (t *generic) ProcessRTPPacket(
|
|
u *unit.Unit,
|
|
_ bool,
|
|
) error {
|
|
pkt := u.RTPPackets[0]
|
|
|
|
// remove padding
|
|
pkt.Padding = false
|
|
pkt.PaddingSize = 0
|
|
|
|
if len(pkt.Payload) > t.RTPMaxPayloadSize {
|
|
return fmt.Errorf("RTP payload size (%d) is greater than maximum allowed (%d)",
|
|
len(pkt.Payload), t.RTPMaxPayloadSize)
|
|
}
|
|
|
|
return nil
|
|
}
|