import 'package:fis_common/web/shell_api_hepler.dart';

class ShellApi {
  static Future<void> initRtmpPublisher(RtmpPublishProfile profile) {
    return ShellApiHelper.call("initRtmpPublisher", profile.toJson());
  }

  static Future<void> startRtmpPublish() {
    return ShellApiHelper.call("startRtmpPublish", []);
  }

  static Future<void> stopRtmpPublish() {
    return ShellApiHelper.call("stopRtmpPublish", []);
  }

  static Future<void> setRtmpPublishVideoMute(bool isMute) {
    return ShellApiHelper.call("setRtmpPublishVideoMute", isMute);
  }

  static Future<void> setRtmpPublishAudioMute(bool isMute) {
    return ShellApiHelper.call("setRtmpPublishAudioMute", isMute);
  }

  static Future<void> setRtmpPublishVolume(int volume) {
    return ShellApiHelper.call("setRtmpPublishVolume", volume);
  }
}

class RtmpPublishProfile {
  final String url;
  final int frameRate;
  final int? bitRate;
  final String? cameraName;
  final String? microphoneName;

  RtmpPublishProfile({
    required this.url,
    this.frameRate = 15,
    this.bitRate,
    this.cameraName,
    this.microphoneName,
  });

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map["Url"] = url;
    map["FrameRate"] = frameRate;
    map["BitRate"] = bitRate;
    map["CameraName"] = cameraName;
    map["MicrophoneName"] = microphoneName;
    return map;
  }
}
