MPEG: 整合复用ts/ps生成代码

This commit is contained in:
ziyue
2021-12-28 21:04:53 +08:00
parent dce6b27f4f
commit 89870190e9
12 changed files with 425 additions and 481 deletions

View File

@@ -12,18 +12,18 @@
#define ZLMEDIAKIT_TSMEDIASOURCEMUXER_H
#include "TSMediaSource.h"
#include "Record/TsMuxer.h"
#include "Record/MPEG.h"
namespace mediakit {
class TSMediaSourceMuxer : public TsMuxer, public MediaSourceEventInterceptor,
class TSMediaSourceMuxer : public MpegMuxer, public MediaSourceEventInterceptor,
public std::enable_shared_from_this<TSMediaSourceMuxer> {
public:
using Ptr = std::shared_ptr<TSMediaSourceMuxer>;
TSMediaSourceMuxer(const string &vhost,
const string &app,
const string &stream_id) {
const string &stream_id) : MpegMuxer(false) {
_media_src = std::make_shared<TSMediaSource>(vhost, app, stream_id);
}
@@ -54,7 +54,7 @@ public:
_media_src->clearCache();
}
if (_enabled || !ts_demand) {
return TsMuxer::inputFrame(frame);
return MpegMuxer::inputFrame(frame);
}
return false;
}
@@ -66,13 +66,13 @@ public:
}
protected:
void onTs(std::shared_ptr<Buffer> buffer, uint32_t timestamp, bool is_idr_fast_packet) override {
void onWrite(std::shared_ptr<Buffer> buffer, uint32_t timestamp, bool key_pos) override {
if (!buffer) {
return;
}
auto packet = std::make_shared<TSPacket>(std::move(buffer));
packet->time_stamp = timestamp;
_media_src->onWrite(std::move(packet), is_idr_fast_packet);
_media_src->onWrite(std::move(packet), key_pos);
}
private: