简化命名空间

This commit is contained in:
xiongziliang
2018-10-24 17:17:55 +08:00
parent ed1402e9d6
commit 9f16cc1201
133 changed files with 446 additions and 788 deletions

View File

@@ -27,8 +27,7 @@
#include "HttpClient.h"
#include "Rtsp/Rtsp.h"
namespace ZL {
namespace Http {
namespace mediakit {
HttpClient::HttpClient() {
@@ -272,6 +271,5 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
}
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -38,11 +38,9 @@
#include "HttpCookie.h"
using namespace std;
using namespace ZL::Util;
using namespace ZL::Network;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
class HttpArgs : public StrCaseMap {
public:
@@ -311,21 +309,6 @@ private:
float _fTimeOutSec = 0;
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* Http_HttpClient_h */

View File

@@ -24,10 +24,9 @@
* SOFTWARE.
*/
#include <Http/HttpClientImp.h>
#include "Http/HttpClientImp.h"
namespace ZL {
namespace Http {
namespace mediakit {
HttpClientImp::HttpClientImp() {
// TODO Auto-generated constructor stub
@@ -87,5 +86,4 @@ int HttpClientImp::send(const Buffer::Ptr &buf) {
}
#endif //ENABLE_OPENSSL
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -30,11 +30,11 @@
#include "HttpClient.h"
#ifdef ENABLE_OPENSSL
#include "Util/SSLBox.h"
using namespace ZL::Util;
#endif //ENABLE_OPENSSL
namespace ZL {
namespace Http {
using namespace toolkit;
namespace mediakit {
class HttpClientImp: public HttpClient {
public:
@@ -59,7 +59,6 @@ private:
#endif //ENABLE_OPENSSL
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_HTTP_HTTPCLIENTIMP_H_ */

View File

@@ -26,10 +26,9 @@
#include "HttpCookie.h"
#include "Util/util.h"
using namespace ZL::Util;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
void HttpCookie::setPath(const string &path){
_path = path;
@@ -104,5 +103,4 @@ vector<HttpCookie::Ptr> HttpCookieStorage::get(const string &host, const string
}
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -34,8 +34,7 @@
#include <mutex>
using namespace std;
namespace ZL {
namespace Http {
namespace mediakit {
class HttpCookie {
public:
@@ -75,7 +74,6 @@ private:
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif //ZLMEDIAKIT_HTTPCOOKIE_H

View File

@@ -27,11 +27,9 @@
#include "HttpDownloader.h"
#include "Util/MD5.h"
#include "Util/File.h"
using namespace toolkit;
using namespace ZL::Util;
namespace ZL {
namespace Http {
namespace mediakit {
HttpDownloader::HttpDownloader() {
@@ -115,5 +113,4 @@ void HttpDownloader::closeFile() {
}
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -29,8 +29,7 @@
#include "HttpClientImp.h"
namespace ZL {
namespace Http {
namespace mediakit {
class HttpDownloader: public HttpClientImp {
public:
@@ -60,7 +59,6 @@ private:
bool _bDownloadSuccess = false;
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_HTTP_HTTPDOWNLOADER_H_ */

View File

@@ -28,10 +28,9 @@
#include "HttpRequestSplitter.h"
#include "Util/logger.h"
#include "Util/util.h"
using namespace ZL::Util;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
void HttpRequestSplitter::input(const char *data,uint64_t len) {
const char *ptr = data;
@@ -126,6 +125,5 @@ void HttpRequestSplitter::reset() {
}
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -30,8 +30,7 @@
#include <string>
using namespace std;
namespace ZL {
namespace Http {
namespace mediakit {
class HttpRequestSplitter {
public:
@@ -79,7 +78,6 @@ private:
int64_t _content_len = 0;
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif //ZLMEDIAKIT_HTTPREQUESTSPLITTER_H

View File

@@ -25,8 +25,7 @@
*/
#include "HttpRequester.h"
namespace ZL{
namespace Http{
namespace mediakit{
HttpRequester::HttpRequester(){
@@ -63,6 +62,4 @@ void HttpRequester::startRequester(const string &url,const HttpRequesterResult &
}
}//namespace Http
}//namespace ZL
}//namespace mediakit

View File

@@ -29,9 +29,8 @@
#include "HttpClientImp.h"
namespace ZL{
namespace Http{
namespace mediakit{
class HttpRequester : public HttpClientImp
{
public:
@@ -50,7 +49,6 @@ private:
HttpRequesterResult _onResult;
};
}//namespace Http
}//namespace ZL
}//namespace mediakit
#endif /* Htt_HttpRequester_h */

View File

@@ -43,11 +43,9 @@
#include "Util/base64.h"
#include "Util/SHA1.h"
#include "Rtmp/utils.h"
using namespace toolkit;
using namespace ZL::Util;
namespace ZL {
namespace Http {
namespace mediakit {
static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE;
@@ -109,7 +107,7 @@ HttpSession::HttpSession(const std::shared_ptr<ThreadPool> &pTh, const Socket::P
//设置15秒发送超时时间
pSock->setSendTimeOutSecond(15);
GET_CONFIG_AND_REGISTER(string,rootPath,Config::Http::kRootPath);
GET_CONFIG_AND_REGISTER(string,rootPath,Http::kRootPath);
_strPath = rootPath;
}
@@ -178,7 +176,7 @@ void HttpSession::onError(const SockException& err) {
}
void HttpSession::onManager() {
GET_CONFIG_AND_REGISTER(uint32_t,keepAliveSec,Config::Http::kKeepAliveSecond);
GET_CONFIG_AND_REGISTER(uint32_t,keepAliveSec,Http::kKeepAliveSecond);
if(_ticker.elapsedTime() > keepAliveSec * 1000){
//1分钟超时
@@ -298,7 +296,7 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
string strFile = _strPath + "/" + _mediaInfo._vhost + _parser.Url();
/////////////HTTP连接是否需要被关闭////////////////
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Config::Http::kMaxReqCount);
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Http::kMaxReqCount);
bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
//访问的是文件夹
@@ -369,7 +367,7 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
//回复Content部分
std::shared_ptr<int64_t> piLeft(new int64_t(iRangeEnd - iRangeStart + 1));
GET_CONFIG_AND_REGISTER(uint32_t,sendBufSize,Config::Http::kSendBufSize);
GET_CONFIG_AND_REGISTER(uint32_t,sendBufSize,Http::kSendBufSize);
weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this());
auto onFlush = [pFilePtr,bClose,weakSelf,piLeft]() {
@@ -529,9 +527,9 @@ inline void HttpSession::sendResponse(const char* pcStatus, const KeyValue& head
}
inline HttpSession::KeyValue HttpSession::makeHttpHeader(bool bClose, int64_t iContentSize,const char* pcContentType) {
KeyValue headerOut;
GET_CONFIG_AND_REGISTER(string,charSet,Config::Http::kCharSet);
GET_CONFIG_AND_REGISTER(uint32_t,keepAliveSec,Config::Http::kKeepAliveSecond);
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Config::Http::kMaxReqCount);
GET_CONFIG_AND_REGISTER(string,charSet,Http::kCharSet);
GET_CONFIG_AND_REGISTER(uint32_t,keepAliveSec,Http::kKeepAliveSecond);
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Http::kMaxReqCount);
headerOut.emplace("Date", dateStr());
headerOut.emplace("Server", SERVER_NAME);
@@ -552,7 +550,7 @@ inline HttpSession::KeyValue HttpSession::makeHttpHeader(bool bClose, int64_t iC
string HttpSession::urlDecode(const string &str){
auto ret = strCoding::UrlUTF8Decode(str);
#ifdef _WIN32
GET_CONFIG_AND_REGISTER(string,charSet,Config::Http::kCharSet);
GET_CONFIG_AND_REGISTER(string,charSet,Http::kCharSet);
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
if (isGb2312) {
ret = strCoding::UTF8ToGB2312(ret);
@@ -570,7 +568,7 @@ inline void HttpSession::urlDecode(Parser &parser){
inline bool HttpSession::emitHttpEvent(bool doInvoke){
///////////////////是否断开本链接///////////////////////
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Config::Http::kMaxReqCount);
GET_CONFIG_AND_REGISTER(uint32_t,reqCnt,Http::kMaxReqCount);
bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt);
auto Origin = _parser["Origin"];
@@ -594,7 +592,7 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
};
///////////////////广播HTTP事件///////////////////////////
bool consumed = false;//该事件是否被消费
NoticeCenter::Instance().emitEvent(Config::Broadcast::kBroadcastHttpRequest,_parser,invoker,consumed,*this);
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpRequest,_parser,invoker,consumed,*this);
if(!consumed && doInvoke){
//该事件无人消费所以返回404
invoker("404 Not Found",KeyValue(),"");
@@ -606,8 +604,8 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
return consumed;
}
inline bool HttpSession::Handle_Req_POST(int64_t &content_len) {
GET_CONFIG_AND_REGISTER(uint64_t,maxReqSize,Config::Http::kMaxReqSize);
GET_CONFIG_AND_REGISTER(int,maxReqCnt,Config::Http::kMaxReqCount);
GET_CONFIG_AND_REGISTER(uint64_t,maxReqSize,Http::kMaxReqSize);
GET_CONFIG_AND_REGISTER(int,maxReqCnt,Http::kMaxReqCount);
int64_t totalContentLen = _parser["Content-Length"].empty() ? -1 : atoll(_parser["Content-Length"].data());
@@ -686,7 +684,7 @@ void HttpSession::responseDelay(const string &Origin,bool bClose,
sendResponse(codeOut.data(), headerOut, contentOut);
}
inline void HttpSession::sendNotFound(bool bClose) {
GET_CONFIG_AND_REGISTER(string,notFound,Config::Http::kNotFound);
GET_CONFIG_AND_REGISTER(string,notFound,Http::kNotFound);
sendResponse("404 Not Found", makeHttpHeader(bClose, notFound.size()), notFound);
}
@@ -728,5 +726,4 @@ std::shared_ptr<FlvMuxer> HttpSession::getSharedPtr(){
return dynamic_pointer_cast<FlvMuxer>(shared_from_this());
}
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -37,11 +37,9 @@
#include "WebSocketSplitter.h"
using namespace std;
using namespace ZL::Rtmp;
using namespace ZL::Network;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
class HttpSession: public TcpSession,
public FlvMuxer,
@@ -128,7 +126,6 @@ private:
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_HTTP_HTTPSESSION_H_ */

View File

@@ -31,10 +31,9 @@
#include "Util/SSLBox.h"
#include "Util/TimeTicker.h"
using namespace ZL::Util;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
class HttpsSession: public HttpSession {
public:
@@ -284,7 +283,6 @@ typedef WebSocketSession<EchoSession,HttpSession> EchoWebSocketSession;
typedef WebSocketSession<EchoSession,HttpsSession> SSLEchoWebSocketSession;
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_HTTP_HTTPSSESSION_H_ */

View File

@@ -30,11 +30,9 @@
#include <arpa/inet.h>
#include "Util/logger.h"
#include "Util/util.h"
using namespace ZL::Util;
using namespace toolkit;
namespace ZL {
namespace Http {
namespace mediakit {
/**
*
@@ -210,27 +208,7 @@ void WebSocketSplitter::encode(const WebSocketHeader &header,uint8_t *data, cons
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -34,8 +34,7 @@
using namespace std;
namespace ZL {
namespace Http {
namespace mediakit {
class WebSocketHeader {
public:
@@ -130,8 +129,7 @@ private:
uint64_t _playload_offset = 0;
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif //ZLMEDIAKIT_WEBSOCKETSPLITTER_H

View File

@@ -31,8 +31,7 @@
#include <windows.h>
#endif//defined(_WIN32)
namespace ZL {
namespace Http {
namespace mediakit {
//////////////////////////通用///////////////////////
void UTF8ToUnicode(wchar_t* pOut, const char *pText)
@@ -239,5 +238,4 @@ string strCoding::GB2312ToUTF8(const string &str) {
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */

View File

@@ -32,8 +32,7 @@
using namespace std;
namespace ZL {
namespace Http {
namespace mediakit {
class strCoding {
public:
@@ -51,7 +50,6 @@ private:
virtual ~strCoding(void);
};
} /* namespace Http */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_HTTP_STRCODING_H_ */