package e0;

import io.flutter.embedding.android.KeyboardMap;
import java.io.DataOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteOrder;

/* JADX INFO: loaded from: classes.dex */
public final class c extends FilterOutputStream {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final DataOutputStream f6175k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public ByteOrder f6176l;

    public c(OutputStream outputStream, ByteOrder byteOrder) {
        super(outputStream);
        this.f6175k = new DataOutputStream(outputStream);
        this.f6176l = byteOrder;
    }

    public final void a(int i) throws IOException {
        this.f6175k.write(i);
    }

    public final void e(int i) throws IOException {
        ByteOrder byteOrder = this.f6176l;
        ByteOrder byteOrder2 = ByteOrder.LITTLE_ENDIAN;
        DataOutputStream dataOutputStream = this.f6175k;
        if (byteOrder == byteOrder2) {
            dataOutputStream.write(i & 255);
            dataOutputStream.write((i >>> 8) & 255);
            dataOutputStream.write((i >>> 16) & 255);
            dataOutputStream.write((i >>> 24) & 255);
            return;
        }
        if (byteOrder == ByteOrder.BIG_ENDIAN) {
            dataOutputStream.write((i >>> 24) & 255);
            dataOutputStream.write((i >>> 16) & 255);
            dataOutputStream.write((i >>> 8) & 255);
            dataOutputStream.write(i & 255);
        }
    }

    public final void f(short s5) throws IOException {
        ByteOrder byteOrder = this.f6176l;
        ByteOrder byteOrder2 = ByteOrder.LITTLE_ENDIAN;
        DataOutputStream dataOutputStream = this.f6175k;
        if (byteOrder == byteOrder2) {
            dataOutputStream.write(s5 & 255);
            dataOutputStream.write((s5 >>> 8) & 255);
        } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
            dataOutputStream.write((s5 >>> 8) & 255);
            dataOutputStream.write(s5 & 255);
        }
    }

    public final void h(long j5) throws IOException {
        if (j5 > KeyboardMap.kValueMask) {
            throw new IllegalArgumentException("val is larger than the maximum value of a 32-bit unsigned integer");
        }
        e((int) j5);
    }

    public final void k(int i) throws IOException {
        if (i > 65535) {
            throw new IllegalArgumentException("val is larger than the maximum value of a 16-bit unsigned integer");
        }
        f((short) i);
    }

    @Override // java.io.FilterOutputStream, java.io.OutputStream
    public final void write(byte[] bArr) throws IOException {
        this.f6175k.write(bArr);
    }

    @Override // java.io.FilterOutputStream, java.io.OutputStream
    public final void write(byte[] bArr, int i, int i5) throws IOException {
        this.f6175k.write(bArr, i, i5);
    }
}
