完善主动关断流机制

This commit is contained in:
xiongziliang
2019-05-27 14:14:42 +08:00
parent 3f211d1653
commit f563274cda
6 changed files with 50 additions and 3 deletions

View File

@@ -79,6 +79,11 @@ PlayerProxy::PlayerProxy(const string &strVhost,
void PlayerProxy::setPlayCallbackOnce(const function<void(const SockException &ex)> &cb){
_playCB = cb;
}
void PlayerProxy::setOnClose(const function<void()> &cb){
_onClose = cb;
}
void PlayerProxy::play(const string &strUrlTmp) {
weak_ptr<PlayerProxy> weakSelf = shared_from_this();
std::shared_ptr<int> piFailedCnt(new int(0)); //连续播放失败次数
@@ -148,6 +153,9 @@ bool PlayerProxy::close() {
if (stronSelf) {
stronSelf->_mediaMuxer.reset();
stronSelf->teardown();
if(stronSelf->_onClose){
stronSelf->_onClose();
}
}
});
return true;