package com.foxx.androidcast.network.usb;

import com.foxx.androidcast.network.CastProtocol;
import com.foxx.androidcast.network.CastTransport;

import java.io.IOException;

/**
 * Future cast transport over USB tethering or ADB reverse port forward (roadmap E).
 * Same {@link CastProtocol} framing as TCP/UDP once a byte stream is available.
 */
public interface UsbTetherCastTransport extends CastTransport {

    /** Returns true when {@link android.hardware.usb.UsbManager} reports tether active, etc. */
    boolean isUsbLinkAvailable();

    static UsbTetherCastTransport createStub() {
        return new UsbTetherCastTransportStub();
    }

    final class UsbTetherCastTransportStub implements UsbTetherCastTransport {
        @Override
        public boolean isUsbLinkAvailable() {
            return false;
        }

        @Override
        public void listen(int port) throws IOException {
            throw new UnsupportedOperationException(
                    "USB-tether cast is not implemented yet. Enable in developer settings only for "
                            + "future testing; use UDP/TCP over Wi-Fi for alpha.");
        }

        @Override
        public void connect(String host, int port) throws IOException {
            throw new UnsupportedOperationException(
                    "USB-tether cast is not implemented yet (roadmap E).");
        }

        @Override
        public void send(byte type, byte[] payload) throws IOException {
            throw new UnsupportedOperationException("USB-tether cast is not implemented yet");
        }

        @Override
        public CastProtocol.Message receive(int timeoutMs) throws IOException {
            throw new UnsupportedOperationException("USB-tether cast is not implemented yet");
        }

        @Override
        public String getModeLabel() {
            return "USB tether (stub)";
        }

        @Override
        public void close() {}
    }
}
