import {AVError} from './AVError'
import {TMGAudioCtrl} from './TMGAudioCtrl';
import {ITMG_AUDIO_ROUTE, TMGAudioDeviceInfo, TMGAudioFrame} from './TMGType'

export class TMGAudioCtrlImpl implements TMGAudioCtrl {
  private audioCtrl: TMGAudioCtrlBindings|undefined;
  constructor(contextBindings: TMGContextBindings) {
    this.audioCtrl = new TMGAudioCtrlBindings(contextBindings);
  }

  EnableMic(enable: boolean): number {
    return this.audioCtrl.enableMic(enable);
  };

  GetMicState(): number {
    return this.audioCtrl.getMicState();
  };

  EnableSpeaker(enable: boolean): number {
    return this.audioCtrl.enableSpeaker(enable);
  };

  GetSpeakerState(): number {
    return this.audioCtrl.getSpeakerState();
  };

  EnableAudioCaptureDevice(enable: boolean): number {
    return this.audioCtrl.enableAudioCaptureDevice(enable);
  };

  IsAudioCaptureDeviceEnabled(): boolean {
    return this.audioCtrl.isAudioCaptureDeviceEnabled();
  };

  EnableAudioPlayDevice(enable: boolean): number {
    return this.audioCtrl.enableAudioPlayDevice(enable);
  };

  IsAudioPlayDeviceEnabled(): boolean {
    return this.audioCtrl.isAudioPlayDeviceEnabled();
  };

  EnableAudioSend(enable: boolean): number {
    return this.audioCtrl.enableAudioSend(enable);
  };

  IsAudioSendEnabled(): boolean {
    return this.audioCtrl.isAudioSendEnabled();
  };

  EnableAudioRecv(enable: boolean): number {
    return this.audioCtrl.enableAudioRecv(enable);
  };

  IsAudioRecvEnabled(): boolean {
    return this.audioCtrl.isAudioRecvEnabled();
  };

  SetMicVolume(volume: number): number {
    return this.audioCtrl.setMicVolume(volume);
  };

  GetMicVolume(): number {
    return this.audioCtrl.getMicVolume();
  };

  SetSpeakerVolume(volume: number): number {
    return this.audioCtrl.setSpeakerVolume(volume);
  };

  GetSpeakerVolume(): number {
    return this.audioCtrl.getSpeakerVolume();
  };

  SetSpeakerVolumeByUserID(userID: string, volume: number): number {
    return this.audioCtrl.setSpeakerVolumeByUserID(userID, volume);
  };

  GetSpeakerVolumeByUserID(userID: string): number {
    return this.audioCtrl.getSpeakerVolumeByUserID(userID);
  };

  EnableLoopBack(enable: boolean): number {
    return this.audioCtrl.enableLoopBack(enable);
  };

  AddAudioBlackList(userID: string): number {
    return this.audioCtrl.addAudioBlackList(userID);
  };

  RemoveAudioBlackList(userID: string): number {
    return this.audioCtrl.removeAudioBlackList(userID);
  };

  IsUserIDInAudioBlackList(userID: string): boolean {
    return this.audioCtrl.isUserIDInAudioBlackList(userID);
  };

  InitSpatializer(modelPath: string): number {
    return this.audioCtrl.initSpatializer(modelPath);
  };

  EnableSpatializer(enable: boolean): number {
    return this.audioCtrl.enableSpatializer(enable);
  };

  IsEnableSpatializer(): boolean {
    return this.audioCtrl.isEnableSpatializer();
  };

  GetMicListCount(): number {
    return this.audioCtrl.getMicListCount();
  }

  GetMicList(nCount: number): TMGAudioDeviceInfo[] {
    return this.audioCtrl.getMicList(nCount);
  }

  SelectMic(micId: string): number {
    return this.audioCtrl.selectMic(micId);
  }

  GetCurrentMic(): TMGAudioDeviceInfo {
    return this.audioCtrl.getCurrentMic();
  }

  GetSpeakerListCount(): number {
    return this.audioCtrl.getSpeakerListCount();
  }

  GetSpeakerList(nCount: number): TMGAudioDeviceInfo[] {
    return this.audioCtrl.getSpeakerList(nCount);
  }

  SelectSpeaker(speakerID: string): number {
    return this.audioCtrl.selectSpeaker(speakerID);
  }

  GetCurrentSpeaker(): TMGAudioDeviceInfo {
    return this.audioCtrl.getCurrentSpeaker();
  }

  EnableCustomAudioCapture(enable: boolean): number{return AVError.AV_ERR_NOT_IMPLEMENTED}

  SetAudioRoute(route: ITMG_AUDIO_ROUTE): number {
    return this.audioCtrl.setAudioRoute(route);
  }

  SendCustomAudioData(frame: TMGAudioFrame): number {
    return AVError.AV_ERR_NOT_IMPLEMENTED;
  }

  EnableCustomAudioRendering(enable: boolean): number {
    return AVError.AV_ERR_NOT_IMPLEMENTED;
  }

  GetCustomAudioRenderingFrame(frame: TMGAudioFrame): number {
    return AVError.AV_ERR_NOT_IMPLEMENTED;
  }

  TrackingVolume(interval: number): number {
    return this.audioCtrl.trackingVolume(interval);
  };

  StopTrackingVolume(): number {
    return this.audioCtrl.stopTrackingVolume();
  };

  GetMicLevel(): number {
    return this.audioCtrl.getMicLevel();
  };

  GetSpeakerLevel(): number {
    return this.audioCtrl.getSpeakerLevel();
  };

  GetSendStreamLevel(): number {
    return this.audioCtrl.getSendStreamLevel();
  };

  GetRecvStreamLevel(userID: string): number {
    return this.audioCtrl.getRecvStreamLevel(userID);
  };

  StartMicDeviceTest(interval: number): number {
    return this.audioCtrl.startMicDeviceTest(interval);
  }

  StopMicDeviceTest(): number {
    return this.audioCtrl.stopMicDeviceTest();
  }

  StartSpeakerDeviceTest(filePath: string): number {
    return this.audioCtrl.startSpeakerDeviceTest(filePath);
  }

  StopSpeakerDeviceTest(): number {
    return this.audioCtrl.stopSpeakerDeviceTest();
  }
}