This commit is contained in:
madao
2025-02-05 19:49:09 +08:00
parent 684f045e08
commit 3aefddd1e2
10 changed files with 169 additions and 131 deletions

View File

@@ -59,7 +59,7 @@ CREATE TABLE public.camera_record (
start_time timestamp NULL, -- 开始时间 start_time timestamp NULL, -- 开始时间
end_time timestamp NULL, -- 结束时间 end_time timestamp NULL, -- 结束时间
id_camera varchar(255) NOT NULL, -- 摄像头主属性 id_camera varchar(255) NOT NULL, -- 摄像头主属性
has_audio bool NULL, -- 是否有音频 has_audio bool NULL DEFAULT true, -- 是否有音频
CONSTRAINT pk_camera_record PRIMARY KEY (id_camera_record) CONSTRAINT pk_camera_record PRIMARY KEY (id_camera_record)
); );
COMMENT ON TABLE public.camera_record IS '摄像头记录'; COMMENT ON TABLE public.camera_record IS '摄像头记录';

View File

@@ -7,7 +7,7 @@ server:
port: 8080 port: 8080
static: static:
path: ./resources/static path: ./resources/static
use-https: true use-https: false
cert: cert:
private-key-path: ./resources/conf/cert/private_key.pem private-key-path: ./resources/conf/cert/private_key.pem
cert-path: ./resources/conf/cert/certificate.crt cert-path: ./resources/conf/cert/certificate.crt

File diff suppressed because one or more lines are too long

View File

@@ -241,6 +241,7 @@ func (ffw *FileFlvWriter) flvWrite() {
FgTemp: true, FgTemp: true,
FgRemove: false, FgRemove: false,
Duration: 0, Duration: 0,
HasAudio: hasAudio(ffw.codecs),
} }
_, err = base_service.CameraRecordCreate(cameraRecord) _, err = base_service.CameraRecordCreate(cameraRecord)
if err != nil { if err != nil {
@@ -255,6 +256,15 @@ func (ffw *FileFlvWriter) flvWrite() {
} }
} }
func hasAudio(streams []av.CodecData) bool {
for _, stream := range streams {
if stream.Type().IsAudio() {
return true
}
}
return false
}
func (ffw *FileFlvWriter) writeScriptTagData() { func (ffw *FileFlvWriter) writeScriptTagData() {
var filters = []common.EqualFilter{{Name: "idCamera", Value: ffw.idCamera}, {Name: "tempFileName", Value: ffw.tempFileName}} var filters = []common.EqualFilter{{Name: "idCamera", Value: ffw.idCamera}, {Name: "tempFileName", Value: ffw.tempFileName}}
condition := common.GetEqualConditions(filters) condition := common.GetEqualConditions(filters)

View File

@@ -14,6 +14,7 @@ import (
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/flvadmin" "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/flvadmin"
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/flvadmin/fileflvmanager/fileflvreader" "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/flvadmin/fileflvmanager/fileflvreader"
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common" "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/vo/ext/flv_file"
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base" base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
) )
@@ -113,13 +114,17 @@ func HttpFlvVODFileDuration(ctx *gin.Context) {
return return
} }
duration, err := fileflvreader.FlvDurationReadUntilErr(fileName) durationInt, err := fileflvreader.FlvDurationReadUntilErr(fileName)
mediaInfo := flv_file.FlvMediaInfo{
Duration: uint32(durationInt),
HasAudio: true,
}
if err != nil { if err != nil {
logs.Error("file: %s get duration error", fileName) logs.Error("file: %s get mediaInfo error", fileName)
http.Error(ctx.Writer, "Internal Server Error", http.StatusInternalServerError) http.Error(ctx.Writer, "Internal Server Error", http.StatusInternalServerError)
return return
} }
result := common.SuccessResultData(duration) result := common.SuccessResultData(mediaInfo)
ctx.JSON(http.StatusOK, result) ctx.JSON(http.StatusOK, result)
} }

View File

@@ -5,123 +5,133 @@ import (
) )
func GetCameraRecordDesc() *common.EntityDesc { func GetCameraRecordDesc() *common.EntityDesc {
var entityInfo = common.EntityInfo{ var entityInfo = common.EntityInfo {
Name: "CameraRecord", Name: "CameraRecord",
DisplayName: "摄像头记录", DisplayName: "摄像头记录",
ClassName: "CameraRecord", ClassName: "CameraRecord",
TableName: "camera_record", TableName: "camera_record",
BasePath: "entity::camera_record", BasePath: "entity::camera_record",
} }
var idRecordAttributeInfo = &common.AttributeInfo{ var idCameraRecordAttributeInfo = &common.AttributeInfo {
ColumnName: "id_camera_record", ColumnName: "id_camera_record",
Name: "idCameraRecord", Name: "idCameraRecord",
DisplayName: "记录id", DisplayName: "记录id",
DataType: "InternalPK", DataType: "InternalPK",
ValueType: "string", ValueType: "string",
} };
var createdAttributeInfo = &common.AttributeInfo{ var createdAttributeInfo = &common.AttributeInfo {
ColumnName: "created", ColumnName: "created",
Name: "created", Name: "created",
DisplayName: "创建时间", DisplayName: "创建时间",
DataType: "DateTime", DataType: "DateTime",
ValueType: "DateTime", ValueType: "DateTime",
} };
var tempFileNameAttributeInfo = &common.AttributeInfo{ var tempFileNameAttributeInfo = &common.AttributeInfo {
ColumnName: "temp_file_name", ColumnName: "temp_file_name",
Name: "tempFileName", Name: "tempFileName",
DisplayName: "临时文件名称", DisplayName: "临时文件名称",
DataType: "String", DataType: "String",
ValueType: "string", ValueType: "string",
} };
var fgTempAttributeInfo = &common.AttributeInfo{ var fgTempAttributeInfo = &common.AttributeInfo {
ColumnName: "fg_temp", ColumnName: "fg_temp",
Name: "fgTemp", Name: "fgTemp",
DisplayName: "临时文件标志", DisplayName: "临时文件标志",
DataType: "Boolean", DataType: "Boolean",
ValueType: "bool", ValueType: "bool",
} };
var fileNameAttributeInfo = &common.AttributeInfo{ var fileNameAttributeInfo = &common.AttributeInfo {
ColumnName: "file_name", ColumnName: "file_name",
Name: "fileName", Name: "fileName",
DisplayName: "文件名称", DisplayName: "文件名称",
DataType: "String", DataType: "String",
ValueType: "string", ValueType: "string",
} };
var fgRemoveAttributeInfo = &common.AttributeInfo{ var fgRemoveAttributeInfo = &common.AttributeInfo {
ColumnName: "fg_remove", ColumnName: "fg_remove",
Name: "fgRemove", Name: "fgRemove",
DisplayName: "文件删除标志", DisplayName: "文件删除标志",
DataType: "Boolean", DataType: "Boolean",
ValueType: "bool", ValueType: "bool",
} };
var durationAttributeInfo = &common.AttributeInfo{ var durationAttributeInfo = &common.AttributeInfo {
ColumnName: "duration", ColumnName: "duration",
Name: "duration", Name: "duration",
DisplayName: "文件时长", DisplayName: "文件时长",
DataType: "Integer", DataType: "Integer",
ValueType: "number", ValueType: "number",
} };
var startTimeAttributeInfo = &common.AttributeInfo{ var startTimeAttributeInfo = &common.AttributeInfo {
ColumnName: "start_time", ColumnName: "start_time",
Name: "startTime", Name: "startTime",
DisplayName: "开始时间", DisplayName: "开始时间",
DataType: "DateTime", DataType: "DateTime",
ValueType: "DateTime", ValueType: "DateTime",
} };
var endTimeAttributeInfo = &common.AttributeInfo{ var endTimeAttributeInfo = &common.AttributeInfo {
ColumnName: "end_time", ColumnName: "end_time",
Name: "endTime", Name: "endTime",
DisplayName: "结束时间", DisplayName: "结束时间",
DataType: "DateTime", DataType: "DateTime",
ValueType: "DateTime", ValueType: "DateTime",
} };
var idCameraAttributeInfo = &common.AttributeInfo{ var hasAudioAttributeInfo = &common.AttributeInfo {
ColumnName: "id_camera", ColumnName: "has_audio",
Name: "idCamera", Name: "hasAudio",
DisplayName: "摄像头主属性", DisplayName: "是否有音频",
DataType: "InternalFK", DataType: "Boolean",
ValueType: "string", ValueType: "bool",
InnerAttributeName: "camera", };
OutEntityName: "Camera", var idCameraAttributeInfo = &common.AttributeInfo {
OutEntityPkAttributeName: "id", ColumnName: "id_camera",
OutEntityReversalAttributeName: "cameraRecords", Name: "idCamera",
} DisplayName: "摄像头主属性",
var cameraAttributeInfo = &common.AttributeInfo{ DataType: "InternalFK",
ColumnName: "", ValueType: "string",
Name: "camera", InnerAttributeName: "camera",
DisplayName: "摄像头", OutEntityName: "Camera",
DataType: "InternalRef", OutEntityPkAttributeName: "id",
ValueType: "", OutEntityReversalAttributeName: "cameraRecords",
InnerAttributeName: "idCamera", };
OutEntityName: "Camera", var cameraAttributeInfo = &common.AttributeInfo {
OutEntityPkAttributeName: "id", ColumnName: "",
OutEntityReversalAttributeName: "cameraRecords", Name: "camera",
} DisplayName: "摄像头",
var entityDesc = &common.EntityDesc{ DataType: "InternalRef",
EntityInfo: entityInfo, ValueType: "",
PkAttributeInfo: idRecordAttributeInfo, InnerAttributeName: "idCamera",
NormalFkIdAttributeInfos: []*common.AttributeInfo{ OutEntityName: "Camera",
idCameraAttributeInfo, OutEntityPkAttributeName: "id",
}, OutEntityReversalAttributeName: "cameraRecords",
NormalFkAttributeInfos: []*common.AttributeInfo{ };
cameraAttributeInfo, var entityDesc = &common.EntityDesc {
}, EntityInfo: entityInfo,
NormalChildren: []*common.AttributeInfo{}, PkAttributeInfo: idCameraRecordAttributeInfo,
NormalOne2OneChildren: []*common.AttributeInfo{}, NormalFkIdAttributeInfos: []*common.AttributeInfo{
AttributeInfoMap: map[string]*common.AttributeInfo{ idCameraAttributeInfo,
"idCameraRecord": idRecordAttributeInfo, },
"created": createdAttributeInfo, NormalFkAttributeInfos: []*common.AttributeInfo{
"tempFileName": tempFileNameAttributeInfo, cameraAttributeInfo,
"fgTemp": fgTempAttributeInfo, },
"fileName": fileNameAttributeInfo, NormalChildren: []*common.AttributeInfo{
"fgRemove": fgRemoveAttributeInfo, },
"duration": durationAttributeInfo, NormalOne2OneChildren: []*common.AttributeInfo{
"startTime": startTimeAttributeInfo, },
"endTime": endTimeAttributeInfo, AttributeInfoMap: map[string]*common.AttributeInfo{
"idCamera": idCameraAttributeInfo, "idCameraRecord": idCameraRecordAttributeInfo,
"camera": cameraAttributeInfo, "created": createdAttributeInfo,
}, "tempFileName": tempFileNameAttributeInfo,
} "fgTemp": fgTempAttributeInfo,
"fileName": fileNameAttributeInfo,
"fgRemove": fgRemoveAttributeInfo,
"duration": durationAttributeInfo,
"startTime": startTimeAttributeInfo,
"endTime": endTimeAttributeInfo,
"hasAudio": hasAudioAttributeInfo,
"idCamera": idCameraAttributeInfo,
"camera": cameraAttributeInfo,
},
}
return entityDesc return entityDesc
} }

View File

@@ -3,11 +3,10 @@ package entity
import ( import (
"time" "time"
) )
// 摄像头记录 // 摄像头记录
type CameraRecord struct { type CameraRecord struct {
// 记录id // 记录id
IdCameraRecord string `orm:"pk;column(id_camera_record)" json:"idCameraRecord"` IdCameraRecord string `orm:"pk;column(id_camera_record)" json:"idCameraRecord"`
// 创建时间: // 创建时间:
Created time.Time `orm:"column(created)" json:"created"` Created time.Time `orm:"column(created)" json:"created"`
// 临时文件名称: // 临时文件名称:
@@ -24,6 +23,8 @@ type CameraRecord struct {
StartTime time.Time `orm:"column(start_time)" json:"startTime"` StartTime time.Time `orm:"column(start_time)" json:"startTime"`
// 结束时间: // 结束时间:
EndTime time.Time `orm:"column(end_time)" json:"endTime"` EndTime time.Time `orm:"column(end_time)" json:"endTime"`
// 是否有音频
HasAudio bool `orm:"column(has_audio)" json:"hasAudio"`
// 摄像头主属性: // 摄像头主属性:
IdCamera string `orm:"column(id_camera)" json:"idCamera"` IdCamera string `orm:"column(id_camera)" json:"idCamera"`
// 摄像头: // 摄像头:

View File

@@ -24,6 +24,8 @@ type CameraRecordPO struct {
StartTime time.Time `json:"startTime"` StartTime time.Time `json:"startTime"`
// 结束时间: // 结束时间:
EndTime time.Time `json:"endTime"` EndTime time.Time `json:"endTime"`
// 是否有音频
HasAudio bool `json:"hasAudio"`
// 摄像头主属性: // 摄像头主属性:
IdCamera string `json:"idCamera"` IdCamera string `json:"idCamera"`
// 摄像头: // 摄像头:

View File

@@ -24,6 +24,8 @@ type CameraRecordVO struct {
StartTime time.Time `json:"startTime"` StartTime time.Time `json:"startTime"`
// 结束时间: // 结束时间:
EndTime time.Time `json:"endTime"` EndTime time.Time `json:"endTime"`
// 是否有音频
HasAudio bool `json:"hasAudio"`
// 摄像头主属性: // 摄像头主属性:
IdCamera string `json:"idCamera"` IdCamera string `json:"idCamera"`
// 摄像头: // 摄像头:
@@ -52,4 +54,12 @@ type CameraVO struct {
Live bool `json:"live"` Live bool `json:"live"`
// 创建时间: // 创建时间:
Created time.Time `json:"created"` Created time.Time `json:"created"`
// 加密标志:
FgEncrypt bool `json:"fgEncrypt"`
// 被动推送rtmp标志
FgPassive bool `json:"fgPassive"`
// rtmp识别码:
RtmpAuthCode string `json:"rtmpAuthCode"`
// 摄像头类型:
CameraType string `json:"cameraType"`
} }

View File

@@ -59,7 +59,7 @@ func CameraRecordBatchDelete(es []entity.CameraRecord) (i int64, err error) {
func CameraRecordSelectById(id string) (model entity.CameraRecord, err error) { func CameraRecordSelectById(id string) (model entity.CameraRecord, err error) {
o := orm.NewOrm() o := orm.NewOrm()
model = entity.CameraRecord{IdCameraRecord: id} model = entity.CameraRecord{ IdCameraRecord: id }
err = o.Read(&model) err = o.Read(&model)
@@ -96,7 +96,7 @@ func CameraRecordSelectByIds(ids []string) (models []entity.CameraRecord, err er
// execute the raw query string // execute the raw query string
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models) _, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
if err_query != nil { if err_query != nil {
err = fmt.Errorf("selectByIds error: %v", err_make_sql) err = fmt.Errorf("selectByIds error: %v", err_query)
return return
} }
@@ -118,7 +118,7 @@ func CameraRecordFindCollectionByCondition(condition common.AqCondition) (models
// execute the raw query string // execute the raw query string
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models) _, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
if err_query != nil { if err_query != nil {
err = fmt.Errorf("findCollectionByCondition error: %v", err_make_sql) err = fmt.Errorf("findCollectionByCondition error: %v", err_query)
return return
} }
return return
@@ -140,7 +140,7 @@ func CameraRecordFindOneByCondition(condition common.AqCondition) (model entity.
models := make([]entity.CameraRecord, 0) models := make([]entity.CameraRecord, 0)
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models) _, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
if err_query != nil { if err_query != nil {
err = fmt.Errorf("findOneByCondition error: %v", err_make_sql) err = fmt.Errorf("findOneByCondition error: %v", err_query)
return return
} }
if len(models) < 1 { if len(models) < 1 {
@@ -184,7 +184,7 @@ func CameraRecordFindPageByCondition(aqPageInfoInput common.AqPageInfoInput) (pa
models := make([]entity.CameraRecord, 0) models := make([]entity.CameraRecord, 0)
_, err_query := o.Raw(pageSqlStr, params...).QueryRows(&models) _, err_query := o.Raw(pageSqlStr, params...).QueryRows(&models)
if err_query != nil { if err_query != nil {
err = fmt.Errorf("findPageByCondition error: %v", err_make_sql) err = fmt.Errorf("findPageByCondition error: %v", err_query)
return return
} }
dataList := make([]interface{}, 0) dataList := make([]interface{}, 0)