mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-10-25 09:10:48 +08:00
fix: api/list add channelcout,KeepAliveTime
This commit is contained in:
@@ -95,19 +95,19 @@ func (gb *GB28181ProPlugin) List(ctx context.Context, req *pb.GetDevicesRequest)
|
||||
}
|
||||
|
||||
pbDevices = append(pbDevices, &pb.Device{
|
||||
Id: d.DeviceID,
|
||||
Name: d.Name,
|
||||
Manufacturer: d.Manufacturer,
|
||||
Model: d.Model,
|
||||
Owner: d.Owner,
|
||||
Status: string(d.Status),
|
||||
Online: d.Online,
|
||||
Longitude: d.Longitude,
|
||||
Latitude: d.Latitude,
|
||||
GpsTime: timestamppb.New(d.GpsTime),
|
||||
RegisterTime: timestamppb.New(d.RegisterTime),
|
||||
UpdateTime: timestamppb.New(d.UpdateTime),
|
||||
Channels: pbChannels,
|
||||
DeviceID: d.DeviceID,
|
||||
Name: d.Name,
|
||||
Manufacturer: d.Manufacturer,
|
||||
Model: d.Model,
|
||||
Status: string(d.Status),
|
||||
Online: d.Online,
|
||||
Longitude: d.Longitude,
|
||||
Latitude: d.Latitude,
|
||||
RegisterTime: timestamppb.New(d.RegisterTime),
|
||||
UpdateTime: timestamppb.New(d.UpdateTime),
|
||||
KeepAliveTime: timestamppb.New(d.KeepaliveTime),
|
||||
ChannelCount: int32(d.ChannelCount),
|
||||
Channels: pbChannels,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,16 +176,14 @@ func (gb *GB28181ProPlugin) GetDevice(ctx context.Context, req *pb.GetDeviceRequ
|
||||
})
|
||||
}
|
||||
resp.Data = &pb.Device{
|
||||
Id: d.DeviceID,
|
||||
DeviceID: d.DeviceID,
|
||||
Name: d.Name,
|
||||
Manufacturer: d.Manufacturer,
|
||||
Model: d.Model,
|
||||
Owner: d.Owner,
|
||||
Status: string(d.Status),
|
||||
Online: d.Online,
|
||||
Longitude: d.Longitude,
|
||||
Latitude: d.Latitude,
|
||||
GpsTime: timestamppb.New(d.GpsTime),
|
||||
RegisterTime: timestamppb.New(d.RegisterTime),
|
||||
UpdateTime: timestamppb.New(d.UpdateTime),
|
||||
Channels: channels,
|
||||
@@ -273,19 +271,18 @@ func (gb *GB28181ProPlugin) GetDevices(ctx context.Context, req *pb.GetDevicesRe
|
||||
}
|
||||
|
||||
pbDevice := &pb.Device{
|
||||
Id: d.DeviceID,
|
||||
Name: d.Name,
|
||||
Manufacturer: d.Manufacturer,
|
||||
Model: d.Model,
|
||||
Owner: d.Owner,
|
||||
Status: string(d.Status),
|
||||
Online: d.Online,
|
||||
Longitude: d.Longitude,
|
||||
Latitude: d.Latitude,
|
||||
GpsTime: timestamppb.New(d.GpsTime),
|
||||
RegisterTime: timestamppb.New(d.RegisterTime),
|
||||
UpdateTime: timestamppb.New(d.UpdateTime),
|
||||
Channels: pbChannels,
|
||||
DeviceID: d.DeviceID,
|
||||
Name: d.Name,
|
||||
Manufacturer: d.Manufacturer,
|
||||
Model: d.Model,
|
||||
Status: string(d.Status),
|
||||
Online: d.Online,
|
||||
Longitude: d.Longitude,
|
||||
Latitude: d.Latitude,
|
||||
RegisterTime: timestamppb.New(d.RegisterTime),
|
||||
UpdateTime: timestamppb.New(d.UpdateTime),
|
||||
KeepAliveTime: timestamppb.New(d.KeepaliveTime),
|
||||
Channels: pbChannels,
|
||||
}
|
||||
pbDevices = append(pbDevices, pbDevice)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ type Device struct {
|
||||
Name string // 设备名
|
||||
Manufacturer string // 生产厂商
|
||||
Model string // 型号
|
||||
Owner string // 所有者
|
||||
Firmware string // 固件版本
|
||||
Transport string // 传输协议(UDP/TCP)
|
||||
StreamMode string // 数据流传输模式(UDP:udp传输/TCP-ACTIVE:tcp主动模式/TCP-PASSIVE:tcp被动模式)
|
||||
@@ -68,8 +67,7 @@ type Device struct {
|
||||
Recipient sip.Uri `gorm:"-:all"`
|
||||
channels util.Collection[string, *Channel] `gorm:"-:all"`
|
||||
mediaIp string
|
||||
GpsTime time.Time // gps时间
|
||||
Longitude, Latitude string // 经度,纬度
|
||||
Longitude, Latitude string // 经度,纬度
|
||||
eventChan chan any
|
||||
client *sipgo.Client
|
||||
dialogClient *sipgo.DialogClient
|
||||
@@ -126,7 +124,7 @@ func (d *Device) onMessage(req *sip.Request, tx sip.ServerTransaction, msg *gb28
|
||||
}
|
||||
}
|
||||
// 更新当前设备的通道数
|
||||
d.ChannelCount = len(msg.DeviceChannelList)
|
||||
d.ChannelCount = msg.SumNum
|
||||
d.UpdateTime = time.Now()
|
||||
if err := d.plugin.DB.Save(d).Error; err != nil {
|
||||
d.Error("save device failed", "error", err)
|
||||
@@ -146,6 +144,7 @@ func (d *Device) onMessage(req *sip.Request, tx sip.ServerTransaction, msg *gb28
|
||||
d.Name = msg.DeviceName
|
||||
d.Manufacturer = msg.Manufacturer
|
||||
d.Model = msg.Model
|
||||
d.Firmware = msg.Firmware
|
||||
// 更新设备信息到数据库
|
||||
if d.plugin.DB != nil {
|
||||
d.UpdateTime = time.Now()
|
||||
|
||||
@@ -44,7 +44,7 @@ type GB28181ProPlugin struct {
|
||||
m7s.Plugin
|
||||
AutoInvite bool `default:"true" desc:"自动邀请"`
|
||||
Serial string `default:"34020000002000000001" desc:"sip 服务 id"` //sip 服务器 id, 默认 34020000002000000001
|
||||
Realm string `default:"3402000000" desc:"sip 服务域"` //sip 服务器域,默认 3402000000
|
||||
Realm string `default:"3402000000" desc:"sip 服务域"` //sip 服务器域,默认 3402000000
|
||||
Username string
|
||||
Password string
|
||||
Sip SipConfig
|
||||
@@ -510,23 +510,24 @@ func (gb *GB28181ProPlugin) StoreDevice(deviceid string, req *sip.Request) (d *D
|
||||
|
||||
now := time.Now()
|
||||
d = &Device{
|
||||
DeviceID: deviceid,
|
||||
CreateTime: now,
|
||||
UpdateTime: now,
|
||||
RegisterTime: now,
|
||||
Status: DeviceRegisterStatus,
|
||||
Online: true,
|
||||
StreamMode: "UDP", // 默认UDP传输
|
||||
Charset: "GB2312", // 默认GB2312字符集
|
||||
GeoCoordSys: "WGS84", // 默认WGS84坐标系
|
||||
Transport: req.Transport(), // 传输协议
|
||||
IP: hostname,
|
||||
Port: port,
|
||||
HostAddress: hostname + ":" + portStr,
|
||||
LocalIP: host,
|
||||
mediaIp: host,
|
||||
Expires: int(expSec),
|
||||
eventChan: make(chan any, 10),
|
||||
DeviceID: deviceid,
|
||||
CreateTime: now,
|
||||
UpdateTime: now,
|
||||
RegisterTime: now,
|
||||
KeepaliveTime: now,
|
||||
Status: DeviceRegisterStatus,
|
||||
Online: true,
|
||||
StreamMode: "UDP", // 默认UDP传输
|
||||
Charset: "GB2312", // 默认GB2312字符集
|
||||
GeoCoordSys: "WGS84", // 默认WGS84坐标系
|
||||
Transport: req.Transport(), // 传输协议
|
||||
IP: hostname,
|
||||
Port: port,
|
||||
HostAddress: hostname + ":" + portStr,
|
||||
LocalIP: host,
|
||||
mediaIp: host,
|
||||
Expires: int(expSec),
|
||||
eventChan: make(chan any, 10),
|
||||
Recipient: sip.Uri{
|
||||
Host: hostname,
|
||||
Port: port,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -488,25 +488,25 @@ message Channel {
|
||||
int32 RegisterWay = 12;
|
||||
int32 Secrecy =13;
|
||||
string Status =14;
|
||||
google.protobuf.Timestamp gpsTime=15;
|
||||
google.protobuf.Timestamp GpsTime=15;
|
||||
string Longitude = 16;
|
||||
string Latitude = 17;
|
||||
}
|
||||
|
||||
message Device {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string manufacturer = 3;
|
||||
string model = 4;
|
||||
string owner = 5;
|
||||
google.protobuf.Timestamp gpsTime=6;
|
||||
string longitude = 7;
|
||||
string latitude = 8;
|
||||
string status = 9;
|
||||
google.protobuf.Timestamp registerTime=10;
|
||||
google.protobuf.Timestamp updateTime=11;
|
||||
repeated Channel channels = 12;
|
||||
bool online = 13;
|
||||
string DeviceID = 1;
|
||||
string Name = 2;
|
||||
string Manufacturer = 3;
|
||||
string Model = 4;
|
||||
string Longitude = 5;
|
||||
string Latitude = 6;
|
||||
string Status = 9;
|
||||
google.protobuf.Timestamp RegisterTime=10;
|
||||
google.protobuf.Timestamp UpdateTime=11;
|
||||
google.protobuf.Timestamp KeepAliveTime=12;
|
||||
int32 ChannelCount = 13;
|
||||
bool Online = 14;
|
||||
repeated Channel Channels = 15;
|
||||
}
|
||||
|
||||
message ResponseList {
|
||||
|
||||
@@ -119,6 +119,7 @@ type (
|
||||
Manufacturer string
|
||||
Model string
|
||||
Channel string
|
||||
Firmware string
|
||||
DeviceChannelList []DeviceChannel `xml:"DeviceList>Item"`
|
||||
RecordList struct {
|
||||
Num int `xml:"Num,attr"`
|
||||
|
||||
Reference in New Issue
Block a user