mediamtx/internal/hls/muxer_variant_mpegts.go
Alessandro Ros e115983296
Implement Low-Latency HLS (#938)
* add hlsVariant parameter

* hls: split muxer into variants

* hls: implement fmp4 segments

* hls muxer: implement low latency mode

* hls muxer: support audio with fmp4 mode

* hls muxer: rewrite file router

* hls muxer: implement preload hint

* hls muxer: add various error codes

* hls muxer: use explicit flags

* hls muxer: fix error in aac pts

* hls muxer: fix sudden freezes with video+audio

* hls muxer: skip empty parts

* hls muxer: fix video FPS

* hls muxer: add parameter hlsPartDuration

* hls muxer: refactor fmp4 muxer

* hls muxer: fix CAN-SKIP-UNTIL

* hls muxer: refactor code

* hls muxer: show only parts of last 2 segments

* hls muxer: implementa playlist delta updates

* hls muxer: change playlist content type

* hls muxer: improve video dts precision

* hls muxer: fix video sample flags

* hls muxer: improve iphone audio support

* hls muxer: improve mp4 timestamp precision

* hls muxer: add offset between pts and dts

* hls muxer: close muxer in case of error

* hls muxer: stop logging requests with the info level

* hls muxer: rename entry into sample

* hls muxer: compensate video dts error over time

* hls muxer: change default segment count

* hls muxer: add starting gap

* hls muxer: set default part duration to 200ms

* hls muxer: fix audio-only streams on ios

* hls muxer: add playsinline attribute to video tag of default web page

* hls muxer: keep mpegts as the default hls variant

* hls muxer: implement encryption

* hls muxer: rewrite dts estimation

* hls muxer: improve DTS precision

* hls muxer: use right SPS/PPS for each sample

* hls muxer: adjust part duration dynamically

* add comments

* update readme

* hls muxer: fix memory leak

* hls muxer: decrease ram consumption
2022-05-31 19:17:26 +02:00

53 lines
1.1 KiB
Go

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,
audioTrack *gortsplib.TrackAAC,
) *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()
}
func (v *muxerVariantMPEGTS) writeH264(pts time.Duration, nalus [][]byte) error {
return v.segmenter.writeH264(pts, nalus)
}
func (v *muxerVariantMPEGTS) writeAAC(pts time.Duration, aus [][]byte) error {
return v.segmenter.writeAAC(pts, aus)
}
func (v *muxerVariantMPEGTS) file(name string, msn string, part string, skip string) *MuxerFileResponse {
return v.playlist.file(name)
}