mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 23:57:37 +08:00
listStreamProxy接口支持返回track、status_str信息
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user