From a6b2e28d50917eefc06d493a879d077bb55f825b Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 10 Jul 2020 18:06:07 +0800 Subject: [PATCH] RTC: Refine the api for context. --- trunk/src/core/srs_core.cpp | 10 +++++++--- trunk/src/core/srs_core.hpp | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/trunk/src/core/srs_core.cpp b/trunk/src/core/srs_core.cpp index 96db00bc9..8f409f4ec 100644 --- a/trunk/src/core/srs_core.cpp +++ b/trunk/src/core/srs_core.cpp @@ -37,17 +37,21 @@ _SrsContextId::_SrsContextId(const _SrsContextId& cp) v_ = cp.v_; } -const char* _SrsContextId::c_str() +_SrsContextId::~_SrsContextId() +{ +} + +const char* _SrsContextId::c_str() const { return v_.c_str(); } -bool _SrsContextId::empty() +bool _SrsContextId::empty() const { return v_.empty(); } -int _SrsContextId::compare(const _SrsContextId& to) +int _SrsContextId::compare(const _SrsContextId& to) const { return v_.compare(to.v_); } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 65da94cd0..a68549697 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -125,14 +125,15 @@ public: _SrsContextId(); _SrsContextId(std::string v); _SrsContextId(const _SrsContextId& cp); + virtual ~_SrsContextId(); public: - const char* c_str(); - bool empty(); + const char* c_str() const; + bool empty() const; // Compare the two context id. @see http://www.cplusplus.com/reference/string/string/compare/ // 0 They compare equal // <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter. // >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer. - int compare(const _SrsContextId& to); + int compare(const _SrsContextId& to) const; }; typedef _SrsContextId SrsContextId; #else