diff --git a/api/include/mk_media.h b/api/include/mk_media.h index 8b7b5974..d41f3dc7 100755 --- a/api/include/mk_media.h +++ b/api/include/mk_media.h @@ -26,14 +26,12 @@ typedef void *mk_media; * @param app 应用名,推荐为live * @param stream 流id,例如camera * @param duration 时长(单位秒),直播则为0 - * @param rtsp_enabled 是否启用rtsp协议 - * @param rtmp_enabled 是否启用rtmp协议 * @param hls_enabled 是否生成hls * @param mp4_enabled 是否生成mp4 * @return 对象指针 */ -API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, float duration, - int rtsp_enabled, int rtmp_enabled, int hls_enabled, int mp4_enabled); +API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, + float duration, int hls_enabled, int mp4_enabled); /** * 销毁媒体源 diff --git a/api/source/mk_media.cpp b/api/source/mk_media.cpp index 73f7b07b..1ad6ba64 100755 --- a/api/source/mk_media.cpp +++ b/api/source/mk_media.cpp @@ -117,11 +117,10 @@ API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx){ return (*obj)->getChannel()->totalReaderCount(); } -API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, float duration, - int rtsp_enabled, int rtmp_enabled, int hls_enabled, int mp4_enabled) { +API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, + float duration, int hls_enabled, int mp4_enabled) { assert(vhost && app && stream); - MediaHelper::Ptr *obj(new MediaHelper::Ptr(new MediaHelper(vhost, app, stream, duration, - rtsp_enabled, rtmp_enabled, hls_enabled, mp4_enabled))); + MediaHelper::Ptr *obj(new MediaHelper::Ptr(new MediaHelper(vhost, app, stream, duration, hls_enabled, mp4_enabled))); (*obj)->attachEvent(); return (mk_media) obj; } diff --git a/api/source/mk_proxyplayer.cpp b/api/source/mk_proxyplayer.cpp index 91e496af..0ae63f1d 100644 --- a/api/source/mk_proxyplayer.cpp +++ b/api/source/mk_proxyplayer.cpp @@ -16,7 +16,7 @@ using namespace mediakit; API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *vhost, const char *app, const char *stream, int hls_enabled, int mp4_enabled) { assert(vhost && app && stream); - PlayerProxy::Ptr *obj(new PlayerProxy::Ptr(new PlayerProxy(vhost, app, stream, true, true, hls_enabled, mp4_enabled))); + PlayerProxy::Ptr *obj(new PlayerProxy::Ptr(new PlayerProxy(vhost, app, stream, hls_enabled, mp4_enabled))); return (mk_proxy_player) obj; } diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 0064a462..8f2a8f7a 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -596,8 +596,6 @@ void installWebApi() { const string &app, const string &stream, const string &url, - bool enable_rtsp, - bool enable_rtmp, bool enable_hls, bool enable_mp4, int rtp_type, @@ -610,7 +608,7 @@ void installWebApi() { return; } //添加拉流代理 - PlayerProxy::Ptr player(new PlayerProxy(vhost,app,stream,enable_rtsp,enable_rtmp,enable_hls,enable_mp4)); + PlayerProxy::Ptr player(new PlayerProxy(vhost, app, stream, enable_hls, enable_mp4)); s_proxyMap[key] = player; //指定RTP over TCP(播放rtsp时有效) @@ -636,13 +634,11 @@ void installWebApi() { //测试url http://127.0.0.1/index/api/addStreamProxy?vhost=__defaultVhost__&app=proxy&enable_rtsp=1&enable_rtmp=1&stream=0&url=rtmp://127.0.0.1/live/obs api_regist2("/index/api/addStreamProxy",[](API_ARGS2){ CHECK_SECRET(); - CHECK_ARGS("vhost","app","stream","url","enable_rtsp","enable_rtmp"); + CHECK_ARGS("vhost","app","stream","url"); addStreamProxy(allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["url"], - allArgs["enable_rtsp"],/* 是否rtsp转发 */ - allArgs["enable_rtmp"],/* 是否rtmp转发 */ allArgs["enable_hls"],/* 是否hls转发 */ allArgs["enable_mp4"],/* 是否MP4录制 */ allArgs["rtp_type"], @@ -1071,8 +1067,6 @@ void installWebApi() { allArgs["stream"], /** 支持rtsp和rtmp方式拉流 ,rtsp支持h265/h264/aac,rtmp仅支持h264/aac **/ "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov", - true,/* 开启rtsp转发 */ - true,/* 开启rtmp转发 */ true,/* 开启hls转发 */ false,/* 禁用MP4录制 */ 0,//rtp over tcp方式拉流 diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index 0231600f..0b08289d 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -20,9 +20,9 @@ using namespace toolkit; namespace mediakit { -DevChannel::DevChannel(const string &vhost, const string &app, const string &stream_id, float duration, - bool enable_rtsp, bool enable_rtmp, bool enable_hls, bool enable_mp4) : - MultiMediaSourceMuxer(vhost, app, stream_id, duration, enable_rtsp, enable_rtmp, enable_hls, enable_mp4) {} +DevChannel::DevChannel(const string &vhost, const string &app, const string &stream_id, + float duration, bool enable_hls, bool enable_mp4) : + MultiMediaSourceMuxer(vhost, app, stream_id, duration, true, true, enable_hls, enable_mp4) {} DevChannel::~DevChannel() {} diff --git a/src/Common/Device.h b/src/Common/Device.h index dbff5424..5f726f79 100644 --- a/src/Common/Device.h +++ b/src/Common/Device.h @@ -53,8 +53,8 @@ class DevChannel : public MultiMediaSourceMuxer{ public: typedef std::shared_ptr Ptr; //fDuration<=0为直播,否则为点播 - DevChannel(const string &vhost, const string &app, const string &stream_id, float duration = 0, - bool enable_rtsp = true, bool enable_rtmp = true, bool enable_hls = true, bool enable_mp4 = false); + DevChannel(const string &vhost, const string &app, const string &stream_id, + float duration = 0, bool enable_hls = true, bool enable_mp4 = false); ~DevChannel() override ; diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 83d4b5cb..e63b5a6a 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -47,13 +47,11 @@ static uint8_t s_mute_adts[] = {0xff, 0xf1, 0x6c, 0x40, 0x2d, 0x3f, 0xfc, 0x00, #define MUTE_ADTS_DATA_MS 130 PlayerProxy::PlayerProxy(const string &vhost, const string &app, const string &stream_id, - bool enable_rtsp, bool enable_rtmp, bool enable_hls, bool enable_mp4, - int retry_count, const EventPoller::Ptr &poller) : MediaPlayer(poller){ + bool enable_hls, bool enable_mp4, int retry_count, const EventPoller::Ptr &poller) + : MediaPlayer(poller) { _vhost = vhost; _app = app; _stream_id = stream_id; - _enable_rtsp = enable_rtsp; - _enable_rtmp = enable_rtmp; _enable_hls = enable_hls; _enable_mp4 = enable_mp4; _retry_count = retry_count; @@ -119,15 +117,12 @@ void PlayerProxy::play(const string &strUrlTmp) { if(dynamic_pointer_cast(_delegate)){ //rtsp拉流 GET_CONFIG(bool,directProxy,Rtsp::kDirectProxy); - if(directProxy && _enable_rtsp){ + if(directProxy){ mediaSource = std::make_shared(_vhost, _app, _stream_id); } } else if(dynamic_pointer_cast(_delegate)){ - //rtmp拉流 - if(_enable_rtmp){ - //rtmp强制直接代理 - mediaSource = std::make_shared(_vhost, _app, _stream_id); - } + //rtmp拉流,rtmp强制直接代理 + mediaSource = std::make_shared(_vhost, _app, _stream_id); } if(mediaSource){ setMediaSouce(mediaSource); @@ -224,17 +219,17 @@ void PlayerProxy::onPlaySuccess() { if (dynamic_pointer_cast(_pMediaSrc)) { //rtsp拉流代理 if (resetWhenRePlay || !_muxer) { - _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), false, _enable_rtmp, _enable_hls, _enable_mp4)); + _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), false, true, _enable_hls, _enable_mp4)); } } else if (dynamic_pointer_cast(_pMediaSrc)) { //rtmp拉流代理 if (resetWhenRePlay || !_muxer) { - _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), _enable_rtsp, false, _enable_hls, _enable_mp4)); + _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), true, false, _enable_hls, _enable_mp4)); } } else { //其他拉流代理 if (resetWhenRePlay || !_muxer) { - _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), _enable_rtsp, _enable_rtmp, _enable_hls, _enable_mp4)); + _muxer.reset(new MultiMediaSourceMuxer(_vhost, _app, _stream_id, getDuration(), true, true, _enable_hls, _enable_mp4)); } } _muxer->setMediaListener(shared_from_this()); diff --git a/src/Player/PlayerProxy.h b/src/Player/PlayerProxy.h index 999786f4..35089ee5 100644 --- a/src/Player/PlayerProxy.h +++ b/src/Player/PlayerProxy.h @@ -27,7 +27,7 @@ public: //如果retry_count<0,则一直重试播放;否则重试retry_count次数 //默认一直重试 PlayerProxy(const string &vhost, const string &app, const string &stream_id, - bool enable_rtsp = true, bool enable_rtmp = true, bool enable_hls = true, bool enable_mp4 = false, + bool enable_hls = true, bool enable_mp4 = false, int retry_count = -1, const EventPoller::Ptr &poller = nullptr); ~PlayerProxy() override; @@ -63,8 +63,6 @@ private: void onPlaySuccess(); private: - bool _enable_rtsp; - bool _enable_rtmp; bool _enable_hls; bool _enable_mp4; int _retry_count; diff --git a/tests/test_pusher.cpp b/tests/test_pusher.cpp index d64c84ad..fe7f1b0b 100644 --- a/tests/test_pusher.cpp +++ b/tests/test_pusher.cpp @@ -75,14 +75,7 @@ int domain(const string &playUrl, const string &pushUrl) { //拉一个流,生成一个RtmpMediaSource,源的名称是"app/stream" //你也可以以其他方式生成RtmpMediaSource,比如说MP4文件(请查看test_rtmpPusherMp4.cpp代码) MediaInfo info(pushUrl); - bool enable_rtsp = true; - bool enable_rtmp = true; - if(info._schema == RTSP_SCHEMA){ - enable_rtmp = false; - }else if(info._schema == RTMP_SCHEMA){ - enable_rtsp = false; - } - PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "app", "stream",enable_rtsp,enable_rtmp,false,false,-1 , poller)); + PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "app", "stream",false,false,-1 , poller)); //可以指定rtsp拉流方式,支持tcp和udp方式,默认tcp // (*player)[Client::kRtpType] = Rtsp::RTP_UDP; player->play(playUrl.data());