package com.platform.plugs.live;

import com.platform.plugs.common.rpc.CommonRpc;
import com.platform.plugs.common.rpc.DefaultRequestParams;
import com.platform.plugs.common.rpc.Profile;
import com.platform.plugs.live.config.*;
import com.platform.plugs.live.handlers.*;
import com.platform.plugs.live.proxy.HandlerProxy;

/**
 * @Author TONG
 * @Date 2019/2/18 14:30
 **/
public class LiveClient {

    private CommonRpc commonRpc;

    private ILiveStreamHandler liveStreamHandler;

    private ILiveRecordHandler liveRecordHandler;

    private ILiveCasterHandler liveCasterHandler;
    
    private ILiveUploadToVoDHandler liveUploadToVoDHandler;

    private ILiveTransCodeHandler liveTransCodeHandler;
    
    private ILiveAudioHandler liveAudioHandler;
    
    private ILivePullStreamHandler livePullStreamHandler;

    public LiveClient(Profile profile, DefaultRequestParams requestParams) {
        this.commonRpc = new CommonRpc(profile, requestParams);
        this.liveStreamHandler = new HandlerProxy<LiveStreamHandler>().getHandler(new LiveStreamHandler(commonRpc));
        this.liveRecordHandler = new HandlerProxy<LiveRecordHandler>().getHandler(new LiveRecordHandler(commonRpc, liveStreamHandler));
        this.liveCasterHandler = new HandlerProxy<LiveCasterHandler>().getHandler(new LiveCasterHandler(commonRpc));
        this.liveUploadToVoDHandler = new HandlerProxy<LiveUploadToVoDHandler>().getHandler(new LiveUploadToVoDHandler());
        this.liveTransCodeHandler = new HandlerProxy<LiveTransCodeHandler>().getHandler(new LiveTransCodeHandler(commonRpc));
//        this.liveAudioHandler = new HandlerProxy<LiveAudioHandler>().getHandler(new LiveAudioHandler());
        this.livePullStreamHandler = new HandlerProxy<LivePullStreamHandler>().getHandler(new LivePullStreamHandler());
    }

    public ILiveStreamHandler liveStream() {
        return this.liveStreamHandler;
    }

    public ILiveRecordHandler liveRecord() {
        return this.liveRecordHandler;
    }

    public ILiveCasterHandler liveCaster() {
        return this.liveCasterHandler;
    }
    
    public ILiveUploadToVoDHandler liveUploadToVoD() {
        return this.liveUploadToVoDHandler;
    }
    
//    public ILiveAudioHandler liveAudio(){
//    	return this.liveAudioHandler;
//    }

    public ILiveTransCodeHandler liveTransCode(){
    	return this.liveTransCodeHandler;
    }
    
    public ILivePullStreamHandler livePullStream(){
    	return this.livePullStreamHandler;
    }

    public LiveClient configLiveRecord(LiveRecordConfig liveRecordConfig) {
        this.liveRecordHandler.configLiveRecord(liveRecordConfig);
        return this;
    }

    public LiveClient configLiveStream(LiveStreamConfig liveStreamConfig) {
        this.liveStreamHandler.configLiveStream(liveStreamConfig);
        return this;
    }

    public LiveClient configLiveCaster(LiveCasterConfig liveCasterConfig) {
        this.liveCasterHandler.configLiveCaster(liveCasterConfig);
        return this;
    }
    
    public LiveClient configLiveUploadToVoD(LiveUploadToVoDConfig liveUploadToVoDConfig) {
        this.liveUploadToVoDHandler.configLiveUploadToVoD(liveUploadToVoDConfig);
        return this;
    }

    public LiveClient configLiveTransCode(LiveTransCodeConfig liveTransCodeConfig){
        this.liveTransCodeHandler.configLiveTransCode(liveTransCodeConfig);
        return this;
    }

    public LiveClient configLiveAudio(LiveAudioConfig liveAudioConfig){
    	this.liveAudioHandler.configLiveAudio(liveAudioConfig);
    	return this;
    }
    
    public LiveClient configLivePullStream(LivePullStreamConfig livePullStreamConfig){
    	this.livePullStreamHandler.configLivePullStream(livePullStreamConfig);
    	return this;
    }
}
