// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.10.1
//   protoc               v3.21.12
// source: EncodedFrame.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { CameraSettings, ImgTransformation, Timestamp } from "./common";
export const protobufPackage = "dai.proto.encoded_frame";
export var Profile;
(function (Profile) {
    Profile[Profile["JPEG"] = 0] = "JPEG";
    Profile[Profile["AVC"] = 1] = "AVC";
    Profile[Profile["HEVC"] = 2] = "HEVC";
    Profile[Profile["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Profile || (Profile = {}));
export function profileFromJSON(object) {
    switch (object) {
        case 0:
        case "JPEG":
            return Profile.JPEG;
        case 1:
        case "AVC":
            return Profile.AVC;
        case 2:
        case "HEVC":
            return Profile.HEVC;
        case -1:
        case "UNRECOGNIZED":
        default:
            return Profile.UNRECOGNIZED;
    }
}
export function profileToJSON(object) {
    switch (object) {
        case Profile.JPEG:
            return "JPEG";
        case Profile.AVC:
            return "AVC";
        case Profile.HEVC:
            return "HEVC";
        case Profile.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var FrameType;
(function (FrameType) {
    FrameType[FrameType["I"] = 0] = "I";
    FrameType[FrameType["P"] = 1] = "P";
    FrameType[FrameType["B"] = 2] = "B";
    FrameType[FrameType["UNKNOWN"] = 3] = "UNKNOWN";
    FrameType[FrameType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(FrameType || (FrameType = {}));
export function frameTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "I":
            return FrameType.I;
        case 1:
        case "P":
            return FrameType.P;
        case 2:
        case "B":
            return FrameType.B;
        case 3:
        case "UNKNOWN":
            return FrameType.UNKNOWN;
        case -1:
        case "UNRECOGNIZED":
        default:
            return FrameType.UNRECOGNIZED;
    }
}
export function frameTypeToJSON(object) {
    switch (object) {
        case FrameType.I:
            return "I";
        case FrameType.P:
            return "P";
        case FrameType.B:
            return "B";
        case FrameType.UNKNOWN:
            return "UNKNOWN";
        case FrameType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function createBaseEncodedFrame() {
    return {
        cam: undefined,
        instanceNum: 0,
        width: 0,
        height: 0,
        quality: 0,
        bitrate: 0,
        profile: 0,
        lossless: false,
        type: 0,
        frameOffset: 0,
        frameSize: 0,
        sequenceNum: 0,
        ts: undefined,
        tsDevice: undefined,
        transformation: undefined,
        data: new Uint8Array(0),
    };
}
export const EncodedFrame = {
    encode(message, writer = new BinaryWriter()) {
        if (message.cam !== undefined) {
            CameraSettings.encode(message.cam, writer.uint32(10).fork()).join();
        }
        if (message.instanceNum !== 0) {
            writer.uint32(16).uint32(message.instanceNum);
        }
        if (message.width !== 0) {
            writer.uint32(24).uint32(message.width);
        }
        if (message.height !== 0) {
            writer.uint32(32).uint32(message.height);
        }
        if (message.quality !== 0) {
            writer.uint32(40).uint32(message.quality);
        }
        if (message.bitrate !== 0) {
            writer.uint32(48).uint32(message.bitrate);
        }
        if (message.profile !== 0) {
            writer.uint32(56).int32(message.profile);
        }
        if (message.lossless !== false) {
            writer.uint32(64).bool(message.lossless);
        }
        if (message.type !== 0) {
            writer.uint32(72).int32(message.type);
        }
        if (message.frameOffset !== 0) {
            writer.uint32(80).uint32(message.frameOffset);
        }
        if (message.frameSize !== 0) {
            writer.uint32(88).uint32(message.frameSize);
        }
        if (message.sequenceNum !== 0) {
            writer.uint32(96).int64(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(106).fork()).join();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(114).fork()).join();
        }
        if (message.transformation !== undefined) {
            ImgTransformation.encode(message.transformation, writer.uint32(122).fork()).join();
        }
        if (message.data.length !== 0) {
            writer.uint32(130).bytes(message.data);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseEncodedFrame();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.cam = CameraSettings.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.instanceNum = reader.uint32();
                    continue;
                }
                case 3: {
                    if (tag !== 24) {
                        break;
                    }
                    message.width = reader.uint32();
                    continue;
                }
                case 4: {
                    if (tag !== 32) {
                        break;
                    }
                    message.height = reader.uint32();
                    continue;
                }
                case 5: {
                    if (tag !== 40) {
                        break;
                    }
                    message.quality = reader.uint32();
                    continue;
                }
                case 6: {
                    if (tag !== 48) {
                        break;
                    }
                    message.bitrate = reader.uint32();
                    continue;
                }
                case 7: {
                    if (tag !== 56) {
                        break;
                    }
                    message.profile = reader.int32();
                    continue;
                }
                case 8: {
                    if (tag !== 64) {
                        break;
                    }
                    message.lossless = reader.bool();
                    continue;
                }
                case 9: {
                    if (tag !== 72) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                }
                case 10: {
                    if (tag !== 80) {
                        break;
                    }
                    message.frameOffset = reader.uint32();
                    continue;
                }
                case 11: {
                    if (tag !== 88) {
                        break;
                    }
                    message.frameSize = reader.uint32();
                    continue;
                }
                case 12: {
                    if (tag !== 96) {
                        break;
                    }
                    message.sequenceNum = longToNumber(reader.int64());
                    continue;
                }
                case 13: {
                    if (tag !== 106) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 14: {
                    if (tag !== 114) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 15: {
                    if (tag !== 122) {
                        break;
                    }
                    message.transformation = ImgTransformation.decode(reader, reader.uint32());
                    continue;
                }
                case 16: {
                    if (tag !== 130) {
                        break;
                    }
                    message.data = reader.bytes();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            cam: isSet(object.cam) ? CameraSettings.fromJSON(object.cam) : undefined,
            instanceNum: isSet(object.instanceNum) ? globalThis.Number(object.instanceNum) : 0,
            width: isSet(object.width) ? globalThis.Number(object.width) : 0,
            height: isSet(object.height) ? globalThis.Number(object.height) : 0,
            quality: isSet(object.quality) ? globalThis.Number(object.quality) : 0,
            bitrate: isSet(object.bitrate) ? globalThis.Number(object.bitrate) : 0,
            profile: isSet(object.profile) ? profileFromJSON(object.profile) : 0,
            lossless: isSet(object.lossless) ? globalThis.Boolean(object.lossless) : false,
            type: isSet(object.type) ? frameTypeFromJSON(object.type) : 0,
            frameOffset: isSet(object.frameOffset) ? globalThis.Number(object.frameOffset) : 0,
            frameSize: isSet(object.frameSize) ? globalThis.Number(object.frameSize) : 0,
            sequenceNum: isSet(object.sequenceNum) ? globalThis.Number(object.sequenceNum) : 0,
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
            transformation: isSet(object.transformation) ? ImgTransformation.fromJSON(object.transformation) : undefined,
            data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0),
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.cam !== undefined) {
            obj.cam = CameraSettings.toJSON(message.cam);
        }
        if (message.instanceNum !== 0) {
            obj.instanceNum = Math.round(message.instanceNum);
        }
        if (message.width !== 0) {
            obj.width = Math.round(message.width);
        }
        if (message.height !== 0) {
            obj.height = Math.round(message.height);
        }
        if (message.quality !== 0) {
            obj.quality = Math.round(message.quality);
        }
        if (message.bitrate !== 0) {
            obj.bitrate = Math.round(message.bitrate);
        }
        if (message.profile !== 0) {
            obj.profile = profileToJSON(message.profile);
        }
        if (message.lossless !== false) {
            obj.lossless = message.lossless;
        }
        if (message.type !== 0) {
            obj.type = frameTypeToJSON(message.type);
        }
        if (message.frameOffset !== 0) {
            obj.frameOffset = Math.round(message.frameOffset);
        }
        if (message.frameSize !== 0) {
            obj.frameSize = Math.round(message.frameSize);
        }
        if (message.sequenceNum !== 0) {
            obj.sequenceNum = Math.round(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        if (message.transformation !== undefined) {
            obj.transformation = ImgTransformation.toJSON(message.transformation);
        }
        if (message.data.length !== 0) {
            obj.data = base64FromBytes(message.data);
        }
        return obj;
    },
    create(base) {
        return EncodedFrame.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseEncodedFrame();
        message.cam = (object.cam !== undefined && object.cam !== null)
            ? CameraSettings.fromPartial(object.cam)
            : undefined;
        message.instanceNum = object.instanceNum ?? 0;
        message.width = object.width ?? 0;
        message.height = object.height ?? 0;
        message.quality = object.quality ?? 0;
        message.bitrate = object.bitrate ?? 0;
        message.profile = object.profile ?? 0;
        message.lossless = object.lossless ?? false;
        message.type = object.type ?? 0;
        message.frameOffset = object.frameOffset ?? 0;
        message.frameSize = object.frameSize ?? 0;
        message.sequenceNum = object.sequenceNum ?? 0;
        message.ts = (object.ts !== undefined && object.ts !== null) ? Timestamp.fromPartial(object.ts) : undefined;
        message.tsDevice = (object.tsDevice !== undefined && object.tsDevice !== null)
            ? Timestamp.fromPartial(object.tsDevice)
            : undefined;
        message.transformation = (object.transformation !== undefined && object.transformation !== null)
            ? ImgTransformation.fromPartial(object.transformation)
            : undefined;
        message.data = object.data ?? new Uint8Array(0);
        return message;
    },
};
function bytesFromBase64(b64) {
    if (globalThis.Buffer) {
        return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
    }
    else {
        const bin = globalThis.atob(b64);
        const arr = new Uint8Array(bin.length);
        for (let i = 0; i < bin.length; ++i) {
            arr[i] = bin.charCodeAt(i);
        }
        return arr;
    }
}
function base64FromBytes(arr) {
    if (globalThis.Buffer) {
        return globalThis.Buffer.from(arr).toString("base64");
    }
    else {
        const bin = [];
        arr.forEach((byte) => {
            bin.push(globalThis.String.fromCharCode(byte));
        });
        return globalThis.btoa(bin.join(""));
    }
}
function longToNumber(int64) {
    const num = globalThis.Number(int64.toString());
    if (num > globalThis.Number.MAX_SAFE_INTEGER) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (num < globalThis.Number.MIN_SAFE_INTEGER) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return num;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
export const protobufName = "EncodedFrame";
//# sourceMappingURL=EncodedFrame.js.map