export type StreamType = 'video' | 'audio' | 'all';

export interface AgoraSdkClient {
  init: (appid: string, success?: any, err?: any) => void;
  join: (token: string, cid: string, uid: number, success?: any, err?: any) => void;
  rejoin: (cb: any) => void;
  publish(onSuccess: (url: string) => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  on(event: "error", callback: (evt: { code: number; reason: string }) => void): void;
  on(event: "stream-added", callback: (evt: { uid: number, url?: string }) => void): void;
  on(event: "update-url", callback: (evt: { uid: number, url?: string }) => void): void;
  on(event: "stream-removed", callback: (evt: { uid: number[] }) => void): void;
  on(event: "mute-video", callback?: (evt: { uid: number }) => void): void;
  on(event: "unmute-video", callback: (evt: { uid: number }) => void): void
  off: (evt: any) => void;
  subscribe(uid: number, onSuccess: (url: string) => void, onFailure?: (err: any) => void): void;
  mute(uid: number, target: string, onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  unmute(uid: number, target: string, onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  muteLocal(target: StreamType, onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  unmuteLocal(target: string, onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  leave(onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void;
  unpublish(onSuccess: () => void, onFailure: (err: any) => void): void;
  setRole(role: string, onSuccess?: () => void, onFailure?: (err: { code: number; reason: string }) => void): void
  destory: (cb?: any) => void;
}

export interface AgoraAppStore {
  appid: string;
  sdk: any;
  platform: 'web' | 'mini-app' | 'electron';
  client: AgoraSdkClient;
  log?: any;
  stream?: any;
}

export interface AgoraStreamItem {
  url?: string;
  uid: number; //agora仅支持类型为number的uid
  videoPause?: boolean;
  audioPause?: boolean;
}