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

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