package com.platform.plugs.live.responseEntity;

import com.aliyuncs.live.model.v20161101.DescribeCasterSceneAudioResponse;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author TONG
 * @Date 2019/3/7 11:21
 **/
@Data
public class CasterSceneAudio {

    /** 导播台id*/
    private String casterId;
    /** 是否启用音频跟随。默认启用音频跟随。0：混音模式，1：音频跟随视频模式*/
    private Integer followEnable;
    /** Audiolayer配置列表*/
    private List<AudioLayer> audioLayers;
    /** 位置关联列表。与AudioLayers顺序保持一致*/
    private List<String> mixList;


    public static CasterSceneAudio parse(DescribeCasterSceneAudioResponse data) {
        CasterSceneAudio casterSceneAudio = new CasterSceneAudio();
        casterSceneAudio.setCasterId(data.getCasterId());
        casterSceneAudio.setFollowEnable(data.getFollowEnable());
        casterSceneAudio.setMixList(data.getMixList());
        List<AudioLayer> audioLayers = new ArrayList<>();
        List<DescribeCasterSceneAudioResponse.AudioLayer> dataList = data.getAudioLayers();
        if(dataList != null && dataList.size() > 0) {
            for (DescribeCasterSceneAudioResponse.AudioLayer obj : dataList) {
                AudioLayer audioLayer = new AudioLayer();
                audioLayer.setFixedDelayDuration(obj.getFixedDelayDuration());
                audioLayer.setValidChannel(obj.getValidChannel());
                audioLayer.setVolumeRate(obj.getVolumeRate());
                audioLayers.add(audioLayer);
            }
        }
        casterSceneAudio.setAudioLayers(audioLayers);
        return casterSceneAudio;
    }
}
