From f76a203768aae11a7e8893885bca113766986a3a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 10 Mar 2020 23:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/include/mk_events_objects.h | 15 ++++++++++++++- src/Common/MultiMediaSourceMuxer.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/include/mk_events_objects.h b/api/include/mk_events_objects.h index a385fdfb..730f1dc0 100644 --- a/api/include/mk_events_objects.h +++ b/api/include/mk_events_objects.h @@ -109,7 +109,20 @@ API_EXPORT const char* API_CALL mk_media_source_get_stream(const mk_media_source 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() +/** + * 直播源在ZLMediaKit中被称作为MediaSource, + * 目前支持3种,分别是RtmpMediaSource、RtspMediaSource、HlsMediaSource + * 源的产生有被动和主动方式: + * 被动方式分别是rtsp/rtmp/rtp推流、mp4点播 + * 主动方式包括mk_media_create创建的对象(DevChannel)、mk_proxy_player_create创建的对象(PlayerProxy) + * 被动方式你不用做任何处理,ZLMediaKit已经默认适配了MediaSource::close()事件,都会关闭直播流 + * 主动方式你要设置这个事件的回调,你要自己选择删除对象 + * 通过mk_proxy_player_set_on_close、mk_media_set_on_close函数可以设置回调, + * 请在回调中删除对象来完成媒体的关闭,否则又为什么要调用mk_media_source_close函数? + * @param ctx 对象 + * @param force 是否强制关闭,如果强制关闭,在有人观看的情况下也会关闭 + * @return 0代表失败,1代表成功 + */ API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force); //MediaSource::seekTo() API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32_t stamp); diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 0ec1f2ed..c0a79adb 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -33,6 +33,10 @@ #include "Record/HlsMediaSource.h" #include "Record/HlsRecorder.h" +/** + * 使用该对象时,应该使用setListener方法来绑定MediaSource相关的事件 + * 否则多种不同类型的MediaSource(rtsp/rtmp/hls)将无法产生关联 + */ class MultiMediaSourceMuxer : public MediaSink , public std::enable_shared_from_this{ public: class Listener{