listStreamProxy接口支持返回track、status_str信息

This commit is contained in:
xia-chu
2026-03-13 15:13:18 +08:00
parent 4e170e9281
commit 3b54168b44
3 changed files with 65 additions and 41 deletions

View File

@@ -110,6 +110,7 @@ void PlayerProxy::play(const string &strUrlTmp) {
}
if (err) {
NOTICE_EMIT(BroadcastPlayerProxyFailedArgs, Broadcast::kBroadcastPlayerProxyFailed, *strongSelf, err);
strongSelf->_status = std::make_shared<std::string>(std::string("play failed: ") + err.what());
}
if (strongSelf->_on_play) {
strongSelf->_on_play(err);
@@ -131,6 +132,7 @@ void PlayerProxy::play(const string &strUrlTmp) {
strongSelf->_on_connect(strongSelf->_transtalion_info);
InfoL << "play " << strUrlTmp << " success";
strongSelf->_status = std::make_shared<std::string>("playing");
} else if (*piFailedCnt < strongSelf->_retry_count || strongSelf->_retry_count < 0) {
// 播放失败,延时重试播放 [AUTO-TRANSLATED:d7537c9c]
// Play failed, retry playing with delay
@@ -154,6 +156,7 @@ void PlayerProxy::play(const string &strUrlTmp) {
strongSelf->_on_play(err);
strongSelf->_on_play = nullptr;
}
strongSelf->_status = std::make_shared<std::string>(std::string("play shutdown: ") + err.what());
// 注销直接拉流代理产生的流:#532 [AUTO-TRANSLATED:c6343a3b]
// Unregister the stream generated by the direct stream proxy: #532
@@ -193,8 +196,10 @@ void PlayerProxy::play(const string &strUrlTmp) {
}
});
try {
_status = std::make_shared<std::string>("connecting");
MediaPlayer::play(strUrlTmp);
} catch (std::exception &ex) {
_status = std::make_shared<std::string>(std::string("play failed: ") + ex.what());
ErrorL << ex.what();
onPlayResult(SockException(Err_other, ex.what()));
return;
@@ -365,6 +370,12 @@ void PlayerProxy::onPlaySuccess() {
int PlayerProxy::getStatus() {
return _live_status.load();
}
std::string PlayerProxy::getStatusStr() const {
auto status = _status;
return status ? *status : "unknown";
}
uint64_t PlayerProxy::getLiveSecs() {
if (_live_status == 0) {
return _live_secs + _live_ticker.elapsedTime() / 1000;

View File

@@ -129,6 +129,7 @@ public:
int totalReaderCount();
int getStatus();
std::string getStatusStr() const;
uint64_t getLiveSecs();
uint64_t getRePullCount();
@@ -155,6 +156,7 @@ private:
void setTranslationInfo();
private:
std::shared_ptr<std::string> _status;
int _retry_count;
int _reconnect_delay_min;
int _reconnect_delay_max;