新增媒体流flush机制:#1996

This commit is contained in:
ziyue
2022-10-16 19:49:56 +08:00
parent 80eef693c6
commit ac1abb34da
44 changed files with 287 additions and 124 deletions

View File

@@ -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(); }
/**
* 获取媒体源的环形缓冲

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -73,6 +73,11 @@ public:
*/
bool inputFrame(const Frame::Ptr &frame) override;
/**
* 刷新输出所有frame缓存
*/
void flush() override;
/**
* 重置所有track
*/