package com.sonic.cow.service;

import com.sonic.cow.client.request.InputRequest;
import com.sonic.cow.domain.input.GenerateRtcTokenInput;
import com.sonic.cow.domain.input.VoiceChatOptInput;
import com.sonic.cow.domain.output.GenerateRtcTokenOutput;
import com.sonic.cow.domain.output.VoiceChatOptOutput;
import org.apache.ibatis.annotations.Param;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @description: 语音通话
 * @author: mzc
 * @date: 2025-07-30 11:12
 **/
public interface VoiceChatService {

    /**
     * 生成RTC令牌
     *
     * @param currentUserId
     * @param input
     * @return
     */
    GenerateRtcTokenOutput generateRtcToken(Long currentUserId, GenerateRtcTokenInput input);

    /**
     * 语音通话操作
     *
     * @param userId
     * @param input
     * @return
     */
    VoiceChatOptOutput voiceChatOpt(Long userId, VoiceChatOptInput input);

    /**
     * webhook回调通知
     *
     * @param request
     * @param response
     */
    void webhook(HttpServletRequest request, HttpServletResponse response);

    /**
     * 会话状态回调通知(监听智能体状态)
     * 文档： https://docs.byteplus.com/en/docs/byteplus-rtc/docs-1415216#receiving-via-server
     *
     * @param request
     * @param response
     */
    void conversationStateCallback(@Param("request") HttpServletRequest request, @Param("response") HttpServletResponse response);

    /**
     * 实时字幕回调
     *
     * @param request
     * @param response
     */
    void rtsCallback(HttpServletRequest request, HttpServletResponse response);

    /**
     * 语音通话结束处理
     *
     * @param userId
     * @param aiId
     * @param voiceChatInputRequestList 语音通话对话内容列表
     * @param duration
     */
    void voiceCallEndHandler(Long userId, Long aiId, List<InputRequest> voiceChatInputRequestList, Long duration);

    /**
     * 停止语音通话(用户离开1分钟，杀app，刷新网页，关闭网页情况下)
     *
     * @param userId
     */
    Boolean stopVoiceChat(Long userId);
}
