mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
feat: add broadcast event for player count change (#3562)
This commit is contained in:
parent
968f6c69c3
commit
373620cfc6
@ -126,6 +126,8 @@ wait_track_ready_ms=10000
|
|||||||
wait_add_track_ms=3000
|
wait_add_track_ms=3000
|
||||||
#如果track未就绪,我们先缓存帧数据,但是有最大个数限制,防止内存溢出
|
#如果track未就绪,我们先缓存帧数据,但是有最大个数限制,防止内存溢出
|
||||||
unready_frame_cache=100
|
unready_frame_cache=100
|
||||||
|
#是否启用观看人数变化事件广播,置1则启用,置0则关闭
|
||||||
|
broadcast_player_count_changed=0
|
||||||
|
|
||||||
[hls]
|
[hls]
|
||||||
#hls写文件的buf大小,调整参数可以提高文件io性能
|
#hls写文件的buf大小,调整参数可以提高文件io性能
|
||||||
|
@ -652,6 +652,10 @@ MediaSource::Ptr MediaSource::createFromMP4(const string &schema, const string &
|
|||||||
/////////////////////////////////////MediaSourceEvent//////////////////////////////////////
|
/////////////////////////////////////MediaSourceEvent//////////////////////////////////////
|
||||||
|
|
||||||
void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
|
void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
|
||||||
|
GET_CONFIG(bool, enable, General::kBroadcastPlayerCountChanged);
|
||||||
|
if (enable) {
|
||||||
|
NOTICE_EMIT(BroadcastPlayerCountChangedArgs, Broadcast::kBroadcastPlayerCountChanged, sender.getMediaTuple(), sender.totalReaderCount());
|
||||||
|
}
|
||||||
if (size || sender.totalReaderCount()) {
|
if (size || sender.totalReaderCount()) {
|
||||||
//还有人观看该视频,不触发关闭事件
|
//还有人观看该视频,不触发关闭事件
|
||||||
_async_close_timer = nullptr;
|
_async_close_timer = nullptr;
|
||||||
|
@ -64,6 +64,7 @@ const string kBroadcastRtcSctpFailed = "kBroadcastRtcSctpFailed";
|
|||||||
const string kBroadcastRtcSctpClosed = "kBroadcastRtcSctpClosed";
|
const string kBroadcastRtcSctpClosed = "kBroadcastRtcSctpClosed";
|
||||||
const string kBroadcastRtcSctpSend = "kBroadcastRtcSctpSend";
|
const string kBroadcastRtcSctpSend = "kBroadcastRtcSctpSend";
|
||||||
const string kBroadcastRtcSctpReceived = "kBroadcastRtcSctpReceived";
|
const string kBroadcastRtcSctpReceived = "kBroadcastRtcSctpReceived";
|
||||||
|
const string kBroadcastPlayerCountChanged = "kBroadcastPlayerCountChanged";
|
||||||
|
|
||||||
} // namespace Broadcast
|
} // namespace Broadcast
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ const string kEnableFFmpegLog = GENERAL_FIELD "enable_ffmpeg_log";
|
|||||||
const string kWaitTrackReadyMS = GENERAL_FIELD "wait_track_ready_ms";
|
const string kWaitTrackReadyMS = GENERAL_FIELD "wait_track_ready_ms";
|
||||||
const string kWaitAddTrackMS = GENERAL_FIELD "wait_add_track_ms";
|
const string kWaitAddTrackMS = GENERAL_FIELD "wait_add_track_ms";
|
||||||
const string kUnreadyFrameCache = GENERAL_FIELD "unready_frame_cache";
|
const string kUnreadyFrameCache = GENERAL_FIELD "unready_frame_cache";
|
||||||
|
const string kBroadcastPlayerCountChanged = GENERAL_FIELD "broadcast_player_count_changed";
|
||||||
|
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
mINI::Instance()[kFlowThreshold] = 1024;
|
mINI::Instance()[kFlowThreshold] = 1024;
|
||||||
@ -96,6 +98,7 @@ static onceToken token([]() {
|
|||||||
mINI::Instance()[kWaitTrackReadyMS] = 10000;
|
mINI::Instance()[kWaitTrackReadyMS] = 10000;
|
||||||
mINI::Instance()[kWaitAddTrackMS] = 3000;
|
mINI::Instance()[kWaitAddTrackMS] = 3000;
|
||||||
mINI::Instance()[kUnreadyFrameCache] = 100;
|
mINI::Instance()[kUnreadyFrameCache] = 100;
|
||||||
|
mINI::Instance()[kBroadcastPlayerCountChanged] = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
} // namespace General
|
} // namespace General
|
||||||
|
@ -124,6 +124,10 @@ extern const std::string kBroadcastRtcSctpSend;
|
|||||||
extern const std::string kBroadcastRtcSctpReceived;
|
extern const std::string kBroadcastRtcSctpReceived;
|
||||||
#define BroadcastRtcSctpReceivedArgs WebRtcTransport& sender, uint16_t &streamId, uint32_t &ppid, const uint8_t *&msg, size_t &len
|
#define BroadcastRtcSctpReceivedArgs WebRtcTransport& sender, uint16_t &streamId, uint32_t &ppid, const uint8_t *&msg, size_t &len
|
||||||
|
|
||||||
|
// 观看人数变化广播
|
||||||
|
extern const std::string kBroadcastPlayerCountChanged;
|
||||||
|
#define BroadcastPlayerCountChangedArgs const MediaTuple& args, const int& count
|
||||||
|
|
||||||
#define ReloadConfigTag ((void *)(0xFF))
|
#define ReloadConfigTag ((void *)(0xFF))
|
||||||
#define RELOAD_KEY(arg, key) \
|
#define RELOAD_KEY(arg, key) \
|
||||||
do { \
|
do { \
|
||||||
@ -196,6 +200,8 @@ extern const std::string kWaitTrackReadyMS;
|
|||||||
extern const std::string kWaitAddTrackMS;
|
extern const std::string kWaitAddTrackMS;
|
||||||
// 如果track未就绪,我们先缓存帧数据,但是有最大个数限制(100帧时大约4秒),防止内存溢出
|
// 如果track未就绪,我们先缓存帧数据,但是有最大个数限制(100帧时大约4秒),防止内存溢出
|
||||||
extern const std::string kUnreadyFrameCache;
|
extern const std::string kUnreadyFrameCache;
|
||||||
|
// 是否启用观看人数变化事件广播,置1则启用,置0则关闭
|
||||||
|
extern const std::string kBroadcastPlayerCountChanged;
|
||||||
} // namespace General
|
} // namespace General
|
||||||
|
|
||||||
namespace Protocol {
|
namespace Protocol {
|
||||||
|
Loading…
Reference in New Issue
Block a user