add getProxyPusherInfo and getProxyInfo restful api

This commit is contained in:
xiongguangjie
2023-05-03 18:52:11 +08:00
parent bfec1b1e0e
commit 7c89c1655f
6 changed files with 191 additions and 8 deletions

View File

@@ -20,6 +20,9 @@ PusherProxy::PusherProxy(const MediaSource::Ptr &src, int retry_count, const Eve
_retry_count = retry_count;
_on_close = [](const SockException &) {};
_weak_src = src;
_live_secs = 0;
_live_status = 1;
_republish_count = 0;
}
PusherProxy::~PusherProxy() {
@@ -52,10 +55,14 @@ void PusherProxy::publish(const string &dst_url) {
auto src = strong_self->_weak_src.lock();
if (!err) {
// 推流成功
strong_self->_live_ticker.resetTime();
strong_self->_live_status = 0;
*failed_cnt = 0;
InfoL << "Publish " << dst_url << " success";
} else if (src && (*failed_cnt < strong_self->_retry_count || strong_self->_retry_count < 0)) {
// 推流失败,延时重试推送
strong_self->_republish_count++;
strong_self->_live_status = 1;
strong_self->rePublish(dst_url, (*failed_cnt)++);
} else {
//如果媒体源已经注销, 或达到了最大重试次数,回调关闭
@@ -69,9 +76,17 @@ void PusherProxy::publish(const string &dst_url) {
return;
}
if(*failed_cnt == 0){
// 第一次重推更新时长
strong_self->_live_secs += strong_self->_live_ticker.elapsedTime()/1000;
strong_self->_live_ticker.resetTime();
TraceL<<" live secs "<<strong_self->_live_secs;
}
auto src = strong_self->_weak_src.lock();
//推流异常中断,延时重试播放
if (src && (*failed_cnt < strong_self->_retry_count || strong_self->_retry_count < 0)) {
strong_self->_republish_count++;
strong_self->rePublish(dst_url, (*failed_cnt)++);
} else {
//如果媒体源已经注销, 或达到了最大重试次数,回调关闭
@@ -97,4 +112,19 @@ void PusherProxy::rePublish(const string &dst_url, int failed_cnt) {
}, getPoller());
}
int PusherProxy::getStatus() {
return _live_status.load();
}
uint64_t PusherProxy::getLiveSecs() {
if(_live_status == 0){
return _live_secs + _live_ticker.elapsedTime()/1000;
}else{
return _live_secs;
}
}
uint64_t PusherProxy::getRePublishCount(){
return _republish_count;
}
} /* namespace mediakit */