import { Emitter } from "mitt";
import { ChannelId, Message, Quality } from "./common.js";
import { RecorderProvider } from "./manager.js";
import { AnyObject, PickRequired, UnknownObject } from "./utils.js";
type FormatName = "auto" | "flv" | "hls" | "fmp4" | "flv_only" | "hls_only" | "fmp4_only";
type CodecName = "auto" | "avc" | "hevc" | "avc_only" | "hevc_only";
export interface RecorderCreateOpts<E extends AnyObject = UnknownObject> {
    providerId: RecorderProvider<E>["id"];
    channelId: ChannelId;
    id?: string;
    remarks?: string;
    disableAutoCheck?: boolean;
    disableProvideCommentsWhenRecording?: boolean;
    quality: Quality;
    streamPriorities: string[];
    sourcePriorities: string[];
    formatPriorities?: string[];
    source?: string;
    segment?: number;
    saveGiftDanma?: boolean;
    saveSCDanma?: boolean;
    /** 保存封面 */
    saveCover?: boolean;
    /** 身份验证 */
    auth?: string;
    /** cookie所有者uid,B站弹幕录制 */
    uid?: number;
    /** 画质匹配重试次数 */
    qualityRetry?: number;
    /** B站是否使用m3u8代理 */
    useM3U8Proxy?: boolean;
    /**B站m3u8代理url */
    m3u8ProxyUrl?: string;
    /** 流格式 */
    formatName?: FormatName;
    /** 流编码 */
    codecName?: CodecName;
    /** 选择使用的api，虎牙支持 */
    api?: "auto" | "web" | "mp";
    /** 标题关键词，如果直播间标题包含这些关键词，则不会自动录制（仅对斗鱼有效），多个关键词用英文逗号分隔 */
    titleKeywords?: string;
    /** 用于指定录制文件格式，auto时，分段使用ts，不分段使用mp4 */
    videoFormat?: "auto" | "ts" | "mkv";
    extra?: Partial<E>;
}
export type SerializedRecorder<E extends AnyObject> = PickRequired<RecorderCreateOpts<E>, "id">;
export type RecorderState = "idle" | "recording" | "stopping-record";
export type Progress = {
    time: string | null;
};
export interface RecordHandle {
    id: string;
    stream: string;
    source: string;
    url: string;
    ffmpegArgs?: string[];
    progress?: Progress;
    savePath: string;
    stop: (this: RecordHandle, reason?: string, tempStopIntervalCheck?: boolean) => Promise<void>;
}
export interface DebugLog {
    type: string | "common" | "ffmpeg";
    text: string;
}
export type GetSavePath = (data: {
    owner: string;
    title: string;
    startTime?: number;
}) => string;
export interface Recorder<E extends AnyObject = UnknownObject> extends Emitter<{
    RecordStart: RecordHandle;
    RecordSegment?: RecordHandle;
    videoFileCreated: {
        filename: string;
    };
    videoFileCompleted: {
        filename: string;
    };
    progress: Progress;
    LiveStart: {
        liveId: string;
    };
    RecordStop: {
        recordHandle: RecordHandle;
        reason?: string;
    };
    Updated: (string | keyof Recorder)[];
    Message: Message;
    DebugLog: DebugLog;
}>, RecorderCreateOpts<E> {
    id: string;
    extra: Partial<E>;
    availableStreams: string[];
    availableSources: string[];
    usedStream?: string;
    usedSource?: string;
    state: RecorderState;
    qualityMaxRetry: number;
    qualityRetry: number;
    uid?: number;
    liveInfo?: {
        living: boolean;
        owner: string;
        title: string;
        startTime?: Date;
        avatar: string;
        cover: string;
        liveId?: string;
    };
    tempStopIntervalCheck?: boolean;
    getChannelURL: (this: Recorder<E>) => string;
    checkLiveStatusAndRecord: (this: Recorder<E>, opts: {
        getSavePath: GetSavePath;
        banLiveId?: string;
        isManualStart?: boolean;
    }) => Promise<RecordHandle | null>;
    recordHandle?: RecordHandle;
    toJSON: (this: Recorder<E>) => SerializedRecorder<E>;
    getLiveInfo: (this: Recorder<E>) => Promise<{
        owner: string;
        title: string;
        avatar: string;
        cover: string;
        channelId: ChannelId;
        living: boolean;
        startTime: Date;
    }>;
    getStream: (this: Recorder<E>) => Promise<{
        source: string;
        name: string;
        url: string;
    }>;
}
export {};
