mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-18 20:46:53 +00:00
update gortsplib
This commit is contained in:
parent
2b5661c74e
commit
af7a815f83
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.17
|
||||
require (
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
|
||||
github.com/abema/go-mp4 v0.7.2
|
||||
github.com/aler9/gortsplib v0.0.0-20220724100730-2c8889602c59
|
||||
github.com/aler9/gortsplib v0.0.0-20220805214011-702cac94a6e9
|
||||
github.com/asticode/go-astits v1.10.1-0.20220319093903-4abe66a9b757
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
|
4
go.sum
4
go.sum
@ -6,8 +6,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/aler9/gortsplib v0.0.0-20220724100730-2c8889602c59 h1:t8g7rbQ621GVD06B32H8VqN2+NfW27FIXdVaMI5RQGc=
|
||||
github.com/aler9/gortsplib v0.0.0-20220724100730-2c8889602c59/go.mod h1:WI3nMhY2mM6nfoeW9uyk7TyG5Qr6YnYxmFoCply0sbo=
|
||||
github.com/aler9/gortsplib v0.0.0-20220805214011-702cac94a6e9 h1:VxKfEuGpn99XKz56xBcoj9T2rFMOgkH1kgUhbOsFSDY=
|
||||
github.com/aler9/gortsplib v0.0.0-20220805214011-702cac94a6e9/go.mod h1:WI3nMhY2mM6nfoeW9uyk7TyG5Qr6YnYxmFoCply0sbo=
|
||||
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82 h1:9WgSzBLo3a9ToSVV7sRTBYZ1GGOZUpq4+5H3SN0UZq4=
|
||||
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82/go.mod h1:qsMrZCbeBf/mCLOeF16KDkPu4gktn/pOWyaq1aYQE7U=
|
||||
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=
|
||||
|
@ -292,7 +292,7 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{})
|
||||
|
||||
var videoTrack *gortsplib.TrackH264
|
||||
videoTrackID := -1
|
||||
var audioTrack *gortsplib.TrackAAC
|
||||
var audioTrack *gortsplib.TrackMPEG4Audio
|
||||
audioTrackID := -1
|
||||
var aacDecoder *rtpaac.Decoder
|
||||
|
||||
@ -306,7 +306,7 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{})
|
||||
videoTrack = tt
|
||||
videoTrackID = i
|
||||
|
||||
case *gortsplib.TrackAAC:
|
||||
case *gortsplib.TrackMPEG4Audio:
|
||||
if audioTrack != nil {
|
||||
return fmt.Errorf("can't encode track %d with HLS: too many tracks", i+1)
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func (s *hlsSource) run(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
onTracks := func(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackAAC) error {
|
||||
onTracks := func(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackMPEG4Audio) error {
|
||||
var tracks gortsplib.Tracks
|
||||
|
||||
if videoTrack != nil {
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
"github.com/aler9/gortsplib/pkg/ringbuffer"
|
||||
"github.com/aler9/gortsplib/pkg/rtpaac"
|
||||
"github.com/aler9/gortsplib/pkg/rtph264"
|
||||
@ -254,7 +254,7 @@ func (c *rtmpConn) runRead(ctx context.Context, u *url.URL) error {
|
||||
|
||||
var videoTrack *gortsplib.TrackH264
|
||||
videoTrackID := -1
|
||||
var audioTrack *gortsplib.TrackAAC
|
||||
var audioTrack *gortsplib.TrackMPEG4Audio
|
||||
audioTrackID := -1
|
||||
var aacDecoder *rtpaac.Decoder
|
||||
|
||||
@ -268,7 +268,7 @@ func (c *rtmpConn) runRead(ctx context.Context, u *url.URL) error {
|
||||
videoTrack = tt
|
||||
videoTrackID = i
|
||||
|
||||
case *gortsplib.TrackAAC:
|
||||
case *gortsplib.TrackMPEG4Audio:
|
||||
if audioTrack != nil {
|
||||
return fmt.Errorf("can't read track %d with RTMP: too many tracks", i+1)
|
||||
}
|
||||
@ -469,7 +469,8 @@ func (c *rtmpConn) runRead(ctx context.Context, u *url.URL) error {
|
||||
Channels: flvio.SOUND_STEREO,
|
||||
AACType: flvio.AAC_RAW,
|
||||
Payload: au,
|
||||
DTS: pts + time.Duration(i)*aac.SamplesPerAccessUnit*time.Second/time.Duration(audioTrack.ClockRate()),
|
||||
DTS: pts + time.Duration(i)*mpeg4audio.SamplesPerAccessUnit*
|
||||
time.Second/time.Duration(audioTrack.ClockRate()),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -46,7 +46,7 @@ type ClientLogger interface {
|
||||
|
||||
// Client is a HLS client.
|
||||
type Client struct {
|
||||
onTracks func(*gortsplib.TrackH264, *gortsplib.TrackAAC) error
|
||||
onTracks func(*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio) error
|
||||
onVideoData func(time.Duration, [][]byte)
|
||||
onAudioData func(time.Duration, [][]byte)
|
||||
logger ClientLogger
|
||||
@ -70,7 +70,7 @@ type Client struct {
|
||||
|
||||
tracksMutex sync.RWMutex
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
|
||||
// in
|
||||
allocateProcs chan clientAllocateProcsReq
|
||||
@ -83,7 +83,7 @@ type Client struct {
|
||||
func NewClient(
|
||||
primaryPlaylistURLStr string,
|
||||
fingerprint string,
|
||||
onTracks func(*gortsplib.TrackH264, *gortsplib.TrackAAC) error,
|
||||
onTracks func(*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio) error,
|
||||
onVideoData func(time.Duration, [][]byte),
|
||||
onAudioData func(time.Duration, [][]byte),
|
||||
logger ClientLogger,
|
||||
@ -536,7 +536,7 @@ func (c *Client) onVideoProcessorData(pts time.Duration, nalus [][]byte) {
|
||||
c.onVideoData(pts, nalus)
|
||||
}
|
||||
|
||||
func (c *Client) onAudioProcessorTrack(track *gortsplib.TrackAAC) error {
|
||||
func (c *Client) onAudioProcessorTrack(track *gortsplib.TrackMPEG4Audio) error {
|
||||
c.tracksMutex.Lock()
|
||||
defer c.tracksMutex.Unlock()
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
)
|
||||
|
||||
type clientAudioProcessorData struct {
|
||||
@ -16,7 +16,7 @@ type clientAudioProcessorData struct {
|
||||
|
||||
type clientAudioProcessor struct {
|
||||
ctx context.Context
|
||||
onTrack func(*gortsplib.TrackAAC) error
|
||||
onTrack func(*gortsplib.TrackMPEG4Audio) error
|
||||
onData func(time.Duration, [][]byte)
|
||||
|
||||
trackInitialized bool
|
||||
@ -26,7 +26,7 @@ type clientAudioProcessor struct {
|
||||
|
||||
func newClientAudioProcessor(
|
||||
ctx context.Context,
|
||||
onTrack func(*gortsplib.TrackAAC) error,
|
||||
onTrack func(*gortsplib.TrackMPEG4Audio) error,
|
||||
onData func(time.Duration, [][]byte),
|
||||
) *clientAudioProcessor {
|
||||
p := &clientAudioProcessor{
|
||||
@ -58,7 +58,7 @@ func (p *clientAudioProcessor) doProcess(
|
||||
data []byte,
|
||||
pts time.Duration,
|
||||
) error {
|
||||
var adtsPkts aac.ADTSPackets
|
||||
var adtsPkts mpeg4audio.ADTSPackets
|
||||
err := adtsPkts.Unmarshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -79,9 +79,9 @@ func (p *clientAudioProcessor) doProcess(
|
||||
if !p.trackInitialized {
|
||||
p.trackInitialized = true
|
||||
|
||||
track := &gortsplib.TrackAAC{
|
||||
track := &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: pkt.Type,
|
||||
SampleRate: pkt.SampleRate,
|
||||
ChannelCount: pkt.ChannelCount,
|
||||
|
@ -214,7 +214,7 @@ func TestClient(t *testing.T) {
|
||||
c, err := NewClient(
|
||||
prefix+"://localhost:5780/stream.m3u8",
|
||||
"33949E05FFFB5FF3E8AA16F8213A6251B4D9363804BA53233C4DA9A46D6F2739",
|
||||
func(*gortsplib.TrackH264, *gortsplib.TrackAAC) error {
|
||||
func(*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio) error {
|
||||
return nil
|
||||
},
|
||||
func(pts time.Duration, nalus [][]byte) {
|
||||
|
@ -28,7 +28,7 @@ func NewMuxer(
|
||||
partDuration time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
) (*Muxer, error) {
|
||||
m := &Muxer{}
|
||||
|
||||
|
@ -14,13 +14,13 @@ import (
|
||||
type muxerPrimaryPlaylist struct {
|
||||
fmp4 bool
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
}
|
||||
|
||||
func newMuxerPrimaryPlaylist(
|
||||
fmp4 bool,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
) *muxerPrimaryPlaylist {
|
||||
return &muxerPrimaryPlaylist{
|
||||
fmp4: fmp4,
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
"github.com/asticode/go-astits"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@ -29,9 +29,9 @@ func TestMuxerVideoAudio(t *testing.T) {
|
||||
PPS: []byte{0x08},
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackAAC{
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 97,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -282,9 +282,9 @@ func TestMuxerVideoOnly(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMuxerAudioOnly(t *testing.T) {
|
||||
audioTrack := &gortsplib.TrackAAC{
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 97,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
|
@ -40,7 +40,7 @@ type muxerVariantFMP4 struct {
|
||||
playlist *muxerVariantFMP4Playlist
|
||||
segmenter *muxerVariantFMP4Segmenter
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
|
||||
mutex sync.Mutex
|
||||
videoLastSPS []byte
|
||||
@ -55,7 +55,7 @@ func newMuxerVariantFMP4(
|
||||
partDuration time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
) *muxerVariantFMP4 {
|
||||
v := &muxerVariantFMP4{
|
||||
videoTrack: videoTrack,
|
||||
|
@ -265,7 +265,7 @@ func mp4InitGenerateVideoTrack(w *mp4.Writer, trackID int, videoTrack *gortsplib
|
||||
return nil
|
||||
}
|
||||
|
||||
func mp4InitGenerateAudioTrack(w *mp4.Writer, trackID int, audioTrack *gortsplib.TrackAAC) error {
|
||||
func mp4InitGenerateAudioTrack(w *mp4.Writer, trackID int, audioTrack *gortsplib.TrackMPEG4Audio) error {
|
||||
/*
|
||||
trak
|
||||
- tkhd
|
||||
@ -511,7 +511,7 @@ func mp4InitGenerateAudioTrack(w *mp4.Writer, trackID int, audioTrack *gortsplib
|
||||
return nil
|
||||
}
|
||||
|
||||
func mp4InitGenerate(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackAAC) ([]byte, error) {
|
||||
func mp4InitGenerate(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackMPEG4Audio) ([]byte, error) {
|
||||
/*
|
||||
- ftyp
|
||||
- moov
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
gomp4 "github.com/abema/go-mp4"
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/mp4"
|
||||
)
|
||||
@ -105,7 +105,7 @@ func mp4PartGenerateVideoTraf(
|
||||
func mp4PartGenerateAudioTraf(
|
||||
w *mp4.Writer,
|
||||
trackID int,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
audioSamples []*fmp4AudioSample,
|
||||
) (*gomp4.Trun, int, error) {
|
||||
/*
|
||||
@ -182,7 +182,7 @@ func mp4PartGenerateAudioTraf(
|
||||
|
||||
func mp4PartGenerate(
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
videoSamples []*fmp4VideoSample,
|
||||
audioSamples []*fmp4AudioSample,
|
||||
) ([]byte, error) {
|
||||
@ -301,7 +301,7 @@ func fmp4PartName(id uint64) string {
|
||||
|
||||
type muxerVariantFMP4Part struct {
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
id uint64
|
||||
|
||||
isIndependent bool
|
||||
@ -313,7 +313,7 @@ type muxerVariantFMP4Part struct {
|
||||
|
||||
func newMuxerVariantFMP4Part(
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
id uint64,
|
||||
) *muxerVariantFMP4Part {
|
||||
p := &muxerVariantFMP4Part{
|
||||
@ -350,7 +350,7 @@ func (p *muxerVariantFMP4Part) duration() time.Duration {
|
||||
// not the real duration,
|
||||
// otherwise on iPhone iOS the stream freezes.
|
||||
return time.Duration(len(p.audioSamples)) * time.Second *
|
||||
time.Duration(aac.SamplesPerAccessUnit) / time.Duration(p.audioTrack.ClockRate())
|
||||
time.Duration(mpeg4audio.SamplesPerAccessUnit) / time.Duration(p.audioTrack.ClockRate())
|
||||
}
|
||||
|
||||
func (p *muxerVariantFMP4Part) finalize() error {
|
||||
|
@ -71,7 +71,7 @@ type muxerVariantFMP4Playlist struct {
|
||||
lowLatency bool
|
||||
segmentCount int
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
|
||||
mutex sync.Mutex
|
||||
cond *sync.Cond
|
||||
@ -90,7 +90,7 @@ func newMuxerVariantFMP4Playlist(
|
||||
lowLatency bool,
|
||||
segmentCount int,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
) *muxerVariantFMP4Playlist {
|
||||
p := &muxerVariantFMP4Playlist{
|
||||
lowLatency: lowLatency,
|
||||
|
@ -46,7 +46,7 @@ type muxerVariantFMP4Segment struct {
|
||||
startDTS time.Duration
|
||||
segmentMaxSize uint64
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
genPartID func() uint64
|
||||
onPartFinalized func(*muxerVariantFMP4Part)
|
||||
|
||||
@ -63,7 +63,7 @@ func newMuxerVariantFMP4Segment(
|
||||
startDTS time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
genPartID func() uint64,
|
||||
onPartFinalized func(*muxerVariantFMP4Part),
|
||||
) *muxerVariantFMP4Segment {
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
)
|
||||
|
||||
func partDurationIsCompatible(partDuration time.Duration, sampleDuration time.Duration) bool {
|
||||
@ -50,7 +50,7 @@ type muxerVariantFMP4Segmenter struct {
|
||||
partDuration time.Duration
|
||||
segmentMaxSize uint64
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
onSegmentFinalized func(*muxerVariantFMP4Segment)
|
||||
onPartFinalized func(*muxerVariantFMP4Part)
|
||||
|
||||
@ -75,7 +75,7 @@ func newMuxerVariantFMP4Segmenter(
|
||||
partDuration time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
onSegmentFinalized func(*muxerVariantFMP4Segment),
|
||||
onPartFinalized func(*muxerVariantFMP4Part),
|
||||
) *muxerVariantFMP4Segmenter {
|
||||
@ -261,7 +261,7 @@ func (m *muxerVariantFMP4Segmenter) writeH264Entry(sample *fmp4VideoSample) erro
|
||||
func (m *muxerVariantFMP4Segmenter) writeAAC(pts time.Duration, aus [][]byte) error {
|
||||
for i, au := range aus {
|
||||
err := m.writeAACEntry(&fmp4AudioSample{
|
||||
pts: pts + time.Duration(i)*aac.SamplesPerAccessUnit*time.Second/time.Duration(m.audioTrack.ClockRate()),
|
||||
pts: pts + time.Duration(i)*mpeg4audio.SamplesPerAccessUnit*time.Second/time.Duration(m.audioTrack.ClockRate()),
|
||||
au: au,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -16,7 +16,7 @@ func newMuxerVariantMPEGTS(
|
||||
segmentDuration time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
) *muxerVariantMPEGTS {
|
||||
v := &muxerVariantMPEGTS{}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
"github.com/asticode/go-astits"
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@ const (
|
||||
type muxerVariantMPEGTSSegment struct {
|
||||
segmentMaxSize uint64
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
writeData func(*astits.MuxerData) (int, error)
|
||||
|
||||
startTime time.Time
|
||||
@ -36,7 +36,7 @@ func newMuxerVariantMPEGTSSegment(
|
||||
startTime time.Time,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
writeData func(*astits.MuxerData) (int, error),
|
||||
) *muxerVariantMPEGTSSegment {
|
||||
t := &muxerVariantMPEGTSSegment{
|
||||
@ -147,10 +147,10 @@ func (t *muxerVariantMPEGTSSegment) writeAAC(
|
||||
pts time.Duration,
|
||||
aus [][]byte,
|
||||
) error {
|
||||
pkts := make(aac.ADTSPackets, len(aus))
|
||||
pkts := make(mpeg4audio.ADTSPackets, len(aus))
|
||||
|
||||
for i, au := range aus {
|
||||
pkts[i] = &aac.ADTSPacket{
|
||||
pkts[i] = &mpeg4audio.ADTSPacket{
|
||||
Type: t.audioTrack.Config.Type,
|
||||
SampleRate: t.audioTrack.Config.SampleRate,
|
||||
ChannelCount: t.audioTrack.Config.ChannelCount,
|
||||
|
@ -23,7 +23,7 @@ type muxerVariantMPEGTSSegmenter struct {
|
||||
segmentDuration time.Duration
|
||||
segmentMaxSize uint64
|
||||
videoTrack *gortsplib.TrackH264
|
||||
audioTrack *gortsplib.TrackAAC
|
||||
audioTrack *gortsplib.TrackMPEG4Audio
|
||||
onSegmentReady func(*muxerVariantMPEGTSSegment)
|
||||
|
||||
writer *astits.Muxer
|
||||
@ -37,7 +37,7 @@ func newMuxerVariantMPEGTSSegmenter(
|
||||
segmentDuration time.Duration,
|
||||
segmentMaxSize uint64,
|
||||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
audioTrack *gortsplib.TrackMPEG4Audio,
|
||||
onSegmentReady func(*muxerVariantMPEGTSSegment),
|
||||
) *muxerVariantMPEGTSSegmenter {
|
||||
m := &muxerVariantMPEGTSSegmenter{
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
"github.com/notedit/rtmp/format/flv/flvio"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmp/bytecounter"
|
||||
@ -588,14 +588,14 @@ func trackFromH264DecoderConfig(data []byte) (*gortsplib.TrackH264, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func trackFromAACDecoderConfig(data []byte) (*gortsplib.TrackAAC, error) {
|
||||
var mpegConf aac.MPEG4AudioConfig
|
||||
func trackFromAACDecoderConfig(data []byte) (*gortsplib.TrackMPEG4Audio, error) {
|
||||
var mpegConf mpeg4audio.Config
|
||||
err := mpegConf.Unmarshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &gortsplib.TrackAAC{
|
||||
return &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &mpegConf,
|
||||
SizeLength: 13,
|
||||
@ -606,7 +606,7 @@ func trackFromAACDecoderConfig(data []byte) (*gortsplib.TrackAAC, error) {
|
||||
|
||||
var errEmptyMetadata = errors.New("metadata is empty")
|
||||
|
||||
func (c *Conn) readTracksFromMetadata(payload []interface{}) (*gortsplib.TrackH264, *gortsplib.TrackAAC, error) {
|
||||
func (c *Conn) readTracksFromMetadata(payload []interface{}) (*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio, error) {
|
||||
if len(payload) != 1 {
|
||||
return nil, nil, fmt.Errorf("invalid metadata")
|
||||
}
|
||||
@ -677,7 +677,7 @@ func (c *Conn) readTracksFromMetadata(payload []interface{}) (*gortsplib.TrackH2
|
||||
}
|
||||
|
||||
var videoTrack *gortsplib.TrackH264
|
||||
var audioTrack *gortsplib.TrackAAC
|
||||
var audioTrack *gortsplib.TrackMPEG4Audio
|
||||
|
||||
for {
|
||||
msg, err := c.ReadMessage()
|
||||
@ -726,10 +726,10 @@ func (c *Conn) readTracksFromMetadata(payload []interface{}) (*gortsplib.TrackH2
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) readTracksFromMessages(msg message.Message) (*gortsplib.TrackH264, *gortsplib.TrackAAC, error) {
|
||||
func (c *Conn) readTracksFromMessages(msg message.Message) (*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio, error) {
|
||||
var startTime *time.Duration
|
||||
var videoTrack *gortsplib.TrackH264
|
||||
var audioTrack *gortsplib.TrackAAC
|
||||
var audioTrack *gortsplib.TrackMPEG4Audio
|
||||
|
||||
// analyze 1 second of packets
|
||||
outer:
|
||||
@ -801,7 +801,7 @@ outer:
|
||||
}
|
||||
|
||||
// ReadTracks reads track informations.
|
||||
func (c *Conn) ReadTracks() (*gortsplib.TrackH264, *gortsplib.TrackAAC, error) {
|
||||
func (c *Conn) ReadTracks() (*gortsplib.TrackH264, *gortsplib.TrackMPEG4Audio, error) {
|
||||
msg, err := c.ReadMessage()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -844,7 +844,7 @@ func (c *Conn) ReadTracks() (*gortsplib.TrackH264, *gortsplib.TrackAAC, error) {
|
||||
}
|
||||
|
||||
// WriteTracks writes track informations.
|
||||
func (c *Conn) WriteTracks(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackAAC) error {
|
||||
func (c *Conn) WriteTracks(videoTrack *gortsplib.TrackH264, audioTrack *gortsplib.TrackMPEG4Audio) error {
|
||||
err := c.WriteMessage(&message.MsgDataAMF0{
|
||||
ChunkStreamID: 4,
|
||||
MessageStreamID: 0x1000000,
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
||||
"github.com/notedit/rtmp/format/flv/flvio"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -525,9 +525,9 @@ func TestReadTracks(t *testing.T) {
|
||||
PPS: pps,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackAAC{
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -544,9 +544,9 @@ func TestReadTracks(t *testing.T) {
|
||||
PPS: pps,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackAAC{
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -563,9 +563,9 @@ func TestReadTracks(t *testing.T) {
|
||||
PPS: pps,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackAAC{
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -784,7 +784,7 @@ func TestReadTracks(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// C->S AAC decoder config
|
||||
enc, err := aac.MPEG4AudioConfig{
|
||||
enc, err := mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -842,7 +842,7 @@ func TestReadTracks(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// C->S AAC decoder config
|
||||
enc, err := aac.MPEG4AudioConfig{
|
||||
enc, err := mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -875,7 +875,7 @@ func TestReadTracks(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// C->S AAC decoder config
|
||||
enc, err := aac.MPEG4AudioConfig{
|
||||
enc, err := mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@ -924,9 +924,9 @@ func TestWriteTracks(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackAAC{
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
Config: &aac.MPEG4AudioConfig{
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
|
Loading…
Reference in New Issue
Block a user