summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp')
-rw-r--r--Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp79
1 files changed, 15 insertions, 64 deletions
diff --git a/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp b/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp
index 353e309dd..2c7e0d364 100644
--- a/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp
+++ b/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
* Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2015, 2016 Ericsson AB. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,84 +31,34 @@
*/
#include "config.h"
-
-#if ENABLE(MEDIA_STREAM)
-
#include "RTCIceCandidate.h"
-#include "Dictionary.h"
+#if ENABLE(WEB_RTC)
+
#include "ExceptionCode.h"
-#include "RTCIceCandidateDescriptor.h"
namespace WebCore {
-PassRefPtr<RTCIceCandidate> RTCIceCandidate::create(const Dictionary& dictionary, ExceptionCode& ec)
-{
- String candidate;
- bool ok = dictionary.get("candidate", candidate);
- if (ok && candidate.isEmpty()) {
- ec = TYPE_MISMATCH_ERR;
- return nullptr;
- }
-
- String sdpMid;
- ok = dictionary.get("sdpMid", sdpMid);
- if (ok && sdpMid.isEmpty()) {
- ec = TYPE_MISMATCH_ERR;
- return nullptr;
- }
-
- String tempLineIndex;
- unsigned short sdpMLineIndex = 0;
- // First we check if the property exists in the Dictionary.
- ok = dictionary.get("sdpMLineIndex", tempLineIndex);
- // Then we try to convert it to a number and check if it was successful.
- if (ok) {
- bool intConversionOk;
- sdpMLineIndex = tempLineIndex.toUIntStrict(&intConversionOk);
- if (!intConversionOk) {
- ec = TYPE_MISMATCH_ERR;
- return nullptr;
- }
- }
-
- return adoptRef(new RTCIceCandidate(RTCIceCandidateDescriptor::create(candidate, sdpMid, sdpMLineIndex)));
-}
-
-PassRefPtr<RTCIceCandidate> RTCIceCandidate::create(PassRefPtr<RTCIceCandidateDescriptor> descriptor)
-{
- return adoptRef(new RTCIceCandidate(descriptor));
-}
-
-RTCIceCandidate::RTCIceCandidate(PassRefPtr<RTCIceCandidateDescriptor> descriptor)
- : m_descriptor(descriptor)
-{
-}
-
-RTCIceCandidate::~RTCIceCandidate()
-{
-}
-
-const String& RTCIceCandidate::candidate() const
-{
- return m_descriptor->candidate();
-}
-
-const String& RTCIceCandidate::sdpMid() const
+inline RTCIceCandidate::RTCIceCandidate(const String& candidate, const String& sdpMid, std::optional<unsigned short> sdpMLineIndex)
+ : m_candidate(candidate)
+ , m_sdpMid(sdpMid)
+ , m_sdpMLineIndex(sdpMLineIndex)
{
- return m_descriptor->sdpMid();
+ ASSERT(!sdpMid.isNull() || sdpMLineIndex);
}
-unsigned short RTCIceCandidate::sdpMLineIndex() const
+ExceptionOr<Ref<RTCIceCandidate>> RTCIceCandidate::create(const Init& dictionary)
{
- return m_descriptor->sdpMLineIndex();
+ if (dictionary.sdpMid.isNull() && !dictionary.sdpMLineIndex)
+ return Exception { TypeError };
+ return create(dictionary.candidate, dictionary.sdpMid, dictionary.sdpMLineIndex);
}
-RTCIceCandidateDescriptor* RTCIceCandidate::descriptor()
+Ref<RTCIceCandidate> RTCIceCandidate::create(const String& candidate, const String& sdpMid, std::optional<unsigned short> sdpMLineIndex)
{
- return m_descriptor.get();
+ return adoptRef(*new RTCIceCandidate(candidate, sdpMid, sdpMLineIndex));
}
} // namespace WebCore
-#endif // ENABLE(MEDIA_STREAM)
+#endif // ENABLE(WEB_RTC)