JSRTCSessionDescriptionCustom.cpp [plain text]
#include "config.h"
#if ENABLE(MEDIA_STREAM)
#include "JSRTCSessionDescription.h"
#include "Dictionary.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
using namespace JSC;
namespace WebCore {
EncodedJSValue JSC_HOST_CALL constructJSRTCSessionDescription(ExecState* exec)
{
ExceptionCode ec = 0;
Dictionary sessionInit;
if (exec->argumentCount() > 0) {
sessionInit = Dictionary(exec, exec->argument(0));
if (!sessionInit.isObject())
return throwVMError(exec, createTypeError(exec, "Optional RTCSessionDescription constructor argument must be a valid Dictionary"));
if (exec->hadException())
return JSValue::encode(jsUndefined());
}
DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::create(sessionInit, ec);
if (ec == TYPE_MISMATCH_ERR) {
setDOMException(exec, ec);
return throwVMError(exec, createTypeError(exec, "Invalid RTCSessionDescription constructor arguments"));
}
if (ec) {
setDOMException(exec, ec);
return throwVMError(exec, createTypeError(exec, "Error creating RTCSessionDescription"));
}
return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), RTCSessionDescription, sessionDescription.get()));
}
}
#endif // ENABLE(MEDIA_STREAM)