Compare commits

...

3 Commits

Author SHA1 Message Date
pggiroro
e7a6f0bba5 fix: catalog after recover register 2025-09-23 11:02:39 +08:00
langhuihui
4f75725a0e fix: ffmpeg8 need bitrate arg 2025-09-23 10:51:35 +08:00
pggiroro
ae698c7b5a fix: db. SetMaxOpenConns, gb28181 device do not update Longitude, Latitude when the two param is 0 2025-09-22 22:46:12 +08:00
5 changed files with 22 additions and 7 deletions

View File

@@ -133,6 +133,8 @@ func (gb *GB28181Plugin) List(ctx context.Context, req *pb.GetDevicesRequest) (*
Port: int32(d.Port),
BroadcastPushAfterAck: d.BroadcastPushAfterAck,
SubscribeCatalog: util.Conditional(d.SubscribeCatalog == 0, false, true),
SubscribePosition: util.Conditional(d.SubscribePosition == 0, false, true),
SubscribeAlarm: util.Conditional(d.SubscribeAlarm == 0, false, true),
})
}
@@ -564,7 +566,7 @@ func (gb *GB28181Plugin) UpdateDevice(ctx context.Context, req *pb.Device) (*pb.
d.PositionSubscribeTask.Tick(nil)
} else {
if d.PositionSubscribeTask != nil {
d.CatalogSubscribeTask.Tick(nil)
d.PositionSubscribeTask.Tick(nil)
d.PositionSubscribeTask.Ticker.Reset(time.Hour * 999999)
}
}
@@ -2895,7 +2897,7 @@ func (gb *GB28181Plugin) UpdateChannel(ctx context.Context, req *pb.UpdateChanne
}
// 记录日志
gb.Info("通道信息已更新",
gb.Debug("通道信息已更新",
"通道ID", req.Id,
"自定义通道ID", channel.DeviceChannel.CustomChannelId,
"自定义名称", channel.DeviceChannel.CustomName)

View File

@@ -364,8 +364,12 @@ func (d *Device) onMessage(req *sip.Request, tx sip.ServerTransaction, msg *gb28
d.Model = msg.Model
d.Firmware = msg.Firmware
d.UpdateTime = time.Now()
d.Latitude = msg.Latitude
d.Longitude = msg.Longitude
if msg.Latitude != "" {
d.Latitude = msg.Latitude
}
if msg.Longitude != "" {
d.Longitude = msg.Longitude
}
case "Alarm":
// 创建报警记录
alarm := &gb28181.DeviceAlarm{
@@ -766,8 +770,12 @@ func (d *Device) onNotify(req *sip.Request, tx sip.ServerTransaction, msg *gb281
gpsTime = gpsTime.UTC()
// 更新设备的经纬度信息
d.Longitude = fmt.Sprintf("%.6f", posNotify.Longitude)
d.Latitude = fmt.Sprintf("%.6f", posNotify.Latitude)
if posNotify.Longitude != 0 {
d.Longitude = fmt.Sprintf("%.6f", posNotify.Longitude)
}
if posNotify.Latitude != 0 {
d.Latitude = fmt.Sprintf("%.6f", posNotify.Latitude)
}
d.UpdateTime = time.Now()
// 如果需要,可以将更新保存到数据库

View File

@@ -327,6 +327,7 @@ func (task *registerHandlerTask) RecoverDevice(d *Device, req *sip.Request) {
//}
task.gb.DB.Save(d)
}
d.catalog()
return
}

View File

@@ -34,7 +34,7 @@ func (rt *AcceptPushTask) Start() error {
}
// 添加视频编码参数
if !rt.testCase.AudioOnly {
args = append(args, "-c:v", rt.testCase.VideoCodec)
args = append(args, "-c:v", rt.testCase.VideoCodec, "-b:v", "200k")
} else {
args = append(args, "-vn")
}

View File

@@ -299,6 +299,10 @@ func (s *Server) Start() (err error) {
s.Error("failed to connect database", "error", err, "dsn", s.config.DSN, "type", s.config.DBType)
return
}
sqlDB, _ := s.DB.DB()
sqlDB.SetMaxIdleConns(25)
sqlDB.SetMaxOpenConns(100)
sqlDB.SetConnMaxLifetime(5 * time.Minute)
// Auto-migrate models
if err = s.DB.AutoMigrate(&db.User{}, &PullProxyConfig{}, &PushProxyConfig{}, &StreamAliasDB{}, &AlarmInfo{}); err != nil {
s.Error("failed to auto-migrate models", "error", err)