Commit 24db0454 by ziyue

不支持的协议直接抛异常, 防止非法推拉流:#1725

parent 54f400a6
...@@ -56,10 +56,9 @@ PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller, const s ...@@ -56,10 +56,9 @@ PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller, const s
} else if (end_with(url, ".ts") || end_with(url_in, ".ts")) { } else if (end_with(url, ".ts") || end_with(url_in, ".ts")) {
return PlayerBase::Ptr(new TsPlayerImp(poller), releasePlayer); return PlayerBase::Ptr(new TsPlayerImp(poller), releasePlayer);
} }
return PlayerBase::Ptr(new TsPlayerImp(poller), releasePlayer);
} }
return PlayerBase::Ptr(new RtspPlayerImp(poller), releasePlayer); throw std::invalid_argument("not supported play schema:" + url_in);
} }
PlayerBase::PlayerBase() { PlayerBase::PlayerBase() {
......
...@@ -19,14 +19,14 @@ namespace mediakit { ...@@ -19,14 +19,14 @@ namespace mediakit {
PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &poller, PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &poller,
const MediaSource::Ptr &src, const MediaSource::Ptr &src,
const std::string & strUrl) { const std::string & url) {
static auto releasePusher = [](PusherBase *ptr){ static auto releasePusher = [](PusherBase *ptr){
onceToken token(nullptr,[&](){ onceToken token(nullptr,[&](){
delete ptr; delete ptr;
}); });
ptr->teardown(); ptr->teardown();
}; };
std::string prefix = FindField(strUrl.data(), NULL, "://"); std::string prefix = FindField(url.data(), NULL, "://");
if (strcasecmp("rtsps",prefix.data()) == 0) { if (strcasecmp("rtsps",prefix.data()) == 0) {
return PusherBase::Ptr(new TcpClientWithSSL<RtspPusherImp>(poller, std::dynamic_pointer_cast<RtspMediaSource>(src)), releasePusher); return PusherBase::Ptr(new TcpClientWithSSL<RtspPusherImp>(poller, std::dynamic_pointer_cast<RtspMediaSource>(src)), releasePusher);
...@@ -44,7 +44,7 @@ PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &poller, ...@@ -44,7 +44,7 @@ PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &poller,
return PusherBase::Ptr(new RtmpPusherImp(poller, std::dynamic_pointer_cast<RtmpMediaSource>(src)), releasePusher); return PusherBase::Ptr(new RtmpPusherImp(poller, std::dynamic_pointer_cast<RtmpMediaSource>(src)), releasePusher);
} }
return PusherBase::Ptr(new RtspPusherImp(poller, std::dynamic_pointer_cast<RtspMediaSource>(src)), releasePusher); throw std::invalid_argument("not supported push schema:" + url);
} }
PusherBase::PusherBase() { PusherBase::PusherBase() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论