namespace OF_DL.Widevine;

public class CDMApi
{
    private string SessionId { get; set; }

    public byte[] GetChallenge(string initDataB64, string certDataB64, bool offline = false, bool raw = false)
    {
        SessionId = CDM.OpenSession(initDataB64, Constants.DEVICE_NAME, offline, raw);
        CDM.SetServiceCertificate(SessionId, Convert.FromBase64String(certDataB64));
        return CDM.GetLicenseRequest(SessionId);
    }

    public bool ProvideLicense(string licenseB64)
    {
        CDM.ProvideLicense(SessionId, Convert.FromBase64String(licenseB64));
        return true;
    }

    public List<ContentKey> GetKeys() => CDM.GetKeys(SessionId);
}
