优化获取播放器列表相关功能

This commit is contained in:
xia-chu
2023-09-02 12:06:35 +08:00
parent d286ac1d73
commit 39dd886ec1
15 changed files with 68 additions and 27 deletions

View File

@@ -46,7 +46,11 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
std::weak_ptr<FlvMuxer> weak_self = getSharedPtr();
media->pause(false);
_ring_reader = media->getRing()->attach(poller);
_ring_reader->setGetInfoCB([weak_self]() { return dynamic_pointer_cast<HttpSession>(weak_self.lock()); });
_ring_reader->setGetInfoCB([weak_self]() {
Any ret;
ret.set(dynamic_pointer_cast<SockInfo>(weak_self.lock()));
return ret;
});
_ring_reader->setDetachCB([weak_self]() {
auto strong_self = weak_self.lock();
if (!strong_self) {

View File

@@ -57,8 +57,8 @@ public:
return _ring;
}
void getPlayerList(const std::function<void(const std::list<std::shared_ptr<void>> &info_list)> &cb,
const std::function<std::shared_ptr<void>(std::shared_ptr<void> &&info)> &on_change) override {
void getPlayerList(const std::function<void(const std::list<toolkit::Any> &info_list)> &cb,
const std::function<toolkit::Any(toolkit::Any &&info)> &on_change) override {
_ring->getInfoList(cb, on_change);
}

View File

@@ -306,7 +306,11 @@ void RtmpSession::sendPlayResponse(const string &err, const RtmpMediaSource::Ptr
src->pause(false);
_ring_reader = src->getRing()->attach(getPoller());
weak_ptr<RtmpSession> weak_self = static_pointer_cast<RtmpSession>(shared_from_this());
_ring_reader->setGetInfoCB([weak_self]() { return weak_self.lock(); });
_ring_reader->setGetInfoCB([weak_self]() {
Any ret;
ret.set(static_pointer_cast<SockInfo>(weak_self.lock()));
return ret;
});
_ring_reader->setReadCB([weak_self](const RtmpMediaSource::RingDataType &pkt) {
auto strong_self = weak_self.lock();
if (!strong_self) {