Improve srt print and check pusher (#4113)

This commit is contained in:
xiongguangjie
2025-01-12 10:01:35 +08:00
committed by GitHub
parent b7b7989fae
commit ac6bb9b332
2 changed files with 31 additions and 0 deletions

View File

@@ -20,6 +20,32 @@ using namespace toolkit;
namespace mediakit {
static bool checkMediaSourceAndUrlMatch(const MediaSource::Ptr &src, const std::string &url) {
std::string prefix = findSubString(url.data(), NULL, "://");
if (strcasecmp("rtsps", prefix.data()) == 0 || strcasecmp("rtsp", prefix.data()) == 0) {
auto rtsp_src = std::dynamic_pointer_cast<RtspMediaSource>(src);
if (!rtsp_src) {
return false;
}
}
if (strcasecmp("rtmp", prefix.data()) == 0 || strcasecmp("rtmps", prefix.data()) == 0) {
auto rtmp_src = std::dynamic_pointer_cast<RtmpMediaSource>(src);
if (!rtmp_src) {
return false;
}
}
if (strcasecmp("srt", prefix.data()) == 0) {
auto ts_src = std::dynamic_pointer_cast<TSMediaSource>(src);
if (!ts_src) {
return false;
}
}
return true;
}
PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &in_poller,
const MediaSource::Ptr &src,
const std::string & url) {
@@ -35,6 +61,10 @@ PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &in_poller,
delete ptr;
}
};
if (!checkMediaSourceAndUrlMatch(src, url)) {
throw std::invalid_argument(" media source (schema) and push url not match");
}
std::string prefix = findSubString(url.data(), NULL, "://");
if (strcasecmp("rtsps",prefix.data()) == 0) {

View File

@@ -117,6 +117,7 @@ bool SrtTransportImp::parseStreamid(std::string &streamid) {
_media_info.app = app;
_media_info.stream = stream_name;
_media_info.full_url = _media_info.getUrl() + "?" + _media_info.params;
TraceL << " mediainfo=" << _media_info.shortUrl() << " params=" << _media_info.params;