"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const RTCRtpEncodingParameters_1 = __importDefault(require("./RTCRtpEncodingParameters"));
const RTCRtpParameters_1 = __importDefault(require("./RTCRtpParameters"));
/**
 * Class to convert degradation preference format. Native has a format such as
 * MAINTAIN_FRAMERATE whereas the web APIs expect maintain-framerate
 */
class DegradationPreference {
    static fromNative(nativeFormat) {
        const stringFormat = nativeFormat.toLowerCase().replace('_', '-');
        return stringFormat;
    }
    static toNative(format) {
        return format.toUpperCase().replace('-', '_');
    }
}
class RTCRtpSendParameters extends RTCRtpParameters_1.default {
    constructor(init) {
        super(init);
        this.transactionId = init.transactionId;
        this.encodings = [];
        this.degradationPreference = init.degradationPreference ?
            DegradationPreference.fromNative(init.degradationPreference) : null;
        for (const enc of init.encodings) {
            this.encodings.push(new RTCRtpEncodingParameters_1.default(enc));
        }
    }
    toJSON() {
        const obj = super.toJSON();
        obj['transactionId'] = this.transactionId;
        obj['encodings'] = this.encodings.map(e => e.toJSON());
        if (this.degradationPreference !== null) {
            obj['degradationPreference'] = DegradationPreference.toNative(this.degradationPreference);
        }
        return obj;
    }
}
exports.default = RTCRtpSendParameters;
//# sourceMappingURL=RTCRtpSendParameters.js.map