mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-17 12:14:34 +00:00
hls source: set type of audio medias to 'audio' (#1489)
it was wrongly set to "video".
This commit is contained in:
parent
f1455a6e1f
commit
339d6ab16e
@ -59,7 +59,6 @@ func (s *hlsSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan
|
||||
|
||||
for _, track := range tracks {
|
||||
medi := &media.Media{
|
||||
Type: media.TypeVideo,
|
||||
Formats: []format.Format{track},
|
||||
}
|
||||
medias = append(medias, medi)
|
||||
@ -67,6 +66,8 @@ func (s *hlsSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan
|
||||
|
||||
switch track.(type) {
|
||||
case *format.H264:
|
||||
medi.Type = media.TypeVideo
|
||||
|
||||
c.OnData(track, func(pts time.Duration, dat interface{}) {
|
||||
err := stream.writeData(medi, ctrack, &formatprocessor.DataH264{
|
||||
PTS: pts,
|
||||
@ -79,6 +80,8 @@ func (s *hlsSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan
|
||||
})
|
||||
|
||||
case *format.H265:
|
||||
medi.Type = media.TypeVideo
|
||||
|
||||
c.OnData(track, func(pts time.Duration, dat interface{}) {
|
||||
err := stream.writeData(medi, ctrack, &formatprocessor.DataH265{
|
||||
PTS: pts,
|
||||
@ -91,6 +94,8 @@ func (s *hlsSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan
|
||||
})
|
||||
|
||||
case *format.MPEG4Audio:
|
||||
medi.Type = media.TypeAudio
|
||||
|
||||
c.OnData(track, func(pts time.Duration, dat interface{}) {
|
||||
err := stream.writeData(medi, ctrack, &formatprocessor.DataMPEG4Audio{
|
||||
PTS: pts,
|
||||
@ -103,6 +108,8 @@ func (s *hlsSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan
|
||||
})
|
||||
|
||||
case *format.Opus:
|
||||
medi.Type = media.TypeAudio
|
||||
|
||||
c.OnData(track, func(pts time.Duration, dat interface{}) {
|
||||
err := stream.writeData(medi, ctrack, &formatprocessor.DataOpus{
|
||||
PTS: pts,
|
||||
|
@ -11,6 +11,9 @@ import (
|
||||
|
||||
"github.com/aler9/gortsplib/v2"
|
||||
"github.com/aler9/gortsplib/v2/pkg/codecs/h264"
|
||||
"github.com/aler9/gortsplib/v2/pkg/codecs/mpeg4audio"
|
||||
"github.com/aler9/gortsplib/v2/pkg/format"
|
||||
"github.com/aler9/gortsplib/v2/pkg/media"
|
||||
"github.com/aler9/gortsplib/v2/pkg/url"
|
||||
"github.com/asticode/go-astits"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -69,6 +72,11 @@ func (ts *testHLSServer) onSegment(ctx *gin.Context) {
|
||||
StreamType: astits.StreamTypeH264Video,
|
||||
})
|
||||
|
||||
mux.AddElementaryStream(astits.PMTElementaryStream{
|
||||
ElementaryPID: 257,
|
||||
StreamType: astits.StreamTypeAACAudio,
|
||||
})
|
||||
|
||||
mux.SetPCRPID(256)
|
||||
|
||||
mux.WriteTables()
|
||||
@ -87,7 +95,33 @@ func (ts *testHLSServer) onSegment(ctx *gin.Context) {
|
||||
PTSDTSIndicator: astits.PTSDTSIndicatorOnlyPTS,
|
||||
PTS: &astits.ClockReference{Base: int64(1 * 90000)},
|
||||
},
|
||||
StreamID: 224, // = video
|
||||
StreamID: 224,
|
||||
},
|
||||
Data: enc,
|
||||
},
|
||||
})
|
||||
|
||||
pkts := mpeg4audio.ADTSPackets{
|
||||
{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
AU: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
},
|
||||
}
|
||||
|
||||
enc, _ = pkts.Marshal()
|
||||
|
||||
mux.WriteData(&astits.MuxerData{
|
||||
PID: 257,
|
||||
PES: &astits.PESData{
|
||||
Header: &astits.PESHeader{
|
||||
OptionalHeader: &astits.PESOptionalHeader{
|
||||
MarkerBits: 2,
|
||||
PTSDTSIndicator: astits.PTSDTSIndicatorOnlyPTS,
|
||||
PTS: &astits.ClockReference{Base: int64(1 * 90000)},
|
||||
},
|
||||
StreamID: 192,
|
||||
},
|
||||
Data: enc,
|
||||
},
|
||||
@ -148,6 +182,36 @@ func TestHLSSource(t *testing.T) {
|
||||
medias, baseURL, _, err := c.Describe(u)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, media.Medias{
|
||||
{
|
||||
Type: media.TypeVideo,
|
||||
Control: medias[0].Control,
|
||||
Formats: []format.Format{
|
||||
&format.H264{
|
||||
PayloadTyp: 96,
|
||||
PacketizationMode: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: media.TypeAudio,
|
||||
Control: medias[1].Control,
|
||||
Formats: []format.Format{
|
||||
&format.MPEG4Audio{
|
||||
PayloadTyp: 96,
|
||||
Config: &mpeg4audio.Config{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
},
|
||||
SizeLength: 13,
|
||||
IndexLength: 3,
|
||||
IndexDeltaLength: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, medias)
|
||||
|
||||
err = c.SetupAll(medias, baseURL)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user