mirror of
https://github.com/nonoo/kappanhang.git
synced 2025-12-06 08:02:00 +01:00
Add audio stream close
This commit is contained in:
parent
276e31b111
commit
c80ecd2d3b
|
|
@ -10,6 +10,10 @@ type audioStream struct {
|
||||||
common streamCommon
|
common streamCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *audioStream) sendDisconnect() {
|
||||||
|
s.common.sendDisconnect()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *audioStream) start() {
|
func (s *audioStream) start() {
|
||||||
s.common.open("audio", 50003)
|
s.common.open("audio", 50003)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,7 @@ func (s *controlStream) sendDisconnect() {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||||
s.common.send([]byte{0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
s.common.sendDisconnect()
|
||||||
byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID),
|
|
||||||
byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID)})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controlStream) sendPkt0() {
|
func (s *controlStream) sendPkt0() {
|
||||||
|
|
|
||||||
13
main.go
13
main.go
|
|
@ -14,12 +14,21 @@ var streams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func exit(err error) {
|
func exit(err error) {
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
}
|
||||||
log.Print("disconnecting")
|
log.Print("disconnecting")
|
||||||
streams.control.sendDisconnect()
|
|
||||||
|
if streams.audio.common.conn != nil {
|
||||||
|
streams.audio.sendDisconnect()
|
||||||
|
}
|
||||||
|
if streams.control.common.conn != nil {
|
||||||
|
streams.control.sendDisconnect()
|
||||||
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else {
|
} else {
|
||||||
log.Error(err.Error())
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,3 +149,9 @@ func (s *streamCommon) sendPkt7() {
|
||||||
func (s *streamCommon) sendPkt7Reply(replyID []byte, seq uint16) {
|
func (s *streamCommon) sendPkt7Reply(replyID []byte, seq uint16) {
|
||||||
s.sendPkt7Do(replyID, seq)
|
s.sendPkt7Do(replyID, seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *streamCommon) sendDisconnect() {
|
||||||
|
s.send([]byte{0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||||
|
byte(s.localSID >> 24), byte(s.localSID >> 16), byte(s.localSID >> 8), byte(s.localSID),
|
||||||
|
byte(s.remoteSID >> 24), byte(s.remoteSID >> 16), byte(s.remoteSID >> 8), byte(s.remoteSID)})
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue