change track initialization method

This commit is contained in:
aler9
2022-06-23 13:13:36 +02:00
parent 3223af460e
commit 9f4fea8a01
40 changed files with 765 additions and 706 deletions

View File

@@ -34,9 +34,14 @@ func main() {
log.Println("stream connected")
// create an AAC track
track, err := gortsplib.NewTrackAAC(96, 2, 48000, 2, nil, 13, 3, 3)
if err != nil {
panic(err)
track := &gortsplib.TrackAAC{
PayloadType: 96,
Type: 2,
SampleRate: 48000,
ChannelCount: 2,
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}
// connect to the server and start publishing the track

View File

@@ -35,9 +35,8 @@ func main() {
log.Println("stream connected")
// create an H264 track
track, err := gortsplib.NewTrackH264(96, nil, nil, nil)
if err != nil {
panic(err)
track := &gortsplib.TrackH264{
PayloadType: 96,
}
// connect to the server and start publishing the track

View File

@@ -36,9 +36,8 @@ func main() {
log.Println("stream connected")
// create an H264 track
track, err := gortsplib.NewTrackH264(96, nil, nil, nil)
if err != nil {
panic(err)
track := &gortsplib.TrackH264{
PayloadType: 96,
}
// Client allows to set additional client options

View File

@@ -34,7 +34,11 @@ func main() {
log.Println("stream connected")
// create an Opus track
track := gortsplib.NewTrackOpus(96, 48000, 2)
track := &gortsplib.TrackOpus{
PayloadType: 96,
SampleRate: 48000,
ChannelCount: 2,
}
c := gortsplib.Client{}

View File

@@ -37,9 +37,8 @@ func main() {
log.Println("stream connected")
// create an H264 track
track, err := gortsplib.NewTrackH264(96, nil, nil, nil)
if err != nil {
panic(err)
track := &gortsplib.TrackH264{
PayloadType: 96,
}
// connect to the server and start publishing the track

View File

@@ -34,7 +34,7 @@ func main() {
log.Println("stream connected")
// create a PCMU track
track := gortsplib.NewTrackPCMU()
track := &gortsplib.TrackPCMU{}
c := gortsplib.Client{}

View File

@@ -50,10 +50,10 @@ func main() {
// setup decoder
dec := &rtpaac.Decoder{
SampleRate: aacTrack.ClockRate(),
SizeLength: aacTrack.SizeLength(),
IndexLength: aacTrack.IndexLength(),
IndexDeltaLength: aacTrack.IndexDeltaLength(),
SampleRate: aacTrack.SampleRate,
SizeLength: aacTrack.SizeLength,
IndexLength: aacTrack.IndexLength,
IndexDeltaLength: aacTrack.IndexDeltaLength,
}
dec.Init()

View File

@@ -81,11 +81,13 @@ func main() {
defer h264dec.close()
// if present, send SPS and PPS from the SDP to the decoder
if h264track.SPS() != nil {
h264dec.decode(h264track.SPS())
sps := h264track.SafeSPS()
if sps != nil {
h264dec.decode(sps)
}
if h264track.PPS() != nil {
h264dec.decode(h264track.PPS())
pps := h264track.SafePPS()
if pps != nil {
h264dec.decode(pps)
}
// called when a RTP packet arrives

View File

@@ -46,7 +46,7 @@ func main() {
}
// setup H264->MPEGTS encoder
enc, err := newMPEGTSEncoder(h264track.SPS(), h264track.PPS())
enc, err := newMPEGTSEncoder(h264track.SafeSPS(), h264track.SafePPS())
if err != nil {
panic(err)
}

View File

@@ -58,11 +58,13 @@ func main() {
defer h264dec.close()
// if present, send SPS and PPS from the SDP to the decoder
if h264track.SPS() != nil {
h264dec.decode(h264track.SPS())
sps := h264track.SafeSPS()
if sps != nil {
h264dec.decode(sps)
}
if h264track.PPS() != nil {
h264dec.decode(h264track.PPS())
pps := h264track.SafePPS()
if pps != nil {
h264dec.decode(pps)
}
// called when a RTP packet arrives