"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.receiverCapabilities = exports.senderCapabilities = exports.DEFAULT_AUDIO_CAPABILITIES = void 0;
const react_native_1 = require("react-native");
const RTCRtpCodecCapability_1 = __importDefault(require("./RTCRtpCodecCapability"));
const { WebRTCModule } = react_native_1.NativeModules;
/**
 * @brief represents codec capabilities for senders and receivers. Currently
 * this only supports codec names and does not have other
 * fields like clockRate and numChannels and such.
 */
class RTCRtpCapabilities {
    constructor(codecs) {
        this._codecs = [];
        this._codecs = codecs;
        Object.freeze(this);
    }
    get codecs() {
        return this._codecs;
    }
}
exports.default = RTCRtpCapabilities;
function getCapabilities(endpoint) {
    switch (endpoint) {
        case 'sender': {
            const capabilities = WebRTCModule.senderGetCapabilities();
            if (!capabilities) {
                return null;
            }
            return new RTCRtpCapabilities(capabilities.codecs);
        }
        case 'receiver': {
            const capabilities = WebRTCModule.receiverGetCapabilities();
            if (!capabilities) {
                return null;
            }
            return new RTCRtpCapabilities(capabilities.codecs);
        }
        default:
            throw new TypeError('Invalid endpoint: ' + endpoint);
    }
}
/**
 * Hardcoded audio capabilities based on the WebRTC native documentation:
 * https://webrtc.github.io/webrtc-org/faq/. The mime type is specified in
 * https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-2.
 */
exports.DEFAULT_AUDIO_CAPABILITIES = new RTCRtpCapabilities([
    new RTCRtpCodecCapability_1.default({ mimeType: 'audio/G722' }),
    new RTCRtpCodecCapability_1.default({ mimeType: 'audio/iLBC' }),
]);
// Initialize capabilities on module import
exports.senderCapabilities = getCapabilities('sender');
exports.receiverCapabilities = getCapabilities('receiver');
//# sourceMappingURL=RTCRtpCapabilities.js.map