mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Context: Refine API
This commit is contained in:
parent
cf428b8db4
commit
311cb77b36
5 changed files with 12 additions and 10 deletions
|
@ -340,7 +340,7 @@ srs_error_t SrsPublishRecvThread::error_code()
|
|||
return srs_error_copy(recv_error);
|
||||
}
|
||||
|
||||
void SrsPublishRecvThread::set_cid(std::string v)
|
||||
void SrsPublishRecvThread::set_cid(SrsContextId v)
|
||||
{
|
||||
ncid = v;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
virtual int64_t nb_msgs();
|
||||
virtual uint64_t nb_video_frames();
|
||||
virtual srs_error_t error_code();
|
||||
virtual void set_cid(std::string v);
|
||||
virtual void set_cid(SrsContextId v);
|
||||
virtual SrsContextId get_cid();
|
||||
public:
|
||||
virtual srs_error_t start();
|
||||
|
|
|
@ -27,11 +27,6 @@ _SrsContextId::_SrsContextId()
|
|||
{
|
||||
}
|
||||
|
||||
_SrsContextId::_SrsContextId(std::string v)
|
||||
{
|
||||
v_ = v;
|
||||
}
|
||||
|
||||
_SrsContextId::_SrsContextId(const _SrsContextId& cp)
|
||||
{
|
||||
v_ = cp.v_;
|
||||
|
@ -57,6 +52,12 @@ bool _SrsContextId::empty() const
|
|||
return v_.empty();
|
||||
}
|
||||
|
||||
_SrsContextId& _SrsContextId::set_value(const std::string& v)
|
||||
{
|
||||
v_ = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int _SrsContextId::compare(const _SrsContextId& to) const
|
||||
{
|
||||
return v_.compare(to.v_);
|
||||
|
|
|
@ -124,13 +124,14 @@ private:
|
|||
std::string v_;
|
||||
public:
|
||||
_SrsContextId();
|
||||
_SrsContextId(std::string v);
|
||||
_SrsContextId(const _SrsContextId& cp);
|
||||
_SrsContextId& operator=(const _SrsContextId& cp);
|
||||
virtual ~_SrsContextId();
|
||||
public:
|
||||
const char* c_str() const;
|
||||
bool empty() const;
|
||||
// Set the value of context id.
|
||||
_SrsContextId& set_value(const std::string& v);
|
||||
// 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.
|
||||
|
|
|
@ -45,8 +45,8 @@ SrsThreadContext::~SrsThreadContext()
|
|||
|
||||
SrsContextId SrsThreadContext::generate_id()
|
||||
{
|
||||
SrsContextId cid = SrsContextId(srs_random_str(8));
|
||||
return cid;
|
||||
SrsContextId cid = SrsContextId();
|
||||
return cid.set_value(srs_random_str(8));
|
||||
}
|
||||
|
||||
const SrsContextId& SrsThreadContext::get_id()
|
||||
|
|
Loading…
Reference in a new issue