mirror of
https://github.com/Monibuca/plugin-rtmp.git
synced 2025-10-05 23:47:04 +08:00
🐛 FIX: 修复与srs服务器互联不通的问题
This commit is contained in:
8
amf.go
8
amf.go
@@ -160,8 +160,8 @@ func (amf *AMF) readDate() uint64 {
|
|||||||
|
|
||||||
func (amf *AMF) readStrictArray() (list []AMFValue) {
|
func (amf *AMF) readStrictArray() (list []AMFValue) {
|
||||||
amf.ReadByte()
|
amf.ReadByte()
|
||||||
size := amf.ReadUint16()
|
size := amf.ReadUint32()
|
||||||
for i := uint16(0); i < size; i++ {
|
for i := uint32(0); i < size; i++ {
|
||||||
list = append(list, amf.decodeObject())
|
list = append(list, amf.decodeObject())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -170,8 +170,8 @@ func (amf *AMF) readStrictArray() (list []AMFValue) {
|
|||||||
func (amf *AMF) readECMAArray() (m AMFObject) {
|
func (amf *AMF) readECMAArray() (m AMFObject) {
|
||||||
m = make(AMFObject, 0)
|
m = make(AMFObject, 0)
|
||||||
amf.ReadByte()
|
amf.ReadByte()
|
||||||
size := amf.ReadUint16()
|
size := amf.ReadUint32()
|
||||||
for i := uint16(0); i < size; i++ {
|
for i := uint32(0); i < size; i++ {
|
||||||
k := amf.readString1()
|
k := amf.readString1()
|
||||||
v := amf.decodeObject()
|
v := amf.decodeObject()
|
||||||
if k == "" && v == ObjectEnd {
|
if k == "" && v == ObjectEnd {
|
||||||
|
@@ -50,7 +50,7 @@ func NewRTMPClient(addr string) (client *NetConnection, err error) {
|
|||||||
"app": client.appName,
|
"app": client.appName,
|
||||||
"flashVer": "monibuca/" + engine.Engine.Version,
|
"flashVer": "monibuca/" + engine.Engine.Version,
|
||||||
"swfUrl": addr,
|
"swfUrl": addr,
|
||||||
"tcUrl": addr,
|
"tcUrl": strings.TrimSuffix(addr, u.Path) + "/" + client.appName,
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
})
|
})
|
||||||
|
25
media.go
25
media.go
@@ -119,18 +119,18 @@ func (r *RTMPReceiver) ReceiveAudio(msg *Chunk) {
|
|||||||
r.WriteAVCCAudio(0, msg.Body)
|
r.WriteAVCCAudio(0, msg.Body)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// plugin.Tracef("rec_audio chunkType:%d chunkStreamID:%d ts:%d", msg.ChunkType, msg.ChunkStreamID, msg.Timestamp)
|
ts := msg.Timestamp
|
||||||
|
if ts == 0xffffff {
|
||||||
|
ts = msg.ExtendTimestamp
|
||||||
|
}
|
||||||
if msg.ChunkType == 0 {
|
if msg.ChunkType == 0 {
|
||||||
if r.AudioTrack.GetBase().Name == "" {
|
if r.AudioTrack.GetBase().Name == "" {
|
||||||
r.absTs[msg.ChunkStreamID] = 0
|
r.absTs[msg.ChunkStreamID] = 0
|
||||||
} else {
|
} else {
|
||||||
r.absTs[msg.ChunkStreamID] = r.AudioTrack.PreFrame().AbsTime
|
r.absTs[msg.ChunkStreamID] = ts
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if msg.Timestamp == 0xffffff {
|
|
||||||
r.absTs[msg.ChunkStreamID] += msg.ExtendTimestamp
|
|
||||||
} else {
|
} else {
|
||||||
r.absTs[msg.ChunkStreamID] += msg.Timestamp
|
r.absTs[msg.ChunkStreamID] += ts
|
||||||
}
|
}
|
||||||
r.AudioTrack.WriteAVCC(r.absTs[msg.ChunkStreamID], msg.Body)
|
r.AudioTrack.WriteAVCC(r.absTs[msg.ChunkStreamID], msg.Body)
|
||||||
}
|
}
|
||||||
@@ -140,19 +140,18 @@ func (r *RTMPReceiver) ReceiveVideo(msg *Chunk) {
|
|||||||
r.WriteAVCCVideo(0, msg.Body)
|
r.WriteAVCCVideo(0, msg.Body)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// plugin.Tracef("rev_video chunkType:%d chunkStreamID:%d ts:%d", msg.ChunkType, msg.ChunkStreamID, msg.Timestamp)
|
ts := msg.Timestamp
|
||||||
|
if ts == 0xffffff {
|
||||||
|
ts = msg.ExtendTimestamp
|
||||||
|
}
|
||||||
if msg.ChunkType == 0 {
|
if msg.ChunkType == 0 {
|
||||||
if r.VideoTrack.GetBase().Name == "" {
|
if r.VideoTrack.GetBase().Name == "" {
|
||||||
r.absTs[msg.ChunkStreamID] = 0
|
r.absTs[msg.ChunkStreamID] = 0
|
||||||
} else {
|
} else {
|
||||||
r.absTs[msg.ChunkStreamID] = r.VideoTrack.PreFrame().AbsTime
|
r.absTs[msg.ChunkStreamID] = ts
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if msg.Timestamp == 0xffffff {
|
|
||||||
r.absTs[msg.ChunkStreamID] += msg.ExtendTimestamp
|
|
||||||
} else {
|
} else {
|
||||||
r.absTs[msg.ChunkStreamID] += msg.Timestamp
|
r.absTs[msg.ChunkStreamID] += ts
|
||||||
}
|
}
|
||||||
|
|
||||||
r.VideoTrack.WriteAVCC(r.absTs[msg.ChunkStreamID], msg.Body)
|
r.VideoTrack.WriteAVCC(r.absTs[msg.ChunkStreamID], msg.Body)
|
||||||
}
|
}
|
||||||
|
18
msg.go
18
msg.go
@@ -334,7 +334,9 @@ func decodeCommandAMF0(chunk *Chunk) {
|
|||||||
chunk.MsgData = response
|
chunk.MsgData = response
|
||||||
}
|
}
|
||||||
case "FCPublish", "FCUnpublish":
|
case "FCPublish", "FCUnpublish":
|
||||||
|
fallthrough
|
||||||
default:
|
default:
|
||||||
|
chunk.MsgData = &struct{ CommandMessage }{cmdMsg}
|
||||||
RTMPPlugin.Info("decode command amf0 ", zap.String("cmd", cmd))
|
RTMPPlugin.Info("decode command amf0 ", zap.String("cmd", cmd))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,16 +507,16 @@ func (msg *PlayMessage) Encode() []byte {
|
|||||||
amf.writeNumber(float64(msg.TransactionId))
|
amf.writeNumber(float64(msg.TransactionId))
|
||||||
amf.writeNull()
|
amf.writeNull()
|
||||||
amf.writeString(msg.StreamName)
|
amf.writeString(msg.StreamName)
|
||||||
|
amf.writeNumber(-2000)
|
||||||
|
// if msg.Start > 0 {
|
||||||
|
// amf.writeNumber(msg.Start)
|
||||||
|
// }
|
||||||
|
|
||||||
if msg.Start > 0 {
|
// if msg.Duration > 0 {
|
||||||
amf.writeNumber(msg.Start)
|
// amf.writeNumber(msg.Duration)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if msg.Duration > 0 {
|
// amf.writeBool(msg.Reset)
|
||||||
amf.writeNumber(msg.Duration)
|
|
||||||
}
|
|
||||||
|
|
||||||
amf.writeBool(msg.Reset)
|
|
||||||
return amf.Buffer
|
return amf.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user