mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 07:22:23 +08:00
@@ -202,6 +202,11 @@ public:
|
||||
|
||||
template <typename MAP>
|
||||
ProtocolOption(const MAP &allArgs) : ProtocolOption() {
|
||||
load(allArgs);
|
||||
}
|
||||
|
||||
template <typename MAP>
|
||||
void load(const MAP &allArgs) {
|
||||
#define GET_OPT_VALUE(key) getArgsValue(allArgs, #key, key)
|
||||
GET_OPT_VALUE(modify_stamp);
|
||||
GET_OPT_VALUE(enable_audio);
|
||||
|
||||
@@ -21,6 +21,20 @@ using namespace toolkit;
|
||||
namespace mediakit {
|
||||
|
||||
MP4Reader::MP4Reader(const std::string &vhost, const std::string &app, const std::string &stream_id, const string &file_path) {
|
||||
ProtocolOption option;
|
||||
// 读取mp4文件并流化时,不重复生成mp4/hls文件
|
||||
option.enable_mp4 = false;
|
||||
option.enable_hls = false;
|
||||
option.enable_hls_fmp4 = false;
|
||||
|
||||
setup(vhost, app, stream_id, file_path, option);
|
||||
}
|
||||
|
||||
MP4Reader::MP4Reader(const std::string &vhost, const std::string &app, const std::string &stream_id, const string &file_path, const ProtocolOption &option) {
|
||||
setup(vhost, app, stream_id, file_path, option);
|
||||
}
|
||||
|
||||
void MP4Reader::setup(const std::string &vhost, const std::string &app, const std::string &stream_id, const std::string &file_path, const ProtocolOption &option) {
|
||||
//读写文件建议放在后台线程
|
||||
auto tuple = MediaTuple{vhost, app, stream_id};
|
||||
_poller = WorkThreadPool::Instance().getPoller();
|
||||
@@ -42,10 +56,7 @@ MP4Reader::MP4Reader(const std::string &vhost, const std::string &app, const std
|
||||
if (tuple.stream.empty()) {
|
||||
return;
|
||||
}
|
||||
ProtocolOption option;
|
||||
//读取mp4文件并流化时,不重复生成mp4/hls文件
|
||||
option.enable_mp4 = false;
|
||||
option.enable_hls = false;
|
||||
|
||||
_muxer = std::make_shared<MultiMediaSourceMuxer>(tuple, _demuxer->getDurationMS() / 1000.0f, option);
|
||||
auto tracks = _demuxer->getTracks(false);
|
||||
if (tracks.empty()) {
|
||||
|
||||
@@ -28,7 +28,12 @@ public:
|
||||
* @param stream_id 流id,置空时,只解复用mp4,但是不生成MediaSource
|
||||
* @param file_path 文件路径,如果为空则根据配置文件和上面参数自动生成,否则使用指定的文件
|
||||
*/
|
||||
MP4Reader(const std::string &vhost, const std::string &app, const std::string &stream_id, const std::string &file_path = "");
|
||||
MP4Reader(const std::string &vhost, const std::string &app, const std::string &stream_id,
|
||||
const std::string &file_path = "");
|
||||
|
||||
MP4Reader(const std::string &vhost, const std::string &app, const std::string &stream_id,
|
||||
const std::string &file_path, const ProtocolOption &option);
|
||||
|
||||
~MP4Reader() override = default;
|
||||
|
||||
/**
|
||||
@@ -66,6 +71,8 @@ private:
|
||||
void setCurrentStamp(uint32_t stamp);
|
||||
bool seekTo(uint32_t stamp_seek);
|
||||
|
||||
void setup(const std::string &vhost, const std::string &app, const std::string &stream_id, const std::string &file_path, const ProtocolOption &option);
|
||||
|
||||
private:
|
||||
bool _file_repeat = false;
|
||||
bool _have_video = false;
|
||||
|
||||
Reference in New Issue
Block a user