-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTC: Support statistic for HTTP-API, HTTP-Callback and Security #2483
Changes from 3 commits
47e7708
0c34cba
6c0825e
4718861
d8790ec
9b0471c
55c236c
32f39f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,6 +404,10 @@ SrsRtcPlayStream::~SrsRtcPlayStream() | |
srs_freep(it->second); | ||
} | ||
} | ||
|
||
// update the statistic when client coveried. | ||
SrsStatistic* stat = SrsStatistic::instance(); | ||
stat->on_disconnect(cid_.c_str()); | ||
} | ||
|
||
srs_error_t SrsRtcPlayStream::initialize(SrsRequest* req, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations) | ||
|
@@ -529,6 +533,12 @@ srs_error_t SrsRtcPlayStream::start() | |
return srs_error_wrap(err, "on start play"); | ||
} | ||
} | ||
|
||
// update the statistic when client discoveried. | ||
SrsStatistic* stat = SrsStatistic::instance(); | ||
if ((err = stat->on_client(cid_.c_str(), req_, session_, SrsRtcConnPlay)) != srs_success) { | ||
srs_trace("webrtc: add client failed!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on_client always returns srs_success, which can be ignored.
|
||
} | ||
|
||
is_started = true; | ||
|
||
|
@@ -998,6 +1008,10 @@ SrsRtcPublishStream::~SrsRtcPublishStream() | |
srs_freep(twcc_epp_); | ||
srs_freep(pli_epp); | ||
srs_freep(req); | ||
|
||
// update the statistic when client coveried. | ||
SrsStatistic* stat = SrsStatistic::instance(); | ||
stat->on_disconnect(cid_.c_str()); | ||
} | ||
|
||
srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescription* stream_desc) | ||
|
@@ -1112,6 +1126,12 @@ srs_error_t SrsRtcPublishStream::start() | |
return srs_error_wrap(err, "on start publish"); | ||
} | ||
} | ||
|
||
// update the statistic when client discoveried. | ||
SrsStatistic* stat = SrsStatistic::instance(); | ||
if ((err = stat->on_client(cid_.c_str(), req, session_, SrsRtcConnPublish)) != srs_success) { | ||
srs_trace("webrtc: add client failed!"); | ||
} | ||
|
||
is_started = true; | ||
|
||
|
@@ -1823,6 +1843,11 @@ std::string SrsRtcConnection::desc() | |
return "RtcConn"; | ||
} | ||
|
||
void SrsRtcConnection::expire() | ||
{ | ||
_srs_rtc_manager->remove(this); | ||
} | ||
|
||
void SrsRtcConnection::switch_to_context() | ||
{ | ||
_srs_context->set_id(cid_); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,7 +404,7 @@ class SrsRtcConnectionNackTimer : public ISrsFastTimer | |
// | ||
// For performance, we use non-public from resource, | ||
// see https://stackoverflow.com/questions/3747066/c-cannot-convert-from-base-a-to-derived-type-b-via-virtual-base-a | ||
class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler | ||
class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler, public ISrsExpire | ||
{ | ||
friend class SrsSecurityTransport; | ||
friend class SrsRtcPlayStream; | ||
|
@@ -486,6 +486,9 @@ class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler | |
public: | ||
virtual const SrsContextId& get_id(); | ||
virtual std::string desc(); | ||
// Interface ISrsExpire. | ||
public: | ||
virtual void expire(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This interface supports kickoff. We need to test if there will be any issues.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is used for the kickoff feature. I have tested it locally and it passed.
|
||
public: | ||
void switch_to_context(); | ||
const SrsContextId& context_id(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1628,7 +1628,9 @@ SrsResponse::~SrsResponse() | |
string srs_client_type_string(SrsRtmpConnType type) | ||
{ | ||
switch (type) { | ||
case SrsRtmpConnPlay: return "Play"; | ||
case SrsRtmpConnPlay: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to distinguish between these two and return rtmp-play and rtc-play?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At present, this field is not being used, but it can still be distinguished.
|
||
case SrsRtcConnPlay: | ||
return "Play"; | ||
case SrsRtmpConnFlashPublish: return "flash-publish"; | ||
case SrsRtmpConnFMLEPublish: return "fmle-publish"; | ||
case SrsRtmpConnHaivisionPublish: return "haivision-publish"; | ||
|
@@ -1638,7 +1640,7 @@ string srs_client_type_string(SrsRtmpConnType type) | |
|
||
bool srs_client_type_is_publish(SrsRtmpConnType type) | ||
{ | ||
return type != SrsRtmpConnPlay; | ||
return ((type != SrsRtmpConnPlay) && (type != SrsRtcConnPlay)); | ||
} | ||
|
||
SrsHandshakeBytes::SrsHandshakeBytes() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many scattered local variables, which can easily lead to misuse.
Can we move the declaration of SrsRtcUserConfig ruc; forward and directly use its variable, for example:
TRANS_BY_GPT3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll make some changes.
TRANS_BY_GPT3