1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 11:51:57 +00:00

Log: Refine context id

This commit is contained in:
winlin 2020-07-09 17:16:59 +08:00
parent 742826a655
commit 7052a1fafb
2 changed files with 38 additions and 18 deletions

View file

@ -23,4 +23,32 @@
#include <srs_core.hpp>
_SrsContextId::_SrsContextId()
{
}
_SrsContextId::_SrsContextId(std::string v)
{
v_ = v;
}
_SrsContextId::_SrsContextId(const _SrsContextId& cp)
{
v_ = cp.v_;
}
const char* _SrsContextId::c_str()
{
return v_.c_str();
}
bool _SrsContextId::empty()
{
return v_.empty();
}
int _SrsContextId::compare(const _SrsContextId& to)
{
return v_.compare(to.v_);
}

View file

@ -117,30 +117,22 @@ typedef SrsCplxError* srs_error_t;
// The context ID, it default to a string object, we can also use other objects.
// @remark User can directly user string as SrsContextId, we user struct to ensure the context is an object.
#if 1
struct _SrsContextId
class _SrsContextId
{
private:
std::string v_;
_SrsContextId() {
}
_SrsContextId(std::string v) {
v_ = v;
}
_SrsContextId(const _SrsContextId& cp) {
v_ = cp.v_;
}
const char* c_str() {
return v_.c_str();
}
bool empty() {
return v_.empty();
}
public:
_SrsContextId();
_SrsContextId(std::string v);
_SrsContextId(const _SrsContextId& cp);
public:
const char* c_str();
bool empty();
// 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) {
return v_.compare(to.v_);
}
int compare(const _SrsContextId& to);
};
typedef _SrsContextId SrsContextId;
#else