diff --git a/api/proto/media/proto/proto.go b/api/proto/media/proto/proto.go index 9eccf513..2aab03b3 100644 --- a/api/proto/media/proto/proto.go +++ b/api/proto/media/proto/proto.go @@ -104,3 +104,9 @@ type OpUpdateVideoCompressReq struct { } type OpUpdateVideoCompressData struct{} + +type OpUpdateVideoPFReq struct { + Id int64 `json:"id"` + PixelFormat string `json:"pixel_format"` + PixelFormat720 string `json:"pixel_format_720"` +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 09126fca..ef5653bc 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -539,6 +539,7 @@ func Init(r *gin.Engine) { opMediaGroup := r.Group("/op/media", PrepareToC()) opMediaGroup.POST("get_videos_by_status", middleware.JSONParamValidator(mediaproto.OpGetVideosByStatusReq{}), OpGetVideosByStatus) opMediaGroup.POST("update_video_compress", middleware.JSONParamValidator(mediaproto.OpUpdateVideoCompressReq{}), OpUpdateVideoCompress) + opMediaGroup.POST("update_video_pf", middleware.JSONParamValidator(mediaproto.OpUpdateVideoPFReq{}), OpUpdateVideoPF) // 主播标签 opStreamerTagGroup := r.Group("/op/streamer_tag", PrepareOp()) diff --git a/app/mix/controller/media.go b/app/mix/controller/media.go index 08d054bc..26baf624 100644 --- a/app/mix/controller/media.go +++ b/app/mix/controller/media.go @@ -68,3 +68,14 @@ func OpUpdateVideoCompress(ctx *gin.Context) { } ReplyOk(ctx, nil) } + +func OpUpdateVideoPF(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*mediaproto.OpUpdateVideoPFReq) + ec := service.DefaultService.OpUpdateVideoPF(ctx, req) + if ec != errcode.ErrCodeMediaSrvOk { + logger.Error("OpUpdateVideoPF fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + ReplyOk(ctx, nil) +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 62d51d5d..438b403e 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1087,6 +1087,24 @@ func (m *Mongo) UpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpdateVi return col.UpdateId(ctx, req.Id, up) } +func (m *Mongo) UpdateVideoPF(ctx *gin.Context, req *mediaproto.OpUpdateVideoPFReq) error { + col := m.getColVideo() + set := qmgo.M{} + if len(req.PixelFormat) > 0 { + set["pixel_format"] = req.PixelFormat + } + if len(req.PixelFormat720) > 0 { + set["pixel_format_720"] = req.PixelFormat720 + } + if len(set) <= 0 { + return nil + } + up := qmgo.M{ + "$set": set, + } + return col.UpdateId(ctx, req.Id, up) +} + // 登录表 func (m *Mongo) CreateLogin(ctx *gin.Context, login *dbstruct.Login) error { col := m.getColLogin() diff --git a/app/mix/service/logic/media.go b/app/mix/service/logic/media.go index 8ee32a96..6a7f6d3d 100644 --- a/app/mix/service/logic/media.go +++ b/app/mix/service/logic/media.go @@ -275,3 +275,7 @@ func (m *Media) OpGetVideosByStatus(ctx *gin.Context, req *mediaproto.OpGetVideo func (m *Media) OpUpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpdateVideoCompressReq) error { return m.store.UpdateVideoCompress(ctx, req) } + +func (m *Media) OpUpdateVideoPF(ctx *gin.Context, req *mediaproto.OpUpdateVideoPFReq) error { + return m.store.UpdateVideoPF(ctx, req) +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 989a9124..6de3d464 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3006,6 +3006,17 @@ func (s *Service) OpUpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpda return } +func (s *Service) OpUpdateVideoPF(ctx *gin.Context, req *mediaproto.OpUpdateVideoPFReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeMediaSrvOk + err := _DefaultMedia.OpUpdateVideoPF(ctx, req) + if err != nil { + logger.Error("OpUpdateVideoPF fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeMediaSrvFail + return + } + return +} + func (s *Service) OpGetPlatformListByIds(ctx *gin.Context, ids []int64) (list []*apollostruct.PlatformCfg, ec errcode.ErrCode) { ec = errcode.ErrCodeOk