diff --git a/ZLToolKit b/ZLToolKit index d7487e37..6e69a082 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit d7487e37dd915e8391c1d6a45f1773af13b366a7 +Subproject commit 6e69a082a2f6e6161785b00c7421bf1a811ed34a diff --git a/c_wrapper/src/common.cpp b/c_wrapper/src/common.cpp index 9508d011..c265eed6 100755 --- a/c_wrapper/src/common.cpp +++ b/c_wrapper/src/common.cpp @@ -39,10 +39,7 @@ #include "cleaner.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Rtmp; -using namespace ZL::Rtsp; -using namespace ZL::Http; +using namespace toolkit; static TcpServer::Ptr s_pRtspSrv; static TcpServer::Ptr s_pRtmpSrv; diff --git a/c_wrapper/src/flvrecorder.cpp b/c_wrapper/src/flvrecorder.cpp index dbad196c..80f57d1e 100644 --- a/c_wrapper/src/flvrecorder.cpp +++ b/c_wrapper/src/flvrecorder.cpp @@ -5,7 +5,7 @@ #include "flvrecorder.h" #include "Rtmp/FlvMuxer.h" -using namespace ZL::Rtmp; +using namespace toolkit; API_EXPORT FlvRecorderContex API_CALL createFlvRecorder(){ DebugL; diff --git a/c_wrapper/src/httpdownloader.cpp b/c_wrapper/src/httpdownloader.cpp index e850aa07..3e93202c 100755 --- a/c_wrapper/src/httpdownloader.cpp +++ b/c_wrapper/src/httpdownloader.cpp @@ -33,9 +33,7 @@ #include "cleaner.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Http; - +using namespace toolkit; static recursive_mutex s_mtxMapDownloader; static unordered_map s_mapDownloader; diff --git a/c_wrapper/src/media.cpp b/c_wrapper/src/media.cpp index 8fa916e0..2de5d082 100755 --- a/c_wrapper/src/media.cpp +++ b/c_wrapper/src/media.cpp @@ -32,8 +32,7 @@ #include "cleaner.h" using namespace std; -using namespace ZL::DEV; -using namespace ZL::Util; +using namespace toolkit; static recursive_mutex s_mtxMapMedia; static unordered_map s_mapMedia; diff --git a/c_wrapper/src/player.cpp b/c_wrapper/src/player.cpp index fb7c30a4..6558a464 100755 --- a/c_wrapper/src/player.cpp +++ b/c_wrapper/src/player.cpp @@ -35,11 +35,7 @@ #include "cleaner.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Thread; -using namespace ZL::Player; -using namespace ZL::Rtmp; -using namespace ZL::Rtsp; +using namespace toolkit; static recursive_mutex s_mtxMapPlayer; static unordered_map s_mapPlayer; diff --git a/c_wrapper/src/proxyplayer.cpp b/c_wrapper/src/proxyplayer.cpp index af942019..1b190d41 100644 --- a/c_wrapper/src/proxyplayer.cpp +++ b/c_wrapper/src/proxyplayer.cpp @@ -28,8 +28,7 @@ #include "Device/PlayerProxy.h" #include "Util/onceToken.h" -using namespace ZL::DEV; -using namespace ZL::Util; +using namespace toolkit; static recursive_mutex s_mtxMapProxyPlayer; static unordered_map s_mapProxyPlayer; diff --git a/src/Codec/AACEncoder.cpp b/src/Codec/AACEncoder.cpp index b7d2a681..aba8867b 100644 --- a/src/Codec/AACEncoder.cpp +++ b/src/Codec/AACEncoder.cpp @@ -38,10 +38,9 @@ extern "C" { } #endif -using namespace ZL::Util; +using namespace toolkit; -namespace ZL { -namespace Codec { +namespace mediakit { AACEncoder::AACEncoder() { @@ -117,8 +116,7 @@ int AACEncoder::inputData(char *pcPcmBufr, int iLen, unsigned char **ppucOutBuff return nRet; } -} /* namespace Codec */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ENABLE_FAAC diff --git a/src/Codec/AACEncoder.h b/src/Codec/AACEncoder.h index 23ee35b2..d75c5672 100644 --- a/src/Codec/AACEncoder.h +++ b/src/Codec/AACEncoder.h @@ -28,8 +28,7 @@ #ifndef CODEC_AACENCODER_H_ #define CODEC_AACENCODER_H_ -namespace ZL { -namespace Codec { +namespace mediakit { class AACEncoder { public: @@ -51,7 +50,6 @@ private: }; -} /* namespace Codec */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* CODEC_AACENCODER_H_ */ diff --git a/src/Codec/H264Encoder.cpp b/src/Codec/H264Encoder.cpp index 1ae2fc49..a4bcb661 100644 --- a/src/Codec/H264Encoder.cpp +++ b/src/Codec/H264Encoder.cpp @@ -28,10 +28,10 @@ #include "H264Encoder.h" #include "Util/TimeTicker.h" -using namespace ZL::Util; -namespace ZL { -namespace Codec { +using namespace toolkit; + +namespace mediakit { H264Encoder::H264Encoder() { @@ -347,8 +347,7 @@ int H264Encoder::inputData(char* apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H26 return iNal; } -} /* namespace Codec */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ENABLE_X264 diff --git a/src/Codec/H264Encoder.h b/src/Codec/H264Encoder.h index d102ccd1..96921339 100644 --- a/src/Codec/H264Encoder.h +++ b/src/Codec/H264Encoder.h @@ -38,8 +38,7 @@ extern "C" { } #endif //__cplusplus -namespace ZL { -namespace Codec { +namespace mediakit { class H264Encoder { public: @@ -60,7 +59,6 @@ private: H264Frame _aFrames[10]; }; -} /* namespace Codec */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* CODEC_H264ENCODER_H_ */ diff --git a/src/Common/Factory.cpp b/src/Common/Factory.cpp index 40f57b84..b9f114e9 100644 --- a/src/Common/Factory.cpp +++ b/src/Common/Factory.cpp @@ -4,6 +4,8 @@ #include "Factory.h" +namespace mediakit{ + Sdp::Ptr Factory::getSdpByTrack(const Track::Ptr &track) { switch (track->getCodecId()){ case CodecH264:{ @@ -101,3 +103,5 @@ RtpCodec::Ptr Factory::getRtpDecoderById(CodecId codecId, uint32_t ui32SampleRat } } +}//namespace mediakit + diff --git a/src/Common/Factory.h b/src/Common/Factory.h index 341177ed..d9f2bd5f 100644 --- a/src/Common/Factory.h +++ b/src/Common/Factory.h @@ -10,7 +10,9 @@ #include "Rtsp/RtspSdp.h" using namespace std; -using namespace ZL::Rtsp; +using namespace toolkit; + +namespace mediakit{ class Factory { public: @@ -53,5 +55,6 @@ public: static RtpCodec::Ptr getRtpDecoderById(CodecId codecId, uint32_t ui32SampleRate); }; +}//namespace mediakit #endif //ZLMEDIAKIT_FACTORY_H diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index eff1433c..105b062d 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -31,12 +31,9 @@ #include "Rtsp/Rtsp.h" #include "Network/sockutil.h" -using namespace ZL::Util; -using namespace ZL::Network; -using namespace ZL::MediaFile; +using namespace toolkit; -namespace ZL { -namespace Media { +namespace mediakit { recursive_mutex MediaSource::g_mtxMediaSrc; MediaSource::SchemaVhostAppStreamMap MediaSource::g_mapMediaSrc; @@ -174,5 +171,4 @@ void MediaInfo::parse(const string &url){ } -} /* namespace Media */ -} /* namespace ZL */ \ No newline at end of file +} /* namespace mediakit */ \ No newline at end of file diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 038d0414..3615f972 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -40,11 +40,9 @@ #include "Rtsp/Rtsp.h" using namespace std; -using namespace Config; -using namespace ZL::Util; +using namespace toolkit; -namespace ZL { -namespace Media { +namespace mediakit { class MediaSourceEvent { @@ -234,8 +232,7 @@ private: static recursive_mutex g_mtxMediaSrc; //访问静态的媒体源表的互斥锁 }; -} /* namespace Media */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ZLMEDIAKIT_MEDIASOURCE_H diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 833a461a..1f8deace 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -30,9 +30,9 @@ #include "Util/onceToken.h" #include "Network/sockutil.h" -using namespace ZL::Network; +using namespace toolkit; -namespace Config { +namespace mediakit { bool loadIniConfig(const char *ini_path){ string ini; @@ -293,6 +293,6 @@ onceToken token([](){ } //namespace Hls -} // namespace Config +} // namespace mediakit diff --git a/src/Common/config.h b/src/Common/config.h index 28c8b23b..a5a351d3 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -34,9 +34,9 @@ #include "Util/NoticeCenter.h" using namespace std; -using namespace ZL::Util; +using namespace toolkit; -namespace Config { +namespace mediakit { //加载配置文件,如果配置文件不存在,那么会导出默认配置并生成配置文件 //加载配置文件成功后会触发kBroadcastUpdateConfig广播 @@ -131,7 +131,7 @@ extern const char kBroadcastReloadConfig[]; #define RELOAD_KEY_REGISTER(arg,key) \ do{ \ static onceToken s_token([](){ \ - NoticeCenter::Instance().addListener(ReloadConfigTag,Config::Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs){ \ + NoticeCenter::Instance().addListener(ReloadConfigTag,Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs){ \ RELOAD_KEY(arg,key); \ }); \ }); \ @@ -234,6 +234,6 @@ extern const char kFileBufSize[]; extern const char kFilePath[]; } //namespace Hls -} // namespace Config +} // namespace mediakit #endif /* COMMON_CONFIG_H */ diff --git a/src/Device/Device.cpp b/src/Device/Device.cpp index b15c4f46..863a5acd 100644 --- a/src/Device/Device.cpp +++ b/src/Device/Device.cpp @@ -31,10 +31,9 @@ #include "Util/base64.h" #include "Util/TimeTicker.h" -using namespace ZL::Util; +using namespace toolkit; -namespace ZL { -namespace DEV { +namespace mediakit { DevChannel::DevChannel(const char *strVhost, const char *strApp, @@ -107,7 +106,7 @@ void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t uiStamp) { auto lam = [this](const RtpPacket::Ptr &pkt, bool bKeyPos) { onGetRTP(pkt,bKeyPos); }; - GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,Config::Rtp::kVideoMtuSize); + GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,Rtp::kVideoMtuSize); _pRtpMaker_h264.reset(new RtpMaker_H264(lam, ui32Ssrc,videoMtu)); } if (!_bSdp_gotH264 && _video) { @@ -139,7 +138,7 @@ void DevChannel::inputAAC(const char *pcDataWithoutAdts,int iDataLen, uint32_t u auto lam = [this](const RtpPacket::Ptr &pkt, bool keyPos) { onGetRTP(pkt,keyPos); }; - GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,Config::Rtp::kAudioMtuSize); + GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,Rtp::kAudioMtuSize); _pRtpMaker_aac.reset(new RtpMaker_AAC(lam, ssrc, audioMtu,_audio->iSampleRate)); } if (!_bSdp_gotAAC && _audio && pcAdtsHeader) { @@ -304,6 +303,5 @@ void DevChannel::initAudio(const AudioInfo& info) { _pAdtsHeader->no_raw_data_blocks_in_frame = 0; } -} /* namespace DEV */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Device/Device.h b/src/Device/Device.h index cac80ed2..20c2f232 100644 --- a/src/Device/Device.h +++ b/src/Device/Device.h @@ -39,22 +39,18 @@ #include "Util/TimeTicker.h" using namespace std; -using namespace ZL::Rtsp; -using namespace ZL::Util; +using namespace toolkit; #ifdef ENABLE_FAAC #include "Codec/AACEncoder.h" -using namespace ZL::Codec; #endif //ENABLE_FAAC #ifdef ENABLE_X264 #include "Codec/H264Encoder.h" -using namespace ZL::Codec; #endif //ENABLE_X264 -namespace ZL { -namespace DEV { +namespace mediakit { class VideoInfo { public: @@ -124,7 +120,6 @@ private: }; -} /* namespace DEV */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* DEVICE_DEVICE_H_ */ diff --git a/src/Device/MediaSourceMaker.cpp b/src/Device/MediaSourceMaker.cpp new file mode 100644 index 00000000..8d8c4a0c --- /dev/null +++ b/src/Device/MediaSourceMaker.cpp @@ -0,0 +1,8 @@ +// +// Created by xzl on 2018/10/24. +// + +#include "MediaSourceMaker.h" +namespace mediakit{ + +} \ No newline at end of file diff --git a/src/Device/MediaSourceMaker.h b/src/Device/MediaSourceMaker.h new file mode 100644 index 00000000..e1460096 --- /dev/null +++ b/src/Device/MediaSourceMaker.h @@ -0,0 +1,24 @@ +// +// Created by xzl on 2018/10/24. +// + +#ifndef ZLMEDIAKIT_MEDIASOURCEMAKER_H +#define ZLMEDIAKIT_MEDIASOURCEMAKER_H + +#include "Player/Track.h" +#include "Rtsp/RtspMediaSource.h" +#include "Rtmp/RtmpMediaSource.h" + +namespace mediakit { + +class MediaSourceMaker { +public: + MediaSourceMaker() {} + virtual ~MediaSourceMaker() {} +private: + RtspMediaSource::Ptr _rtspSrc; + RtmpMediaSource::Ptr _rtmpSrc; +}; + +} //namespace mediakit +#endif //ZLMEDIAKIT_MEDIASOURCEMAKER_H diff --git a/src/Device/PlayerProxy.cpp b/src/Device/PlayerProxy.cpp index 3efe3d73..6fa09195 100644 --- a/src/Device/PlayerProxy.cpp +++ b/src/Device/PlayerProxy.cpp @@ -32,11 +32,9 @@ #include "Util/logger.h" #include "Thread/AsyncTaskThread.h" -using namespace ZL::Util; -using namespace ZL::Thread; +using namespace toolkit; -namespace ZL { -namespace DEV { +namespace mediakit { static uint8_t s_mute_adts[] = {0xff, 0xf1, 0x6c, 0x40, 0x2d, 0x3f, 0xfc, 0x00, 0xe0, 0x34, 0x20, 0xad, 0xf2, 0x3f, 0xb5, 0xdd, 0x73, 0xac, 0xbd, 0xca, 0xd7, 0x7d, 0x4a, 0x13, 0x2d, 0x2e, 0xa2, 0x62, 0x02, 0x70, 0x3c, 0x1c, @@ -220,5 +218,4 @@ void PlayerProxy::makeMuteAudio(uint32_t stamp) { } - } /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Device/PlayerProxy.h b/src/Device/PlayerProxy.h index 2eb26356..d5e6bf6a 100644 --- a/src/Device/PlayerProxy.h +++ b/src/Device/PlayerProxy.h @@ -33,10 +33,10 @@ #include "Util/TimeTicker.h" using namespace std; -using namespace ZL::Player; +using namespace toolkit; -namespace ZL { -namespace DEV { + +namespace mediakit { class PlayerProxy :public MediaPlayer, public std::enable_shared_from_this , public MediaSourceEvent { public: @@ -71,7 +71,6 @@ private: int _iAudioIndex = 0; }; -} /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_DEVICE_PLAYERPROXY_H_ */ diff --git a/src/H264/H264Parser.cpp b/src/H264/H264Parser.cpp index d9ef5ae3..42c80288 100644 --- a/src/H264/H264Parser.cpp +++ b/src/H264/H264Parser.cpp @@ -26,8 +26,8 @@ #include "H264Parser.h" #include "Util/logger.h" +using namespace toolkit; -using namespace ZL::Util; H264Parser::H264Parser(){ diff --git a/src/H264/h264_parser.cpp b/src/H264/h264_parser.cpp index e5ef76b2..cc11ffb9 100644 --- a/src/H264/h264_parser.cpp +++ b/src/H264/h264_parser.cpp @@ -7,8 +7,7 @@ #include #include "macros.h" #include "Util/logger.h" -using namespace ZL::Util; - +using namespace toolkit; template void STLDeleteContainerPairSecondPointers(ForwardIterator begin, diff --git a/src/H264/h264_poc.cpp b/src/H264/h264_poc.cpp index 3b4198d5..e8a6af7e 100644 --- a/src/H264/h264_poc.cpp +++ b/src/H264/h264_poc.cpp @@ -8,8 +8,7 @@ #include "macros.h" #include "h264_parser.h" #include "h264_poc.h" - -using namespace ZL::Util; +using namespace toolkit; namespace media { diff --git a/src/H264/macros.h b/src/H264/macros.h index ad4d0958..c6d3b01e 100644 --- a/src/H264/macros.h +++ b/src/H264/macros.h @@ -88,7 +88,7 @@ static type& name = *new type arguments #include #include "Util/logger.h" -using namespace ZL::Util; +using namespace toolkit; #define DCHECK(x) if(!(x)) { ErrorL << "DCHECK " << #x < (y))) { ErrorL << "DCHECK_GT:" << #x << #y << endl; } diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index 480b0bb8..d0b22125 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -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 */ diff --git a/src/Http/HttpClient.h b/src/Http/HttpClient.h index 4e0c3241..e60c9df4 100644 --- a/src/Http/HttpClient.h +++ b/src/Http/HttpClient.h @@ -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 */ diff --git a/src/Http/HttpClientImp.cpp b/src/Http/HttpClientImp.cpp index 32d74656..31b04617 100644 --- a/src/Http/HttpClientImp.cpp +++ b/src/Http/HttpClientImp.cpp @@ -24,10 +24,9 @@ * SOFTWARE. */ -#include +#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 */ diff --git a/src/Http/HttpClientImp.h b/src/Http/HttpClientImp.h index 05a14894..300f8049 100644 --- a/src/Http/HttpClientImp.h +++ b/src/Http/HttpClientImp.h @@ -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_ */ diff --git a/src/Http/HttpCookie.cpp b/src/Http/HttpCookie.cpp index 0b2636ca..175c9543 100644 --- a/src/Http/HttpCookie.cpp +++ b/src/Http/HttpCookie.cpp @@ -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 HttpCookieStorage::get(const string &host, const string } -} /* namespace Http */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Http/HttpCookie.h b/src/Http/HttpCookie.h index 2037c79e..54d1db14 100644 --- a/src/Http/HttpCookie.h +++ b/src/Http/HttpCookie.h @@ -34,8 +34,7 @@ #include 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 diff --git a/src/Http/HttpDownloader.cpp b/src/Http/HttpDownloader.cpp index 10c817e3..b939a9d8 100644 --- a/src/Http/HttpDownloader.cpp +++ b/src/Http/HttpDownloader.cpp @@ -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 */ diff --git a/src/Http/HttpDownloader.h b/src/Http/HttpDownloader.h index f314c47e..2c694c8a 100644 --- a/src/Http/HttpDownloader.h +++ b/src/Http/HttpDownloader.h @@ -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_ */ diff --git a/src/Http/HttpRequestSplitter.cpp b/src/Http/HttpRequestSplitter.cpp index af7fe663..00e6e5fa 100644 --- a/src/Http/HttpRequestSplitter.cpp +++ b/src/Http/HttpRequestSplitter.cpp @@ -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 */ diff --git a/src/Http/HttpRequestSplitter.h b/src/Http/HttpRequestSplitter.h index f0781e85..4b05d137 100644 --- a/src/Http/HttpRequestSplitter.h +++ b/src/Http/HttpRequestSplitter.h @@ -30,8 +30,7 @@ #include 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 diff --git a/src/Http/HttpRequester.cpp b/src/Http/HttpRequester.cpp index 60793c79..68e4fa77 100644 --- a/src/Http/HttpRequester.cpp +++ b/src/Http/HttpRequester.cpp @@ -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 diff --git a/src/Http/HttpRequester.h b/src/Http/HttpRequester.h index b86a644b..36032379 100644 --- a/src/Http/HttpRequester.h +++ b/src/Http/HttpRequester.h @@ -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 */ diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 487dfc27..88de812a 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -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 &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 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 weakSelf = dynamic_pointer_cast(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 HttpSession::getSharedPtr(){ return dynamic_pointer_cast(shared_from_this()); } -} /* namespace Http */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index 12897160..16cd23a4 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -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_ */ diff --git a/src/Http/HttpsSession.h b/src/Http/HttpsSession.h index 0de64e71..70e6c173 100644 --- a/src/Http/HttpsSession.h +++ b/src/Http/HttpsSession.h @@ -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 EchoWebSocketSession; typedef WebSocketSession SSLEchoWebSocketSession; -} /* namespace Http */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_HTTP_HTTPSSESSION_H_ */ diff --git a/src/Http/WebSocketSplitter.cpp b/src/Http/WebSocketSplitter.cpp index 3a026811..ee661b22 100644 --- a/src/Http/WebSocketSplitter.cpp +++ b/src/Http/WebSocketSplitter.cpp @@ -30,11 +30,9 @@ #include #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 */ diff --git a/src/Http/WebSocketSplitter.h b/src/Http/WebSocketSplitter.h index ef8bf9eb..ad0dd074 100644 --- a/src/Http/WebSocketSplitter.h +++ b/src/Http/WebSocketSplitter.h @@ -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 diff --git a/src/Http/strCoding.cpp b/src/Http/strCoding.cpp index 78fc04d4..6c11e1e1 100644 --- a/src/Http/strCoding.cpp +++ b/src/Http/strCoding.cpp @@ -31,8 +31,7 @@ #include #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 */ diff --git a/src/Http/strCoding.h b/src/Http/strCoding.h index ea1382eb..b86af081 100644 --- a/src/Http/strCoding.h +++ b/src/Http/strCoding.h @@ -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_ */ diff --git a/src/MediaFile/HLSMaker.cpp b/src/MediaFile/HLSMaker.cpp index e0c63c05..4fc5136b 100644 --- a/src/MediaFile/HLSMaker.cpp +++ b/src/MediaFile/HLSMaker.cpp @@ -27,11 +27,9 @@ #include "HLSMaker.h" #include "Util/File.h" #include "Util/uv_errno.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace MediaFile { +namespace mediakit { HLSMaker::HLSMaker(const string& strM3u8File, uint32_t ui32BufSize, @@ -184,6 +182,5 @@ bool HLSMaker::removets() { return true; } -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/MediaFile/HLSMaker.h b/src/MediaFile/HLSMaker.h index ea3973e4..6a464eb7 100644 --- a/src/MediaFile/HLSMaker.h +++ b/src/MediaFile/HLSMaker.h @@ -34,11 +34,9 @@ #include "Util/util.h" #include "Util/logger.h" #include +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace MediaFile { +namespace mediakit { class HLSMaker { public: @@ -75,7 +73,6 @@ private: bool removets(); }; -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* HLSMAKER_H_ */ diff --git a/src/MediaFile/MediaReader.cpp b/src/MediaFile/MediaReader.cpp index ca4fa322..aae801e1 100644 --- a/src/MediaFile/MediaReader.cpp +++ b/src/MediaFile/MediaReader.cpp @@ -28,16 +28,13 @@ #include "Common/config.h" #include "Util/mini.h" #include "Http/HttpSession.h" +using namespace toolkit; -using namespace ZL::Util; - - -namespace ZL { -namespace MediaFile { +namespace mediakit { #ifdef ENABLE_MP4V2 MediaReader::MediaReader(const string &strVhost,const string &strApp, const string &strId) { - GET_CONFIG_AND_REGISTER(string,recordPath,Config::Record::kFilePath); + GET_CONFIG_AND_REGISTER(string,recordPath,Record::kFilePath); auto strFileName = recordPath + "/" + strVhost + "/" + strApp + "/" + strId; @@ -169,7 +166,7 @@ MediaReader::~MediaReader() { void MediaReader::startReadMP4() { auto strongSelf = shared_from_this(); - GET_CONFIG_AND_REGISTER(uint32_t,sampleMS,Config::Record::kSampleMS); + GET_CONFIG_AND_REGISTER(uint32_t,sampleMS,Record::kSampleMS); AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast(this), sampleMS, [strongSelf](){ return strongSelf->readSample(); @@ -323,7 +320,7 @@ void MediaReader::seek(int iSeekTime,bool bReStart){ MediaSource::Ptr MediaReader::onMakeMediaSource(const string &strSchema,const string &strVhost,const string &strApp, const string &strId){ #ifdef ENABLE_MP4V2 - GET_CONFIG_AND_REGISTER(string,appName,Config::Record::kAppName); + GET_CONFIG_AND_REGISTER(string,appName,Record::kAppName); if (strApp != appName) { return nullptr; @@ -343,5 +340,4 @@ MediaSource::Ptr MediaReader::onMakeMediaSource(const string &strSchema,const st -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/MediaFile/MediaReader.h b/src/MediaFile/MediaReader.h index 7c752bb4..b1428a69 100644 --- a/src/MediaFile/MediaReader.h +++ b/src/MediaFile/MediaReader.h @@ -34,13 +34,9 @@ #ifdef ENABLE_MP4V2 #include #endif //ENABLE_MP4V2 +using namespace toolkit; -using namespace ZL::DEV; -using namespace ZL::Rtsp; -using namespace ZL::Rtmp; - -namespace ZL { -namespace MediaFile { +namespace mediakit { class MediaReader : public std::enable_shared_from_this ,public MediaSourceEvent{ public: @@ -103,7 +99,6 @@ private: #endif //ENABLE_MP4V2 }; -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_MEDIAFILE_MEDIAREADER_H_ */ diff --git a/src/MediaFile/MediaRecorder.cpp b/src/MediaFile/MediaRecorder.cpp index 3cdeb845..bcb20d8c 100644 --- a/src/MediaFile/MediaRecorder.cpp +++ b/src/MediaFile/MediaRecorder.cpp @@ -30,12 +30,9 @@ #include "Util/util.h" #include "Util/mini.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace MediaFile { +namespace mediakit { MediaRecorder::MediaRecorder(const string &strVhost_tmp, const string &strApp, @@ -44,10 +41,10 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp, bool enableHls, bool enableMp4) { - GET_CONFIG_AND_REGISTER(string,hlsPath,Config::Hls::kFilePath); - GET_CONFIG_AND_REGISTER(uint32_t,hlsBufSize,Config::Hls::kFileBufSize); - GET_CONFIG_AND_REGISTER(uint32_t,hlsDuration,Config::Hls::kSegmentDuration); - GET_CONFIG_AND_REGISTER(uint32_t,hlsNum,Config::Hls::kSegmentNum); + GET_CONFIG_AND_REGISTER(string,hlsPath,Hls::kFilePath); + GET_CONFIG_AND_REGISTER(uint32_t,hlsBufSize,Hls::kFileBufSize); + GET_CONFIG_AND_REGISTER(uint32_t,hlsDuration,Hls::kSegmentDuration); + GET_CONFIG_AND_REGISTER(uint32_t,hlsNum,Hls::kSegmentNum); string strVhost = strVhost_tmp; if(trim(strVhost).empty()){ @@ -61,8 +58,8 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp, } #ifdef ENABLE_MP4V2 - GET_CONFIG_AND_REGISTER(string,recordPath,Config::Record::kFilePath); - GET_CONFIG_AND_REGISTER(string,recordAppName,Config::Record::kAppName); + GET_CONFIG_AND_REGISTER(string,recordPath,Record::kFilePath); + GET_CONFIG_AND_REGISTER(string,recordAppName,Record::kAppName); if(enableMp4){ auto mp4FilePath = recordPath + "/" + strVhost + "/" + recordAppName + "/" + strApp + "/" + strId + "/"; @@ -96,5 +93,4 @@ void MediaRecorder::inputAAC(void* pData, uint32_t ui32Length, uint32_t ui32Time #endif //ENABLE_MP4V2 } -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/MediaFile/MediaRecorder.h b/src/MediaFile/MediaRecorder.h index 93477f61..205ae698 100644 --- a/src/MediaFile/MediaRecorder.h +++ b/src/MediaFile/MediaRecorder.h @@ -35,13 +35,9 @@ #endif //ENABLE_MP4V2 #include "HLSMaker.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Player; - -namespace ZL { -namespace MediaFile { - +namespace mediakit { class MediaRecorder { public: @@ -70,7 +66,6 @@ private: }; -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_MEDIAFILE_MEDIARECORDER_H_ */ diff --git a/src/MediaFile/Mp4Maker.cpp b/src/MediaFile/Mp4Maker.cpp index 2d469014..0356ac84 100644 --- a/src/MediaFile/Mp4Maker.cpp +++ b/src/MediaFile/Mp4Maker.cpp @@ -34,11 +34,9 @@ #include "Util/mini.h" #include "Util/util.h" #include "Util/NoticeCenter.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace MediaFile { +namespace mediakit { string timeStr(const char *fmt) { std::tm tm_snapshot; @@ -116,7 +114,7 @@ void Mp4Maker::inputAAC(void *pData, uint32_t ui32Length, uint32_t ui32TimeStamp } void Mp4Maker::_inputH264(void* pData, uint32_t ui32Length, uint32_t ui32Duration, int iType) { - GET_CONFIG_AND_REGISTER(uint32_t,recordSec,Config::Record::kFileSecond); + GET_CONFIG_AND_REGISTER(uint32_t,recordSec,Record::kFileSecond); if(iType == 5 && (_hMp4 == MP4_INVALID_FILE_HANDLE || _ticker.elapsedTime() > recordSec * 1000)){ //在I帧率处新建MP4文件 @@ -129,7 +127,7 @@ void Mp4Maker::_inputH264(void* pData, uint32_t ui32Length, uint32_t ui32Duratio } void Mp4Maker::_inputAAC(void* pData, uint32_t ui32Length, uint32_t ui32Duration) { - GET_CONFIG_AND_REGISTER(uint32_t,recordSec,Config::Record::kFileSecond); + GET_CONFIG_AND_REGISTER(uint32_t,recordSec,Record::kFileSecond); //todo(xzl) 修复此处 @@ -161,7 +159,7 @@ void Mp4Maker::createFile() { _info.strFileName = strTime + ".mp4"; _info.strFilePath = strFile; - GET_CONFIG_AND_REGISTER(string,appName,Config::Record::kAppName); + GET_CONFIG_AND_REGISTER(string,appName,Record::kAppName); _info.strUrl = _info.strVhost + "/" + appName + "/" @@ -230,12 +228,11 @@ void Mp4Maker::closeFile() { stat(_strFile.data(), &fileData); _info.ui64FileSize = fileData.st_size; //----record 业务逻辑----// - NoticeCenter::Instance().emitEvent(Config::Broadcast::kBroadcastRecordMP4,_info,*this); + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordMP4,_info,*this); } } -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ENABLE_MP4V2 diff --git a/src/MediaFile/Mp4Maker.h b/src/MediaFile/Mp4Maker.h index 49149a5a..8cfe3dff 100644 --- a/src/MediaFile/Mp4Maker.h +++ b/src/MediaFile/Mp4Maker.h @@ -37,13 +37,9 @@ #include "Util/logger.h" #include "Util/TimeTicker.h" #include "Util/TimeTicker.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; - -namespace ZL { -namespace MediaFile { +namespace mediakit { class Mp4Info { @@ -98,8 +94,7 @@ private: Mp4Info _info; }; -} /* namespace MediaFile */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif ///ENABLE_MP4V2 diff --git a/src/MediaFile/TSMaker.cpp b/src/MediaFile/TSMaker.cpp index 66d3c418..9c8538f0 100644 --- a/src/MediaFile/TSMaker.cpp +++ b/src/MediaFile/TSMaker.cpp @@ -26,8 +26,7 @@ #include "TSMaker.h" #include "Util/logger.h" - -using namespace ZL::Util; +using namespace toolkit; TSMaker::TSMaker() { m_pOutVideoTs = NULL; diff --git a/src/MediaFile/TSMaker.h b/src/MediaFile/TSMaker.h index a5f9fbc8..fd420e78 100644 --- a/src/MediaFile/TSMaker.h +++ b/src/MediaFile/TSMaker.h @@ -34,9 +34,8 @@ #include #include #include "Util/File.h" - using namespace std; -using namespace ZL::Util; +using namespace toolkit; #define TS_PACKET_SIZE 188 #define TS_PACKET_HEADER 4 diff --git a/src/Player/Frame.cpp b/src/Player/Frame.cpp index 5bc00601..1f9359d8 100644 --- a/src/Player/Frame.cpp +++ b/src/Player/Frame.cpp @@ -3,3 +3,7 @@ // #include "Frame.h" + +namespace mediakit{ + +} \ No newline at end of file diff --git a/src/Player/Frame.h b/src/Player/Frame.h index 2ec25772..3ab8d692 100644 --- a/src/Player/Frame.h +++ b/src/Player/Frame.h @@ -7,9 +7,9 @@ #include "Util/RingBuffer.h" #include "Network/Socket.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; +namespace mediakit{ typedef enum { CodecInvalid = -1, @@ -290,6 +290,6 @@ public: } ; - +}//namespace mediakit #endif //ZLMEDIAKIT_FRAME_H diff --git a/src/Player/MediaPlayer.cpp b/src/Player/MediaPlayer.cpp index 8b8d1ddd..cc2df9db 100644 --- a/src/Player/MediaPlayer.cpp +++ b/src/Player/MediaPlayer.cpp @@ -28,12 +28,9 @@ #include "MediaPlayer.h" #include "Rtmp/RtmpPlayerImp.h" #include "Rtsp/RtspPlayerImp.h" +using namespace toolkit; -using namespace ZL::Rtmp; -using namespace ZL::Rtsp; - -namespace ZL { -namespace Player { +namespace mediakit { MediaPlayer::MediaPlayer() { } @@ -78,5 +75,4 @@ void MediaPlayer::teardown() { } -} /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Player/MediaPlayer.h b/src/Player/MediaPlayer.h index 6dd52351..13649781 100644 --- a/src/Player/MediaPlayer.h +++ b/src/Player/MediaPlayer.h @@ -34,14 +34,9 @@ #include "Rtsp/RtspPlayer.h" #include "Rtmp/RtmpPlayer.h" #include "Thread/TaskExecutor.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Rtsp; -using namespace ZL::Rtmp; -using namespace ZL::Thread; - -namespace ZL { -namespace Player { +namespace mediakit { class MediaPlayer : public PlayerImp { public: @@ -58,7 +53,6 @@ private: }; -} /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_PLAYER_MEDIAPLAYER_H_ */ diff --git a/src/Player/Player.cpp b/src/Player/Player.cpp index 8ad171c0..6825a2aa 100644 --- a/src/Player/Player.cpp +++ b/src/Player/Player.cpp @@ -28,9 +28,7 @@ #include "Player.h" #include "H264/SPSParser.h" #include "Util/logger.h" - -using namespace ZL::Util; - +using namespace toolkit; void writeAdtsHeader(const AACFrame &hed, uint8_t *pcAdts) { pcAdts[0] = (hed.syncword >> 4 & 0xFF); //8bit diff --git a/src/Player/Player.h b/src/Player/Player.h index 78cb1682..a9b090c7 100644 --- a/src/Player/Player.h +++ b/src/Player/Player.h @@ -31,6 +31,7 @@ #include "Frame.h" using namespace std; +using namespace mediakit; unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, diff --git a/src/Player/PlayerBase.cpp b/src/Player/PlayerBase.cpp index e624cd17..d8a4e184 100644 --- a/src/Player/PlayerBase.cpp +++ b/src/Player/PlayerBase.cpp @@ -29,13 +29,9 @@ #include "Rtsp/Rtsp.h" #include "Rtsp/RtspPlayerImp.h" #include "Rtmp/RtmpPlayerImp.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Rtmp; -using namespace ZL::Rtsp; - -namespace ZL { -namespace Player { +namespace mediakit { const char PlayerBase::kNetAdapter[] = "net_adapter"; const char PlayerBase::kRtpType[] = "rtp_type"; @@ -55,5 +51,4 @@ PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) { return PlayerBase::Ptr(new RtspPlayerImp()); } -} /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Player/PlayerBase.h b/src/Player/PlayerBase.h index adf62339..dbd6f722 100644 --- a/src/Player/PlayerBase.h +++ b/src/Player/PlayerBase.h @@ -38,14 +38,9 @@ #include "Common/MediaSource.h" #include "Frame.h" #include "Track.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Media; -using namespace ZL::Network; - -namespace ZL { -namespace Player { +namespace mediakit { class PlayerBase : public mINI{ public: @@ -170,7 +165,6 @@ protected: MediaSource::Ptr _pMediaSrc; }; -} /* namespace Player */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_PLAYER_PLAYERBASE_H_ */ diff --git a/src/Player/Track.h b/src/Player/Track.h index b8e1c97b..bbe97c67 100644 --- a/src/Player/Track.h +++ b/src/Player/Track.h @@ -11,9 +11,9 @@ #include "Util/RingBuffer.h" #include "Rtsp/Rtsp.h" #include "Player.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; +namespace mediakit{ class Track : public FrameRing , public CodecInfo{ public: @@ -324,5 +324,6 @@ private: int _channel = 0; }; +}//namespace mediakit #endif //ZLMEDIAKIT_TRACK_H diff --git a/src/Rtmp/FlvMuxer.cpp b/src/Rtmp/FlvMuxer.cpp index 57e5313c..fac7de0f 100644 --- a/src/Rtmp/FlvMuxer.cpp +++ b/src/Rtmp/FlvMuxer.cpp @@ -8,8 +8,7 @@ #define FILE_BUF_SIZE (64 * 1024) -namespace ZL { -namespace Rtmp { +namespace mediakit { FlvMuxer::FlvMuxer() { @@ -227,5 +226,4 @@ FlvRecorder::~FlvRecorder() { } - }//namespace Rtmp -}//namespace ZL +}//namespace mediakit diff --git a/src/Rtmp/FlvMuxer.h b/src/Rtmp/FlvMuxer.h index bb754395..1f57a4c2 100644 --- a/src/Rtmp/FlvMuxer.h +++ b/src/Rtmp/FlvMuxer.h @@ -8,11 +8,9 @@ #include "Rtmp.h" #include "RtmpMediaSource.h" #include "Network/Socket.h" +using namespace toolkit; -using namespace ZL::Network; - -namespace ZL { -namespace Rtmp { +namespace mediakit { class FlvMuxer{ public: @@ -55,7 +53,6 @@ private: }; -}//namespace Rtmp -}//namespace ZL +}//namespace mediakit #endif //ZLMEDIAKIT_FLVRECORDER_H diff --git a/src/Rtmp/Rtmp.h b/src/Rtmp/Rtmp.h index af20b58a..c5f01097 100644 --- a/src/Rtmp/Rtmp.h +++ b/src/Rtmp/Rtmp.h @@ -31,10 +31,7 @@ #include "Util/util.h" #include "Util/logger.h" #include "Network/sockutil.h" - -using namespace std; -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; #define PORT 1935 #define DEFAULT_CHUNK_LEN 128 diff --git a/src/Rtmp/RtmpMediaSource.h b/src/Rtmp/RtmpMediaSource.h index c4c6c833..9716a4c1 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -44,14 +44,9 @@ #include "Util/ResourcePool.h" #include "Util/NoticeCenter.h" #include "Thread/ThreadPool.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Thread; -using namespace ZL::Media; - -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpMediaSource: public MediaSource { public: @@ -122,7 +117,6 @@ protected: bool _bRegisted = false; }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPMEDIASOURCE_H_ */ diff --git a/src/Rtmp/RtmpParser.cpp b/src/Rtmp/RtmpParser.cpp index 4caa660f..fe48a6ef 100644 --- a/src/Rtmp/RtmpParser.cpp +++ b/src/Rtmp/RtmpParser.cpp @@ -26,8 +26,7 @@ #include "RtmpParser.h" -namespace ZL { -namespace Rtmp { +namespace mediakit { RtmpParser::RtmpParser(const AMFValue &val) { auto videoCodec = val["videocodecid"]; @@ -232,29 +231,4 @@ inline void RtmpParser::onCheckMedia(const AMFValue& obj) { } - - - - - - - - - - - - - - - - - - - - - - - - -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpParser.h b/src/Rtmp/RtmpParser.h index 4554f20e..a3888f24 100644 --- a/src/Rtmp/RtmpParser.h +++ b/src/Rtmp/RtmpParser.h @@ -34,16 +34,12 @@ #include "Player/Player.h" #include "Util/TimeTicker.h" #include "Player/PlayerBase.h" - -using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; +using namespace toolkit; #define H264_CODEC_ID 7 #define AAC_CODEC_ID 10 -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpParser : public PlayerBase{ public: @@ -112,7 +108,6 @@ private: }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPPARSER_H_ */ diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 1385865d..9dfa262e 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -30,11 +30,9 @@ #include "Util/util.h" #include "Util/onceToken.h" #include "Thread/ThreadPool.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace Rtmp { +namespace mediakit { unordered_map RtmpPlayer::g_mapCmd; RtmpPlayer::RtmpPlayer() { @@ -351,6 +349,5 @@ void RtmpPlayer::seekToTime(float fTime){ } -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpPlayer.h b/src/Rtmp/RtmpPlayer.h index dc7594ea..c62b1880 100644 --- a/src/Rtmp/RtmpPlayer.h +++ b/src/Rtmp/RtmpPlayer.h @@ -39,14 +39,9 @@ #include "Util/TimeTicker.h" #include "Network/Socket.h" #include "Network/TcpClient.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; -using namespace ZL::Network; - -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpPlayer:public PlayerBase, public TcpClient, public RtmpProtocol{ public: @@ -156,7 +151,6 @@ private: Ticker _aNowStampTicker[2]; }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RtmpPlayer2_H_ */ diff --git a/src/Rtmp/RtmpPlayerImp.h b/src/Rtmp/RtmpPlayerImp.h index 860b74c1..c55c6b0c 100644 --- a/src/Rtmp/RtmpPlayerImp.h +++ b/src/Rtmp/RtmpPlayerImp.h @@ -35,13 +35,10 @@ #include "RtmpMediaSource.h" #include "Poller/Timer.h" #include "Util/TimeTicker.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; +namespace mediakit { -namespace ZL { -namespace Rtmp { class RtmpPlayerImp: public PlayerImp { public: typedef std::shared_ptr Ptr; @@ -92,7 +89,6 @@ private: }; -} /* namespace Rtmp */ -} /* namespace ZL */ - +} /* namespace mediakit */ + #endif /* SRC_RTMP_RTMPPLAYERIMP_H_ */ diff --git a/src/Rtmp/RtmpProtocol.cpp b/src/Rtmp/RtmpProtocol.cpp index 40f9853b..58e81aa8 100644 --- a/src/Rtmp/RtmpProtocol.cpp +++ b/src/Rtmp/RtmpProtocol.cpp @@ -29,7 +29,7 @@ #include "Util/util.h" #include "Util/onceToken.h" #include "Thread/ThreadPool.h" -using namespace ZL::Util; +using namespace toolkit; #ifdef ENABLE_OPENSSL #include "Util/SSLBox.h" @@ -72,8 +72,7 @@ static string openssl_HMACsha256(const void *key,unsigned int key_len, #define S2_FMS_KEY_SIZE 68 #define C1_OFFSET_SIZE 4 -namespace ZL { -namespace Rtmp { +namespace mediakit { RtmpProtocol::RtmpProtocol() { _nextHandle = [this](){ @@ -697,5 +696,4 @@ BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, int len) { return buffer; } -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpProtocol.h b/src/Rtmp/RtmpProtocol.h index a835baf1..72099f5b 100644 --- a/src/Rtmp/RtmpProtocol.h +++ b/src/Rtmp/RtmpProtocol.h @@ -39,11 +39,9 @@ #include "Util/ResourcePool.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpProtocol { public: @@ -119,7 +117,6 @@ private: function _nextHandle; }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPPROTOCOL_H_ */ diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index 5de6ccfe..f63bcdcf 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -29,11 +29,9 @@ #include "Util/util.h" #include "Util/onceToken.h" #include "Thread/ThreadPool.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace Rtmp { +namespace mediakit { static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE; @@ -286,6 +284,5 @@ void RtmpPusher::onRtmpChunk(RtmpPacket &chunkData) { } -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpPusher.h b/src/Rtmp/RtmpPusher.h index 9dc73fcd..795f658b 100644 --- a/src/Rtmp/RtmpPusher.h +++ b/src/Rtmp/RtmpPusher.h @@ -31,8 +31,7 @@ #include "RtmpMediaSource.h" #include "Network/TcpClient.h" -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpPusher: public RtmpProtocol , public TcpClient{ public: @@ -123,7 +122,6 @@ private: Event _onPublished; }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPPUSHER_H_ */ diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 37e5a178..559aa706 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -29,8 +29,7 @@ #include "Common/config.h" #include "Util/onceToken.h" -namespace ZL { -namespace Rtmp { +namespace mediakit { static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE; @@ -191,7 +190,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) { onRes(err); }); }; - auto flag = NoticeCenter::Instance().emitEvent(Config::Broadcast::kBroadcastRtmpPublish, + auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRtmpPublish, _mediaInfo, invoker, *this); @@ -506,7 +505,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) { if (!_pPublisherSrc) { throw std::runtime_error("Not a rtmp publisher!"); } - GET_CONFIG_AND_REGISTER(bool,rtmp_modify_stamp,Config::Rtmp::kModifyStamp); + GET_CONFIG_AND_REGISTER(bool,rtmp_modify_stamp,Rtmp::kModifyStamp); if(rtmp_modify_stamp){ chunkData.timeStamp = _stampTicker[chunkData.typeId % 2].elapsedTime(); } @@ -565,5 +564,4 @@ void RtmpSession::cancelDelyaTask(){ } -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index d4fa59e0..1acc7c0e 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -37,12 +37,9 @@ #include "Util/util.h" #include "Util/TimeTicker.h" #include "Network/TcpSession.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpSession: public TcpSession ,public RtmpProtocol , public MediaSourceEvent{ public: @@ -107,7 +104,6 @@ private: }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPSESSION_H_ */ diff --git a/src/Rtmp/RtmpToRtspMediaSource.cpp b/src/Rtmp/RtmpToRtspMediaSource.cpp index b13e3fac..4d03eaea 100644 --- a/src/Rtmp/RtmpToRtspMediaSource.cpp +++ b/src/Rtmp/RtmpToRtspMediaSource.cpp @@ -29,12 +29,9 @@ #include "Util/util.h" #include "Util/base64.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Rtmp { +namespace mediakit { RtmpToRtspMediaSource::RtmpToRtspMediaSource(const string &vhost, const string &app, @@ -89,7 +86,7 @@ void RtmpToRtspMediaSource::makeSDP() { // _pRtspSrc->onGetRTP(pkt,bKeyPos); // }; // -// GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,Config::Rtp::kVideoMtuSize); +// GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,Rtp::kVideoMtuSize); // _pRtpMaker_h264.reset(new RtpMaker_H264(lam, ssrc0,videoMtu)); // // char strTemp[100]; @@ -131,7 +128,7 @@ void RtmpToRtspMediaSource::makeSDP() { // auto lam = [this](const RtpPacket::Ptr &pkt, bool bKeyPos) { // _pRtspSrc->onGetRTP(pkt,bKeyPos); // }; -// GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,Config::Rtp::kAudioMtuSize); +// GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,Rtp::kAudioMtuSize); // _pRtpMaker_aac.reset(new RtpMaker_AAC(lam, ssrc1, audioMtu,_pParser->getAudioSampleRate())); // // char configStr[32]; @@ -159,5 +156,4 @@ void RtmpToRtspMediaSource::makeSDP() { } -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtmp/RtmpToRtspMediaSource.h b/src/Rtmp/RtmpToRtspMediaSource.h index 99504743..6628a356 100644 --- a/src/Rtmp/RtmpToRtspMediaSource.h +++ b/src/Rtmp/RtmpToRtspMediaSource.h @@ -43,14 +43,10 @@ #include "Util/util.h" #include "Util/logger.h" #include "MediaFile/MediaRecorder.h" - using namespace std; -using namespace ZL::Util; -using namespace ZL::Rtsp; -using namespace ZL::MediaFile; +using namespace toolkit; -namespace ZL { -namespace Rtmp { +namespace mediakit { class RtmpToRtspMediaSource: public RtmpMediaSource { public: @@ -100,7 +96,6 @@ private: void makeSDP(); }; -} /* namespace Rtmp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTMP_RTMPTORTSPMEDIASOURCE_H_ */ diff --git a/src/Rtmp/amf.cpp b/src/Rtmp/amf.cpp index d481c5a9..b3789b81 100644 --- a/src/Rtmp/amf.cpp +++ b/src/Rtmp/amf.cpp @@ -30,9 +30,7 @@ #include "Util/util.h" #include "Util/logger.h" #include "Network/sockutil.h" - -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; /////////////////////AMFValue///////////////////////////// inline void AMFValue::destroy() { diff --git a/src/Rtmp/utils.cpp b/src/Rtmp/utils.cpp index 780caff2..89aca078 100644 --- a/src/Rtmp/utils.cpp +++ b/src/Rtmp/utils.cpp @@ -30,9 +30,7 @@ #include #include "Util/util.h" #include "Network/sockutil.h" - -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; /* * Used to do unaligned loads on archs that don't support them. GCC can mostly diff --git a/src/RtmpCodec/AACRtmpCodec.cpp b/src/RtmpCodec/AACRtmpCodec.cpp index 746e71ca..6ac02098 100644 --- a/src/RtmpCodec/AACRtmpCodec.cpp +++ b/src/RtmpCodec/AACRtmpCodec.cpp @@ -5,8 +5,7 @@ #include #include "AACRtmpCodec.h" -namespace ZL{ -namespace Rtmp { +namespace mediakit{ AACRtmpDecoder::AACRtmpDecoder() { _adts = obtainFrame(); @@ -127,13 +126,4 @@ void AACRtmpEncoder::makeAudioConfigPkt() { - - - - - - - - -}//namespace Rtmp -}//namespace ZL \ No newline at end of file +}//namespace mediakit \ No newline at end of file diff --git a/src/RtmpCodec/AACRtmpCodec.h b/src/RtmpCodec/AACRtmpCodec.h index e704c482..a2b2e994 100644 --- a/src/RtmpCodec/AACRtmpCodec.h +++ b/src/RtmpCodec/AACRtmpCodec.h @@ -7,8 +7,7 @@ #include "RtmpCodec.h" -namespace ZL{ -namespace Rtmp { +namespace mediakit{ /** * aac Rtmp转adts类 */ @@ -64,7 +63,6 @@ private: uint8_t _ui8AudioFlags; }; -}//namespace Rtmp -}//namespace ZL +}//namespace mediakit #endif //ZLMEDIAKIT_AACRTMPCODEC_H diff --git a/src/RtmpCodec/H264RtmpCodec.cpp b/src/RtmpCodec/H264RtmpCodec.cpp index 4b42c99c..e46932ec 100644 --- a/src/RtmpCodec/H264RtmpCodec.cpp +++ b/src/RtmpCodec/H264RtmpCodec.cpp @@ -4,6 +4,7 @@ #include "H264RtmpCodec.h" +namespace mediakit{ H264RtmpDecoder::H264RtmpDecoder() { _h264frame = obtainFrame(); @@ -185,20 +186,7 @@ void H264RtmpEncoder::makeVideoConfigPkt() { } - - - - - - - - - - - - - - +}//namespace mediakit diff --git a/src/RtmpCodec/H264RtmpCodec.h b/src/RtmpCodec/H264RtmpCodec.h index 2cdf2629..48b074f9 100644 --- a/src/RtmpCodec/H264RtmpCodec.h +++ b/src/RtmpCodec/H264RtmpCodec.h @@ -7,9 +7,9 @@ #include "RtmpCodec.h" #include "Util/ResourcePool.h" +using namespace toolkit; -using namespace ZL::Rtmp; - +namespace mediakit{ /** * h264 Rtmp解码类 */ @@ -64,4 +64,6 @@ private: void makeVideoConfigPkt(); }; +}//namespace mediakit + #endif //ZLMEDIAKIT_H264RTMPCODEC_H diff --git a/src/RtmpCodec/RtmpCodec.cpp b/src/RtmpCodec/RtmpCodec.cpp index 9c7a71be..c0610cfe 100644 --- a/src/RtmpCodec/RtmpCodec.cpp +++ b/src/RtmpCodec/RtmpCodec.cpp @@ -3,3 +3,6 @@ // #include "RtmpCodec.h" +namespace mediakit{ + +} \ No newline at end of file diff --git a/src/RtmpCodec/RtmpCodec.h b/src/RtmpCodec/RtmpCodec.h index 46201144..2869bfaa 100644 --- a/src/RtmpCodec/RtmpCodec.h +++ b/src/RtmpCodec/RtmpCodec.h @@ -8,12 +8,9 @@ #include "Rtmp/Rtmp.h" #include "Player/Frame.h" #include "Util/RingBuffer.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL{ -namespace Rtmp { - +namespace mediakit{ class RtmpRingInterface { public: @@ -78,9 +75,6 @@ public: }; - - -}//namespace Rtmp -}//namespace ZL +}//namespace mediakit #endif //ZLMEDIAKIT_RTMPCODEC_H diff --git a/src/RtpCodec/AACRtpCodec.cpp b/src/RtpCodec/AACRtpCodec.cpp index 282cac53..20192afc 100644 --- a/src/RtpCodec/AACRtpCodec.cpp +++ b/src/RtpCodec/AACRtpCodec.cpp @@ -4,6 +4,8 @@ #include "AACRtpCodec.h" +namespace mediakit{ + AACRtpEncoder::AACRtpEncoder(uint32_t ui32Ssrc, uint32_t ui32MtuSize, uint32_t ui32SampleRate, @@ -20,7 +22,7 @@ AACRtpEncoder::AACRtpEncoder(uint32_t ui32Ssrc, void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) { RtpCodec::inputFrame(frame); - GET_CONFIG_AND_REGISTER(uint32_t, cycleMS, Config::Rtp::kCycleMS); + GET_CONFIG_AND_REGISTER(uint32_t, cycleMS, Rtp::kCycleMS); auto uiStamp = frame->stamp(); auto pcData = frame->data() + frame->prefixSize(); auto iLen = frame->size() - frame->prefixSize(); @@ -125,6 +127,7 @@ void AACRtpDecoder::onGetAAC(const AACFrame::Ptr &frame) { _adts = obtainFrame(); } +}//namespace mediakit diff --git a/src/RtpCodec/AACRtpCodec.h b/src/RtpCodec/AACRtpCodec.h index de1571a3..81b083f9 100644 --- a/src/RtpCodec/AACRtpCodec.h +++ b/src/RtpCodec/AACRtpCodec.h @@ -7,6 +7,7 @@ #include "RtpCodec.h" +namespace mediakit{ /** * aac rtp转adts类 */ @@ -75,5 +76,6 @@ private: unsigned char _aucSectionBuf[1600]; }; +}//namespace mediakit #endif //ZLMEDIAKIT_AACRTPCODEC_H diff --git a/src/RtpCodec/H264RtpCodec.cpp b/src/RtpCodec/H264RtpCodec.cpp index e54ad040..c15b155e 100644 --- a/src/RtpCodec/H264RtpCodec.cpp +++ b/src/RtpCodec/H264RtpCodec.cpp @@ -4,6 +4,7 @@ #include "H264RtpCodec.h" +namespace mediakit{ H264RtpDecoder::H264RtpDecoder() { _h264frame = obtainFrame(); @@ -121,7 +122,7 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ui32Ssrc, void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) { RtpCodec::inputFrame(frame); - GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Config::Rtp::kCycleMS); + GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Rtp::kCycleMS); auto pcData = frame->data() + frame->prefixSize(); auto uiStamp = frame->stamp(); auto iLen = frame->size() - frame->prefixSize(); @@ -202,4 +203,6 @@ void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark, uint8_t type = ((uint8_t *) (data))[0] & 0x1F; RtpCodec::inputRtp(rtppkt,type == 5); _ui16Sequence++; -} \ No newline at end of file +} + +}//namespace mediakit \ No newline at end of file diff --git a/src/RtpCodec/H264RtpCodec.h b/src/RtpCodec/H264RtpCodec.h index 1a8e13ba..2f4d923d 100644 --- a/src/RtpCodec/H264RtpCodec.h +++ b/src/RtpCodec/H264RtpCodec.h @@ -7,8 +7,9 @@ #include "RtpCodec.h" #include "Util/ResourcePool.h" +using namespace toolkit; -using namespace ZL::Util; +namespace mediakit{ /** * h264 rtp解码类 @@ -74,5 +75,6 @@ private: unsigned char _aucSectionBuf[1600]; }; +}//namespace mediakit{ #endif //ZLMEDIAKIT_H264RTPCODEC_H diff --git a/src/RtpCodec/RtpCodec.h b/src/RtpCodec/RtpCodec.h index cfc04b45..8c33af11 100644 --- a/src/RtpCodec/RtpCodec.h +++ b/src/RtpCodec/RtpCodec.h @@ -9,10 +9,9 @@ #include "Util/RingBuffer.h" #include "Rtsp/Rtsp.h" #include "Player/PlayerBase.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; +namespace mediakit{ class RtpPacket : public CodecInfo { public: @@ -156,7 +155,7 @@ public: virtual ~RtpCodec(){} }; - +}//namespace mediakit diff --git a/src/RtpCodec/RtpMaker.h b/src/RtpCodec/RtpMaker.h index 42a5d40d..81a45318 100644 --- a/src/RtpCodec/RtpMaker.h +++ b/src/RtpCodec/RtpMaker.h @@ -34,12 +34,9 @@ #include "Util/TimeTicker.h" #include "Util/ResourcePool.h" #include "Thread/ThreadPool.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Thread; - -namespace ZL { -namespace Rtsp { +namespace mediakit{ class RtpMaker { public: @@ -102,7 +99,7 @@ private: onGetRTP callBack; }; -} /* namespace RTP */ -} /* namespace ZL */ +} //namespace mediakit + #endif /* RTP_RTPMAKER_H_ */ diff --git a/src/RtpCodec/RtpMakerAAC.cpp b/src/RtpCodec/RtpMakerAAC.cpp index 6697d25b..9b399ef8 100644 --- a/src/RtpCodec/RtpMakerAAC.cpp +++ b/src/RtpCodec/RtpMakerAAC.cpp @@ -28,15 +28,12 @@ #include "RtpMakerAAC.h" #include "Util/mini.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Rtsp { +namespace mediakit{ void RtpMaker_AAC::makeRtp(const char *pcData, int iLen, uint32_t uiStamp) { - GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Config::Rtp::kCycleMS); + GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Rtp::kCycleMS); uiStamp %= cycleMS; char *ptr = (char *) pcData; @@ -99,5 +96,4 @@ inline void RtpMaker_AAC::makeAACRtp(const void *pData, unsigned int uiLen, bool _ui16Sequence++; } -} /* namespace RTP */ -} /* namespace ZL */ +}//namespace mediakit \ No newline at end of file diff --git a/src/RtpCodec/RtpMakerAAC.h b/src/RtpCodec/RtpMakerAAC.h index 13f1a71a..29147243 100644 --- a/src/RtpCodec/RtpMakerAAC.h +++ b/src/RtpCodec/RtpMakerAAC.h @@ -35,10 +35,9 @@ #include "Util/ResourcePool.h" using namespace std; -using namespace ZL::Util; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit{ class RtpMaker_AAC: public RtpMaker { public: @@ -56,7 +55,6 @@ private: unsigned char _aucSectionBuf[1600]; }; -} /* namespace RTP */ -} /* namespace ZL */ +}//namespace mediakit #endif /* RTP_RTPMAKERAAC_H_ */ diff --git a/src/RtpCodec/RtpMakerH264.cpp b/src/RtpCodec/RtpMakerH264.cpp index 4a2d3866..b178913b 100644 --- a/src/RtpCodec/RtpMakerH264.cpp +++ b/src/RtpCodec/RtpMakerH264.cpp @@ -28,15 +28,12 @@ #include "RtpMakerH264.h" #include "Util/mini.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Rtsp { +namespace mediakit{ void RtpMaker_H264::makeRtp(const char* pcData, int iLen, uint32_t uiStamp) { - GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Config::Rtp::kCycleMS); + GET_CONFIG_AND_REGISTER(uint32_t,cycleMS,Rtp::kCycleMS); uiStamp %= cycleMS; int iSize = _iMtuSize - 2; @@ -118,5 +115,4 @@ inline void RtpMaker_H264::makeH264Rtp(const void* data, unsigned int len, bool //InfoL< MultiCastAddressMaker::obtain(uint32_t iTry) { lock_guard lck(_mtx); - GET_CONFIG_AND_REGISTER(string,addrMinStr,Config::MultiCast::kAddrMin); - GET_CONFIG_AND_REGISTER(string,addrMaxStr,Config::MultiCast::kAddrMax); + GET_CONFIG_AND_REGISTER(string,addrMinStr,MultiCast::kAddrMin); + GET_CONFIG_AND_REGISTER(string,addrMaxStr,MultiCast::kAddrMax); uint32_t addrMin = addressToInt(addrMinStr); uint32_t addrMax = addressToInt(addrMaxStr); @@ -112,7 +111,7 @@ RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strVhost,c throw std::runtime_error(strErr); } auto fd = _apUdpSock[i]->rawFD(); - GET_CONFIG_AND_REGISTER(uint32_t,udpTTL,Config::MultiCast::kUdpTTL); + GET_CONFIG_AND_REGISTER(uint32_t,udpTTL,MultiCast::kUdpTTL); SockUtil::setMultiTTL(fd, udpTTL); SockUtil::setMultiLOOP(fd, false); @@ -184,8 +183,4 @@ RtpBroadCaster::Ptr RtpBroadCaster::get(const string &strLocalIp,const string &s } - -} /* namespace Rtsp */ -} /* namespace ZL */ - - +}//namespace mediakit diff --git a/src/Rtsp/RtpBroadCaster.h b/src/Rtsp/RtpBroadCaster.h index ddebd60b..1899b83f 100644 --- a/src/Rtsp/RtpBroadCaster.h +++ b/src/Rtsp/RtpBroadCaster.h @@ -39,11 +39,9 @@ #include "Network/Socket.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit{ class MultiCastAddressMaker { @@ -51,8 +49,8 @@ public: static MultiCastAddressMaker &Instance(); static bool isMultiCastAddress(uint32_t iAddr){ - static uint32_t addrMin = mINI::Instance()[Config::MultiCast::kAddrMin].as(); - static uint32_t addrMax = mINI::Instance()[Config::MultiCast::kAddrMax].as(); + static uint32_t addrMin = mINI::Instance()[MultiCast::kAddrMin].as(); + static uint32_t addrMax = mINI::Instance()[MultiCast::kAddrMax].as(); return iAddr >= addrMin && iAddr <= addrMax; } static string toString(uint32_t iAddr){ @@ -93,7 +91,6 @@ private: }; -} /* namespace Rtsp */ -} /* namespace ZL */ +}//namespace mediakit #endif /* SRC_RTSP_RTPBROADCASTER_H_ */ diff --git a/src/Rtsp/RtpParser.cpp b/src/Rtsp/RtpParser.cpp index 42910919..3f148e61 100644 --- a/src/Rtsp/RtpParser.cpp +++ b/src/Rtsp/RtpParser.cpp @@ -33,8 +33,7 @@ using namespace std; -namespace ZL { -namespace Rtsp { +namespace mediakit { static int getTimeInSDP(const string &sdp) { auto strRange = FindField(sdp.data(), "a=range:npt=", "\r\n"); @@ -127,5 +126,4 @@ vector RtpParser::getTracks() const { } -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtsp/RtpParser.h b/src/Rtsp/RtpParser.h index 060e1dbb..7c2d9af4 100644 --- a/src/Rtsp/RtpParser.h +++ b/src/Rtsp/RtpParser.h @@ -35,11 +35,9 @@ #include "RtpCodec/RtpCodec.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { class RtpParser : public PlayerBase{ public: @@ -83,7 +81,6 @@ private: RtpCodec::Ptr _videoRtpDecoder; }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTP_RTPPARSER_H_ */ diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index 3bbd2619..1928ce21 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -35,7 +35,8 @@ #include "Player/Frame.h" using namespace std; -using namespace ZL::Util; +using namespace toolkit; +using namespace mediakit; class RtspTrack{ diff --git a/src/Rtsp/RtspMaker.cpp b/src/Rtsp/RtspMaker.cpp index d089ef89..c854643f 100644 --- a/src/Rtsp/RtspMaker.cpp +++ b/src/Rtsp/RtspMaker.cpp @@ -5,8 +5,7 @@ #include "RtspMaker.h" #include "Common/Factory.h" -namespace ZL { -namespace Rtsp { +namespace mediakit { void RtspMaker::addTrack(const Track::Ptr &track, uint32_t ssrc, int mtu) { if (track->getCodecId() == CodecInvalid) { @@ -19,5 +18,4 @@ void RtspMaker::addTrack(const Track::Ptr &track, uint32_t ssrc, int mtu) { } } -} /* namespace Rtsp */ -} /* namespace ZL */ \ No newline at end of file +} /* namespace mediakit */ \ No newline at end of file diff --git a/src/Rtsp/RtspMaker.h b/src/Rtsp/RtspMaker.h index bcceecab..e384ff7a 100644 --- a/src/Rtsp/RtspMaker.h +++ b/src/Rtsp/RtspMaker.h @@ -7,8 +7,7 @@ #include "RtspSdp.h" -namespace ZL{ -namespace Rtsp{ +namespace mediakit{ /** * rtsp生成器 */ @@ -131,7 +130,6 @@ private: }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ZLMEDIAKIT_RTSPMAKER_H diff --git a/src/Rtsp/RtspMediaSource.h b/src/Rtsp/RtspMediaSource.h index cd3198cd..4d1884dc 100644 --- a/src/Rtsp/RtspMediaSource.h +++ b/src/Rtsp/RtspMediaSource.h @@ -45,12 +45,9 @@ #include "Thread/ThreadPool.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Thread; -using namespace ZL::Media; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { class RtspMediaSource: public MediaSource { public: @@ -102,7 +99,6 @@ protected: RingType::Ptr _pRing; //rtp环形缓冲 }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTSP_RTSPMEDIASOURCE_H_ */ diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index f9e6e1b5..d0b34692 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -37,11 +37,9 @@ #include "Util/util.h" #include "Util/base64.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace Rtsp { +namespace mediakit { #define POP_HEAD(trackidx) \ auto it = _amapRtpSort[trackidx].begin(); \ @@ -656,8 +654,8 @@ bool RtspPlayer::handleOneRtp(int iTrackidx, unsigned char *pucData, unsigned in //开始排序缓存 if (_abSortStarted[iTrackidx]) { _amapRtpSort[iTrackidx].emplace(rtppt.sequence, pt_ptr); - GET_CONFIG_AND_REGISTER(uint32_t,clearCount,Config::Rtp::kClearCount); - GET_CONFIG_AND_REGISTER(uint32_t,maxRtpCount,Config::Rtp::kMaxRtpCount); + GET_CONFIG_AND_REGISTER(uint32_t,clearCount,Rtp::kClearCount); + GET_CONFIG_AND_REGISTER(uint32_t,maxRtpCount,Rtp::kMaxRtpCount); if (_aui64SeqOkCnt[iTrackidx] >= clearCount) { //网络环境改善,需要清空排序缓存 _aui64SeqOkCnt[iTrackidx] = 0; @@ -841,7 +839,6 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType trackType) const { return -1; } -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index 291d85f4..3310bf49 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -41,14 +41,9 @@ #include "Network/TcpClient.h" using namespace std; -using namespace ZL::Rtsp; -using namespace ZL::Player; -using namespace ZL::Util; -using namespace ZL::Poller; -using namespace ZL::Network; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { //实现了rtsp播放器协议部分的功能 class RtspPlayer: public PlayerBase,public TcpClient { @@ -142,7 +137,6 @@ private: Ticker _aNowStampTicker[2]; }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTSPPLAYER_RTSPPLAYER_H_TXT_ */ diff --git a/src/Rtsp/RtspPlayerImp.h b/src/Rtsp/RtspPlayerImp.h index 9ee72631..ff646a03 100644 --- a/src/Rtsp/RtspPlayerImp.h +++ b/src/Rtsp/RtspPlayerImp.h @@ -37,11 +37,9 @@ #include "Util/TimeTicker.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Player; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { class RtspPlayerImp: public PlayerImp { public: @@ -95,7 +93,6 @@ private: }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTP_RTPPARSERTESTER_H_ */ diff --git a/src/Rtsp/RtspSdp.cpp b/src/Rtsp/RtspSdp.cpp index b975abb5..1024a16b 100644 --- a/src/Rtsp/RtspSdp.cpp +++ b/src/Rtsp/RtspSdp.cpp @@ -1,6 +1,8 @@ #include "RtspSdp.h" #include "Common/Factory.h" +namespace mediakit{ + void Sdp::createRtpEncoder(uint32_t ssrc, int mtu) { _encoder = Factory::getRtpEncoderById(getCodecId(), ssrc, @@ -10,5 +12,6 @@ void Sdp::createRtpEncoder(uint32_t ssrc, int mtu) { getTrackType() * 2); } +} diff --git a/src/Rtsp/RtspSdp.h b/src/Rtsp/RtspSdp.h index b0300b8d..46e56c94 100644 --- a/src/Rtsp/RtspSdp.h +++ b/src/Rtsp/RtspSdp.h @@ -10,8 +10,7 @@ #include "Util/base64.h" #include "Player/Track.h" -namespace ZL { -namespace Rtsp { +namespace mediakit { /** * sdp基类 @@ -259,8 +258,7 @@ private: }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index c062ba7a..908664f4 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -36,12 +36,10 @@ #include "Util/NoticeCenter.h" #include "Network/sockutil.h" -using namespace Config; -using namespace ZL::Util; -using namespace ZL::Network; +using namespace std; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE; @@ -301,7 +299,7 @@ void RtspSession::onAuthFailed(const weak_ptr &weakSelf,const strin int n; char response[2 * 1024]; - GET_CONFIG_AND_REGISTER(bool,authBasic,Config::Rtsp::kAuthBasic); + GET_CONFIG_AND_REGISTER(bool,authBasic,Rtsp::kAuthBasic); if (!authBasic) { //我们需要客户端优先以md5方式认证 strongSelf->_strNonce = makeRandStr(32); @@ -1089,6 +1087,5 @@ inline void RtspSession::sendRTCP() { #endif } -/* namespace Session */ -} /* namespace ZL */ +/* namespace mediakit */ diff --git a/src/Rtsp/RtspSession.h b/src/Rtsp/RtspSession.h index 48446967..348c3947 100644 --- a/src/Rtsp/RtspSession.h +++ b/src/Rtsp/RtspSession.h @@ -41,15 +41,9 @@ #include "Http/HttpRequestSplitter.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Rtsp; -using namespace ZL::Player; -using namespace ZL::Network; -using namespace ZL::Http; +using namespace toolkit; - -namespace ZL { -namespace Rtsp { +namespace mediakit { class RtspSession; @@ -205,7 +199,6 @@ private: }; -} /* namespace Session */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SESSION_RTSPSESSION_H_ */ diff --git a/src/Rtsp/RtspToRtmpMediaSource.cpp b/src/Rtsp/RtspToRtmpMediaSource.cpp index 3b5892b4..15546189 100644 --- a/src/Rtsp/RtspToRtmpMediaSource.cpp +++ b/src/Rtsp/RtspToRtmpMediaSource.cpp @@ -30,13 +30,9 @@ #include "RtspToRtmpMediaSource.h" #include "Util/util.h" #include "Network/sockutil.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Rtsp { - +namespace mediakit { RtspToRtmpMediaSource::RtspToRtmpMediaSource(const string &vhost, const string &app, @@ -220,5 +216,5 @@ void RtspToRtmpMediaSource::makeMetaData() { #endif _pRtmpSrc->onGetMetaData(metaData); } -} /* namespace Rtsp */ -} /* namespace ZL */ + +} /* namespace mediakit */ diff --git a/src/Rtsp/RtspToRtmpMediaSource.h b/src/Rtsp/RtspToRtmpMediaSource.h index 27dac23c..7147bff7 100644 --- a/src/Rtsp/RtspToRtmpMediaSource.h +++ b/src/Rtsp/RtspToRtmpMediaSource.h @@ -32,12 +32,10 @@ #include "Rtmp/amf.h" #include "Rtmp/RtmpMediaSource.h" #include "MediaFile/MediaRecorder.h" +using namespace toolkit; -using namespace ZL::Rtmp; -using namespace ZL::MediaFile; +namespace mediakit { -namespace ZL { -namespace Rtsp { class RtspToRtmpMediaSource: public RtspMediaSource { public: typedef std::shared_ptr Ptr; @@ -109,7 +107,6 @@ private: }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_RTSP_RTSPTORTMPMEDIASOURCE_H_ */ diff --git a/src/Rtsp/UDPServer.cpp b/src/Rtsp/UDPServer.cpp index 5f8d99b6..d41490f4 100644 --- a/src/Rtsp/UDPServer.cpp +++ b/src/Rtsp/UDPServer.cpp @@ -26,11 +26,9 @@ #include "UDPServer.h" #include "Util/TimeTicker.h" +using namespace toolkit; -using namespace ZL::Util; - -namespace ZL { -namespace Rtsp { +namespace mediakit { UDPServer &UDPServer::Instance() { static UDPServer *instance(new UDPServer()); @@ -116,7 +114,6 @@ void UDPServer::onRcvData(int iTrackIndex, const Buffer::Ptr &pBuf, struct socka } } -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ diff --git a/src/Rtsp/UDPServer.h b/src/Rtsp/UDPServer.h index 107f240e..67b998d5 100644 --- a/src/Rtsp/UDPServer.h +++ b/src/Rtsp/UDPServer.h @@ -36,11 +36,9 @@ #include "Network/Socket.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Network; +using namespace toolkit; -namespace ZL { -namespace Rtsp { +namespace mediakit { class UDPServer { public: @@ -63,7 +61,6 @@ private: mutex _mtxDataHandler; }; -} /* namespace Rtsp */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* RTSP_UDPSERVER_H_ */ diff --git a/src/Shell/ShellCMD.cpp b/src/Shell/ShellCMD.cpp index cd75b844..83d5a298 100644 --- a/src/Shell/ShellCMD.cpp +++ b/src/Shell/ShellCMD.cpp @@ -4,12 +4,9 @@ #include "Util/CMD.h" #include "Common/MediaSource.h" +using namespace toolkit; -using namespace ZL::Util; -using namespace ZL::Media; - -namespace ZL { -namespace Shell { +namespace mediakit { class CMD_media: public CMD { @@ -94,5 +91,4 @@ static onceToken s_token([]() { }, nullptr); -}/* namespace Shell */ -} /* namespace ZL */ \ No newline at end of file +} /* namespace mediakit */ \ No newline at end of file diff --git a/src/Shell/ShellSession.cpp b/src/Shell/ShellSession.cpp index 88c917b3..110e03f9 100644 --- a/src/Shell/ShellSession.cpp +++ b/src/Shell/ShellSession.cpp @@ -29,12 +29,9 @@ #include "Util/CMD.h" #include "Util/onceToken.h" #include "Util/NoticeCenter.h" +using namespace toolkit; -using namespace Config; -using namespace ZL::Util; - -namespace ZL { -namespace Shell { +namespace mediakit { ShellSession::ShellSession(const std::shared_ptr &_th, const Socket::Ptr &_sock) : @@ -47,7 +44,7 @@ ShellSession::~ShellSession() { void ShellSession::onRecv(const Buffer::Ptr&buf) { //DebugL << hexdump(buf->data(), buf->size()); - GET_CONFIG_AND_REGISTER(uint32_t,maxReqSize,Config::Shell::kMaxReqSize); + GET_CONFIG_AND_REGISTER(uint32_t,maxReqSize,Shell::kMaxReqSize); if (_strRecvBuf.size() + buf->size() >= maxReqSize) { WarnL << "接收缓冲区溢出!"; shutdown(); @@ -161,5 +158,4 @@ inline void ShellSession::printShellPrefix() { send(StrPrinter << _strUserName << "@" << SERVER_NAME << "# " << endl); } -}/* namespace Shell */ -} /* namespace ZL */ +}/* namespace mediakit */ diff --git a/src/Shell/ShellSession.h b/src/Shell/ShellSession.h index 34095e34..ac5859c4 100644 --- a/src/Shell/ShellSession.h +++ b/src/Shell/ShellSession.h @@ -31,13 +31,9 @@ #include "Common/config.h" #include "Util/TimeTicker.h" #include "Network/TcpSession.h" +using namespace toolkit; -using namespace std; -using namespace ZL::Util; -using namespace ZL::Network; - -namespace ZL { -namespace Shell { +namespace mediakit { class ShellSession: public TcpSession { public: @@ -60,7 +56,6 @@ private: string _strUserName; }; -} /* namespace Shell */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* SRC_SHELL_SHELLSESSION_H_ */ diff --git a/tests/DeviceHK/DeviceHK.cpp b/tests/DeviceHK/DeviceHK.cpp index 39f633ce..d924f390 100644 --- a/tests/DeviceHK/DeviceHK.cpp +++ b/tests/DeviceHK/DeviceHK.cpp @@ -27,8 +27,7 @@ #include "DeviceHK.h" #include "Util/TimeTicker.h" #include "Util/MD5.h" -namespace ZL { -namespace DEV { +namespace mediakit { #define HK_APP_NAME "live" @@ -261,7 +260,6 @@ void DevChannelHK::onGetDecData(char* pBuf, int nSize, FRAME_INFO* pFrameInfo) { } } -} /* namespace DEV */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif //ENABLE_HKDEVICE diff --git a/tests/DeviceHK/DeviceHK.h b/tests/DeviceHK/DeviceHK.h index 698e9d5c..ffb1f441 100644 --- a/tests/DeviceHK/DeviceHK.h +++ b/tests/DeviceHK/DeviceHK.h @@ -35,10 +35,9 @@ #include "Util/logger.h" #include "Util/TimeTicker.h" -using namespace ZL::Util; +using namespace toolkit; -namespace ZL { -namespace DEV { +namespace mediakit { class connectInfo { public: @@ -130,7 +129,6 @@ protected: bool m_bAudioSeted = false; }; -} /* namespace DEV */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* DEVICE_DEVICEHK_H_ */ diff --git a/tests/H264Decoder.h b/tests/H264Decoder.h index 19f62bab..eeb8d412 100644 --- a/tests/H264Decoder.h +++ b/tests/H264Decoder.h @@ -41,8 +41,7 @@ extern "C" { using namespace std; -namespace ZL { -namespace Codec { +namespace mediakit { class H264Decoder { @@ -95,8 +94,7 @@ private: }; -} /* namespace Codec */ -} /* namespace ZL */ +} /* namespace mediakit */ #endif /* H264Decoder_H_ */ diff --git a/tests/YuvDisplayer.h b/tests/YuvDisplayer.h index 8d15603a..f818dab3 100644 --- a/tests/YuvDisplayer.h +++ b/tests/YuvDisplayer.h @@ -38,7 +38,8 @@ extern "C" { #pragma comment(lib,"SDL2.lib") #endif //defined(_WIN32) -using namespace ZL::Util; +using namespace toolkit; +using namespace mediakit; #define REFRESH_EVENT (SDL_USEREVENT + 1) diff --git a/tests/test_benchmark.cpp b/tests/test_benchmark.cpp index a641ca18..9f397e38 100644 --- a/tests/test_benchmark.cpp +++ b/tests/test_benchmark.cpp @@ -36,12 +36,8 @@ #include "Thread/WorkThreadPool.h" using namespace std; -using namespace ZL::DEV; -using namespace ZL::Util; -using namespace ZL::Rtsp; -using namespace ZL::Thread; -using namespace ZL::Network; - +using namespace toolkit; +using namespace mediakit; int main(int argc, char *argv[]) { //设置退出信号处理函数 diff --git a/tests/test_httpApi.cpp b/tests/test_httpApi.cpp index 6cc3dc88..b0f3f189 100644 --- a/tests/test_httpApi.cpp +++ b/tests/test_httpApi.cpp @@ -43,13 +43,11 @@ #include "Util/NoticeCenter.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Http; -using namespace ZL::Thread; -using namespace ZL::Network; +using namespace toolkit; +using namespace mediakit; static onceToken s_token([](){ - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastHttpRequest,[](BroadcastHttpRequestArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastHttpRequest,[](BroadcastHttpRequestArgs){ //const Parser &parser,HttpSession::HttpResponseInvoker &invoker,bool &consumed if(strstr(parser.Url().data(),"/api/") != parser.Url().data()){ return; @@ -98,7 +96,7 @@ int main(int argc,char *argv[]){ Logger::Instance().add(std::make_shared("stdout", LTrace)); Logger::Instance().setWriter(std::make_shared()); //加载配置文件,如果配置文件不存在就创建一个 - Config::loadIniConfig(); + loadIniConfig(); #ifdef ENABLE_OPENSSL //请把证书"test_httpApi.pem"放置在本程序可执行程序同目录下 @@ -113,12 +111,12 @@ int main(int argc,char *argv[]){ //开启http服务器 TcpServer::Ptr httpSrv(new TcpServer()); - httpSrv->start(mINI::Instance()[Config::Http::kPort]);//默认80 + httpSrv->start(mINI::Instance()[Http::kPort]);//默认80 #ifdef ENABLE_OPENSSL //如果支持ssl,还可以开启https服务器 TcpServer::Ptr httpsSrv(new TcpServer()); - httpsSrv->start(mINI::Instance()[Config::Http::kSSLPort]);//默认443 + httpsSrv->start(mINI::Instance()[Http::kSSLPort]);//默认443 #endif //ENABLE_OPENSSL InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl; diff --git a/tests/test_httpClient.cpp b/tests/test_httpClient.cpp index b94159db..9c08932d 100644 --- a/tests/test_httpClient.cpp +++ b/tests/test_httpClient.cpp @@ -36,11 +36,8 @@ #include "Http/HttpDownloader.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Http; -using namespace ZL::Poller; -using namespace ZL::Network; - +using namespace toolkit; +using namespace mediakit; int main(int argc, char *argv[]) { //设置退出信号处理函数 diff --git a/tests/test_player.cpp b/tests/test_player.cpp index 721d4348..25769ab0 100644 --- a/tests/test_player.cpp +++ b/tests/test_player.cpp @@ -36,12 +36,8 @@ #include "Network/sockutil.h" using namespace std; -using namespace ZL::Codec; -using namespace ZL::Util; -using namespace ZL::Thread; -using namespace ZL::Network; -using namespace ZL::Rtsp; -using namespace ZL::Player; +using namespace toolkit; +using namespace mediakit; int main(int argc, char *argv[]) { //设置退出信号处理函数 diff --git a/tests/test_rtmpPusher.cpp b/tests/test_rtmpPusher.cpp index fe29af4a..47aae6f7 100644 --- a/tests/test_rtmpPusher.cpp +++ b/tests/test_rtmpPusher.cpp @@ -34,11 +34,8 @@ #include "Common/config.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Rtmp; -using namespace ZL::Thread; -using namespace ZL::Network; -using namespace ZL::DEV; +using namespace toolkit; +using namespace mediakit; //推流器,保持强引用 RtmpPusher::Ptr pusher; @@ -98,7 +95,7 @@ int domain(const string &playUrl, const string &pushUrl) { player->play(playUrl.data()); //监听RtmpMediaSource注册事件,在PlayerProxy播放成功后触发 - NoticeCenter::Instance().addListener(nullptr, Config::Broadcast::kBroadcastMediaChanged, + NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastMediaChanged, [pushUrl](BroadcastMediaChangedArgs) { //媒体源"app/stream"已经注册,这时方可新建一个RtmpPusher对象并绑定该媒体源 if(bRegist && schema == RTMP_SCHEMA){ diff --git a/tests/test_rtmpPusherMp4.cpp b/tests/test_rtmpPusherMp4.cpp index ccc696ff..62afff38 100644 --- a/tests/test_rtmpPusherMp4.cpp +++ b/tests/test_rtmpPusherMp4.cpp @@ -35,11 +35,8 @@ #include "MediaFile/MediaReader.h" using namespace std; -using namespace ZL::Util; -using namespace ZL::Rtmp; -using namespace ZL::Thread; -using namespace ZL::Network; -using namespace ZL::DEV; +using namespace toolkit; +using namespace mediakit; //推流器,保持强引用 RtmpPusher::Ptr pusher; @@ -101,7 +98,7 @@ int domain(const string & filePath,const string & pushUrl){ Logger::Instance().setWriter(std::make_shared()); //录像应用名称默认为record - string appName = mINI::Instance()[Config::Record::kAppName]; + string appName = mINI::Instance()[Record::kAppName]; //app必须record,filePath(流id)为相对于httpRoot/record的路径,否则MediaReader会找到不该文件 //限制app为record是为了防止服务器上的文件被肆意访问 createPusher(appName,filePath,pushUrl); diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 0f85e6ee..650821c1 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -50,20 +50,13 @@ #include "Device/PlayerProxy.h" using namespace std; -using namespace ZL::DEV; -using namespace ZL::Util; -using namespace ZL::Http; -using namespace ZL::Rtsp; -using namespace ZL::Rtmp; -using namespace ZL::Shell; -using namespace ZL::Thread; -using namespace ZL::Network; - +using namespace toolkit; +using namespace mediakit; #define REALM "realm_zlmedaikit" static onceToken s_token([](){ - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastOnGetRtspRealm,[](BroadcastOnGetRtspRealmArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastOnGetRtspRealm,[](BroadcastOnGetRtspRealmArgs){ if(string("1") == args.m_streamid ){ // live/1需要认证 EventPoller::Instance().async([invoker](){ @@ -80,7 +73,7 @@ static onceToken s_token([](){ } }); - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastOnRtspAuth,[](BroadcastOnRtspAuthArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastOnRtspAuth,[](BroadcastOnRtspAuthArgs){ InfoL << "用户:" << user_name << (must_no_encrypt ? " Base64" : " MD5" )<< " 方式登录"; string user = user_name; //假设我们异步读取数据库 @@ -110,7 +103,7 @@ static onceToken s_token([](){ }); - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastRtmpPublish,[](BroadcastRtmpPublishArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastRtmpPublish,[](BroadcastRtmpPublishArgs){ InfoL << args.m_vhost << " " << args.m_app << " " << args.m_streamid << " " << args.m_param_strs ; EventPoller::Instance().async([invoker](){ invoker("");//鉴权成功 @@ -118,7 +111,7 @@ static onceToken s_token([](){ }); }); - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastMediaPlayed,[](BroadcastMediaPlayedArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastMediaPlayed,[](BroadcastMediaPlayedArgs){ InfoL << args.m_schema << " " << args.m_vhost << " " << args.m_app << " " << args.m_streamid << " " << args.m_param_strs ; EventPoller::Instance().async([invoker](){ invoker("");//鉴权成功 @@ -126,7 +119,7 @@ static onceToken s_token([](){ }); }); - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastShellLogin,[](BroadcastShellLoginArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastShellLogin,[](BroadcastShellLoginArgs){ InfoL << "shell login:" << user_name << " " << passwd; EventPoller::Instance().async([invoker](){ invoker("");//鉴权成功 @@ -135,13 +128,13 @@ static onceToken s_token([](){ }); //此处用于测试rtmp保存为flv录像,保存在http根目录下 - NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastMediaChanged,[](BroadcastMediaChangedArgs){ + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastMediaChanged,[](BroadcastMediaChangedArgs){ if(schema == RTMP_SCHEMA){ static map s_mapFlvRecorder; static mutex s_mtxFlvRecorder; lock_guard lck(s_mtxFlvRecorder); if(bRegist){ - GET_CONFIG_AND_REGISTER(string,http_root,Config::Http::kRootPath); + GET_CONFIG_AND_REGISTER(string,http_root,Http::kRootPath); auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv"; FlvRecorder::Ptr recorder(new FlvRecorder); try{ @@ -166,13 +159,13 @@ static onceToken s_token([](){ int main(int argc,char *argv[]) { //设置退出信号处理函数 signal(SIGINT, [](int) { EventPoller::Instance().shutdown(); }); - signal(SIGHUP, [](int) { Config::loadIniConfig(); }); + signal(SIGHUP, [](int) { loadIniConfig(); }); //设置日志 Logger::Instance().add(std::make_shared("stdout", LTrace)); Logger::Instance().setWriter(std::make_shared()); //加载配置文件,如果配置文件不存在就创建一个 - Config::loadIniConfig(); + loadIniConfig(); { //这里是拉流地址,支持rtmp/rtsp协议,负载必须是H264+AAC //如果是其他不识别的音视频将会被忽略(譬如说h264+adpcm转发后会去除音频) @@ -214,11 +207,11 @@ int main(int argc,char *argv[]) { } #endif //ENABLE_OPENSSL - uint16_t shellPort = mINI::Instance()[Config::Shell::kPort]; - uint16_t rtspPort = mINI::Instance()[Config::Rtsp::kPort]; - uint16_t rtmpPort = mINI::Instance()[Config::Rtmp::kPort]; - uint16_t httpPort = mINI::Instance()[Config::Http::kPort]; - uint16_t httpsPort = mINI::Instance()[Config::Http::kSSLPort]; + uint16_t shellPort = mINI::Instance()[Shell::kPort]; + uint16_t rtspPort = mINI::Instance()[Rtsp::kPort]; + uint16_t rtmpPort = mINI::Instance()[Rtmp::kPort]; + uint16_t httpPort = mINI::Instance()[Http::kPort]; + uint16_t httpsPort = mINI::Instance()[Http::kSSLPort]; //简单的telnet服务器,可用于服务器调试,但是不能使用23端口,否则telnet上了莫名其妙的现象 //测试方法:telnet 127.0.0.1 9000 @@ -238,31 +231,31 @@ int main(int argc,char *argv[]) { httpsSrv->start(httpsPort);//默认443 #endif //ENABLE_OPENSSL - NoticeCenter::Instance().addListener(ReloadConfigTag,Config::Broadcast::kBroadcastReloadConfig,[&](BroadcastReloadConfigArgs){ + NoticeCenter::Instance().addListener(ReloadConfigTag,Broadcast::kBroadcastReloadConfig,[&](BroadcastReloadConfigArgs){ //重新创建服务器 - if(shellPort != mINI::Instance()[Config::Shell::kPort].as()){ - shellPort = mINI::Instance()[Config::Shell::kPort]; + if(shellPort != mINI::Instance()[Shell::kPort].as()){ + shellPort = mINI::Instance()[Shell::kPort]; shellSrv->start(shellPort); InfoL << "重启shell服务器:" << shellPort; } - if(rtspPort != mINI::Instance()[Config::Rtsp::kPort].as()){ - rtspPort = mINI::Instance()[Config::Rtsp::kPort]; + if(rtspPort != mINI::Instance()[Rtsp::kPort].as()){ + rtspPort = mINI::Instance()[Rtsp::kPort]; rtspSrv->start(rtspPort); InfoL << "重启rtsp服务器" << rtspPort; } - if(rtmpPort != mINI::Instance()[Config::Rtmp::kPort].as()){ - rtmpPort = mINI::Instance()[Config::Rtmp::kPort]; + if(rtmpPort != mINI::Instance()[Rtmp::kPort].as()){ + rtmpPort = mINI::Instance()[Rtmp::kPort]; rtmpSrv->start(rtmpPort); InfoL << "重启rtmp服务器" << rtmpPort; } - if(httpPort != mINI::Instance()[Config::Http::kPort].as()){ - httpPort = mINI::Instance()[Config::Http::kPort]; + if(httpPort != mINI::Instance()[Http::kPort].as()){ + httpPort = mINI::Instance()[Http::kPort]; httpSrv->start(httpPort); InfoL << "重启http服务器" << httpPort; } #ifdef ENABLE_OPENSSL - if(httpsPort != mINI::Instance()[Config::Http::kSSLPort].as()){ - httpsPort = mINI::Instance()[Config::Http::kSSLPort]; + if(httpsPort != mINI::Instance()[Http::kSSLPort].as()){ + httpsPort = mINI::Instance()[Http::kSSLPort]; httpsSrv->start(httpsPort); InfoL << "重启https服务器" << httpsPort; }