This source file includes following definitions.
- verifyType
- constructIllegalTypeExceptionMessage
- create
- create
- type
- setType
- sdp
- setSdp
- webSessionDescription
#include "config.h"
#include "modules/mediastream/RTCSessionDescription.h"
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
namespace WebCore {
static bool verifyType(const String& type)
{
return type == "offer" || type == "pranswer" || type == "answer";
}
static String constructIllegalTypeExceptionMessage(const String& type)
{
return "Illegal value of attribute 'type' : " + type;
}
PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(const Dictionary& descriptionInitDict, ExceptionState& exceptionState)
{
String type;
bool ok = descriptionInitDict.get("type", type);
if (ok && !verifyType(type)) {
exceptionState.throwDOMException(TypeMismatchError, constructIllegalTypeExceptionMessage(type));
return nullptr;
}
String sdp;
descriptionInitDict.get("sdp", sdp);
return adoptRef(new RTCSessionDescription(blink::WebRTCSessionDescription(type, sdp)));
}
PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(blink::WebRTCSessionDescription webSessionDescription)
{
return adoptRef(new RTCSessionDescription(webSessionDescription));
}
RTCSessionDescription::RTCSessionDescription(blink::WebRTCSessionDescription webSessionDescription)
: m_webSessionDescription(webSessionDescription)
{
ScriptWrappable::init(this);
}
String RTCSessionDescription::type()
{
return m_webSessionDescription.type();
}
void RTCSessionDescription::setType(const String& type, ExceptionState& exceptionState)
{
if (verifyType(type))
m_webSessionDescription.setType(type);
else
exceptionState.throwDOMException(TypeMismatchError, constructIllegalTypeExceptionMessage(type));
}
String RTCSessionDescription::sdp()
{
return m_webSessionDescription.sdp();
}
void RTCSessionDescription::setSdp(const String& sdp)
{
m_webSessionDescription.setSDP(sdp);
}
blink::WebRTCSessionDescription RTCSessionDescription::webSessionDescription()
{
return m_webSessionDescription;
}
}