From d037acbf629cd2fe6848bb628179fa8e8f9d0282 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Sun, 8 May 2022 17:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84ipv6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/media-server | 2 +- api/source/mk_events_objects.cpp | 2 +- src/Common/MediaSource.cpp | 12 +++--------- src/Common/MediaSource.h | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/3rdpart/media-server b/3rdpart/media-server index d6034e7e..d743ea7f 160000 --- a/3rdpart/media-server +++ b/3rdpart/media-server @@ -1 +1 @@ -Subproject commit d6034e7e3572bcd557fd88438c10b98c5fabdd13 +Subproject commit d743ea7facdd643d7732c0f82f0fd6467380ea8c diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 9b4b2971..d95167e1 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -155,7 +155,7 @@ API_EXPORT const char* API_CALL mk_media_info_get_host(const mk_media_info ctx){ API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx){ assert(ctx); MediaInfo *info = (MediaInfo *)ctx; - return std::stoi(info->_port); + return info->_port; } API_EXPORT const char* API_CALL mk_media_info_get_app(const mk_media_info ctx){ diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 66b8e339..6b395c18 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -506,15 +506,9 @@ void MediaInfo::parse(const string &url_in){ } auto split_vec = split(url.substr(schema_pos + 3), "/"); if (split_vec.size() > 0) { - auto vhost = split_vec[0]; - auto pos = vhost.find(":"); - if (pos != string::npos) { - _host = _vhost = vhost.substr(0, pos); - _port = vhost.substr(pos + 1); - } else { - _host = _vhost = vhost; - } - if (_vhost == "localhost" || isIP(_vhost.data())) { + splitUrl(split_vec[0], _host, _port); + _vhost = _host; + if (_vhost == "localhost" || isIP(_vhost.data())) { //如果访问的是localhost或ip,那么则为默认虚拟主机 _vhost = DEFAULT_VHOST; } diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index f97f751d..f274491d 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -159,7 +159,7 @@ public: std::string _full_url; std::string _schema; std::string _host; - std::string _port; + uint16_t _port = 0; std::string _vhost; std::string _app; std::string _streamid;