RTCPeerConnection.js [plain text]
function initializeRTCPeerConnection(configuration)
{
"use strict";
if (configuration == null)
configuration = {};
else if (!@isObject(configuration))
@throwTypeError("RTCPeerConnection argument must be a valid dictionary");
this.@initializeWith(configuration);
@putByIdDirectPrivate(this, "operations", []);
return this;
}
function createOffer()
{
"use strict";
if (!@isRTCPeerConnection(this))
return @Promise.@reject(@makeThisTypeError("RTCPeerConnection", "createOffer"));
const offerOptions = arguments[0];
return @enqueueOperation(this, () => {
return this.@queuedCreateOffer(offerOptions);
});
}
function createAnswer()
{
"use strict";
if (!@isRTCPeerConnection(this))
return @Promise.@reject(@makeThisTypeError("RTCPeerConnection", "createAnswer"));
const answerOptions = arguments[0];
return @enqueueOperation(this, () => {
return this.@queuedCreateAnswer(answerOptions);
});
}
function setLocalDescription(description)
{
"use strict";
if (!@isRTCPeerConnection(this))
return @Promise.@reject(@makeThisTypeError("RTCPeerConnection", "setLocalDescription"));
if (arguments.length < 1)
return @Promise.@reject(new @TypeError("Not enough arguments"));
const objectInfo = {
"constructor": @RTCSessionDescription,
"argName": "description",
"argType": "RTCSessionDescription",
"maybeDictionary": "true"
};
return @objectOverload(description, "setLocalDescription", objectInfo, (description) => {
return @enqueueOperation(this, () => {
return this.@queuedSetLocalDescription(description);
});
});
}
function setRemoteDescription(description)
{
"use strict";
if (!@isRTCPeerConnection(this))
return @Promise.@reject(@makeThisTypeError("RTCPeerConnection", "setRemoteDescription"));
if (arguments.length < 1)
return @Promise.@reject(new @TypeError("Not enough arguments"));
const objectInfo = {
"constructor": @RTCSessionDescription,
"argName": "description",
"argType": "RTCSessionDescription",
"maybeDictionary": "true"
};
return @objectOverload(description, "setRemoteDescription", objectInfo, (description) => {
return @enqueueOperation(this, () => {
return this.@queuedSetRemoteDescription(description);
});
});
}
function addIceCandidate(candidate)
{
"use strict";
if (!@isRTCPeerConnection(this))
return @Promise.@reject(@makeThisTypeError("RTCPeerConnection", "addIceCandidate"));
if (arguments.length < 1)
return @Promise.@reject(new @TypeError("Not enough arguments"));
const objectInfo = {
"constructor": @RTCIceCandidate,
"argName": "candidate",
"argType": "RTCIceCandidate",
"maybeDictionary": "true",
"defaultsToNull" : "true"
};
return @objectOverload(candidate, "addIceCandidate", objectInfo, (candidate) => {
return @enqueueOperation(this, () => {
return this.@queuedAddIceCandidate(candidate);
});
});
}