mediamtx/internal/stream/stream_media.go
Alessandro Ros 4c3ac34425
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (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_highlevel (push) Waiting to run
fix memory leak in case of errors during initialization of a reader (#3831)
2024-10-05 00:49:44 +02:00

38 lines
813 B
Go

package stream
import (
"github.com/bluenviron/gortsplib/v4/pkg/description"
"github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediamtx/internal/logger"
)
type streamMedia struct {
formats map[format.Format]*streamFormat
}
func newStreamMedia(udpMaxPayloadSize int,
medi *description.Media,
generateRTPPackets bool,
decodeErrLogger logger.Writer,
) (*streamMedia, error) {
sm := &streamMedia{
formats: make(map[format.Format]*streamFormat),
}
for _, forma := range medi.Formats {
sf := &streamFormat{
udpMaxPayloadSize: udpMaxPayloadSize,
format: forma,
generateRTPPackets: generateRTPPackets,
decodeErrLogger: decodeErrLogger,
}
err := sf.initialize()
if err != nil {
return nil, err
}
sm.formats[forma] = sf
}
return sm, nil
}