export type SfuSessionState = 'idle' | 'starting' | 'live' | 'ending' | 'ended';

export type SfuSessionDescriptor = {
  streamSessionId: string;
  ownerUserId: string;
  cameraDeviceId: string;
  requesterDeviceId: string;
  state: SfuSessionState;
  createdAt: string;
};

export type SfuSessionStartInput = {
  streamSessionId: string;
  ownerUserId: string;
  cameraDeviceId: string;
  requesterDeviceId: string;
};

export type SfuPublishTransportRequest = {
  streamSessionId: string;
  cameraDeviceId: string;
};

export type SfuPublishTransportResult = {
  transportId: string;
  iceServers: Array<{ urls: string; username?: string; credential?: string }>;
};

export type SfuSubscribeTransportRequest = {
  streamSessionId: string;
  viewerDeviceId: string;
};

export type SfuSubscribeTransportResult = {
  transportId: string;
  iceServers: Array<{ urls: string; username?: string; credential?: string }>;
};

export interface SfuService {
  mode: 'single_server_sfu';
  startSession(input: SfuSessionStartInput): Promise<SfuSessionDescriptor>;
  setSessionState(streamSessionId: string, state: SfuSessionState): Promise<void>;
  endSession(streamSessionId: string): Promise<void>;
  getSession(streamSessionId: string): Promise<SfuSessionDescriptor | null>;
  listSessions(): Promise<SfuSessionDescriptor[]>;
  createPublishTransport(input: SfuPublishTransportRequest): Promise<SfuPublishTransportResult>;
  createSubscribeTransport(input: SfuSubscribeTransportRequest): Promise<SfuSubscribeTransportResult>;
}
