优化代码

This commit is contained in:
xiongziliang 2018-11-27 11:05:44 +08:00
parent 858d2996c4
commit ad25ea184c
8 changed files with 16 additions and 16 deletions

@ -1 +1 @@
Subproject commit 95aadf51026c37e94d15b3d3a06b9df842d881e1
Subproject commit c632732a699bf1b6d12996235a09cd67fab21ede

View File

@ -81,7 +81,7 @@ Sdp::Ptr Factory::getSdpByTrack(const Track::Ptr &track) {
Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
if (toolkit::strcasecmp(track->_codec.data(), "mpeg4-generic") == 0) {
if (strcasecmp(track->_codec.data(), "mpeg4-generic") == 0) {
string aac_cfg_str = FindField(track->_fmtp.c_str(), "config=", nullptr);
if (aac_cfg_str.size() != 4) {
aac_cfg_str = FindField(track->_fmtp.c_str(), "config=", ";");
@ -105,7 +105,7 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
return std::make_shared<AACTrack>(aac_cfg);
}
if (toolkit::strcasecmp(track->_codec.data(), "h264") == 0) {
if (strcasecmp(track->_codec.data(), "h264") == 0) {
string sps_pps = FindField(track->_fmtp.c_str(), "sprop-parameter-sets=", nullptr);
if(sps_pps.empty()){
return std::make_shared<H264Track>();
@ -121,7 +121,7 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
return std::make_shared<H264Track>(sps,pps,0,0);
}
if (toolkit::strcasecmp(track->_codec.data(), "h265") == 0) {
if (strcasecmp(track->_codec.data(), "h265") == 0) {
//a=fmtp:96 sprop-sps=QgEBAWAAAAMAsAAAAwAAAwBdoAKAgC0WNrkky/AIAAADAAgAAAMBlQg=; sprop-pps=RAHA8vA8kAA=
int pt;
char sprop_vps[128] = {0},sprop_sps[128] = {0},sprop_pps[128] = {0};

View File

@ -41,10 +41,10 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) {
auto protocol = FindField(strUrl.data(), NULL, "://");
uint16_t defaultPort;
bool isHttps;
if (toolkit::strcasecmp(protocol.data(), "http") == 0) {
if (strcasecmp(protocol.data(), "http") == 0) {
defaultPort = 80;
isHttps = false;
} else if (toolkit::strcasecmp(protocol.data(), "https") == 0) {
} else if (strcasecmp(protocol.data(), "https") == 0) {
defaultPort = 443;
isHttps = true;
} else {

View File

@ -208,7 +208,7 @@ inline bool HttpSession::checkLiveFlvStream(){
//未找到".flv"后缀
return false;
}
if(toolkit::strcasecmp(pos,".flv") != 0){
if(strcasecmp(pos,".flv") != 0){
//未找到".flv"后缀
return false;
}
@ -298,7 +298,7 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
/////////////HTTP连接是否需要被关闭////////////////
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Http::kMaxReqCount);
bool bClose = (toolkit::strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
//访问的是文件夹
if (strFile.back() == '/') {
//生成文件夹菜单索引
@ -551,7 +551,7 @@ string HttpSession::urlDecode(const string &str){
auto ret = strCoding::UrlUTF8Decode(str);
#ifdef _WIN32
GET_CONFIG_AND_REGISTER(string,charSet,Http::kCharSet);
bool isGb2312 = !toolkit::strcasecmp(charSet.data(), "gb2312");
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
if (isGb2312) {
ret = strCoding::UTF8ToGB2312(ret);
}
@ -570,7 +570,7 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
///////////////////是否断开本链接///////////////////////
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Http::kMaxReqCount);
bool bClose = (toolkit::strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
auto Origin = _parser["Origin"];
/////////////////////异步回复Invoker///////////////////////////////
weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this());
@ -637,7 +637,7 @@ inline bool HttpSession::Handle_Req_POST(int64_t &content_len) {
content_len = -1;
auto parserCopy = _parser;
std::shared_ptr<uint64_t> recvedContentLen = std::make_shared<uint64_t>(0);
bool bClose = (toolkit::strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > maxReqCnt);
bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > maxReqCnt);
_contentCallBack = [this,parserCopy,totalContentLen,recvedContentLen,bClose](const char *data,uint64_t len){
*(recvedContentLen) += len;

View File

@ -39,7 +39,7 @@ MediaPlayer::~MediaPlayer() {
}
void MediaPlayer::play(const char* strUrl) {
string strPrefix = FindField(strUrl, NULL, "://");
if ((toolkit::strcasecmp(_strPrefix.data(),strPrefix.data()) != 0) || strPrefix.empty()) {
if ((strcasecmp(_strPrefix.data(),strPrefix.data()) != 0) || strPrefix.empty()) {
//协议切换
_strPrefix = strPrefix;
_parser = PlayerBase::createPlayer(strUrl);

View File

@ -48,10 +48,10 @@ PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
ptr->teardown();
};
string prefix = FindField(strUrl, NULL, "://");
if (toolkit::strcasecmp("rtsp",prefix.data()) == 0) {
if (strcasecmp("rtsp",prefix.data()) == 0) {
return PlayerBase::Ptr(new RtspPlayerImp(),releasePlayer);
}
if (toolkit::strcasecmp("rtmp",prefix.data()) == 0) {
if (strcasecmp("rtmp",prefix.data()) == 0) {
return PlayerBase::Ptr(new RtmpPlayerImp(),releasePlayer);
}
return PlayerBase::Ptr(new RtspPlayerImp(),releasePlayer);

View File

@ -101,7 +101,7 @@ string FindField(const char* buf, const char* start, const char *end,int bufSize
struct StrCaseCompare
{
bool operator()(const string& __x, const string& __y) const
{return toolkit::strcasecmp(__x.data(), __y.data()) < 0 ;}
{return strcasecmp(__x.data(), __y.data()) < 0 ;}
};
typedef map<string,string,StrCaseCompare> StrCaseMap;

View File

@ -444,7 +444,7 @@ void RtspSession::onAuthDigest(const weak_ptr<RtspSession> &weakSelf,const strin
}
auto good_response = MD5( encrypted_pwd + ":" + nonce + ":" + MD5(string("DESCRIBE") + ":" + uri).hexdigest()).hexdigest();
if(toolkit::strcasecmp(good_response.data(),response.data()) == 0){
if(strcasecmp(good_response.data(),response.data()) == 0){
//认证成功md5不区分大小写
onAuthSuccess(weakSelf);
TraceL << "onAuthSuccess";