增加对releaseStream的支持

This commit is contained in:
langhuihui
2020-12-09 20:29:46 +08:00
parent fb17dd8e87
commit f7721e2f02
3 changed files with 43 additions and 2 deletions
+22 -1
View File
@@ -266,12 +266,18 @@ func decodeCommandAMF0(chunk *Chunk) {
cmdMsg,
readNumber(amf),
}
case "deleteStream", "closeStream", "releaseStream":
case "deleteStream", "closeStream":
amf.readNull()
chunk.MsgData = &CURDStreamMessage{
cmdMsg,
uint32(readNumber(amf)),
}
case "releaseStream":
amf.readNull()
chunk.MsgData = &ReleaseStreamMessage{
cmdMsg,
readString(amf),
}
case "receiveAudio", "receiveVideo":
amf.readNull()
chunk.MsgData = &ReceiveAVMessage{
@@ -329,6 +335,13 @@ type Commander interface {
func (cmd *CommandMessage) GetCommand() *CommandMessage {
return cmd
}
func (msg *CommandMessage) Encode() (b []byte) {
amf := newAMFEncoder()
amf.writeString(msg.CommandName)
amf.writeNumber(float64(msg.TransactionId))
amf.writeNull()
return amf.Bytes()
}
// Protocol control message 1.
// Set Chunk Size, is used to notify the peer of a new maximum chunk size
@@ -528,6 +541,14 @@ type CURDStreamMessage struct {
func (msg *CURDStreamMessage) Encode0() {
}
type ReleaseStreamMessage struct {
CommandMessage
StreamName string
}
func (msg *ReleaseStreamMessage) Encode0() {
}
// Receive Audio Message
// NetStream sends the receiveAudio message to inform the server whether to send or not to send the audio to the client
type ReceiveAVMessage struct {