Commit 9f16cc12 by xiongziliang

简化命名空间

parent ed1402e9
Subproject commit d7487e37dd915e8391c1d6a45f1773af13b366a7
Subproject commit 6e69a082a2f6e6161785b00c7421bf1a811ed34a
......@@ -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;
......
......@@ -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;
......
......@@ -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<void *, HttpDownloader::Ptr> s_mapDownloader;
......
......@@ -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<void *, DevChannel::Ptr> s_mapMedia;
......
......@@ -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<void *, MediaPlayer::Ptr> s_mapPlayer;
......
......@@ -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<void *, PlayerProxy::Ptr> s_mapProxyPlayer;
......
......@@ -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
......
......@@ -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_ */
......@@ -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
......
......@@ -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_ */
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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 */
......@@ -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 */
......@@ -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_ */
//
// Created by xzl on 2018/10/24.
//
#include "MediaSourceMaker.h"
namespace mediakit{
}
\ No newline at end of file
//
// 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
......@@ -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 */
......@@ -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<PlayerProxy> , public MediaSourceEvent {
public:
......@@ -71,7 +71,6 @@ private:
int _iAudioIndex = 0;
};
} /* namespace Player */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_DEVICE_PLAYERPROXY_H_ */
......@@ -26,8 +26,8 @@
#include "H264Parser.h"
#include "Util/logger.h"
using namespace toolkit;
using namespace ZL::Util;
H264Parser::H264Parser(){
......
......@@ -7,8 +7,7 @@
#include <memory>
#include "macros.h"
#include "Util/logger.h"
using namespace ZL::Util;
using namespace toolkit;
template <class ForwardIterator>
void STLDeleteContainerPairSecondPointers(ForwardIterator begin,
......
......@@ -8,8 +8,7 @@
#include "macros.h"
#include "h264_parser.h"
#include "h264_poc.h"
using namespace ZL::Util;
using namespace toolkit;
namespace media {
......
......@@ -88,7 +88,7 @@ static type& name = *new type arguments
#include <assert.h>
#include "Util/logger.h"
using namespace ZL::Util;
using namespace toolkit;
#define DCHECK(x) if(!(x)) { ErrorL << "DCHECK " << #x <<endl; }
#define DCHECK_GT(x,y) if(!((x) > (y))) { ErrorL << "DCHECK_GT:" << #x << #y << endl; }
......
......@@ -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 */
......@@ -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 */
......@@ -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 */
......@@ -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_ */
......@@ -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 */
......@@ -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
......@@ -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 */
......@@ -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_ */
......@@ -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 */
......@@ -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
......@@ -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
......@@ -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 */
......@@ -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 */
......@@ -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_ */
......@@ -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_ */
......@@ -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 */
......
......@@ -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
......@@ -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 */
......@@ -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_ */
......@@ -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 */
......@@ -34,11 +34,9 @@
#include "Util/util.h"
#include "Util/logger.h"
#include <deque>
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_ */
......@@ -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<uint64_t>(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 */
......@@ -34,13 +34,9 @@
#ifdef ENABLE_MP4V2
#include <mp4v2/mp4v2.h>
#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<MediaReader> ,public MediaSourceEvent{
public:
......@@ -103,7 +99,6 @@ private:
#endif //ENABLE_MP4V2
};
} /* namespace MediaFile */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_MEDIAFILE_MEDIAREADER_H_ */
......@@ -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 */
......@@ -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_ */
......@@ -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
......@@ -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
......
......@@ -26,8 +26,7 @@
#include "TSMaker.h"
#include "Util/logger.h"
using namespace ZL::Util;
using namespace toolkit;
TSMaker::TSMaker() {
m_pOutVideoTs = NULL;
......
......@@ -34,9 +34,8 @@
#include <string>
#include <iostream>
#include "Util/File.h"
using namespace std;
using namespace ZL::Util;
using namespace toolkit;
#define TS_PACKET_SIZE 188
#define TS_PACKET_HEADER 4
......
......@@ -3,3 +3,7 @@
//
#include "Frame.h"
namespace mediakit{
}
\ No newline at end of file
......@@ -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
......@@ -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 */
......@@ -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<PlayerBase,PlayerBase> {
public:
......@@ -58,7 +53,6 @@ private:
};
} /* namespace Player */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_PLAYER_MEDIAPLAYER_H_ */
......@@ -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
......
......@@ -31,6 +31,7 @@
#include "Frame.h"
using namespace std;
using namespace mediakit;
unsigned const samplingFrequencyTable[16] = { 96000, 88200,
64000, 48000,
......
......@@ -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 */
......@@ -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_ */
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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_ */
......@@ -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 */
......@@ -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_ */
......@@ -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<string, RtmpPlayer::rtmpCMDHandle> RtmpPlayer::g_mapCmd;
RtmpPlayer::RtmpPlayer() {
......@@ -351,6 +349,5 @@ void RtmpPlayer::seekToTime(float fTime){
}
} /* namespace Rtmp */
} /* namespace ZL */
} /* namespace mediakit */
......@@ -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_ */
......@@ -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<RtmpPlayer,RtmpParser> {
public:
typedef std::shared_ptr<RtmpPlayerImp> Ptr;
......@@ -92,7 +89,6 @@ private:
};
} /* namespace Rtmp */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_RTMP_RTMPPLAYERIMP_H_ */
......@@ -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 */
......@@ -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<void()> _nextHandle;
};
} /* namespace Rtmp */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_RTMP_RTMPPROTOCOL_H_ */
......@@ -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 */
......@@ -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_ */
......@@ -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 */
......@@ -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_ */
......@@ -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 */
......@@ -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_ */
......@@ -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() {
......
......@@ -30,9 +30,7 @@
#include <stdarg.h>
#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
......
......@@ -5,8 +5,7 @@
#include <Player/Player.h>
#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
......@@ -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
......@@ -4,6 +4,7 @@
#include "H264RtmpCodec.h"
namespace mediakit{
H264RtmpDecoder::H264RtmpDecoder() {
_h264frame = obtainFrame();
......@@ -185,20 +186,7 @@ void H264RtmpEncoder::makeVideoConfigPkt() {
}
}//namespace mediakit
......
......@@ -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
......@@ -3,3 +3,6 @@
//
#include "RtmpCodec.h"
namespace mediakit{
}
\ No newline at end of file
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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_ */
......@@ -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
......@@ -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_ */
......@@ -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<<timeStamp<<" "<<time<<" "<<sampleRate;
}
} /* namespace RTP */
} /* namespace ZL */
}//namespace mediakit
\ No newline at end of file
......@@ -34,11 +34,9 @@
#include "Util/RingBuffer.h"
using namespace std;
using namespace ZL::Util;
using namespace ZL::Rtsp;
using namespace toolkit;
namespace ZL {
namespace Rtsp {
namespace mediakit{
class RtpMaker_H264: public RtpMaker {
public:
......@@ -56,7 +54,7 @@ private:
unsigned char aucSectionBuf[1600];
};
} /* namespace RTP */
} /* namespace ZL */
}//namespace mediakit
#endif /* RTP_RTPMAKERH264_H_ */
......@@ -32,10 +32,9 @@
#include "RtspSession.h"
using namespace std;
using namespace ZL::Network;
using namespace toolkit;
namespace ZL {
namespace Rtsp {
namespace mediakit{
MultiCastAddressMaker &MultiCastAddressMaker::Instance() {
static MultiCastAddressMaker instance;
......@@ -51,8 +50,8 @@ static uint32_t addressToInt(const string &ip){
std::shared_ptr<uint32_t> MultiCastAddressMaker::obtain(uint32_t iTry) {
lock_guard<recursive_mutex> 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
......@@ -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<uint32_t>();
static uint32_t addrMax = mINI::Instance()[Config::MultiCast::kAddrMax].as<uint32_t>();
static uint32_t addrMin = mINI::Instance()[MultiCast::kAddrMin].as<uint32_t>();
static uint32_t addrMax = mINI::Instance()[MultiCast::kAddrMax].as<uint32_t>();
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_ */
......@@ -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<Track::Ptr> RtpParser::getTracks() const {
}
} /* namespace Rtsp */
} /* namespace ZL */
} /* namespace mediakit */
......@@ -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_ */
......@@ -35,7 +35,8 @@
#include "Player/Frame.h"
using namespace std;
using namespace ZL::Util;
using namespace toolkit;
using namespace mediakit;
class RtspTrack{
......
......@@ -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
......@@ -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
......@@ -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_ */
......@@ -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 */
......@@ -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_ */
......@@ -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<RtspPlayer,RtpParser> {
public:
......@@ -95,7 +93,6 @@ private:
};
} /* namespace Rtsp */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_RTP_RTPPARSERTESTER_H_ */
#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);
}
}
......@@ -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 */
......
......@@ -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<RtspSession> &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 */
......@@ -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_ */
......@@ -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 */
......@@ -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<RtspToRtmpMediaSource> Ptr;
......@@ -109,7 +107,6 @@ private:
};
} /* namespace Rtsp */
} /* namespace ZL */
} /* namespace mediakit */
#endif /* SRC_RTSP_RTSPTORTMPMEDIASOURCE_H_ */
......@@ -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 */
......@@ -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_ */
......@@ -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
......@@ -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<ThreadPool> &_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 */
......@@ -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_ */
......@@ -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
......@@ -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_ */
......@@ -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_ */
......
......@@ -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)
......
......@@ -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[]) {
//设置退出信号处理函数
......
......@@ -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<ConsoleChannel>("stdout", LTrace));
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
//加载配置文件,如果配置文件不存在就创建一个
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<EchoWebSocketSession>(mINI::Instance()[Config::Http::kPort]);//默认80
httpSrv->start<EchoWebSocketSession>(mINI::Instance()[Http::kPort]);//默认80
#ifdef ENABLE_OPENSSL
//如果支持ssl,还可以开启https服务器
TcpServer::Ptr httpsSrv(new TcpServer());
httpsSrv->start<SSLEchoWebSocketSession>(mINI::Instance()[Config::Http::kSSLPort]);//默认443
httpsSrv->start<SSLEchoWebSocketSession>(mINI::Instance()[Http::kSSLPort]);//默认443
#endif //ENABLE_OPENSSL
InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl;
......
......@@ -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[]) {
//设置退出信号处理函数
......
......@@ -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[]) {
//设置退出信号处理函数
......
......@@ -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){
......
......@@ -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<AsyncLogWriter>());
//录像应用名称默认为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);
......
......@@ -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<string,FlvRecorder::Ptr> s_mapFlvRecorder;
static mutex s_mtxFlvRecorder;
lock_guard<mutex> 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<ConsoleChannel>("stdout", LTrace));
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
//加载配置文件,如果配置文件不存在就创建一个
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<HttpsSession>(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<uint16_t>()){
shellPort = mINI::Instance()[Config::Shell::kPort];
if(shellPort != mINI::Instance()[Shell::kPort].as<uint16_t>()){
shellPort = mINI::Instance()[Shell::kPort];
shellSrv->start<ShellSession>(shellPort);
InfoL << "重启shell服务器:" << shellPort;
}
if(rtspPort != mINI::Instance()[Config::Rtsp::kPort].as<uint16_t>()){
rtspPort = mINI::Instance()[Config::Rtsp::kPort];
if(rtspPort != mINI::Instance()[Rtsp::kPort].as<uint16_t>()){
rtspPort = mINI::Instance()[Rtsp::kPort];
rtspSrv->start<RtspSession>(rtspPort);
InfoL << "重启rtsp服务器" << rtspPort;
}
if(rtmpPort != mINI::Instance()[Config::Rtmp::kPort].as<uint16_t>()){
rtmpPort = mINI::Instance()[Config::Rtmp::kPort];
if(rtmpPort != mINI::Instance()[Rtmp::kPort].as<uint16_t>()){
rtmpPort = mINI::Instance()[Rtmp::kPort];
rtmpSrv->start<RtmpSession>(rtmpPort);
InfoL << "重启rtmp服务器" << rtmpPort;
}
if(httpPort != mINI::Instance()[Config::Http::kPort].as<uint16_t>()){
httpPort = mINI::Instance()[Config::Http::kPort];
if(httpPort != mINI::Instance()[Http::kPort].as<uint16_t>()){
httpPort = mINI::Instance()[Http::kPort];
httpSrv->start<HttpSession>(httpPort);
InfoL << "重启http服务器" << httpPort;
}
#ifdef ENABLE_OPENSSL
if(httpsPort != mINI::Instance()[Config::Http::kSSLPort].as<uint16_t>()){
httpsPort = mINI::Instance()[Config::Http::kSSLPort];
if(httpsPort != mINI::Instance()[Http::kSSLPort].as<uint16_t>()){
httpsPort = mINI::Instance()[Http::kSSLPort];
httpsSrv->start<HttpsSession>(httpsPort);
InfoL << "重启https服务器" << httpsPort;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论