using Ikar.Shared;

namespace Ikar.Server.Infrastructure.Calls;

public sealed class WebRtcOptions
{
    public const string SectionName = "WebRtc";

    public List<WebRtcIceServerOptions> IceServers { get; set; } =
    [
        new()
        {
            Urls = ["stun:stun.l.google.com:19302"]
        }
    ];

    public IReadOnlyList<CallIceServerDto> ToDto() =>
        IceServers
            .Where(server => server.Urls.Count > 0)
            .Select(server => new CallIceServerDto(
                Urls: server.Urls,
                Username: string.IsNullOrWhiteSpace(server.Username) ? null : server.Username,
                Credential: string.IsNullOrWhiteSpace(server.Credential) ? null : server.Credential))
            .ToList();
}

public sealed class WebRtcIceServerOptions
{
    public List<string> Urls { get; set; } = [];

    public string? Username { get; set; }

    public string? Credential { get; set; }
}
