rtmp拉流播放时间戳问题修正

This commit is contained in:
langhuihui
2021-06-28 21:49:53 +08:00
parent e553c415b7
commit a60267f608

View File

@@ -152,18 +152,18 @@ func processRtmp(conn net.Conn) {
err = nc.SendMessage(SEND_PLAY_RESPONSE_MESSAGE, newPlayResponseMessageData(nc.streamID, NetStream_Play_Reset, Level_Status)) err = nc.SendMessage(SEND_PLAY_RESPONSE_MESSAGE, newPlayResponseMessageData(nc.streamID, NetStream_Play_Reset, Level_Status))
err = nc.SendMessage(SEND_PLAY_RESPONSE_MESSAGE, newPlayResponseMessageData(nc.streamID, NetStream_Play_Start, Level_Status)) err = nc.SendMessage(SEND_PLAY_RESPONSE_MESSAGE, newPlayResponseMessageData(nc.streamID, NetStream_Play_Start, Level_Status))
vt, at := subscriber.WaitVideoTrack(), subscriber.WaitAudioTrack() vt, at := subscriber.WaitVideoTrack(), subscriber.WaitAudioTrack()
var lastTimeStamp uint32 if vt != nil {
var getDeltaTime func(uint32) uint32 var lastTimeStamp uint32
getDeltaTime = func(ts uint32) (t uint32) { var getDeltaTime func(uint32) uint32
lastTimeStamp = ts
getDeltaTime = func(ts uint32) (t uint32) { getDeltaTime = func(ts uint32) (t uint32) {
t = ts - lastTimeStamp
lastTimeStamp = ts lastTimeStamp = ts
getDeltaTime = func(ts uint32) (t uint32) {
t = ts - lastTimeStamp
lastTimeStamp = ts
return
}
return return
} }
return
}
if vt != nil {
err = nc.SendMessage(SEND_FULL_VDIEO_MESSAGE, &AVPack{Payload: vt.ExtraData.Payload}) err = nc.SendMessage(SEND_FULL_VDIEO_MESSAGE, &AVPack{Payload: vt.ExtraData.Payload})
subscriber.OnVideo = func(pack engine.VideoPack) { subscriber.OnVideo = func(pack engine.VideoPack) {
err = nc.SendMessage(SEND_FULL_VDIEO_MESSAGE, &AVPack{Timestamp: 0, Payload: pack.Payload}) err = nc.SendMessage(SEND_FULL_VDIEO_MESSAGE, &AVPack{Timestamp: 0, Payload: pack.Payload})
@@ -173,6 +173,17 @@ func processRtmp(conn net.Conn) {
} }
} }
if at != nil { if at != nil {
var lastTimeStamp uint32
var getDeltaTime func(uint32) uint32
getDeltaTime = func(ts uint32) (t uint32) {
lastTimeStamp = ts
getDeltaTime = func(ts uint32) (t uint32) {
t = ts - lastTimeStamp
lastTimeStamp = ts
return
}
return
}
subscriber.OnAudio = func(pack engine.AudioPack) { subscriber.OnAudio = func(pack engine.AudioPack) {
if at.CodecID == 10 { if at.CodecID == 10 {
err = nc.SendMessage(SEND_FULL_AUDIO_MESSAGE, &AVPack{Payload: at.ExtraData}) err = nc.SendMessage(SEND_FULL_AUDIO_MESSAGE, &AVPack{Payload: at.ExtraData})