RTCOfferAnswerOptions.cpp [plain text]
#include "config.h"
#if ENABLE(MEDIA_STREAM)
#include "RTCOfferAnswerOptions.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
PassRefPtr<RTCOfferAnswerOptions> RTCOfferAnswerOptions::create(const Dictionary& options, ExceptionCode& ec)
{
RefPtr<RTCOfferAnswerOptions> offerAnswerOptions = adoptRef(new RTCOfferAnswerOptions());
String requestIdentity;
if (!offerAnswerOptions->initialize(options)) {
ec = TYPE_MISMATCH_ERR;
return nullptr;
}
return offerAnswerOptions.release();
}
bool RTCOfferAnswerOptions::initialize(const Dictionary& options)
{
if (!m_private)
m_private = RTCOfferAnswerOptionsPrivate::create();
String requestIdentity;
if (!options.isUndefinedOrNull() && (!options.get("requestIdentity", requestIdentity) || requestIdentity.isEmpty()))
return false;
m_private->setRequestIdentity(requestIdentity);
return true;
}
PassRefPtr<RTCOfferOptions> RTCOfferOptions::create(const Dictionary& options, ExceptionCode& ec)
{
RefPtr<RTCOfferOptions> offerOptions = adoptRef(new RTCOfferOptions());
if (!offerOptions->initialize(options)) {
ec = TYPE_MISMATCH_ERR;
return nullptr;
}
return offerOptions.release();
}
bool RTCOfferOptions::initialize(const Dictionary& options)
{
RefPtr<RTCOfferOptionsPrivate> optionsPrivate = RTCOfferOptionsPrivate::create();
m_private = optionsPrivate;
if (options.isUndefinedOrNull())
return true;
if (!RTCOfferAnswerOptions::initialize(options))
return false;
String offerToReceiveVideoStr;
bool numberConversionSuccess;
if (!options.get("offerToReceiveVideo", offerToReceiveVideoStr))
return false;
int64_t intConversionResult = offerToReceiveVideoStr.toInt64Strict(&numberConversionSuccess);
if (!numberConversionSuccess)
return false;
optionsPrivate->setOfferToReceiveVideo(intConversionResult);
String offerToReceiveAudioStr;
if (!options.get("offerToReceiveAudio", offerToReceiveAudioStr))
return false;
intConversionResult = offerToReceiveAudioStr.toInt64Strict(&numberConversionSuccess);
if (!numberConversionSuccess)
return false;
optionsPrivate->setOfferToReceiveAudio(intConversionResult);
bool voiceActivityDetection;
if (options.get("voiceActivityDetection", voiceActivityDetection))
optionsPrivate->setVoiceActivityDetection(voiceActivityDetection);
bool iceRestart;
if (options.get("iceRestart", iceRestart))
optionsPrivate->setIceRestart(iceRestart);
return true;
}
}
#endif // ENABLE(MEDIA_STREAM)