package com.foxx.androidcast.network.transport;

/*********************************************************************
 * StreamProtectionNegotiation.java
 * Created at: Tue 19 May 2026 12:23:39 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class StreamProtectionNegotiation
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 52 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	a4955f74abcb34c96613501e0f6eb25d3889e73816c7a324f7edd39be2253d99
**********************************************************************/
import com.foxx.androidcast.CastSettings;

/** Outcome of matching local/remote {@link CastSettings.StreamProtection} preferences. */
public final class StreamProtectionNegotiation {
    public final CastSettings.StreamProtection agreed;
    public final boolean nackEnabled;
    public final Prompt prompt;

    public StreamProtectionNegotiation(CastSettings.StreamProtection agreed, boolean nackEnabled,
            Prompt prompt) {
        this.agreed = agreed != null ? agreed : CastSettings.StreamProtection.NONE;
        this.nackEnabled = nackEnabled;
        this.prompt = prompt;
    }

    public static StreamProtectionNegotiation none() {
        return new StreamProtectionNegotiation(CastSettings.StreamProtection.NONE, false, null);
    }

    public static final class Prompt {
        public enum Target {
            /** Ask the casting phone to change stream protection in settings. */
            SENDER,
            /** Ask the receiver device to change stream protection in settings. */
            RECEIVER
        }

        public final Target target;
        /** String resource id for a short user-visible hint. */
        public final int messageResId;
        public final CastSettings.StreamProtection localPreference;
        public final CastSettings.StreamProtection remotePreference;

        public Prompt(Target target, int messageResId,
                CastSettings.StreamProtection localPreference,
                CastSettings.StreamProtection remotePreference) {
            this.target = target;
            this.messageResId = messageResId;
            this.localPreference = localPreference;
            this.remotePreference = remotePreference;
        }
    }
}
