1. 局部变量删除前面的下划线

2. windows系统编译时strncasecmp 为_strnicmp
This commit is contained in:
yangkun 2023-10-27 13:54:31 +08:00
parent 7fde20bb4c
commit 0a09cdaeea
1 changed files with 10 additions and 6 deletions

View File

@ -62,28 +62,32 @@ void RtmpPusher::onPublishResult_l(const SockException &ex, bool handshake_done)
shutdown(SockException(Err_shutdown,"teardown")); shutdown(SockException(Err_shutdown,"teardown"));
} }
} }
#ifdef _MSC_VER
//not #if defined(_WIN32) || defined(_WIN64) because we have strncasecmp in mingw
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
void RtmpPusher::publish(const string &url) { void RtmpPusher::publish(const string &url) {
teardown(); teardown();
string _head ; string head ;
// rtmps rt_url head should be rtmps // rtmps rt_url head should be rtmps
const char *rtmp_head = "rtmp://"; const char *rtmp_head = "rtmp://";
const char *rtmps_head = "rtmps://"; const char *rtmps_head = "rtmps://";
if(0 == strncasecmp(url.c_str(), rtmp_head, strlen(rtmp_head))) if(0 == strncasecmp(url.c_str(), rtmp_head, strlen(rtmp_head)))
{ {
_head = rtmp_head; head = rtmp_head;
} }
if(0 == strncasecmp(url.c_str(), rtmps_head, strlen(rtmps_head))) if(0 == strncasecmp(url.c_str(), rtmps_head, strlen(rtmps_head)))
{ {
_head = rtmps_head; head = rtmps_head;
} }
string host_url = findSubString(url.data(), "://", "/"); string host_url = findSubString(url.data(), "://", "/");
_app = findrSubString(url.data(), (host_url + "/").data(), '/'); _app = findrSubString(url.data(), (host_url + "/").data(), '/');
_stream_id = findSubString(url.data(), (host_url + "/" + _app + "/").data(), NULL); _stream_id = findSubString(url.data(), (host_url + "/" + _app + "/").data(), NULL);
_tc_url = _head + host_url + "/" + _app; _tc_url = head + host_url + "/" + _app;
if (!_app.size() || !_stream_id.size() || !_head.size()) { if (!_app.size() || !_stream_id.size() || !head.size()) {
onPublishResult_l(SockException(Err_other, "rtmp url非法"), false); onPublishResult_l(SockException(Err_other, "rtmp url非法"), false);
return; return;
} }