2022-05-31 17:17:26 +00:00
|
|
|
package hls
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aler9/gortsplib"
|
|
|
|
)
|
|
|
|
|
|
|
|
type muxerVariantMPEGTS struct {
|
|
|
|
playlist *muxerVariantMPEGTSPlaylist
|
|
|
|
segmenter *muxerVariantMPEGTSSegmenter
|
|
|
|
}
|
|
|
|
|
|
|
|
func newMuxerVariantMPEGTS(
|
|
|
|
segmentCount int,
|
|
|
|
segmentDuration time.Duration,
|
|
|
|
segmentMaxSize uint64,
|
|
|
|
videoTrack *gortsplib.TrackH264,
|
2022-08-05 21:50:45 +00:00
|
|
|
audioTrack *gortsplib.TrackMPEG4Audio,
|
2022-05-31 17:17:26 +00:00
|
|
|
) *muxerVariantMPEGTS {
|
|
|
|
v := &muxerVariantMPEGTS{}
|
|
|
|
|
|
|
|
v.playlist = newMuxerVariantMPEGTSPlaylist(segmentCount)
|
|
|
|
|
|
|
|
v.segmenter = newMuxerVariantMPEGTSSegmenter(
|
|
|
|
segmentDuration,
|
|
|
|
segmentMaxSize,
|
|
|
|
videoTrack,
|
|
|
|
audioTrack,
|
|
|
|
func(seg *muxerVariantMPEGTSSegment) {
|
|
|
|
v.playlist.pushSegment(seg)
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *muxerVariantMPEGTS) close() {
|
|
|
|
v.playlist.close()
|
|
|
|
}
|
|
|
|
|
2022-08-27 13:43:25 +00:00
|
|
|
func (v *muxerVariantMPEGTS) writeH264(now time.Time, pts time.Duration, nalus [][]byte) error {
|
|
|
|
return v.segmenter.writeH264(now, pts, nalus)
|
2022-05-31 17:17:26 +00:00
|
|
|
}
|
|
|
|
|
2022-08-27 13:43:25 +00:00
|
|
|
func (v *muxerVariantMPEGTS) writeAAC(now time.Time, pts time.Duration, au []byte) error {
|
|
|
|
return v.segmenter.writeAAC(now, pts, au)
|
2022-05-31 17:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *muxerVariantMPEGTS) file(name string, msn string, part string, skip string) *MuxerFileResponse {
|
|
|
|
return v.playlist.file(name)
|
|
|
|
}
|