From d7a3f2c55d687b0aa6134c48c124d6b6b4e0ef73 Mon Sep 17 00:00:00 2001 From: pggiroro Date: Fri, 3 Oct 2025 20:33:01 +0800 Subject: [PATCH] feat: add tags to streampath --- plugin/mp4/api.go | 224 ++++++++++++ plugin/mp4/index.go | 4 + plugin/mp4/pb/mp4.pb.go | 587 ++++++++++++++++++++++++++++-- plugin/mp4/pb/mp4.pb.gw.go | 674 +++++++++++++++++++++-------------- plugin/mp4/pb/mp4.proto | 72 ++++ plugin/mp4/pb/mp4_grpc.pb.go | 152 ++++++++ plugin/mp4/pkg/tagsmodel.go | 23 ++ 7 files changed, 1450 insertions(+), 286 deletions(-) create mode 100644 plugin/mp4/pkg/tagsmodel.go diff --git a/plugin/mp4/api.go b/plugin/mp4/api.go index 2e0308e..4340a0a 100644 --- a/plugin/mp4/api.go +++ b/plugin/mp4/api.go @@ -608,3 +608,227 @@ func (p *MP4Plugin) Delete(ctx context.Context, req *mp4pb.ReqRecordDelete) (res } return p.Server.DeleteRecord(ctx, globalReq) } + +// CreateTag 创建标签 +func (p *MP4Plugin) CreateTag(ctx context.Context, req *mp4pb.ReqCreateTag) (res *mp4pb.ResponseTag, err error) { + res = &mp4pb.ResponseTag{} + + // 检查数据库连接 + if p.DB == nil { + res.Code = 500 + res.Message = pkg.ErrNoDB.Error() + return res, pkg.ErrNoDB + } + + // 解析标签时间 + tagTime, err := util.TimeQueryParse(req.TagTime) + if err != nil { + res.Code = 400 + res.Message = "标签时间格式错误: " + err.Error() + return res, err + } + + // 创建标签记录 + tag := &mp4.TagModel{ + TagName: req.TagName, + StreamPath: req.StreamPath, + TagTime: tagTime, + } + + // 保存到数据库 + if err = p.DB.Create(tag).Error; err != nil { + res.Code = 500 + res.Message = "创建标签失败: " + err.Error() + return res, err + } + + // 返回成功结果 + res.Code = 0 + res.Message = "创建成功" + res.Data = &mp4pb.TagInfo{ + Id: uint32(tag.ID), + TagName: tag.TagName, + StreamPath: tag.StreamPath, + TagTime: tag.TagTime.Format(time.RFC3339), + CreatedAt: tag.CreatedAt.Format(time.RFC3339), + UpdatedAt: tag.UpdatedAt.Format(time.RFC3339), + } + + return res, nil +} + +// UpdateTag 更新标签 +func (p *MP4Plugin) UpdateTag(ctx context.Context, req *mp4pb.ReqUpdateTag) (res *mp4pb.ResponseTag, err error) { + res = &mp4pb.ResponseTag{} + + // 检查数据库连接 + if p.DB == nil { + res.Code = 500 + res.Message = pkg.ErrNoDB.Error() + return res, pkg.ErrNoDB + } + + // 查询标签是否存在 + var tag mp4.TagModel + if err = p.DB.First(&tag, req.Id).Error; err != nil { + res.Code = 404 + res.Message = "标签不存在: " + err.Error() + return res, err + } + + // 更新字段 + if req.TagName != "" { + tag.TagName = req.TagName + } + if req.StreamPath != "" { + tag.StreamPath = req.StreamPath + } + if req.TagTime != "" { + tagTime, err := util.TimeQueryParse(req.TagTime) + if err != nil { + res.Code = 400 + res.Message = "标签时间格式错误: " + err.Error() + return res, err + } + tag.TagTime = tagTime + } + + // 保存更新 + if err = p.DB.Save(&tag).Error; err != nil { + res.Code = 500 + res.Message = "更新标签失败: " + err.Error() + return res, err + } + + // 返回成功结果 + res.Code = 0 + res.Message = "更新成功" + res.Data = &mp4pb.TagInfo{ + Id: uint32(tag.ID), + TagName: tag.TagName, + StreamPath: tag.StreamPath, + TagTime: tag.TagTime.Format(time.RFC3339), + CreatedAt: tag.CreatedAt.Format(time.RFC3339), + UpdatedAt: tag.UpdatedAt.Format(time.RFC3339), + } + + return res, nil +} + +// DeleteTag 删除标签(软删除) +func (p *MP4Plugin) DeleteTag(ctx context.Context, req *mp4pb.ReqDeleteTag) (res *mp4pb.ResponseTag, err error) { + res = &mp4pb.ResponseTag{} + + // 检查数据库连接 + if p.DB == nil { + res.Code = 500 + res.Message = pkg.ErrNoDB.Error() + return res, pkg.ErrNoDB + } + + // 软删除标签 + if err = p.DB.Delete(&mp4.TagModel{}, req.Id).Error; err != nil { + res.Code = 500 + res.Message = "删除标签失败: " + err.Error() + return res, err + } + + // 返回成功结果 + res.Code = 0 + res.Message = "删除成功" + + return res, nil +} + +// ListTag 查询标签列表 +func (p *MP4Plugin) ListTag(ctx context.Context, req *mp4pb.ReqListTag) (res *mp4pb.ResponseTagList, err error) { + res = &mp4pb.ResponseTagList{} + + // 检查数据库连接 + if p.DB == nil { + res.Code = 500 + res.Message = pkg.ErrNoDB.Error() + return res, pkg.ErrNoDB + } + + // 构建查询 + query := p.DB.Model(&mp4.TagModel{}) + + // 流路径过滤(默认模糊匹配) + if req.StreamPath != "" { + if strings.Contains(req.StreamPath, "*") { + query = query.Where("stream_path LIKE ?", strings.ReplaceAll(req.StreamPath, "*", "%")) + } else { + query = query.Where("stream_path LIKE ?", "%"+req.StreamPath+"%") + } + } + + // 标签名称过滤(默认模糊匹配) + if req.TagName != "" { + if strings.Contains(req.TagName, "*") { + query = query.Where("tag_name LIKE ?", strings.ReplaceAll(req.TagName, "*", "%")) + } else { + query = query.Where("tag_name LIKE ?", "%"+req.TagName+"%") + } + } + + // 时间范围过滤(只有当传入了时间参数时才进行过滤) + if req.Start != "" { + startTime, err := util.TimeQueryParse(req.Start) + if err == nil && !startTime.IsZero() { + query = query.Where("tag_time >= ?", startTime) + } + } + if req.End != "" { + endTime, err := util.TimeQueryParse(req.End) + if err == nil && !endTime.IsZero() { + query = query.Where("tag_time <= ?", endTime) + } + } + + // 分页 + page := req.Page + count := req.Count + if page < 1 { + page = 1 + } + if count < 1 { + count = 10 + } + offset := (page - 1) * count + + // 获取总数 + var total int64 + if err = query.Count(&total).Error; err != nil { + res.Code = 500 + res.Message = "查询总数失败: " + err.Error() + return res, err + } + + // 查询数据 + var tags []mp4.TagModel + if err = query.Order("tag_time DESC").Offset(int(offset)).Limit(int(count)).Find(&tags).Error; err != nil { + res.Code = 500 + res.Message = "查询标签失败: " + err.Error() + return res, err + } + + // 转换为响应格式 + res.Code = 0 + res.Message = "查询成功" + res.Total = uint32(total) + res.List = make([]*mp4pb.TagInfo, 0, len(tags)) + + for _, tag := range tags { + res.List = append(res.List, &mp4pb.TagInfo{ + Id: uint32(tag.ID), + TagName: tag.TagName, + StreamPath: tag.StreamPath, + TagTime: tag.TagTime.Format(time.RFC3339), + CreatedAt: tag.CreatedAt.Format(time.RFC3339), + UpdatedAt: tag.UpdatedAt.Format(time.RFC3339), + }) + } + + return res, nil +} diff --git a/plugin/mp4/index.go b/plugin/mp4/index.go index c2858c9..aeb1041 100644 --- a/plugin/mp4/index.go +++ b/plugin/mp4/index.go @@ -56,6 +56,10 @@ func (p *MP4Plugin) Start() (err error) { if err != nil { return } + err = p.DB.AutoMigrate(&mp4.TagModel{}) + if err != nil { + return + } if p.AutoOverWriteDiskPercent > 0 { var deleteRecordTask DeleteRecordTask deleteRecordTask.DB = p.DB diff --git a/plugin/mp4/pb/mp4.pb.go b/plugin/mp4/pb/mp4.pb.go index 3764432..843809a 100644 --- a/plugin/mp4/pb/mp4.pb.go +++ b/plugin/mp4/pb/mp4.pb.go @@ -585,6 +585,475 @@ func (x *ResponseStopRecord) GetData() uint64 { return 0 } +// 标签相关消息定义 +type TagInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + TagName string `protobuf:"bytes,2,opt,name=tagName,proto3" json:"tagName,omitempty"` + StreamPath string `protobuf:"bytes,3,opt,name=streamPath,proto3" json:"streamPath,omitempty"` + TagTime string `protobuf:"bytes,4,opt,name=tagTime,proto3" json:"tagTime,omitempty"` + CreatedAt string `protobuf:"bytes,5,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + UpdatedAt string `protobuf:"bytes,6,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TagInfo) Reset() { + *x = TagInfo{} + mi := &file_mp4_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TagInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TagInfo) ProtoMessage() {} + +func (x *TagInfo) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TagInfo.ProtoReflect.Descriptor instead. +func (*TagInfo) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{8} +} + +func (x *TagInfo) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *TagInfo) GetTagName() string { + if x != nil { + return x.TagName + } + return "" +} + +func (x *TagInfo) GetStreamPath() string { + if x != nil { + return x.StreamPath + } + return "" +} + +func (x *TagInfo) GetTagTime() string { + if x != nil { + return x.TagTime + } + return "" +} + +func (x *TagInfo) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *TagInfo) GetUpdatedAt() string { + if x != nil { + return x.UpdatedAt + } + return "" +} + +type ReqCreateTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + TagName string `protobuf:"bytes,1,opt,name=tagName,proto3" json:"tagName,omitempty"` + StreamPath string `protobuf:"bytes,2,opt,name=streamPath,proto3" json:"streamPath,omitempty"` + TagTime string `protobuf:"bytes,3,opt,name=tagTime,proto3" json:"tagTime,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReqCreateTag) Reset() { + *x = ReqCreateTag{} + mi := &file_mp4_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReqCreateTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqCreateTag) ProtoMessage() {} + +func (x *ReqCreateTag) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReqCreateTag.ProtoReflect.Descriptor instead. +func (*ReqCreateTag) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{9} +} + +func (x *ReqCreateTag) GetTagName() string { + if x != nil { + return x.TagName + } + return "" +} + +func (x *ReqCreateTag) GetStreamPath() string { + if x != nil { + return x.StreamPath + } + return "" +} + +func (x *ReqCreateTag) GetTagTime() string { + if x != nil { + return x.TagTime + } + return "" +} + +type ReqUpdateTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + TagName string `protobuf:"bytes,2,opt,name=tagName,proto3" json:"tagName,omitempty"` + StreamPath string `protobuf:"bytes,3,opt,name=streamPath,proto3" json:"streamPath,omitempty"` + TagTime string `protobuf:"bytes,4,opt,name=tagTime,proto3" json:"tagTime,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReqUpdateTag) Reset() { + *x = ReqUpdateTag{} + mi := &file_mp4_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReqUpdateTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqUpdateTag) ProtoMessage() {} + +func (x *ReqUpdateTag) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReqUpdateTag.ProtoReflect.Descriptor instead. +func (*ReqUpdateTag) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{10} +} + +func (x *ReqUpdateTag) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ReqUpdateTag) GetTagName() string { + if x != nil { + return x.TagName + } + return "" +} + +func (x *ReqUpdateTag) GetStreamPath() string { + if x != nil { + return x.StreamPath + } + return "" +} + +func (x *ReqUpdateTag) GetTagTime() string { + if x != nil { + return x.TagTime + } + return "" +} + +type ReqDeleteTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReqDeleteTag) Reset() { + *x = ReqDeleteTag{} + mi := &file_mp4_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReqDeleteTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqDeleteTag) ProtoMessage() {} + +func (x *ReqDeleteTag) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReqDeleteTag.ProtoReflect.Descriptor instead. +func (*ReqDeleteTag) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{11} +} + +func (x *ReqDeleteTag) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +type ReqListTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + StreamPath string `protobuf:"bytes,1,opt,name=streamPath,proto3" json:"streamPath,omitempty"` + TagName string `protobuf:"bytes,2,opt,name=tagName,proto3" json:"tagName,omitempty"` + Start string `protobuf:"bytes,3,opt,name=start,proto3" json:"start,omitempty"` + End string `protobuf:"bytes,4,opt,name=end,proto3" json:"end,omitempty"` + Page uint32 `protobuf:"varint,5,opt,name=page,proto3" json:"page,omitempty"` + Count uint32 `protobuf:"varint,6,opt,name=count,proto3" json:"count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReqListTag) Reset() { + *x = ReqListTag{} + mi := &file_mp4_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReqListTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqListTag) ProtoMessage() {} + +func (x *ReqListTag) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReqListTag.ProtoReflect.Descriptor instead. +func (*ReqListTag) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{12} +} + +func (x *ReqListTag) GetStreamPath() string { + if x != nil { + return x.StreamPath + } + return "" +} + +func (x *ReqListTag) GetTagName() string { + if x != nil { + return x.TagName + } + return "" +} + +func (x *ReqListTag) GetStart() string { + if x != nil { + return x.Start + } + return "" +} + +func (x *ReqListTag) GetEnd() string { + if x != nil { + return x.End + } + return "" +} + +func (x *ReqListTag) GetPage() uint32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ReqListTag) GetCount() uint32 { + if x != nil { + return x.Count + } + return 0 +} + +type ResponseTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Data *TagInfo `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResponseTag) Reset() { + *x = ResponseTag{} + mi := &file_mp4_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResponseTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseTag) ProtoMessage() {} + +func (x *ResponseTag) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseTag.ProtoReflect.Descriptor instead. +func (*ResponseTag) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{13} +} + +func (x *ResponseTag) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *ResponseTag) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *ResponseTag) GetData() *TagInfo { + if x != nil { + return x.Data + } + return nil +} + +type ResponseTagList struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + List []*TagInfo `protobuf:"bytes,3,rep,name=list,proto3" json:"list,omitempty"` + Total uint32 `protobuf:"varint,4,opt,name=total,proto3" json:"total,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResponseTagList) Reset() { + *x = ResponseTagList{} + mi := &file_mp4_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResponseTagList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseTagList) ProtoMessage() {} + +func (x *ResponseTagList) ProtoReflect() protoreflect.Message { + mi := &file_mp4_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseTagList.ProtoReflect.Descriptor instead. +func (*ResponseTagList) Descriptor() ([]byte, []int) { + return file_mp4_proto_rawDescGZIP(), []int{14} +} + +func (x *ResponseTagList) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *ResponseTagList) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *ResponseTagList) GetList() []*TagInfo { + if x != nil { + return x.List + } + return nil +} + +func (x *ResponseTagList) GetTotal() uint32 { + if x != nil { + return x.Total + } + return 0 +} + var File_mp4_proto protoreflect.FileDescriptor const file_mp4_proto_rawDesc = "" + @@ -645,7 +1114,50 @@ const file_mp4_proto_rawDesc = "" + "\x12ResponseStopRecord\x12\x12\n" + "\x04code\x18\x01 \x01(\x05R\x04code\x12\x18\n" + "\amessage\x18\x02 \x01(\tR\amessage\x12\x12\n" + - "\x04data\x18\x03 \x01(\x04R\x04data2\xca\x04\n" + + "\x04data\x18\x03 \x01(\x04R\x04data\"\xa9\x01\n" + + "\aTagInfo\x12\x0e\n" + + "\x02id\x18\x01 \x01(\rR\x02id\x12\x18\n" + + "\atagName\x18\x02 \x01(\tR\atagName\x12\x1e\n" + + "\n" + + "streamPath\x18\x03 \x01(\tR\n" + + "streamPath\x12\x18\n" + + "\atagTime\x18\x04 \x01(\tR\atagTime\x12\x1c\n" + + "\tcreatedAt\x18\x05 \x01(\tR\tcreatedAt\x12\x1c\n" + + "\tupdatedAt\x18\x06 \x01(\tR\tupdatedAt\"b\n" + + "\fReqCreateTag\x12\x18\n" + + "\atagName\x18\x01 \x01(\tR\atagName\x12\x1e\n" + + "\n" + + "streamPath\x18\x02 \x01(\tR\n" + + "streamPath\x12\x18\n" + + "\atagTime\x18\x03 \x01(\tR\atagTime\"r\n" + + "\fReqUpdateTag\x12\x0e\n" + + "\x02id\x18\x01 \x01(\rR\x02id\x12\x18\n" + + "\atagName\x18\x02 \x01(\tR\atagName\x12\x1e\n" + + "\n" + + "streamPath\x18\x03 \x01(\tR\n" + + "streamPath\x12\x18\n" + + "\atagTime\x18\x04 \x01(\tR\atagTime\"\x1e\n" + + "\fReqDeleteTag\x12\x0e\n" + + "\x02id\x18\x01 \x01(\rR\x02id\"\x98\x01\n" + + "\n" + + "ReqListTag\x12\x1e\n" + + "\n" + + "streamPath\x18\x01 \x01(\tR\n" + + "streamPath\x12\x18\n" + + "\atagName\x18\x02 \x01(\tR\atagName\x12\x14\n" + + "\x05start\x18\x03 \x01(\tR\x05start\x12\x10\n" + + "\x03end\x18\x04 \x01(\tR\x03end\x12\x12\n" + + "\x04page\x18\x05 \x01(\rR\x04page\x12\x14\n" + + "\x05count\x18\x06 \x01(\rR\x05count\"]\n" + + "\vResponseTag\x12\x12\n" + + "\x04code\x18\x01 \x01(\x05R\x04code\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12 \n" + + "\x04data\x18\x03 \x01(\v2\f.mp4.TagInfoR\x04data\"w\n" + + "\x0fResponseTagList\x12\x12\n" + + "\x04code\x18\x01 \x01(\x05R\x04code\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12 \n" + + "\x04list\x18\x03 \x03(\v2\f.mp4.TagInfoR\x04list\x12\x14\n" + + "\x05total\x18\x04 \x01(\rR\x05total2\x94\a\n" + "\x03api\x12]\n" + "\x04List\x12\x12.mp4.ReqRecordList\x1a\x1a.global.RecordResponseList\"%\x82\xd3\xe4\x93\x02\x1f\x12\x1d/mp4/api/list/{streamPath=**}\x12T\n" + "\aCatalog\x12\x16.google.protobuf.Empty\x1a\x17.global.ResponseCatalog\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/mp4/api/catalog\x12b\n" + @@ -654,7 +1166,11 @@ const file_mp4_proto_rawDesc = "" + "EventStart\x12\x13.mp4.ReqEventRecord\x1a\x18.mp4.ResponseEventRecord\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/mp4/api/event/start\x12g\n" + "\vStartRecord\x12\x13.mp4.ReqStartRecord\x1a\x18.mp4.ResponseStartRecord\")\x82\xd3\xe4\x93\x02#:\x01*\"\x1e/mp4/api/start/{streamPath=**}\x12c\n" + "\n" + - "StopRecord\x12\x12.mp4.ReqStopRecord\x1a\x17.mp4.ResponseStopRecord\"(\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/mp4/api/stop/{streamPath=**}B\x1bZ\x19m7s.live/v5/plugin/mp4/pbb\x06proto3" + "StopRecord\x12\x12.mp4.ReqStopRecord\x1a\x17.mp4.ResponseStopRecord\"(\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/mp4/api/stop/{streamPath=**}\x12M\n" + + "\tCreateTag\x12\x11.mp4.ReqCreateTag\x1a\x10.mp4.ResponseTag\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/mp4/api/tag/add\x12U\n" + + "\tUpdateTag\x12\x11.mp4.ReqUpdateTag\x1a\x10.mp4.ResponseTag\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/mp4/api/tag/update/{id}\x12U\n" + + "\tDeleteTag\x12\x11.mp4.ReqDeleteTag\x1a\x10.mp4.ResponseTag\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/mp4/api/tag/delete/{id}\x12K\n" + + "\aListTag\x12\x0f.mp4.ReqListTag\x1a\x14.mp4.ResponseTagList\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/mp4/api/tag/listB\x1bZ\x19m7s.live/v5/plugin/mp4/pbb\x06proto3" var ( file_mp4_proto_rawDescOnce sync.Once @@ -668,7 +1184,7 @@ func file_mp4_proto_rawDescGZIP() []byte { return file_mp4_proto_rawDescData } -var file_mp4_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_mp4_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_mp4_proto_goTypes = []any{ (*ReqRecordList)(nil), // 0: mp4.ReqRecordList (*ReqRecordDelete)(nil), // 1: mp4.ReqRecordDelete @@ -678,31 +1194,48 @@ var file_mp4_proto_goTypes = []any{ (*ResponseStartRecord)(nil), // 5: mp4.ResponseStartRecord (*ReqStopRecord)(nil), // 6: mp4.ReqStopRecord (*ResponseStopRecord)(nil), // 7: mp4.ResponseStopRecord - (*durationpb.Duration)(nil), // 8: google.protobuf.Duration - (*emptypb.Empty)(nil), // 9: google.protobuf.Empty - (*pb.RecordResponseList)(nil), // 10: global.RecordResponseList - (*pb.ResponseCatalog)(nil), // 11: global.ResponseCatalog - (*pb.ResponseDelete)(nil), // 12: global.ResponseDelete + (*TagInfo)(nil), // 8: mp4.TagInfo + (*ReqCreateTag)(nil), // 9: mp4.ReqCreateTag + (*ReqUpdateTag)(nil), // 10: mp4.ReqUpdateTag + (*ReqDeleteTag)(nil), // 11: mp4.ReqDeleteTag + (*ReqListTag)(nil), // 12: mp4.ReqListTag + (*ResponseTag)(nil), // 13: mp4.ResponseTag + (*ResponseTagList)(nil), // 14: mp4.ResponseTagList + (*durationpb.Duration)(nil), // 15: google.protobuf.Duration + (*emptypb.Empty)(nil), // 16: google.protobuf.Empty + (*pb.RecordResponseList)(nil), // 17: global.RecordResponseList + (*pb.ResponseCatalog)(nil), // 18: global.ResponseCatalog + (*pb.ResponseDelete)(nil), // 19: global.ResponseDelete } var file_mp4_proto_depIdxs = []int32{ - 8, // 0: mp4.ReqStartRecord.fragment:type_name -> google.protobuf.Duration - 0, // 1: mp4.api.List:input_type -> mp4.ReqRecordList - 9, // 2: mp4.api.Catalog:input_type -> google.protobuf.Empty - 1, // 3: mp4.api.Delete:input_type -> mp4.ReqRecordDelete - 2, // 4: mp4.api.EventStart:input_type -> mp4.ReqEventRecord - 4, // 5: mp4.api.StartRecord:input_type -> mp4.ReqStartRecord - 6, // 6: mp4.api.StopRecord:input_type -> mp4.ReqStopRecord - 10, // 7: mp4.api.List:output_type -> global.RecordResponseList - 11, // 8: mp4.api.Catalog:output_type -> global.ResponseCatalog - 12, // 9: mp4.api.Delete:output_type -> global.ResponseDelete - 3, // 10: mp4.api.EventStart:output_type -> mp4.ResponseEventRecord - 5, // 11: mp4.api.StartRecord:output_type -> mp4.ResponseStartRecord - 7, // 12: mp4.api.StopRecord:output_type -> mp4.ResponseStopRecord - 7, // [7:13] is the sub-list for method output_type - 1, // [1:7] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 15, // 0: mp4.ReqStartRecord.fragment:type_name -> google.protobuf.Duration + 8, // 1: mp4.ResponseTag.data:type_name -> mp4.TagInfo + 8, // 2: mp4.ResponseTagList.list:type_name -> mp4.TagInfo + 0, // 3: mp4.api.List:input_type -> mp4.ReqRecordList + 16, // 4: mp4.api.Catalog:input_type -> google.protobuf.Empty + 1, // 5: mp4.api.Delete:input_type -> mp4.ReqRecordDelete + 2, // 6: mp4.api.EventStart:input_type -> mp4.ReqEventRecord + 4, // 7: mp4.api.StartRecord:input_type -> mp4.ReqStartRecord + 6, // 8: mp4.api.StopRecord:input_type -> mp4.ReqStopRecord + 9, // 9: mp4.api.CreateTag:input_type -> mp4.ReqCreateTag + 10, // 10: mp4.api.UpdateTag:input_type -> mp4.ReqUpdateTag + 11, // 11: mp4.api.DeleteTag:input_type -> mp4.ReqDeleteTag + 12, // 12: mp4.api.ListTag:input_type -> mp4.ReqListTag + 17, // 13: mp4.api.List:output_type -> global.RecordResponseList + 18, // 14: mp4.api.Catalog:output_type -> global.ResponseCatalog + 19, // 15: mp4.api.Delete:output_type -> global.ResponseDelete + 3, // 16: mp4.api.EventStart:output_type -> mp4.ResponseEventRecord + 5, // 17: mp4.api.StartRecord:output_type -> mp4.ResponseStartRecord + 7, // 18: mp4.api.StopRecord:output_type -> mp4.ResponseStopRecord + 13, // 19: mp4.api.CreateTag:output_type -> mp4.ResponseTag + 13, // 20: mp4.api.UpdateTag:output_type -> mp4.ResponseTag + 13, // 21: mp4.api.DeleteTag:output_type -> mp4.ResponseTag + 14, // 22: mp4.api.ListTag:output_type -> mp4.ResponseTagList + 13, // [13:23] is the sub-list for method output_type + 3, // [3:13] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_mp4_proto_init() } @@ -716,7 +1249,7 @@ func file_mp4_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_mp4_proto_rawDesc), len(file_mp4_proto_rawDesc)), NumEnums: 0, - NumMessages: 8, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/plugin/mp4/pb/mp4.pb.gw.go b/plugin/mp4/pb/mp4.pb.gw.go index 058fdb6..3c0444a 100644 --- a/plugin/mp4/pb/mp4.pb.gw.go +++ b/plugin/mp4/pb/mp4.pb.gw.go @@ -10,6 +10,7 @@ package pb import ( "context" + "errors" "io" "net/http" @@ -25,322 +26,390 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join - var ( - filter_Api_List_0 = &utilities.DoubleArray{Encoding: map[string]int{"streamPath": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join ) +var filter_Api_List_0 = &utilities.DoubleArray{Encoding: map[string]int{"streamPath": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + func request_Api_List_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqRecordList - var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err + protoReq ReqRecordList + metadata runtime.ServerMetadata + err error ) - - val, ok = pathParams["streamPath"] + io.Copy(io.Discard, req.Body) + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Api_List_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.List(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_List_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqRecordList - var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err + protoReq ReqRecordList + metadata runtime.ServerMetadata + err error ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Api_List_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.List(ctx, &protoReq) return msg, metadata, err - } func request_Api_Catalog_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq emptypb.Empty - var metadata runtime.ServerMetadata - + var ( + protoReq emptypb.Empty + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) msg, err := client.Catalog(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_Catalog_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq emptypb.Empty - var metadata runtime.ServerMetadata - + var ( + protoReq emptypb.Empty + metadata runtime.ServerMetadata + ) msg, err := server.Catalog(ctx, &protoReq) return msg, metadata, err - } func request_Api_Delete_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqRecordDelete - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqRecordDelete + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := client.Delete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_Delete_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqRecordDelete - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqRecordDelete + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := server.Delete(ctx, &protoReq) return msg, metadata, err - } func request_Api_EventStart_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqEventRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqEventRecord + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.EventStart(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_EventStart_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqEventRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqEventRecord + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.EventStart(ctx, &protoReq) return msg, metadata, err - } func request_Api_StartRecord_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqStartRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqStartRecord + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := client.StartRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_StartRecord_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqStartRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqStartRecord + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := server.StartRecord(ctx, &protoReq) return msg, metadata, err - } func request_Api_StopRecord_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqStopRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqStopRecord + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := client.StopRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Api_StopRecord_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ReqStopRecord - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ReqStopRecord + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["streamPath"] + val, ok := pathParams["streamPath"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "streamPath") } - protoReq.StreamPath, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "streamPath", err) } - msg, err := server.StopRecord(ctx, &protoReq) return msg, metadata, err +} +func request_Api_CreateTag_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqCreateTag + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateTag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Api_CreateTag_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqCreateTag + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateTag(ctx, &protoReq) + return msg, metadata, err +} + +func request_Api_UpdateTag_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqUpdateTag + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Uint32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.UpdateTag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Api_UpdateTag_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqUpdateTag + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Uint32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.UpdateTag(ctx, &protoReq) + return msg, metadata, err +} + +func request_Api_DeleteTag_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqDeleteTag + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Uint32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteTag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Api_DeleteTag_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqDeleteTag + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Uint32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteTag(ctx, &protoReq) + return msg, metadata, err +} + +var filter_Api_ListTag_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_Api_ListTag_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqListTag + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Api_ListTag_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListTag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Api_ListTag_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ReqListTag + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Api_ListTag_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListTag(ctx, &protoReq) + return msg, metadata, err } // RegisterApiHandlerServer registers the http handlers for service Api to "mux". // UnaryRPC :call ApiServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterApiHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ApiServer) error { - - mux.Handle("GET", pattern_Api_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Api_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/List", runtime.WithHTTPPathPattern("/mp4/api/list/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/List", runtime.WithHTTPPathPattern("/mp4/api/list/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -352,20 +421,15 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_List_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("GET", pattern_Api_Catalog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Api_Catalog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/Catalog", runtime.WithHTTPPathPattern("/mp4/api/catalog")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/Catalog", runtime.WithHTTPPathPattern("/mp4/api/catalog")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -377,20 +441,15 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_Catalog_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/Delete", runtime.WithHTTPPathPattern("/mp4/api/delete/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/Delete", runtime.WithHTTPPathPattern("/mp4/api/delete/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -402,20 +461,15 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_EventStart_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_EventStart_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/EventStart", runtime.WithHTTPPathPattern("/mp4/api/event/start")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/EventStart", runtime.WithHTTPPathPattern("/mp4/api/event/start")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -427,20 +481,15 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_EventStart_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_StartRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_StartRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/StartRecord", runtime.WithHTTPPathPattern("/mp4/api/start/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/StartRecord", runtime.WithHTTPPathPattern("/mp4/api/start/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -452,20 +501,15 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_StartRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_StopRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_StopRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/StopRecord", runtime.WithHTTPPathPattern("/mp4/api/stop/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/StopRecord", runtime.WithHTTPPathPattern("/mp4/api/stop/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -477,9 +521,87 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_StopRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - + }) + mux.Handle(http.MethodPost, pattern_Api_CreateTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/CreateTag", runtime.WithHTTPPathPattern("/mp4/api/tag/add")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Api_CreateTag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_CreateTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_Api_UpdateTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/UpdateTag", runtime.WithHTTPPathPattern("/mp4/api/tag/update/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Api_UpdateTag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_UpdateTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_Api_DeleteTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/DeleteTag", runtime.WithHTTPPathPattern("/mp4/api/tag/delete/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Api_DeleteTag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_DeleteTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Api_ListTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/mp4.Api/ListTag", runtime.WithHTTPPathPattern("/mp4/api/tag/list")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Api_ListTag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_ListTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil @@ -488,25 +610,24 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server // RegisterApiHandlerFromEndpoint is same as RegisterApiHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterApiHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() - return RegisterApiHandler(ctx, mux, conn) } @@ -520,16 +641,13 @@ func RegisterApiHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.C // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ApiClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ApiClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "ApiClient" to call the correct interceptors. +// "ApiClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ApiClient) error { - - mux.Handle("GET", pattern_Api_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Api_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/List", runtime.WithHTTPPathPattern("/mp4/api/list/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/List", runtime.WithHTTPPathPattern("/mp4/api/list/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -540,18 +658,13 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_List_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("GET", pattern_Api_Catalog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Api_Catalog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/Catalog", runtime.WithHTTPPathPattern("/mp4/api/catalog")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/Catalog", runtime.WithHTTPPathPattern("/mp4/api/catalog")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -562,18 +675,13 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_Catalog_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/Delete", runtime.WithHTTPPathPattern("/mp4/api/delete/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/Delete", runtime.WithHTTPPathPattern("/mp4/api/delete/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -584,18 +692,13 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_EventStart_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_EventStart_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/EventStart", runtime.WithHTTPPathPattern("/mp4/api/event/start")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/EventStart", runtime.WithHTTPPathPattern("/mp4/api/event/start")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -606,18 +709,13 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_EventStart_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_StartRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_StartRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/StartRecord", runtime.WithHTTPPathPattern("/mp4/api/start/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/StartRecord", runtime.WithHTTPPathPattern("/mp4/api/start/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -628,18 +726,13 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_StartRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - mux.Handle("POST", pattern_Api_StopRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Api_StopRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/StopRecord", runtime.WithHTTPPathPattern("/mp4/api/stop/{streamPath=**}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/StopRecord", runtime.WithHTTPPathPattern("/mp4/api/stop/{streamPath=**}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -650,38 +743,101 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Api_StopRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - + mux.Handle(http.MethodPost, pattern_Api_CreateTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/CreateTag", runtime.WithHTTPPathPattern("/mp4/api/tag/add")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Api_CreateTag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_CreateTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_Api_UpdateTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/UpdateTag", runtime.WithHTTPPathPattern("/mp4/api/tag/update/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Api_UpdateTag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_UpdateTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_Api_DeleteTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/DeleteTag", runtime.WithHTTPPathPattern("/mp4/api/tag/delete/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Api_DeleteTag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_DeleteTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Api_ListTag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/mp4.Api/ListTag", runtime.WithHTTPPathPattern("/mp4/api/tag/list")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Api_ListTag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Api_ListTag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } var ( - pattern_Api_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "list", "streamPath"}, "")) - - pattern_Api_Catalog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mp4", "api", "catalog"}, "")) - - pattern_Api_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "delete", "streamPath"}, "")) - - pattern_Api_EventStart_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mp4", "api", "event", "start"}, "")) - + pattern_Api_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "list", "streamPath"}, "")) + pattern_Api_Catalog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mp4", "api", "catalog"}, "")) + pattern_Api_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "delete", "streamPath"}, "")) + pattern_Api_EventStart_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mp4", "api", "event", "start"}, "")) pattern_Api_StartRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "start", "streamPath"}, "")) - - pattern_Api_StopRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "stop", "streamPath"}, "")) + pattern_Api_StopRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 3, 0, 4, 1, 5, 3}, []string{"mp4", "api", "stop", "streamPath"}, "")) + pattern_Api_CreateTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mp4", "api", "tag", "add"}, "")) + pattern_Api_UpdateTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"mp4", "api", "tag", "update", "id"}, "")) + pattern_Api_DeleteTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"mp4", "api", "tag", "delete", "id"}, "")) + pattern_Api_ListTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mp4", "api", "tag", "list"}, "")) ) var ( - forward_Api_List_0 = runtime.ForwardResponseMessage - - forward_Api_Catalog_0 = runtime.ForwardResponseMessage - - forward_Api_Delete_0 = runtime.ForwardResponseMessage - - forward_Api_EventStart_0 = runtime.ForwardResponseMessage - + forward_Api_List_0 = runtime.ForwardResponseMessage + forward_Api_Catalog_0 = runtime.ForwardResponseMessage + forward_Api_Delete_0 = runtime.ForwardResponseMessage + forward_Api_EventStart_0 = runtime.ForwardResponseMessage forward_Api_StartRecord_0 = runtime.ForwardResponseMessage - - forward_Api_StopRecord_0 = runtime.ForwardResponseMessage + forward_Api_StopRecord_0 = runtime.ForwardResponseMessage + forward_Api_CreateTag_0 = runtime.ForwardResponseMessage + forward_Api_UpdateTag_0 = runtime.ForwardResponseMessage + forward_Api_DeleteTag_0 = runtime.ForwardResponseMessage + forward_Api_ListTag_0 = runtime.ForwardResponseMessage ) diff --git a/plugin/mp4/pb/mp4.proto b/plugin/mp4/pb/mp4.proto index e1fff2d..f8a275e 100644 --- a/plugin/mp4/pb/mp4.proto +++ b/plugin/mp4/pb/mp4.proto @@ -41,6 +41,29 @@ service api { body: "*" }; } + rpc CreateTag (ReqCreateTag) returns (ResponseTag) { + option (google.api.http) = { + post: "/mp4/api/tag/add" + body: "*" + }; + } + rpc UpdateTag (ReqUpdateTag) returns (ResponseTag) { + option (google.api.http) = { + post: "/mp4/api/tag/update/{id}" + body: "*" + }; + } + rpc DeleteTag (ReqDeleteTag) returns (ResponseTag) { + option (google.api.http) = { + post: "/mp4/api/tag/delete/{id}" + body: "*" + }; + } + rpc ListTag (ReqListTag) returns (ResponseTagList) { + option (google.api.http) = { + get: "/mp4/api/tag/list" + }; + } } message ReqRecordList { @@ -99,4 +122,53 @@ message ResponseStopRecord { int32 code = 1; string message = 2; uint64 data = 3; +} + +// 标签相关消息定义 +message TagInfo { + uint32 id = 1; + string tagName = 2; + string streamPath = 3; + string tagTime = 4; + string createdAt = 5; + string updatedAt = 6; +} + +message ReqCreateTag { + string tagName = 1; + string streamPath = 2; + string tagTime = 3; +} + +message ReqUpdateTag { + uint32 id = 1; + string tagName = 2; + string streamPath = 3; + string tagTime = 4; +} + +message ReqDeleteTag { + uint32 id = 1; +} + +message ReqListTag { + string streamPath = 1; + string tagName = 2; + string start = 3; + string end = 4; + uint32 page = 5; + uint32 count = 6; +} + +message ResponseTag { + int32 code = 1; + string message = 2; + TagInfo data = 3; +} + +message ResponseTagList { + int32 code = 1; + string message = 2; + repeated TagInfo list = 3; + uint32 total = 4; } \ No newline at end of file diff --git a/plugin/mp4/pb/mp4_grpc.pb.go b/plugin/mp4/pb/mp4_grpc.pb.go index c6e04ce..8eff183 100644 --- a/plugin/mp4/pb/mp4_grpc.pb.go +++ b/plugin/mp4/pb/mp4_grpc.pb.go @@ -27,6 +27,10 @@ const ( Api_EventStart_FullMethodName = "/mp4.api/EventStart" Api_StartRecord_FullMethodName = "/mp4.api/StartRecord" Api_StopRecord_FullMethodName = "/mp4.api/StopRecord" + Api_CreateTag_FullMethodName = "/mp4.api/CreateTag" + Api_UpdateTag_FullMethodName = "/mp4.api/UpdateTag" + Api_DeleteTag_FullMethodName = "/mp4.api/DeleteTag" + Api_ListTag_FullMethodName = "/mp4.api/ListTag" ) // ApiClient is the client API for Api service. @@ -39,6 +43,10 @@ type ApiClient interface { EventStart(ctx context.Context, in *ReqEventRecord, opts ...grpc.CallOption) (*ResponseEventRecord, error) StartRecord(ctx context.Context, in *ReqStartRecord, opts ...grpc.CallOption) (*ResponseStartRecord, error) StopRecord(ctx context.Context, in *ReqStopRecord, opts ...grpc.CallOption) (*ResponseStopRecord, error) + CreateTag(ctx context.Context, in *ReqCreateTag, opts ...grpc.CallOption) (*ResponseTag, error) + UpdateTag(ctx context.Context, in *ReqUpdateTag, opts ...grpc.CallOption) (*ResponseTag, error) + DeleteTag(ctx context.Context, in *ReqDeleteTag, opts ...grpc.CallOption) (*ResponseTag, error) + ListTag(ctx context.Context, in *ReqListTag, opts ...grpc.CallOption) (*ResponseTagList, error) } type apiClient struct { @@ -109,6 +117,46 @@ func (c *apiClient) StopRecord(ctx context.Context, in *ReqStopRecord, opts ...g return out, nil } +func (c *apiClient) CreateTag(ctx context.Context, in *ReqCreateTag, opts ...grpc.CallOption) (*ResponseTag, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResponseTag) + err := c.cc.Invoke(ctx, Api_CreateTag_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *apiClient) UpdateTag(ctx context.Context, in *ReqUpdateTag, opts ...grpc.CallOption) (*ResponseTag, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResponseTag) + err := c.cc.Invoke(ctx, Api_UpdateTag_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *apiClient) DeleteTag(ctx context.Context, in *ReqDeleteTag, opts ...grpc.CallOption) (*ResponseTag, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResponseTag) + err := c.cc.Invoke(ctx, Api_DeleteTag_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *apiClient) ListTag(ctx context.Context, in *ReqListTag, opts ...grpc.CallOption) (*ResponseTagList, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResponseTagList) + err := c.cc.Invoke(ctx, Api_ListTag_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // ApiServer is the server API for Api service. // All implementations must embed UnimplementedApiServer // for forward compatibility. @@ -119,6 +167,10 @@ type ApiServer interface { EventStart(context.Context, *ReqEventRecord) (*ResponseEventRecord, error) StartRecord(context.Context, *ReqStartRecord) (*ResponseStartRecord, error) StopRecord(context.Context, *ReqStopRecord) (*ResponseStopRecord, error) + CreateTag(context.Context, *ReqCreateTag) (*ResponseTag, error) + UpdateTag(context.Context, *ReqUpdateTag) (*ResponseTag, error) + DeleteTag(context.Context, *ReqDeleteTag) (*ResponseTag, error) + ListTag(context.Context, *ReqListTag) (*ResponseTagList, error) mustEmbedUnimplementedApiServer() } @@ -147,6 +199,18 @@ func (UnimplementedApiServer) StartRecord(context.Context, *ReqStartRecord) (*Re func (UnimplementedApiServer) StopRecord(context.Context, *ReqStopRecord) (*ResponseStopRecord, error) { return nil, status.Errorf(codes.Unimplemented, "method StopRecord not implemented") } +func (UnimplementedApiServer) CreateTag(context.Context, *ReqCreateTag) (*ResponseTag, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTag not implemented") +} +func (UnimplementedApiServer) UpdateTag(context.Context, *ReqUpdateTag) (*ResponseTag, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateTag not implemented") +} +func (UnimplementedApiServer) DeleteTag(context.Context, *ReqDeleteTag) (*ResponseTag, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteTag not implemented") +} +func (UnimplementedApiServer) ListTag(context.Context, *ReqListTag) (*ResponseTagList, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListTag not implemented") +} func (UnimplementedApiServer) mustEmbedUnimplementedApiServer() {} func (UnimplementedApiServer) testEmbeddedByValue() {} @@ -276,6 +340,78 @@ func _Api_StopRecord_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Api_CreateTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReqCreateTag) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiServer).CreateTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Api_CreateTag_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiServer).CreateTag(ctx, req.(*ReqCreateTag)) + } + return interceptor(ctx, in, info, handler) +} + +func _Api_UpdateTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReqUpdateTag) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiServer).UpdateTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Api_UpdateTag_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiServer).UpdateTag(ctx, req.(*ReqUpdateTag)) + } + return interceptor(ctx, in, info, handler) +} + +func _Api_DeleteTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReqDeleteTag) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiServer).DeleteTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Api_DeleteTag_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiServer).DeleteTag(ctx, req.(*ReqDeleteTag)) + } + return interceptor(ctx, in, info, handler) +} + +func _Api_ListTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReqListTag) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiServer).ListTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Api_ListTag_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiServer).ListTag(ctx, req.(*ReqListTag)) + } + return interceptor(ctx, in, info, handler) +} + // Api_ServiceDesc is the grpc.ServiceDesc for Api service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -307,6 +443,22 @@ var Api_ServiceDesc = grpc.ServiceDesc{ MethodName: "StopRecord", Handler: _Api_StopRecord_Handler, }, + { + MethodName: "CreateTag", + Handler: _Api_CreateTag_Handler, + }, + { + MethodName: "UpdateTag", + Handler: _Api_UpdateTag_Handler, + }, + { + MethodName: "DeleteTag", + Handler: _Api_DeleteTag_Handler, + }, + { + MethodName: "ListTag", + Handler: _Api_ListTag_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "mp4.proto", diff --git a/plugin/mp4/pkg/tagsmodel.go b/plugin/mp4/pkg/tagsmodel.go new file mode 100644 index 0000000..7d7c6da --- /dev/null +++ b/plugin/mp4/pkg/tagsmodel.go @@ -0,0 +1,23 @@ +package mp4 + +import ( + "time" + + "gorm.io/gorm" +) + +// TagModel 标签模型 +type TagModel struct { + ID uint `gorm:"primarykey" json:"id"` + TagName string `json:"tagName" gorm:"type:varchar(255);comment:标签名称"` + StreamPath string `json:"streamPath" gorm:"type:varchar(255);comment:流路径"` + TagTime time.Time `json:"tagTime" gorm:"comment:标签时间"` + CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"` + UpdatedAt time.Time `json:"updatedAt" gorm:"comment:修改时间"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"` +} + +// TableName 指定数据库表名 +func (d *TagModel) TableName() string { + return "record_tag" +}