mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
完善hls播放器个数计数
This commit is contained in:
parent
f93b32740f
commit
e72fa359b6
@ -109,6 +109,8 @@ API_EXPORT const char* API_CALL mk_media_source_get_app(const mk_media_source ct
|
|||||||
API_EXPORT const char* API_CALL mk_media_source_get_stream(const mk_media_source ctx);
|
API_EXPORT const char* API_CALL mk_media_source_get_stream(const mk_media_source ctx);
|
||||||
//MediaSource::readerCount()
|
//MediaSource::readerCount()
|
||||||
API_EXPORT int API_CALL mk_media_source_get_reader_count(const mk_media_source ctx);
|
API_EXPORT int API_CALL mk_media_source_get_reader_count(const mk_media_source ctx);
|
||||||
|
//MediaSource::totalReaderCount()
|
||||||
|
API_EXPORT int API_CALL mk_media_source_get_total_reader_count(const mk_media_source ctx);
|
||||||
//MediaSource::close()
|
//MediaSource::close()
|
||||||
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force);
|
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force);
|
||||||
//MediaSource::seekTo()
|
//MediaSource::seekTo()
|
||||||
|
@ -199,6 +199,13 @@ API_EXPORT int API_CALL mk_media_source_get_reader_count(const mk_media_source c
|
|||||||
MediaSource *src = (MediaSource *)ctx;
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
return src->readerCount();
|
return src->readerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT int API_CALL mk_media_source_get_total_reader_count(const mk_media_source ctx){
|
||||||
|
assert(ctx);
|
||||||
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
return src->totalReaderCount();
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force){
|
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force){
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
MediaSource *src = (MediaSource *)ctx;
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
@ -412,6 +412,7 @@ void installWebApi() {
|
|||||||
item["app"] = media->getApp();
|
item["app"] = media->getApp();
|
||||||
item["stream"] = media->getId();
|
item["stream"] = media->getId();
|
||||||
item["readerCount"] = media->readerCount();
|
item["readerCount"] = media->readerCount();
|
||||||
|
item["totalReaderCount"] = media->totalReaderCount();
|
||||||
for(auto &track : media->getTracks()){
|
for(auto &track : media->getTracks()){
|
||||||
Value obj;
|
Value obj;
|
||||||
obj["codec_id"] = track->getCodecId();
|
obj["codec_id"] = track->getCodecId();
|
||||||
@ -441,6 +442,7 @@ void installWebApi() {
|
|||||||
}
|
}
|
||||||
val["online"] = true;
|
val["online"] = true;
|
||||||
val["readerCount"] = src->readerCount();
|
val["readerCount"] = src->readerCount();
|
||||||
|
val["totalReaderCount"] = src->totalReaderCount();
|
||||||
for(auto &track : src->getTracks()){
|
for(auto &track : src->getTracks()){
|
||||||
Value obj;
|
Value obj;
|
||||||
obj["codec_id"] = track->getCodecId();
|
obj["codec_id"] = track->getCodecId();
|
||||||
|
@ -175,7 +175,7 @@ private:
|
|||||||
void onReaderChanged(int size) {
|
void onReaderChanged(int size) {
|
||||||
//我们记录最后一次活动时间
|
//我们记录最后一次活动时间
|
||||||
_reader_changed_ticker.resetTime();
|
_reader_changed_ticker.resetTime();
|
||||||
if (size != 0 || readerCount() != 0) {
|
if (size != 0 || totalReaderCount() != 0) {
|
||||||
//还有消费者正在观看该流
|
//还有消费者正在观看该流
|
||||||
_async_emit_none_reader = false;
|
_async_emit_none_reader = false;
|
||||||
return;
|
return;
|
||||||
|
@ -302,7 +302,7 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
|
|||||||
strongSelf->shutdown(SockException(Err_shutdown,"rtmp ring buffer detached"));
|
strongSelf->shutdown(SockException(Err_shutdown,"rtmp ring buffer detached"));
|
||||||
});
|
});
|
||||||
_pPlayerSrc = src;
|
_pPlayerSrc = src;
|
||||||
if (src->readerCount() == 1) {
|
if (src->totalReaderCount() == 1) {
|
||||||
src->seekTo(0);
|
src->seekTo(0);
|
||||||
}
|
}
|
||||||
//提高服务器发送性能
|
//提高服务器发送性能
|
||||||
|
@ -195,7 +195,7 @@ private:
|
|||||||
void onReaderChanged(int size) {
|
void onReaderChanged(int size) {
|
||||||
//我们记录最后一次活动时间
|
//我们记录最后一次活动时间
|
||||||
_reader_changed_ticker.resetTime();
|
_reader_changed_ticker.resetTime();
|
||||||
if (size != 0 || readerCount() != 0) {
|
if (size != 0 || totalReaderCount() != 0) {
|
||||||
//还有消费者正在观看该流
|
//还有消费者正在观看该流
|
||||||
_async_emit_none_reader = false;
|
_async_emit_none_reader = false;
|
||||||
return;
|
return;
|
||||||
|
@ -773,7 +773,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
|||||||
auto iStartTime = 1000 * atof(strStart.data());
|
auto iStartTime = 1000 * atof(strStart.data());
|
||||||
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
||||||
useBuf = !pMediaSrc->seekTo(iStartTime);
|
useBuf = !pMediaSrc->seekTo(iStartTime);
|
||||||
}else if(pMediaSrc->readerCount() == 0){
|
}else if(pMediaSrc->totalReaderCount() == 0){
|
||||||
//第一个消费者
|
//第一个消费者
|
||||||
pMediaSrc->seekTo(0);
|
pMediaSrc->seekTo(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user