// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// These functions are ignored because they are not marked as `pub`: `block`

CallParams? decodeVcp({required String vcp, required String conversationId}) =>
    RustLib.instance.api
        .crateApiCallsDecodeVcp(vcp: vcp, conversationId: conversationId);

Future<CallSignaling> connectCallSignaling(
        {required String url, String? userAgent, String? proxy}) =>
    RustLib.instance.api.crateApiCallsConnectCallSignaling(
        url: url, userAgent: userAgent, proxy: proxy);

/// connection notification (JSON string). peer is the participant that isn't my_user_id.
ConnectionInfo parseConnection(
        {required String notificationJson, required PlatformInt64 myUserId}) =>
    RustLib.instance.api.crateApiCallsParseConnection(
        notificationJson: notificationJson, myUserId: myUserId);

TransmittedData? parseTransmittedData({required String notificationJson}) =>
    RustLib.instance.api
        .crateApiCallsParseTransmittedData(notificationJson: notificationJson);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<CallSignaling>>
abstract class CallSignaling implements RustOpaqueInterface {
  Future<String> acceptCall();

  Future<String> changeMediaSettings(
      {required bool audio, required bool video, required bool screen});

  void close();

  Future<String> hangup({required String reason});

  bool isConnected();

  /// ws2 notifications as JSON strings
  Stream<String> notifications();

  /// raw command; extra_json is a JSON object string
  Future<String> sendCommand(
      {required String command, required String extraJson});

  Future<String> transmitCandidate(
      {required PlatformInt64 participantId,
      required String candidate,
      required String sdpMid,
      required PlatformInt64 sdpMlineIndex});

  Future<String> transmitSdp(
      {required PlatformInt64 participantId,
      required String sdpType,
      required String sdp});
}

/// decoded vcp call params, plus the ready ws2 url for the given conversation
class CallParams {
  final String token;
  final String wsEndpoint;
  final String? stun;
  final List<String> turn;
  final String? turnUser;
  final String? turnPassword;
  final bool isVideo;
  final PlatformInt64 userId;
  final List<IceServer> iceServers;
  final String ws2Url;

  const CallParams({
    required this.token,
    required this.wsEndpoint,
    this.stun,
    required this.turn,
    this.turnUser,
    this.turnPassword,
    required this.isVideo,
    required this.userId,
    required this.iceServers,
    required this.ws2Url,
  });

  @override
  int get hashCode =>
      token.hashCode ^
      wsEndpoint.hashCode ^
      stun.hashCode ^
      turn.hashCode ^
      turnUser.hashCode ^
      turnPassword.hashCode ^
      isVideo.hashCode ^
      userId.hashCode ^
      iceServers.hashCode ^
      ws2Url.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is CallParams &&
          runtimeType == other.runtimeType &&
          token == other.token &&
          wsEndpoint == other.wsEndpoint &&
          stun == other.stun &&
          turn == other.turn &&
          turnUser == other.turnUser &&
          turnPassword == other.turnPassword &&
          isVideo == other.isVideo &&
          userId == other.userId &&
          iceServers == other.iceServers &&
          ws2Url == other.ws2Url;
}

/// parsed ws2 `connection` notification
class ConnectionInfo {
  final String? topology;
  final bool isSfu;
  final Int64List participants;
  final PlatformInt64? peer;
  final List<IceServer> iceServers;

  const ConnectionInfo({
    this.topology,
    required this.isSfu,
    required this.participants,
    this.peer,
    required this.iceServers,
  });

  @override
  int get hashCode =>
      topology.hashCode ^
      isSfu.hashCode ^
      participants.hashCode ^
      peer.hashCode ^
      iceServers.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ConnectionInfo &&
          runtimeType == other.runtimeType &&
          topology == other.topology &&
          isSfu == other.isSfu &&
          participants == other.participants &&
          peer == other.peer &&
          iceServers == other.iceServers;
}

class IceServer {
  final List<String> urls;
  final String? username;
  final String? credential;

  const IceServer({
    required this.urls,
    this.username,
    this.credential,
  });

  @override
  int get hashCode => urls.hashCode ^ username.hashCode ^ credential.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is IceServer &&
          runtimeType == other.runtimeType &&
          urls == other.urls &&
          username == other.username &&
          credential == other.credential;
}

/// SDP or ICE candidate from a `transmitted-data` notification. kind is "sdp" or
/// "candidate"; only the matching fields are set.
class TransmittedData {
  final String kind;
  final String? sdpType;
  final String? sdp;
  final String? candidate;
  final String? sdpMid;
  final PlatformInt64? sdpMlineIndex;

  const TransmittedData({
    required this.kind,
    this.sdpType,
    this.sdp,
    this.candidate,
    this.sdpMid,
    this.sdpMlineIndex,
  });

  @override
  int get hashCode =>
      kind.hashCode ^
      sdpType.hashCode ^
      sdp.hashCode ^
      candidate.hashCode ^
      sdpMid.hashCode ^
      sdpMlineIndex.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is TransmittedData &&
          runtimeType == other.runtimeType &&
          kind == other.kind &&
          sdpType == other.sdpType &&
          sdp == other.sdp &&
          candidate == other.candidate &&
          sdpMid == other.sdpMid &&
          sdpMlineIndex == other.sdpMlineIndex;
}
