适配ZLToolKit

This commit is contained in:
xiongziliang 2020-04-24 12:39:22 +08:00
parent a9fcd9dbc1
commit b4228f91c3
12 changed files with 32 additions and 35 deletions

@ -1 +1 @@
Subproject commit ebd96d983d8dd3268e3e77ed08fb57d67666061c
Subproject commit 2dad545fb22083dc9bdcd7ad60e2f90498197320

View File

@ -75,7 +75,7 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
int log_fd = -1;
int flags = O_CREAT | O_WRONLY | O_APPEND;
mode_t mode = S_IRWXO | S_IRWXG | S_IRWXU;// S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
File::createfile_path(log_file.data(), mode);
File::create_path(log_file.data(), mode);
if ((log_fd = ::open(log_file.c_str(), flags, mode)) < 0) {
fprintf(stderr, "open log file %s failed:%d(%s)\r\n", log_file.data(), errno, strerror(errno));
}

View File

@ -185,7 +185,7 @@ private:
template<typename packet, typename policy = FlushPolicy, typename packet_list = List<std::shared_ptr<packet> > >
class VideoPacketCache {
public:
VideoPacketCache() : _policy(true) {
VideoPacketCache() : _policy(false) {
_cache = std::make_shared<packet_list>();
}
@ -231,7 +231,7 @@ private:
template<typename packet, typename policy = FlushPolicy, typename packet_list = List<std::shared_ptr<packet> > >
class AudioPacketCache {
public:
AudioPacketCache() : _policy(false) {
AudioPacketCache() : _policy(true) {
_cache = std::make_shared<packet_list>();
}

View File

@ -28,7 +28,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
if(_filePath.empty()){
_filePath = exeDir() + "HttpDownloader/" + MD5(url).hexdigest();
}
_saveFile = File::createfile_file(_filePath.data(),bAppend ? "ab" : "wb");
_saveFile = File::create_file(_filePath.data(), bAppend ? "ab" : "wb");
if(!_saveFile){
auto strErr = StrPrinter << "打开文件失败:" << filePath << endl;
throw std::runtime_error(strErr);

View File

@ -315,7 +315,7 @@ public:
SockInfoImp() = default;
~SockInfoImp() override = default;
const string &get_local_ip() override{
string get_local_ip() override{
return _local_ip;
}
@ -323,9 +323,8 @@ public:
return _local_port;
}
const string &get_peer_ip() override{
string get_peer_ip() override{
return _peer_ip;
}
uint16_t get_peer_port() override{

View File

@ -59,7 +59,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
string cmd = _parser.Method();
auto it = s_func_map.find(cmd);
if (it == s_func_map.end()) {
WarnL << "不支持该命令:" << cmd;
WarnP(this) << "不支持该命令:" << cmd;
sendResponse("405 Not Allowed", true);
return 0;
}

View File

@ -41,11 +41,11 @@ public:
typedef std::function<void(const string &errMsg,const string &accessPath, int cookieLifeSecond)> HttpAccessPathInvoker;
HttpSession(const Socket::Ptr &pSock);
virtual ~HttpSession();
~HttpSession() override;
virtual void onRecv(const Buffer::Ptr &) override;
virtual void onError(const SockException &err) override;
virtual void onManager() override;
void onRecv(const Buffer::Ptr &) override;
void onError(const SockException &err) override;
void onManager() override;
static string urlDecode(const string &str);
protected:
//FlvMuxer override
@ -80,7 +80,7 @@ protected:
* @return true代表允许websocket连接
*/
virtual bool onWebSocketConnect(const Parser &header){
WarnL << "http server do not support websocket default";
WarnP(this) << "http server do not support websocket default";
return false;
}

View File

@ -92,7 +92,7 @@ void HlsMakerImp::onWriteHls(const char *data, int len) {
std::shared_ptr<FILE> HlsMakerImp::makeFile(const string &file,bool setbuf) {
auto file_buf = _file_buf;
auto ret= shared_ptr<FILE>(File::createfile_file(file.data(), "wb"), [file_buf](FILE *fp) {
auto ret= shared_ptr<FILE>(File::create_file(file.data(), "wb"), [file_buf](FILE *fp) {
if (fp) {
fclose(fp);
}

View File

@ -72,7 +72,7 @@ MP4File::Reader MP4File::createReader(){
void MP4File::openFile(const char *file,const char *mode) {
//创建文件
auto fp = File::createfile_file(file,mode);
auto fp = File::create_file(file, mode);
if(!fp){
throw std::runtime_error(string("打开文件失败:") + file);
}

View File

@ -177,7 +177,7 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller,const RtmpMediaSour
}
});
//新建文件
_file.reset(File::createfile_file(file_path.data(),"wb"),[fileBuf](FILE *fp){
_file.reset(File::create_file(file_path.data(), "wb"), [fileBuf](FILE *fp){
if(fp){
fflush(fp);
fclose(fp);

View File

@ -76,7 +76,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
GET_CONFIG(string,dump_dir,RtpProxy::kDumpDir);
{
FILE *fp = !dump_dir.empty() ? File::createfile_file(File::absolutePath(_media_info._streamid + ".rtp",dump_dir).data(),"wb") : nullptr;
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info._streamid + ".rtp", dump_dir).data(), "wb") : nullptr;
if(fp){
_save_file_rtp.reset(fp,[](FILE *fp){
fclose(fp);
@ -85,7 +85,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
{
FILE *fp = !dump_dir.empty() ? File::createfile_file(File::absolutePath(_media_info._streamid + ".mp2",dump_dir).data(),"wb") : nullptr;
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info._streamid + ".mp2", dump_dir).data(), "wb") : nullptr;
if(fp){
_save_file_ps.reset(fp,[](FILE *fp){
fclose(fp);
@ -94,7 +94,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
{
FILE *fp = !dump_dir.empty() ? File::createfile_file(File::absolutePath(_media_info._streamid + ".video",dump_dir).data(),"wb") : nullptr;
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info._streamid + ".video", dump_dir).data(), "wb") : nullptr;
if(fp){
_save_file_video.reset(fp,[](FILE *fp){
fclose(fp);
@ -119,8 +119,8 @@ RtpProcess::~RtpProcess() {
//流量统计事件广播
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
if (_ui64TotalBytes > iFlowThreshold * 1024) {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _ui64TotalBytes, duration, false, static_cast<SockInfo &>(*this));
if (_total_bytes > iFlowThreshold * 1024) {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, false, static_cast<SockInfo &>(*this));
}
}
@ -146,7 +146,7 @@ bool RtpProcess::inputRtp(const Socket::Ptr &sock, const char *data, int data_le
return false;
}
_ui64TotalBytes += data_len;
_total_bytes += data_len;
_last_rtp_time.resetTime();
bool ret = handleOneRtp(0,_track,(unsigned char *)data,data_len);
if(dts_out){
@ -328,11 +328,11 @@ bool RtpProcess::alive() {
return false;
}
const string& RtpProcess::get_peer_ip() {
if(_peer_ip.empty() && _addr){
_peer_ip = SockUtil::inet_ntoa(((struct sockaddr_in *) _addr)->sin_addr);
string RtpProcess::get_peer_ip() {
if(_addr){
return SockUtil::inet_ntoa(((struct sockaddr_in *) _addr)->sin_addr);
}
return _peer_ip;
return "0.0.0.0";
}
uint16_t RtpProcess::get_peer_port() {
@ -342,11 +342,11 @@ uint16_t RtpProcess::get_peer_port() {
return ntohs(((struct sockaddr_in *) _addr)->sin_port);
}
const string& RtpProcess::get_local_ip() {
string RtpProcess::get_local_ip() {
if(_sock){
_local_ip = _sock->get_local_ip();
return _sock->get_local_ip();
}
return _local_ip;
return "0.0.0.0";
}
uint16_t RtpProcess::get_local_port() {

View File

@ -32,9 +32,9 @@ public:
bool inputRtp(const Socket::Ptr &sock, const char *data,int data_len, const struct sockaddr *addr , uint32_t *dts_out = nullptr);
bool alive();
const string &get_local_ip() override;
string get_local_ip() override;
uint16_t get_local_port() override;
const string &get_peer_ip() override;
string get_peer_ip() override;
uint16_t get_peer_port() override;
string getIdentifier() const override;
@ -65,11 +65,9 @@ private:
unordered_map<int,Stamp> _stamps;
uint32_t _dts = 0;
Decoder::Ptr _decoder;
string _peer_ip;
string _local_ip;
std::weak_ptr<MediaSourceEvent> _listener;
MediaInfo _media_info;
uint64_t _ui64TotalBytes = 0;
uint64_t _total_bytes = 0;
Socket::Ptr _sock;
};