Add skeleton webrtc::SessionDescription and webrtc::MediaDescription classes.

BUG=webrtc:7311

Review-Url: https://codereview.webrtc.org/2743003004
Cr-Commit-Position: refs/heads/master@{#17181}
This commit is contained in:
zhihuang 2017-03-10 18:33:45 -08:00 committed by Commit bot
parent 3a72c228a1
commit 55adc0e1a5
7 changed files with 171 additions and 0 deletions

View File

@ -88,12 +88,16 @@ rtc_static_library("libjingle_peerconnection_api") {
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 @@ rtc_source_set("ortc_api") {
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 @@ if (rtc_include_tests) {
rtc_source_set("rtc_api_unittests") {
testonly = true
sources = [
"ortc/mediadescription_unittest.cc",
"ortc/sessiondescription_unittest.cc",
"rtcerror_unittest.cc",
]
@ -233,6 +243,7 @@ if (rtc_include_tests) {
deps = [
":libjingle_peerconnection_api",
":ortc_api",
"//webrtc/test:test_support",
]
}

View File

@ -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 {}

View File

@ -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_

View File

@ -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());
}
}

View File

@ -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 {}

View File

@ -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_

View File

@ -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());
}
}