mirror of
https://github.com/aler9/gortsplib
synced 2025-10-19 21:44:51 +08:00
change track initialization method
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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{}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -34,7 +34,7 @@ func main() {
|
||||
log.Println("stream connected")
|
||||
|
||||
// create a PCMU track
|
||||
track := gortsplib.NewTrackPCMU()
|
||||
track := &gortsplib.TrackPCMU{}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user