Add skeleton webrtc::SessionDescription and webrtc::MediaDescription classes.
BUG=webrtc:7311
Review-Url: https://codereview.webrtc.org/2743003004
Cr-Original-Commit-Position: refs/heads/master@{#17181}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 55adc0e1a5f39f7b4bb706c1cbc688e75c9754ae
diff --git a/api/BUILD.gn b/api/BUILD.gn
index e42b834..71e5243 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -88,12 +88,16 @@
rtc_source_set("ortc_api") {
check_includes = false # TODO(deadbeef): Remove (bugs.webrtc.org/6828)
sources = [
+ "ortc/mediadescription.cc",
+ "ortc/mediadescription.h",
"ortc/ortcfactoryinterface.h",
"ortc/ortcrtpreceiverinterface.h",
"ortc/ortcrtpsenderinterface.h",
"ortc/packettransportinterface.h",
"ortc/rtptransportcontrollerinterface.h",
"ortc/rtptransportinterface.h",
+ "ortc/sessiondescription.cc",
+ "ortc/sessiondescription.h",
"ortc/srtptransportinterface.h",
"ortc/udptransportinterface.h",
]
@@ -105,6 +109,10 @@
public_deps = [
":libjingle_peerconnection_api",
]
+ if (!build_with_chromium && is_clang) {
+ # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+ suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+ }
}
# TODO(ossu): Remove once downstream projects have updated.
@@ -223,6 +231,8 @@
rtc_source_set("rtc_api_unittests") {
testonly = true
sources = [
+ "ortc/mediadescription_unittest.cc",
+ "ortc/sessiondescription_unittest.cc",
"rtcerror_unittest.cc",
]
@@ -233,6 +243,7 @@
deps = [
":libjingle_peerconnection_api",
+ ":ortc_api",
"//webrtc/test:test_support",
]
}
diff --git a/api/ortc/mediadescription.cc b/api/ortc/mediadescription.cc
new file mode 100644
index 0000000..9fca55c
--- /dev/null
+++ b/api/ortc/mediadescription.cc
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/ortc/mediadescription.h"
+
+namespace webrtc {}
diff --git a/api/ortc/mediadescription.h b/api/ortc/mediadescription.h
new file mode 100644
index 0000000..7e811ec
--- /dev/null
+++ b/api/ortc/mediadescription.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_ORTC_MEDIADESCRIPTION_H_
+#define WEBRTC_API_ORTC_MEDIADESCRIPTION_H_
+
+#include <string>
+#include <utility>
+
+#include "webrtc/base/optional.h"
+
+namespace webrtc {
+
+// A structured representation of a media description within an SDP session
+// description.
+class MediaDescription {
+ public:
+ explicit MediaDescription(std::string mid) : mid_(std::move(mid)) {}
+
+ ~MediaDescription() {}
+
+ // The mid(media stream identification) is used for identifying media streams
+ // within a session description.
+ // https://tools.ietf.org/html/rfc5888#section-6
+ rtc::Optional<std::string> mid() const { return mid_; }
+ void set_mid(std::string mid) { mid_.emplace(std::move(mid)); }
+
+ private:
+ rtc::Optional<std::string> mid_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_API_ORTC_MEDIADESCRIPTION_H_
diff --git a/api/ortc/mediadescription_unittest.cc b/api/ortc/mediadescription_unittest.cc
new file mode 100644
index 0000000..a17fde2
--- /dev/null
+++ b/api/ortc/mediadescription_unittest.cc
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/ortc/mediadescription.h"
+#include "webrtc/test/gtest.h"
+
+namespace webrtc {
+
+class MediaDescriptionTest : public testing::Test {};
+
+TEST_F(MediaDescriptionTest, CreateMediaDescription) {
+ MediaDescription m("a");
+ EXPECT_EQ("a", m.mid());
+}
+}
diff --git a/api/ortc/sessiondescription.cc b/api/ortc/sessiondescription.cc
new file mode 100644
index 0000000..c1d4bbb
--- /dev/null
+++ b/api/ortc/sessiondescription.cc
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/ortc/sessiondescription.h"
+
+namespace webrtc {}
diff --git a/api/ortc/sessiondescription.h b/api/ortc/sessiondescription.h
new file mode 100644
index 0000000..18a48e0
--- /dev/null
+++ b/api/ortc/sessiondescription.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_ORTC_SESSIONDESCRIPTION_H_
+#define WEBRTC_API_ORTC_SESSIONDESCRIPTION_H_
+
+#include <string>
+#include <utility>
+
+namespace webrtc {
+
+// A structured representation of an SDP session description.
+class SessionDescription {
+ public:
+ SessionDescription(std::string session_id, std::string session_version)
+ : session_id_(std::move(session_id)),
+ session_version_(std::move(session_version)) {}
+
+ // https://tools.ietf.org/html/rfc4566#section-5.2
+ // o=<username> <sess-id> <sess-version> <nettype> <addrtype>
+ // <unicast-address>
+ // session_id_ is the "sess-id" field.
+ // session_version_ is the "sess-version" field.
+ const std::string& session_id() const { return session_id_; }
+ void set_session_id(std::string session_id) {
+ session_id_ = std::move(session_id);
+ }
+
+ const std::string& session_version() const { return session_version_; }
+ void set_session_version(std::string session_version) {
+ session_version_ = std::move(session_version);
+ }
+
+ private:
+ std::string session_id_;
+ std::string session_version_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_API_ORTC_SESSIONDESCRIPTION_H_
diff --git a/api/ortc/sessiondescription_unittest.cc b/api/ortc/sessiondescription_unittest.cc
new file mode 100644
index 0000000..c856ea9
--- /dev/null
+++ b/api/ortc/sessiondescription_unittest.cc
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/ortc/sessiondescription.h"
+#include "webrtc/test/gtest.h"
+
+namespace webrtc {
+
+class SessionDescriptionTest : public testing::Test {};
+
+TEST_F(SessionDescriptionTest, CreateSessionDescription) {
+ SessionDescription s("a", "0");
+ EXPECT_EQ("a", s.session_id());
+ EXPECT_EQ("0", s.session_version());
+}
+}