实现rtsp/rtmp按需转协议功能

This commit is contained in:
xiongziliang
2020-09-12 19:09:56 +08:00
parent aff9963f95
commit 9e26a02fb1
23 changed files with 170 additions and 153 deletions

View File

@@ -60,7 +60,7 @@ public:
MediaSource(RTMP_SCHEMA, vhost, app, stream_id), _ring_size(ring_size) {
}
virtual ~RtmpMediaSource() {}
~RtmpMediaSource() override{}
/**
* 获取媒体源的环形缓冲
@@ -134,7 +134,7 @@ public:
if (!_ring) {
weak_ptr<RtmpMediaSource> weakSelf = dynamic_pointer_cast<RtmpMediaSource>(shared_from_this());
auto lam = [weakSelf](const EventPoller::Ptr &, int size, bool) {
auto lam = [weakSelf](int size) {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return;
@@ -174,6 +174,11 @@ public:
return ret;
}
void clearCache() override{
PacketCache<RtmpPacket>::clearCache();
_ring->clearCache();
}
private:
/**
* 批量flush rtmp包时触发该函数
@@ -185,15 +190,6 @@ private:
_ring->write(rtmp_list, _have_video ? key_pos : true);
}
/**
* 每次增减消费者都会触发该函数
*/
void onReaderChanged(int size) {
if (size == 0) {
onNoneReader();
}
}
private:
bool _have_video = false;
int _ring_size;