代码拉取完成,页面将自动刷新
package main
import (
"time"
"github.com/deepch/vdk/av"
)
//ClientAdd Add New Client to Translations
func (obj *StorageST) ClientAdd(streamID string, channelID string, mode int) (string, chan *av.Packet, chan *[]byte, error) {
obj.mutex.Lock()
defer obj.mutex.Unlock()
streamTmp, ok := obj.Streams[streamID]
if !ok {
return "", nil, nil, ErrorStreamNotFound
}
//Generate UUID client
cid, err := generateUUID()
if err != nil {
return "", nil, nil, err
}
chAV := make(chan *av.Packet, 2000)
chRTP := make(chan *[]byte, 2000)
channelTmp, ok := streamTmp.Channels[channelID]
if !ok {
return "", nil, nil, ErrorStreamNotFound
}
channelTmp.clients[cid] = ClientST{mode: mode, outgoingAVPacket: chAV, outgoingRTPPacket: chRTP, signals: make(chan int, 100)}
channelTmp.ack = time.Now()
streamTmp.Channels[channelID] = channelTmp
obj.Streams[streamID] = streamTmp
return cid, chAV, chRTP, nil
}
//ClientDelete Delete Client
func (obj *StorageST) ClientDelete(streamID string, cid string, channelID string) {
obj.mutex.Lock()
defer obj.mutex.Unlock()
if _, ok := obj.Streams[streamID]; ok {
delete(obj.Streams[streamID].Channels[channelID].clients, cid)
}
}
//ClientHas check is client ext
func (obj *StorageST) ClientHas(streamID string, channelID string) bool {
obj.mutex.Lock()
defer obj.mutex.Unlock()
streamTmp, ok := obj.Streams[streamID]
if !ok {
return false
}
channelTmp, ok := streamTmp.Channels[channelID]
if !ok {
return false
}
if time.Now().Sub(channelTmp.ack).Seconds() > 30 {
return false
}
return true
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。