mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-07 04:08:13 +08:00
新增媒体流flush机制:#1996
This commit is contained in:
@@ -56,7 +56,7 @@ public:
|
||||
int ring_size = RTP_GOP_SIZE) :
|
||||
MediaSource(RTSP_SCHEMA, vhost, app, stream_id), _ring_size(ring_size) {}
|
||||
|
||||
~RtspMediaSource() override{}
|
||||
~RtspMediaSource() override { flush(); }
|
||||
|
||||
/**
|
||||
* 获取媒体源的环形缓冲
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "Common/MultiMediaSourceMuxer.h"
|
||||
|
||||
namespace mediakit {
|
||||
class RtspMediaSourceImp : public RtspMediaSource, private TrackListener, public MultiMediaSourceMuxer::Listener {
|
||||
class RtspMediaSourceImp final : public RtspMediaSource, private TrackListener, public MultiMediaSourceMuxer::Listener {
|
||||
public:
|
||||
typedef std::shared_ptr<RtspMediaSourceImp> Ptr;
|
||||
using Ptr = std::shared_ptr<RtspMediaSourceImp>;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
_demuxer->setTrackListener(this);
|
||||
}
|
||||
|
||||
~RtspMediaSourceImp() = default;
|
||||
~RtspMediaSourceImp() override = default;
|
||||
|
||||
/**
|
||||
* 设置sdp
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
class RtspMediaSourceMuxer : public RtspMuxer, public MediaSourceEventInterceptor,
|
||||
public std::enable_shared_from_this<RtspMediaSourceMuxer> {
|
||||
class RtspMediaSourceMuxer final : public RtspMuxer, public MediaSourceEventInterceptor,
|
||||
public std::enable_shared_from_this<RtspMediaSourceMuxer> {
|
||||
public:
|
||||
typedef std::shared_ptr<RtspMediaSourceMuxer> Ptr;
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
getRtpRing()->setDelegate(_media_src);
|
||||
}
|
||||
|
||||
~RtspMediaSourceMuxer() override{}
|
||||
~RtspMediaSourceMuxer() override { RtspMuxer::flush(); }
|
||||
|
||||
void setListener(const std::weak_ptr<MediaSourceEvent> &listener){
|
||||
setDelegate(listener);
|
||||
|
||||
@@ -86,6 +86,14 @@ bool RtspMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
return encoder ? encoder->inputFrame(frame) : false;
|
||||
}
|
||||
|
||||
void RtspMuxer::flush() {
|
||||
for (auto &encoder : _encoder) {
|
||||
if (encoder) {
|
||||
encoder->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string RtspMuxer::getSdp() {
|
||||
return _sdp;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,11 @@ public:
|
||||
*/
|
||||
bool inputFrame(const Frame::Ptr &frame) override;
|
||||
|
||||
/**
|
||||
* 刷新输出所有frame缓存
|
||||
*/
|
||||
void flush() override;
|
||||
|
||||
/**
|
||||
* 重置所有track
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user