package tv.tivilux.nativeplayer.data;

/** Sample-buffer targets, not total process/decoder memory limits. No Android dependency. */
public final class PlaybackBufferBudget {
    private PlaybackBufferBudget() {}

    public static int targetBytes(boolean vod, int memoryClassMb, boolean lowRam) {
        int heapMb = Math.max(64, memoryClassMb);
        int targetMb;
        if (vod) {
            targetMb = Math.max(24, Math.min(lowRam ? 32 : 96, heapMb / 4));
        } else {
            // Also bounds each independent MultiView player's sample-buffer target.
            targetMb = Math.max(8, Math.min(lowRam ? 12 : 24, heapMb / 16));
        }
        return targetMb * 1024 * 1024;
    }
}
