|
|
|
@ -256,17 +256,16 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
@@ -256,17 +256,16 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
|
|
|
|
|
var medi *description.Media |
|
|
|
|
|
|
|
|
|
switch tcodec := track.Codec.(type) { |
|
|
|
|
case *mpegts.CodecH264: |
|
|
|
|
case *mpegts.CodecH265: |
|
|
|
|
medi = &description.Media{ |
|
|
|
|
Type: description.MediaTypeVideo, |
|
|
|
|
Formats: []format.Format{&format.H264{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
PacketizationMode: 1, |
|
|
|
|
Formats: []format.Format{&format.H265{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
}}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
r.OnDataH26x(track, func(pts int64, _ int64, au [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.H264{ |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.H265{ |
|
|
|
|
Base: unit.Base{ |
|
|
|
|
NTP: time.Now(), |
|
|
|
|
PTS: decodeTime(pts), |
|
|
|
@ -276,16 +275,17 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
@@ -276,16 +275,17 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
|
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
case *mpegts.CodecH265: |
|
|
|
|
case *mpegts.CodecH264: |
|
|
|
|
medi = &description.Media{ |
|
|
|
|
Type: description.MediaTypeVideo, |
|
|
|
|
Formats: []format.Format{&format.H265{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
Formats: []format.Format{&format.H264{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
PacketizationMode: 1, |
|
|
|
|
}}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
r.OnDataH26x(track, func(pts int64, _ int64, au [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.H265{ |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.H264{ |
|
|
|
|
Base: unit.Base{ |
|
|
|
|
NTP: time.Now(), |
|
|
|
|
PTS: decodeTime(pts), |
|
|
|
@ -295,45 +295,45 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
@@ -295,45 +295,45 @@ func (c *srtConn) runPublishReader(sconn srt.Conn, path *path) error {
|
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
case *mpegts.CodecMPEG4Audio: |
|
|
|
|
case *mpegts.CodecOpus: |
|
|
|
|
medi = &description.Media{ |
|
|
|
|
Type: description.MediaTypeAudio, |
|
|
|
|
Formats: []format.Format{&format.MPEG4Audio{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
SizeLength: 13, |
|
|
|
|
IndexLength: 3, |
|
|
|
|
IndexDeltaLength: 3, |
|
|
|
|
Config: &tcodec.Config, |
|
|
|
|
Formats: []format.Format{&format.Opus{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
IsStereo: (tcodec.ChannelCount == 2), |
|
|
|
|
}}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
r.OnDataMPEG4Audio(track, func(pts int64, aus [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.MPEG4AudioGeneric{ |
|
|
|
|
r.OnDataOpus(track, func(pts int64, packets [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.Opus{ |
|
|
|
|
Base: unit.Base{ |
|
|
|
|
NTP: time.Now(), |
|
|
|
|
PTS: decodeTime(pts), |
|
|
|
|
}, |
|
|
|
|
AUs: aus, |
|
|
|
|
Packets: packets, |
|
|
|
|
}) |
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
case *mpegts.CodecOpus: |
|
|
|
|
case *mpegts.CodecMPEG4Audio: |
|
|
|
|
medi = &description.Media{ |
|
|
|
|
Type: description.MediaTypeAudio, |
|
|
|
|
Formats: []format.Format{&format.Opus{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
IsStereo: (tcodec.ChannelCount == 2), |
|
|
|
|
Formats: []format.Format{&format.MPEG4Audio{ |
|
|
|
|
PayloadTyp: 96, |
|
|
|
|
SizeLength: 13, |
|
|
|
|
IndexLength: 3, |
|
|
|
|
IndexDeltaLength: 3, |
|
|
|
|
Config: &tcodec.Config, |
|
|
|
|
}}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
r.OnDataOpus(track, func(pts int64, packets [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.Opus{ |
|
|
|
|
r.OnDataMPEG4Audio(track, func(pts int64, aus [][]byte) error { |
|
|
|
|
stream.WriteUnit(medi, medi.Formats[0], &unit.MPEG4AudioGeneric{ |
|
|
|
|
Base: unit.Base{ |
|
|
|
|
NTP: time.Now(), |
|
|
|
|
PTS: decodeTime(pts), |
|
|
|
|
}, |
|
|
|
|
Packets: packets, |
|
|
|
|
AUs: aus, |
|
|
|
|
}) |
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
@ -424,6 +424,8 @@ func (c *srtConn) runRead(req srtNewConnReq, pathName string, user string, pass
@@ -424,6 +424,8 @@ func (c *srtConn) runRead(req srtNewConnReq, pathName string, user string, pass
|
|
|
|
|
|
|
|
|
|
writer := asyncwriter.New(c.writeQueueSize, c) |
|
|
|
|
|
|
|
|
|
defer res.stream.RemoveReader(writer) |
|
|
|
|
|
|
|
|
|
var w *mpegts.Writer |
|
|
|
|
var tracks []*mpegts.Track |
|
|
|
|
var medias []*description.Media |
|
|
|
|