From d3cb0e3d397164c5b09a0564aaceb9737d9e4231 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 20 Sep 2020 00:57:34 +0800 Subject: [PATCH] =?UTF-8?q?ts=E7=9B=B4=E6=92=AD=E6=BA=90=E6=B3=A8=E9=94=80?= =?UTF-8?q?=E6=97=B6=E5=85=B3=E9=97=AD=E6=92=AD=E6=94=BE=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 7d50deb9..bc145759 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -250,19 +250,26 @@ bool HttpSession::checkLiveStreamTS(const function &cb){ //直播牺牲延时提升发送性能 setSocketFlags(); - weak_ptr weakSelf = dynamic_pointer_cast(shared_from_this()); + weak_ptr weak_self = dynamic_pointer_cast(shared_from_this()); _ts_reader = ts_src->getRing()->attach(getPoller()); - _ts_reader->setReadCB([weakSelf](const TSMediaSource::RingDataType &ts_list) { - auto strongSelf = weakSelf.lock(); - if (!strongSelf) { + _ts_reader->setDetachCB([weak_self](){ + auto strong_self = weak_self.lock(); + if (!strong_self) { + //本对象已经销毁 + return; + } + strong_self->shutdown(SockException(Err_shutdown,"ts ring buffer detached")); + }); + _ts_reader->setReadCB([weak_self](const TSMediaSource::RingDataType &ts_list) { + auto strong_self = weak_self.lock(); + if (!strong_self) { //本对象已经销毁 return; } int i = 0; int size = ts_list->size(); - strongSelf->setSendFlushFlag(false); ts_list->for_each([&](const TSPacket::Ptr &ts) { - strongSelf->onWrite(ts, ++i == size); + strong_self->onWrite(ts, ++i == size); }); }); });