UNPKG

react-native-webrtc

Version:
40 lines 1.69 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import RTCRtpEncodingParameters from './RTCRtpEncodingParameters'; import RTCRtpParameters from './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('-', '_'); } } export default class RTCRtpSendParameters extends RTCRtpParameters { constructor(init) { super(init); _defineProperty(this, "transactionId", void 0); _defineProperty(this, "encodings", void 0); _defineProperty(this, "degradationPreference", void 0); 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(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; } } //# sourceMappingURL=RTCRtpSendParameters.js.map