mp4录制支持作为观看者参与播放人数统计 (#1880)

This commit is contained in:
Dw9 2022-08-16 11:47:24 +08:00 committed by GitHub
parent c19fa29e75
commit 30984d2076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 1 deletions

View File

@ -238,6 +238,8 @@ sampleMS=500
fastStart=0 fastStart=0
#MP4点播(rtsp/rtmp/http-flv/ws-flv)是否循环播放文件 #MP4点播(rtsp/rtmp/http-flv/ws-flv)是否循环播放文件
fileRepeat=0 fileRepeat=0
#MP4录制是否当做播放器参与播放人数统计
mp4_as_player=0
[rtmp] [rtmp]
#rtmp必须在此时间内完成握手否则服务器会断开链接单位秒 #rtmp必须在此时间内完成握手否则服务器会断开链接单位秒

View File

@ -966,6 +966,7 @@ void installWebApi() {
ProtocolOption option; ProtocolOption option;
getArgsValue(allArgs, "enable_hls", option.enable_hls); getArgsValue(allArgs, "enable_hls", option.enable_hls);
getArgsValue(allArgs, "enable_mp4", option.enable_mp4); getArgsValue(allArgs, "enable_mp4", option.enable_mp4);
getArgsValue(allArgs, "mp4_as_player", option.mp4_as_player);
getArgsValue(allArgs, "enable_rtsp", option.enable_rtsp); getArgsValue(allArgs, "enable_rtsp", option.enable_rtsp);
getArgsValue(allArgs, "enable_rtmp", option.enable_rtmp); getArgsValue(allArgs, "enable_rtmp", option.enable_rtmp);
getArgsValue(allArgs, "enable_ts", option.enable_ts); getArgsValue(allArgs, "enable_ts", option.enable_ts);

View File

@ -348,6 +348,9 @@ void installWebHook(){
if (obj.isMember("continue_push_ms")) { if (obj.isMember("continue_push_ms")) {
option.continue_push_ms = obj["continue_push_ms"].asUInt(); option.continue_push_ms = obj["continue_push_ms"].asUInt();
} }
if (obj.isMember("mp4_as_player")) {
option.mp4_as_player = obj["mp4_as_player"].asBool();
}
invoker(err, option); invoker(err, option);
} else { } else {
//推流鉴权失败 //推流鉴权失败

View File

@ -26,14 +26,15 @@ ProtocolOption::ProtocolOption() {
GET_CONFIG(bool, s_to_mp4, General::kPublishToMP4); GET_CONFIG(bool, s_to_mp4, General::kPublishToMP4);
GET_CONFIG(bool, s_enabel_audio, General::kEnableAudio); GET_CONFIG(bool, s_enabel_audio, General::kEnableAudio);
GET_CONFIG(bool, s_add_mute_audio, General::kAddMuteAudio); GET_CONFIG(bool, s_add_mute_audio, General::kAddMuteAudio);
GET_CONFIG(bool, s_mp4_as_player, Record::kMP4AsPlayer);
GET_CONFIG(uint32_t, s_continue_push_ms, General::kContinuePushMS); GET_CONFIG(uint32_t, s_continue_push_ms, General::kContinuePushMS);
enable_hls = s_to_hls; enable_hls = s_to_hls;
enable_mp4 = s_to_mp4; enable_mp4 = s_to_mp4;
enable_audio = s_enabel_audio; enable_audio = s_enabel_audio;
add_mute_audio = s_add_mute_audio; add_mute_audio = s_add_mute_audio;
continue_push_ms = s_continue_push_ms; continue_push_ms = s_continue_push_ms;
mp4_as_player = s_mp4_as_player;
} }
static std::shared_ptr<MediaSinkInterface> makeRecorder(MediaSource &sender, const vector<Track::Ptr> &tracks, Recorder::type type, const string &custom_path, size_t max_second){ static std::shared_ptr<MediaSinkInterface> makeRecorder(MediaSource &sender, const vector<Track::Ptr> &tracks, Recorder::type type, const string &custom_path, size_t max_second){
@ -75,6 +76,7 @@ static string getTrackInfoStr(const TrackSource *track_src){
} }
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const string &vhost, const string &app, const string &stream, float dur_sec, const ProtocolOption &option) { MultiMediaSourceMuxer::MultiMediaSourceMuxer(const string &vhost, const string &app, const string &stream, float dur_sec, const ProtocolOption &option) {
_option = option;
_get_origin_url = [this, vhost, app, stream]() { _get_origin_url = [this, vhost, app, stream]() {
auto ret = getOriginUrl(*MediaSource::NullMediaSource); auto ret = getOriginUrl(*MediaSource::NullMediaSource);
if (!ret.empty()) { if (!ret.empty()) {
@ -146,6 +148,7 @@ int MultiMediaSourceMuxer::totalReaderCount() const {
#if defined(ENABLE_MP4) #if defined(ENABLE_MP4)
(_fmp4 ? _fmp4->readerCount() : 0) + (_fmp4 ? _fmp4->readerCount() : 0) +
#endif #endif
(_mp4 ? _option.mp4_as_player : 0) +
(hls ? hls->readerCount() : 0); (hls ? hls->readerCount() : 0);
#if defined(ENABLE_RTPPROXY) #if defined(ENABLE_RTPPROXY)

View File

@ -31,6 +31,8 @@ public:
bool enable_hls = false; bool enable_hls = false;
//是否开启MP4录制 //是否开启MP4录制
bool enable_mp4 = false; bool enable_mp4 = false;
//是否将mp4录制当做观看者
bool mp4_as_player = false;
//是否开启转换为rtsp/webrtc //是否开启转换为rtsp/webrtc
bool enable_rtsp = true; bool enable_rtsp = true;
//是否开启转换为rtmp/flv //是否开启转换为rtmp/flv
@ -175,6 +177,7 @@ protected:
private: private:
bool _is_enable = false; bool _is_enable = false;
ProtocolOption _option;
toolkit::Ticker _last_check; toolkit::Ticker _last_check;
Stamp _stamp[2]; Stamp _stamp[2];
std::weak_ptr<Listener> _track_listener; std::weak_ptr<Listener> _track_listener;

View File

@ -238,6 +238,7 @@ const string kFilePath = RECORD_FIELD "filePath";
const string kFileBufSize = RECORD_FIELD "fileBufSize"; const string kFileBufSize = RECORD_FIELD "fileBufSize";
const string kFastStart = RECORD_FIELD "fastStart"; const string kFastStart = RECORD_FIELD "fastStart";
const string kFileRepeat = RECORD_FIELD "fileRepeat"; const string kFileRepeat = RECORD_FIELD "fileRepeat";
const string kMP4AsPlayer = RECORD_FIELD "mp4_as_player";
static onceToken token([]() { static onceToken token([]() {
mINI::Instance()[kAppName] = "record"; mINI::Instance()[kAppName] = "record";
@ -247,6 +248,7 @@ static onceToken token([]() {
mINI::Instance()[kFileBufSize] = 64 * 1024; mINI::Instance()[kFileBufSize] = 64 * 1024;
mINI::Instance()[kFastStart] = false; mINI::Instance()[kFastStart] = false;
mINI::Instance()[kFileRepeat] = false; mINI::Instance()[kFileRepeat] = false;
mINI::Instance()[kMP4AsPlayer] = false;
}); });
} // namespace Record } // namespace Record

View File

@ -295,6 +295,8 @@ extern const std::string kFileBufSize;
extern const std::string kFastStart; extern const std::string kFastStart;
// mp4文件是否重头循环读取 // mp4文件是否重头循环读取
extern const std::string kFileRepeat; extern const std::string kFileRepeat;
//MP4录制是否当做播放器参与播放人数统计
extern const std::string kMP4AsPlayer;
} // namespace Record } // namespace Record
////////////HLS相关配置/////////// ////////////HLS相关配置///////////