package com.foxx.androidcast.network.webrtc;

/*********************************************************************
 * WebRtcPeerAdapter.java
 * Created at: Sat 16 May 2026 18:50:36 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * interface WebRtcPeerAdapter
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 44 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	fffc6dd70bc526851d144abc9716bbd2a69849e8d788f6bced7573febcf027c4
**********************************************************************/
/**
 * Abstraction over future {@code org.webrtc.PeerConnection} or pion peer APIs.
 * Implementations will map cast frames to SCTP DataChannel or encoded tracks.
 */
public interface WebRtcPeerAdapter {

    interface Observer {
        void onIceCandidate(String sdpMid, int sdpMLineIndex, String candidate);

        void onConnectionStateChanged(WebRtcConnectionState state);

        void onDataChannelMessage(byte[] payload);

        void onEncodedVideoFrame(long ptsUs, boolean keyFrame, byte[] data);
    }

    enum WebRtcConnectionState {
        NEW, CONNECTING, CONNECTED, DISCONNECTED, FAILED, CLOSED
    }

    void setObserver(Observer observer);

    void createOffer();

    void createAnswer(String remoteDescription);

    void setRemoteDescription(String sdp, boolean isOffer);

    void addIceCandidate(String sdpMid, int sdpMLineIndex, String candidate);

    /** Send opaque cast protocol bytes on a labeled DataChannel. */
    void sendDataChannel(byte[] payload);

    void close();
}
