package cn.reghao.tnb.content.app.vod.model.po;

import cn.reghao.file.api.dto.VideoMeta;
import cn.reghao.jutil.jdk.web.db.BaseObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 视频文件
 *
 * @author reghao
 * @date 2021-11-22 10:21:15
 */
@NoArgsConstructor
@Setter
@Getter
public class VideoFile extends BaseObject<Integer> {
    @NotBlank
    private String videoId;
    @NotBlank
    private String objectId;
    @NotNull
    private Integer channelCode;
    @NotNull
    @Size(max = 255, message = "videoCodec 不能超过 255 个字符")
    private String videoCodec;
    @NotNull
    private Long vbitRate;
    @NotNull
    @Size(max = 255, message = "audioCodec 不能超过 255 个字符")
    private String audioCodec;
    @NotNull
    private Long abitRate;
    @NotNull
    @Size(max = 255, message = "formatName 不能超过 255 个字符")
    private String formatName;
    @NotBlank
    private String urlType;
    @NotBlank
    private String url;
    @NotBlank
    private String quality;
    @NotNull
    private Integer width;
    @NotNull
    private Integer height;
    @NotNull
    private Boolean horizontal;
    @NotNull
    // 单位秒
    private Integer duration;
    @NotNull
    private Long size;

    public VideoFile(String videoId, VideoMeta videoMeta, int channelCode) {
        this.videoId = videoId;
        this.objectId = videoMeta.getObjectId();
        this.channelCode = channelCode;
        this.videoCodec = videoMeta.getVideoCodec();
        this.vbitRate = videoMeta.getVbitRate();
        this.audioCodec = videoMeta.getAudioCodec();
        this.abitRate = videoMeta.getAbitRate();
        this.formatName = videoMeta.getFormatName();
        this.urlType = videoMeta.getUrlType();
        this.url = videoMeta.getUrl();
        this.quality = videoMeta.getQuality();
        this.width = videoMeta.getWidth();
        this.height = videoMeta.getHeight();
        this.horizontal = videoMeta.getWidth()>videoMeta.getHeight();
        this.duration = videoMeta.getDuration();
        this.size = videoMeta.getSize();
    }
}
