2017-10-09 22:11:01 +08:00
|
|
|
|
/*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
2017-09-27 16:20:30 +08:00
|
|
|
|
*
|
2021-01-17 18:31:50 +08:00
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
2017-09-27 16:20:30 +08:00
|
|
|
|
*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
2017-09-27 16:20:30 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2018-02-02 18:06:08 +08:00
|
|
|
|
#ifndef COMMON_CONFIG_H
|
|
|
|
|
#define COMMON_CONFIG_H
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
#include "Util/NoticeCenter.h"
|
2017-04-25 11:35:41 +08:00
|
|
|
|
#include "Util/mini.h"
|
2018-02-08 17:24:42 +08:00
|
|
|
|
#include "Util/onceToken.h"
|
2021-06-28 20:29:56 +08:00
|
|
|
|
#include "macros.h"
|
2022-06-15 00:20:53 +08:00
|
|
|
|
#include <functional>
|
2018-02-09 11:42:55 +08:00
|
|
|
|
|
2021-06-28 20:12:07 +08:00
|
|
|
|
namespace mediakit {
|
|
|
|
|
|
2022-03-12 13:19:21 +08:00
|
|
|
|
class ProtocolOption;
|
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 加载配置文件,如果配置文件不存在,那么会导出默认配置并生成配置文件
|
|
|
|
|
// 加载配置文件成功后会触发kBroadcastUpdateConfig广播
|
|
|
|
|
// 如果指定的文件名(ini_path)为空,那么会加载默认配置文件
|
|
|
|
|
// 默认配置文件名为 /path/to/your/exe.ini
|
|
|
|
|
// 加载配置文件成功后返回true,否则返回false
|
2021-06-28 20:12:07 +08:00
|
|
|
|
bool loadIniConfig(const char *ini_path = nullptr);
|
|
|
|
|
|
2017-04-01 16:35:56 +08:00
|
|
|
|
////////////广播名称///////////
|
|
|
|
|
namespace Broadcast {
|
2017-04-10 17:24:06 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 注册或反注册MediaSource事件广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastMediaChanged;
|
2019-12-24 14:08:16 +08:00
|
|
|
|
#define BroadcastMediaChangedArgs const bool &bRegist, MediaSource &sender
|
2017-04-10 17:24:06 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 录制mp4文件成功后广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastRecordMP4;
|
2020-09-15 19:09:26 +08:00
|
|
|
|
#define BroadcastRecordMP4Args const RecordInfo &info
|
2017-04-10 17:24:06 +08:00
|
|
|
|
|
2020-09-13 14:08:05 +08:00
|
|
|
|
// 录制 ts 文件后广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastRecordTs;
|
2020-09-15 19:09:26 +08:00
|
|
|
|
#define BroadcastRecordTsArgs const RecordInfo &info
|
2020-09-13 14:08:05 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 收到http api请求广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastHttpRequest;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastHttpRequestArgs const Parser &parser, const HttpSession::HttpResponseInvoker &invoker, bool &consumed, SockInfo &sender
|
2017-04-10 17:24:06 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 在http文件服务器中,收到http访问文件或目录的广播,通过该事件控制访问http目录的权限
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastHttpAccess;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastHttpAccessArgs const Parser &parser, const std::string &path, const bool &is_dir, const HttpSession::HttpAccessPathInvoker &invoker, SockInfo &sender
|
2019-06-12 17:53:48 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 在http文件服务器中,收到http访问文件或目录前的广播,通过该事件可以控制http url到文件路径的映射
|
|
|
|
|
// 在该事件中通过自行覆盖path参数,可以做到譬如根据虚拟主机或者app选择不同http根目录的目的
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastHttpBeforeAccess;
|
|
|
|
|
#define BroadcastHttpBeforeAccessArgs const Parser &parser, std::string &path, SockInfo &sender
|
2019-12-23 12:47:04 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 该流是否需要认证?是的话调用invoker并传入realm,否则传入空的realm.如果该事件不监听则不认证
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastOnGetRtspRealm;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
#define BroadcastOnGetRtspRealmArgs const MediaInfo &args, const RtspSession::onGetRealm &invoker, SockInfo &sender
|
2017-12-10 01:34:43 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 请求认证用户密码事件,user_name为用户名,must_no_encrypt如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
|
|
|
|
// 获取到密码后请调用invoker并输入对应类型的密码和密码类型,invoker执行时会匹配密码
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastOnRtspAuth;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastOnRtspAuthArgs const MediaInfo &args, const std::string &realm, const std::string &user_name, const bool &must_no_encrypt, const RtspSession::onAuth &invoker, SockInfo &sender
|
2018-02-05 15:56:44 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 推流鉴权结果回调对象
|
|
|
|
|
// 如果err为空则代表鉴权成功
|
2022-03-12 13:19:21 +08:00
|
|
|
|
using PublishAuthInvoker = std::function<void(const std::string &err, const ProtocolOption &option)>;
|
2018-02-05 15:56:44 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 收到rtsp/rtmp推流事件广播,通过该事件控制推流鉴权
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastMediaPublish;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastMediaPublishArgs const MediaOriginType &type, const MediaInfo &args, const Broadcast::PublishAuthInvoker &invoker, SockInfo &sender
|
2019-09-10 11:06:31 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 播放鉴权结果回调对象
|
|
|
|
|
// 如果err为空则代表鉴权成功
|
2022-03-12 13:19:21 +08:00
|
|
|
|
using AuthInvoker = std::function<void(const std::string &err)>;
|
2018-12-14 17:10:24 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 播放rtsp/rtmp/http-flv事件广播,通过该事件控制播放鉴权
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastMediaPlayed;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
#define BroadcastMediaPlayedArgs const MediaInfo &args, const Broadcast::AuthInvoker &invoker, SockInfo &sender
|
2018-02-05 15:56:44 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// shell登录鉴权
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastShellLogin;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastShellLoginArgs const std::string &user_name, const std::string &passwd, const Broadcast::AuthInvoker &invoker, SockInfo &sender
|
2018-02-08 17:24:42 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 停止rtsp/rtmp/http-flv会话后流量汇报事件广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastFlowReport;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
#define BroadcastFlowReportArgs const MediaInfo &args, const uint64_t &totalBytes, const uint64_t &totalDuration, const bool &isPlayer, SockInfo &sender
|
2018-02-06 15:28:27 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 未找到流后会广播该事件,请在监听该事件后去拉流或其他方式产生流,这样就能按需拉流了
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastNotFoundStream;
|
|
|
|
|
#define BroadcastNotFoundStreamArgs const MediaInfo &args, SockInfo &sender, const std::function<void()> &closePlayer
|
2018-10-31 12:11:14 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 某个流无人消费时触发,目的为了实现无人观看时主动断开拉流等业务逻辑
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastStreamNoneReader;
|
2019-05-27 18:39:43 +08:00
|
|
|
|
#define BroadcastStreamNoneReaderArgs MediaSource &sender
|
|
|
|
|
|
2022-08-27 10:53:47 +08:00
|
|
|
|
// rtp推流被动停止时触发
|
|
|
|
|
extern const std::string kBroadcastSendRtpStopped;
|
|
|
|
|
#define BroadcastSendRtpStopped MultiMediaSourceMuxer &sender, const std::string &ssrc, const SockException &ex
|
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastReloadConfig;
|
2018-02-09 11:42:55 +08:00
|
|
|
|
#define BroadcastReloadConfigArgs void
|
2018-02-08 17:24:42 +08:00
|
|
|
|
|
2022-11-10 16:58:02 +08:00
|
|
|
|
// rtp server 超时
|
|
|
|
|
extern const std::string KBroadcastRtpServerTimeout;
|
|
|
|
|
#define BroadcastRtpServerTimeout uint16_t &local_port, const string &stream_id,int &tcp_mode, bool &re_use_port, uint32_t &ssrc
|
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
#define ReloadConfigTag ((void *)(0xFF))
|
|
|
|
|
#define RELOAD_KEY(arg, key) \
|
|
|
|
|
do { \
|
|
|
|
|
decltype(arg) arg##_tmp = ::toolkit::mINI::Instance()[key]; \
|
|
|
|
|
if (arg == arg##_tmp) { \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
arg = arg##_tmp; \
|
|
|
|
|
InfoL << "reload config:" << key << "=" << arg; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
// 监听某个配置发送变更
|
|
|
|
|
#define LISTEN_RELOAD_KEY(arg, key, ...) \
|
|
|
|
|
do { \
|
|
|
|
|
static ::toolkit::onceToken s_token_listen([]() { \
|
|
|
|
|
::toolkit::NoticeCenter::Instance().addListener( \
|
|
|
|
|
ReloadConfigTag, Broadcast::kBroadcastReloadConfig, [](BroadcastReloadConfigArgs) { __VA_ARGS__; }); \
|
|
|
|
|
}); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define GET_CONFIG(type, arg, key) \
|
|
|
|
|
static type arg = ::toolkit::mINI::Instance()[key]; \
|
|
|
|
|
LISTEN_RELOAD_KEY(arg, key, { RELOAD_KEY(arg, key); });
|
|
|
|
|
|
|
|
|
|
#define GET_CONFIG_FUNC(type, arg, key, ...) \
|
|
|
|
|
static type arg; \
|
|
|
|
|
do { \
|
|
|
|
|
static ::toolkit::onceToken s_token_set([]() { \
|
|
|
|
|
static auto lam = __VA_ARGS__; \
|
|
|
|
|
static auto arg##_str = ::toolkit::mINI::Instance()[key]; \
|
|
|
|
|
arg = lam(arg##_str); \
|
|
|
|
|
LISTEN_RELOAD_KEY(arg, key, { \
|
|
|
|
|
RELOAD_KEY(arg##_str, key); \
|
|
|
|
|
arg = lam(arg##_str); \
|
|
|
|
|
}); \
|
|
|
|
|
}); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
} // namespace Broadcast
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
2019-05-28 17:14:36 +08:00
|
|
|
|
////////////通用配置///////////
|
2022-06-15 00:20:53 +08:00
|
|
|
|
namespace General {
|
|
|
|
|
// 每个流媒体服务器的ID(GUID)
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kMediaServerId;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 流量汇报事件流量阈值,单位KB,默认1MB
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kFlowThreshold;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 流无人观看并且超过若干时间后才触发kBroadcastStreamNoneReader事件
|
|
|
|
|
// 默认连续5秒无人观看然后触发kBroadcastStreamNoneReader事件
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kStreamNoneReaderDelayMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 等待流注册超时时间,收到播放器后请求后,如果未找到相关流,服务器会等待一定时间,
|
|
|
|
|
// 如果在这个时间内,相关流注册上了,那么服务器会立即响应播放器播放成功,
|
|
|
|
|
// 否则会最多等待kMaxStreamWaitTimeMS毫秒,然后响应播放器播放失败
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kMaxStreamWaitTimeMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 是否启动虚拟主机
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kEnableVhost;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 拉流代理时如果断流再重连成功是否删除前一次的媒体流数据,如果删除将重新开始,
|
|
|
|
|
// 如果不删除将会接着上一次的数据继续写(录制hls/mp4时会继续在前一个文件后面写)
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kResetWhenRePlay;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 合并写缓存大小(单位毫秒),合并写指服务器缓存一定的数据后才会一次性写入socket,这样能提高性能,但是会提高延时
|
|
|
|
|
// 开启后会同时关闭TCP_NODELAY并开启MSG_MORE
|
|
|
|
|
extern const std::string kMergeWriteMS;
|
|
|
|
|
// 在docker环境下,不能通过英伟达驱动是否存在来判断是否支持硬件转码
|
2022-05-25 15:11:26 +08:00
|
|
|
|
extern const std::string kCheckNvidiaDev;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 是否开启ffmpeg日志
|
2022-05-25 15:11:26 +08:00
|
|
|
|
extern const std::string kEnableFFmpegLog;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 最多等待未初始化的Track 10秒,超时之后会忽略未初始化的Track
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kWaitTrackReadyMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 如果直播流只有单Track,最多等待3秒,超时后未收到其他Track的数据,则认为是单Track
|
|
|
|
|
// 如果协议元数据有声明特定track数,那么无此等待时间
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kWaitAddTrackMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 如果track未就绪,我们先缓存帧数据,但是有最大个数限制(100帧时大约4秒),防止内存溢出
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kUnreadyFrameCache;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace General
|
2019-05-28 17:14:36 +08:00
|
|
|
|
|
2022-11-12 23:54:35 +08:00
|
|
|
|
namespace Protocol {
|
|
|
|
|
//时间戳修复这一路流标志位
|
|
|
|
|
extern const std::string kModifyStamp;
|
|
|
|
|
//转协议是否开启音频
|
|
|
|
|
extern const std::string kEnableAudio;
|
|
|
|
|
//添加静音音频,在关闭音频时,此开关无效
|
|
|
|
|
extern const std::string kAddMuteAudio;
|
|
|
|
|
//断连续推延时,单位毫秒,默认采用配置文件
|
|
|
|
|
extern const std::string kContinuePushMS;
|
|
|
|
|
|
2023-07-02 12:02:33 +08:00
|
|
|
|
//是否开启转换为hls(mpegts)
|
2022-11-12 23:54:35 +08:00
|
|
|
|
extern const std::string kEnableHls;
|
2023-07-02 12:02:33 +08:00
|
|
|
|
//是否开启转换为hls(fmp4)
|
|
|
|
|
extern const std::string kEnableHlsFmp4;
|
2022-11-12 23:54:35 +08:00
|
|
|
|
//是否开启MP4录制
|
|
|
|
|
extern const std::string kEnableMP4;
|
|
|
|
|
//是否开启转换为rtsp/webrtc
|
|
|
|
|
extern const std::string kEnableRtsp;
|
|
|
|
|
//是否开启转换为rtmp/flv
|
|
|
|
|
extern const std::string kEnableRtmp;
|
|
|
|
|
//是否开启转换为http-ts/ws-ts
|
|
|
|
|
extern const std::string kEnableTS;
|
|
|
|
|
//是否开启转换为http-fmp4/ws-fmp4
|
|
|
|
|
extern const std::string kEnableFMP4;
|
|
|
|
|
|
|
|
|
|
//是否将mp4录制当做观看者
|
|
|
|
|
extern const std::string kMP4AsPlayer;
|
|
|
|
|
//mp4切片大小,单位秒
|
|
|
|
|
extern const std::string kMP4MaxSecond;
|
|
|
|
|
//mp4录制保存路径
|
|
|
|
|
extern const std::string kMP4SavePath;
|
|
|
|
|
|
|
|
|
|
//hls录制保存路径
|
|
|
|
|
extern const std::string kHlsSavePath;
|
|
|
|
|
|
|
|
|
|
// 按需转协议的开关
|
|
|
|
|
extern const std::string kHlsDemand;
|
|
|
|
|
extern const std::string kRtspDemand;
|
|
|
|
|
extern const std::string kRtmpDemand;
|
|
|
|
|
extern const std::string kTSDemand;
|
|
|
|
|
extern const std::string kFMP4Demand;
|
|
|
|
|
} // !Protocol
|
|
|
|
|
|
2017-04-01 16:35:56 +08:00
|
|
|
|
////////////HTTP配置///////////
|
|
|
|
|
namespace Http {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 文件发送缓存大小
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kSendBufSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 最大请求字节数
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kMaxReqSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http keep-alive秒数
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kKeepAliveSecond;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 字符编码
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kCharSet;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 服务器根目录
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRootPath;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 服务器虚拟目录 虚拟目录名和文件路径使用","隔开,多个配置路径间用";"隔开,例如 path_d,d:/record;path_e,e:/record
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kVirtualPath;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// http 404错误提示内容
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kNotFound;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 是否显示文件夹菜单
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kDirMenu;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 禁止缓存文件的后缀
|
2022-02-17 10:35:10 +08:00
|
|
|
|
extern const std::string kForbidCacheSuffix;
|
2022-06-18 22:10:46 +08:00
|
|
|
|
// 可以把http代理前真实客户端ip放在http头中:https://github.com/ZLMediaKit/ZLMediaKit/issues/1388
|
|
|
|
|
extern const std::string kForwardedIpHeader;
|
2023-05-12 11:47:22 +08:00
|
|
|
|
// 是否允许所有跨域请求
|
|
|
|
|
extern const std::string kAllowCrossDomains;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Http
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////SHELL配置///////////
|
|
|
|
|
namespace Shell {
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kMaxReqSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Shell
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////RTSP服务器配置///////////
|
|
|
|
|
namespace Rtsp {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 是否优先base64方式认证?默认Md5方式认证
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kAuthBasic;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 握手超时时间,默认15秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kHandshakeSecond;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 维持链接超时时间,默认15秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kKeepAliveSecond;
|
2019-07-19 11:54:29 +08:00
|
|
|
|
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtsp拉流代理是否直接代理
|
|
|
|
|
// 直接代理后支持任意编码格式,但是会导致GOP缓存无法定位到I帧,可能会导致开播花屏
|
|
|
|
|
// 并且如果是tcp方式拉流,如果rtp大于mtu会导致无法使用udp方式代理
|
|
|
|
|
// 假定您的拉流源地址不是264或265或AAC,那么你可以使用直接代理的方式来支持rtsp代理
|
|
|
|
|
// 默认开启rtsp直接代理,rtmp由于没有这些问题,是强制开启直接代理的
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kDirectProxy;
|
2022-10-19 14:20:53 +08:00
|
|
|
|
|
|
|
|
|
// rtsp 转发是否使用低延迟模式,当开启时,不会缓存rtp包,来提高并发,可以降低一帧的延迟
|
2022-10-19 14:55:39 +08:00
|
|
|
|
extern const std::string kLowLatency;
|
2023-06-21 15:35:27 +08:00
|
|
|
|
|
|
|
|
|
//强制协商rtp传输方式 (0:TCP,1:UDP,2:MULTICAST,-1:不限制)
|
|
|
|
|
//当客户端发起RTSP SETUP的时候如果传输类型和此配置不一致则返回461 Unsupport Transport
|
|
|
|
|
//迫使客户端重新SETUP并切换到对应协议。目前支持FFMPEG和VLC
|
|
|
|
|
extern const std::string kRtpTransportType;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Rtsp
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////RTMP服务器配置///////////
|
|
|
|
|
namespace Rtmp {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 握手超时时间,默认15秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kHandshakeSecond;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 维持链接超时时间,默认15秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kKeepAliveSecond;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Rtmp
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////RTP配置///////////
|
|
|
|
|
namespace Rtp {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// RTP打包最大MTU,公网情况下更小
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kVideoMtuSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// RTP打包最大MTU,公网情况下更小
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kAudioMtuSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp包最大长度限制, 单位KB
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRtpMaxSize;
|
2022-10-19 14:20:53 +08:00
|
|
|
|
// rtp 打包时,低延迟开关,默认关闭(为0),h264存在一帧多个slice(NAL)的情况,在这种情况下,如果开启可能会导致画面花屏
|
2022-10-19 14:55:39 +08:00
|
|
|
|
extern const std::string kLowLatency;
|
2023-06-26 10:04:16 +08:00
|
|
|
|
//H264 rtp打包模式是否采用stap-a模式(为了在老版本浏览器上兼容webrtc)还是采用Single NAL unit packet per H.264 模式
|
|
|
|
|
extern const std::string kH264StapA;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Rtp
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////组播配置///////////
|
|
|
|
|
namespace MultiCast {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 组播分配起始地址
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kAddrMin;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 组播分配截止地址
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kAddrMax;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 组播TTL
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kUdpTTL;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace MultiCast
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////录像配置///////////
|
|
|
|
|
namespace Record {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 查看录像的应用名称
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kAppName;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 每次流化MP4文件的时长,单位毫秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kSampleMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// mp4文件写缓存大小
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kFileBufSize;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// mp4录制完成后是否进行二次关键帧索引写入头部
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kFastStart;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// mp4文件是否重头循环读取
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kFileRepeat;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Record
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
|
|
////////////HLS相关配置///////////
|
|
|
|
|
namespace Hls {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// HLS切片时长,单位秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kSegmentDuration;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// m3u8文件中HLS切片个数,如果设置为0,则不删除切片,而是保存为点播
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kSegmentNum;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 如果设置为0,则不保留切片,设置为1则一直保留切片
|
2022-05-10 17:32:50 +08:00
|
|
|
|
extern const std::string kSegmentKeep;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kSegmentRetain;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// HLS文件写缓存大小
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kFileBufSize;
|
2020-09-15 17:46:12 +08:00
|
|
|
|
// 是否广播 ts 切片完成通知
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBroadcastRecordTs;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// hls直播文件删除延时,单位秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kDeleteDelaySec;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Hls
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
2019-12-06 11:54:10 +08:00
|
|
|
|
////////////Rtp代理相关配置///////////
|
|
|
|
|
namespace RtpProxy {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp调试数据保存目录,置空则不生成
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kDumpDir;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp接收超时时间
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kTimeoutSec;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 随机端口范围,最少确保36个端口
|
|
|
|
|
// 该范围同时限制rtsp服务器udp端口范围
|
2022-03-13 20:48:01 +08:00
|
|
|
|
extern const std::string kPortRange;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp server h264的pt
|
2022-06-16 09:59:09 +08:00
|
|
|
|
extern const std::string kH264PT;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp server h265的pt
|
2022-06-16 09:59:09 +08:00
|
|
|
|
extern const std::string kH265PT;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp server ps 的pt
|
2022-06-16 09:59:09 +08:00
|
|
|
|
extern const std::string kPSPT;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp server opus 的pt
|
2022-06-16 09:59:09 +08:00
|
|
|
|
extern const std::string kOpusPT;
|
2023-04-17 12:19:24 +08:00
|
|
|
|
// RtpSender相关功能是否提前开启gop缓存优化级联秒开体验,默认开启
|
|
|
|
|
extern const std::string kGopCache;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace RtpProxy
|
2019-03-27 18:56:49 +08:00
|
|
|
|
|
2019-05-28 17:27:28 +08:00
|
|
|
|
/**
|
|
|
|
|
* rtsp/rtmp播放器、推流器相关设置名,
|
|
|
|
|
* 这些设置项都不是配置文件用
|
|
|
|
|
* 只用于设置某个播放器或推流器实例用
|
|
|
|
|
*/
|
2019-03-27 18:56:49 +08:00
|
|
|
|
namespace Client {
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 指定网卡ip
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kNetAdapter;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 设置rtp传输类型,可选项有0(tcp,默认)、1(udp)、2(组播)
|
|
|
|
|
// 设置方法:player[PlayerBase::kRtpType] = 0/1/2;
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRtpType;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtsp认证用户名
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRtspUser;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtsp认证用用户密码,可以是明文也可以是md5,md5密码生成方式 md5(username:realm:password)
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRtspPwd;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtsp认证用用户密码是否为md5类型
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kRtspPwdIsMD5;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 握手超时时间,默认10,000 毫秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kTimeoutMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtp/rtmp包接收超时时间,默认5000秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kMediaTimeoutMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// rtsp/rtmp心跳时间,默认5000毫秒
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBeatIntervalMS;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 是否为性能测试模式,性能测试模式开启后不会解析rtp或rtmp包
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kBenchmarkMode;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
// 播放器在触发播放成功事件时,是否等待所有track ready时再回调
|
2022-02-02 20:34:50 +08:00
|
|
|
|
extern const std::string kWaitTrackReady;
|
2022-09-13 16:27:00 +08:00
|
|
|
|
// rtsp播放指定track,可选项有0(不指定,默认)、1(视频)、2(音频)
|
|
|
|
|
// 设置方法:player[Client::kPlayTrack] = 0/1/2;
|
|
|
|
|
extern const std::string kPlayTrack;
|
2022-06-15 00:20:53 +08:00
|
|
|
|
} // namespace Client
|
|
|
|
|
} // namespace mediakit
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
2018-02-02 18:06:08 +08:00
|
|
|
|
#endif /* COMMON_CONFIG_H */
|