2023-07-30 20:34:35 +00:00
|
|
|
package stream
|
2022-12-13 19:54:17 +00:00
|
|
|
|
|
|
|
import (
|
2023-08-26 16:54:28 +00:00
|
|
|
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
|
|
|
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
2023-07-30 20:34:35 +00:00
|
|
|
|
|
|
|
"github.com/bluenviron/mediamtx/internal/logger"
|
2022-12-13 19:54:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type streamMedia struct {
|
2023-08-26 16:54:28 +00:00
|
|
|
formats map[format.Format]*streamFormat
|
2022-12-13 19:54:17 +00:00
|
|
|
}
|
|
|
|
|
2023-03-31 09:53:49 +00:00
|
|
|
func newStreamMedia(udpMaxPayloadSize int,
|
2023-08-26 16:54:28 +00:00
|
|
|
medi *description.Media,
|
2023-03-31 09:53:49 +00:00
|
|
|
generateRTPPackets bool,
|
2023-08-26 21:34:39 +00:00
|
|
|
decodeErrLogger logger.Writer,
|
2023-03-31 09:53:49 +00:00
|
|
|
) (*streamMedia, error) {
|
2022-12-13 19:54:17 +00:00
|
|
|
sm := &streamMedia{
|
2023-08-26 16:54:28 +00:00
|
|
|
formats: make(map[format.Format]*streamFormat),
|
2022-12-13 19:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, forma := range medi.Formats {
|
|
|
|
var err error
|
2023-08-26 21:34:39 +00:00
|
|
|
sm.formats[forma], err = newStreamFormat(udpMaxPayloadSize, forma, generateRTPPackets, decodeErrLogger)
|
2022-12-13 19:54:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sm, nil
|
|
|
|
}
|