"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("react-native");
const RTCRtpCapabilities_1 = require("./RTCRtpCapabilities");
const RTCRtpReceiveParameters_1 = __importDefault(require("./RTCRtpReceiveParameters"));
const { WebRTCModule } = react_native_1.NativeModules;
class RTCRtpReceiver {
    constructor(info) {
        this._track = null;
        this._id = info.id;
        this._peerConnectionId = info.peerConnectionId;
        this._rtpParameters = new RTCRtpReceiveParameters_1.default(info.rtpParameters);
        if (info.track) {
            this._track = info.track;
        }
    }
    static getCapabilities(kind) {
        if (kind === 'audio') {
            return RTCRtpCapabilities_1.DEFAULT_AUDIO_CAPABILITIES;
        }
        if (!RTCRtpCapabilities_1.receiverCapabilities) {
            throw new Error('Receiver Capabilities is null');
        }
        return RTCRtpCapabilities_1.receiverCapabilities;
    }
    getStats() {
        return WebRTCModule.receiverGetStats(this._peerConnectionId, this._id).then(data => 
        /* On both Android and iOS it is faster to construct a single
        JSON string representing the Map of StatsReports and have it
        pass through the React Native bridge rather than the Map of
        StatsReports. While the implementations do try to be faster in
        general, the stress is on being faster to pass through the React
        Native bridge which is a bottleneck that tends to be visible in
        the UI when there is congestion involving UI-related passing.
        */
        new Map(JSON.parse(data)));
    }
    getParameters() {
        return this._rtpParameters;
    }
    get id() {
        return this._id;
    }
    get track() {
        return this._track;
    }
}
exports.default = RTCRtpReceiver;
//# sourceMappingURL=RTCRtpReceiver.js.map