mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
批量添加bom头、批量替换tab字符
This commit is contained in:
parent
7bc7d95249
commit
477475a60f
@ -17,12 +17,12 @@
|
|||||||
|
|
||||||
#ifndef MediaKitApi_STATIC
|
#ifndef MediaKitApi_STATIC
|
||||||
#if defined(MediaKitApi_EXPORTS)
|
#if defined(MediaKitApi_EXPORTS)
|
||||||
#define API_EXPORT __declspec(dllexport)
|
#define API_EXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define API_EXPORT __declspec(dllimport)
|
#define API_EXPORT __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define API_CALL __cdecl
|
#define API_CALL __cdecl
|
||||||
#else
|
#else
|
||||||
#define API_EXPORT
|
#define API_EXPORT
|
||||||
#define API_CALL
|
#define API_CALL
|
||||||
|
@ -43,9 +43,9 @@ public:
|
|||||||
class AudioInfo {
|
class AudioInfo {
|
||||||
public:
|
public:
|
||||||
CodecId codecId = CodecAAC;
|
CodecId codecId = CodecAAC;
|
||||||
int iChannel;
|
int iChannel;
|
||||||
int iSampleBit;
|
int iSampleBit;
|
||||||
int iSampleRate;
|
int iSampleRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +226,7 @@ RtmpCodec::Ptr Factory::getRtmpCodecByTrack(const Track::Ptr &track) {
|
|||||||
case CodecH264 : return std::make_shared<H264RtmpEncoder>(track);
|
case CodecH264 : return std::make_shared<H264RtmpEncoder>(track);
|
||||||
case CodecAAC : return std::make_shared<AACRtmpEncoder>(track);
|
case CodecAAC : return std::make_shared<AACRtmpEncoder>(track);
|
||||||
case CodecH265 : return std::make_shared<H265RtmpEncoder>(track);
|
case CodecH265 : return std::make_shared<H265RtmpEncoder>(track);
|
||||||
case CodecG711A :
|
case CodecG711A :
|
||||||
case CodecG711U : return std::make_shared<G711RtmpEncoder>(track);
|
case CodecG711U : return std::make_shared<G711RtmpEncoder>(track);
|
||||||
default : WarnL << "暂不支持该CodecId:" << track->getCodecName(); return nullptr;
|
default : WarnL << "暂不支持该CodecId:" << track->getCodecName(); return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -737,22 +737,22 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool useBuf = true;
|
bool useBuf = true;
|
||||||
_enableSendRtp = false;
|
_enableSendRtp = false;
|
||||||
float iStartTime = 0;
|
float iStartTime = 0;
|
||||||
if (strRange.size() && !_bFirstPlay) {
|
if (strRange.size() && !_bFirstPlay) {
|
||||||
//这个是seek操作
|
//这个是seek操作
|
||||||
auto strStart = FindField(strRange.data(), "npt=", "-");
|
auto strStart = FindField(strRange.data(), "npt=", "-");
|
||||||
if (strStart == "now") {
|
if (strStart == "now") {
|
||||||
strStart = "0";
|
strStart = "0";
|
||||||
}
|
}
|
||||||
iStartTime = 1000 * atof(strStart.data());
|
iStartTime = 1000 * atof(strStart.data());
|
||||||
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
||||||
useBuf = !pMediaSrc->seekTo(iStartTime);
|
useBuf = !pMediaSrc->seekTo(iStartTime);
|
||||||
}else if(pMediaSrc->totalReaderCount() == 0){
|
}else if(pMediaSrc->totalReaderCount() == 0){
|
||||||
//第一个消费者
|
//第一个消费者
|
||||||
pMediaSrc->seekTo(0);
|
pMediaSrc->seekTo(0);
|
||||||
}
|
}
|
||||||
_bFirstPlay = false;
|
_bFirstPlay = false;
|
||||||
|
|
||||||
_StrPrinter rtp_info;
|
_StrPrinter rtp_info;
|
||||||
for(auto &track : _aTrackInfo){
|
for(auto &track : _aTrackInfo){
|
||||||
@ -772,10 +772,10 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
|||||||
|
|
||||||
rtp_info.pop_back();
|
rtp_info.pop_back();
|
||||||
|
|
||||||
sendRtspResponse("200 OK",
|
sendRtspResponse("200 OK",
|
||||||
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << (useBuf? pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 : iStartTime / 1000),
|
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << (useBuf? pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 : iStartTime / 1000),
|
||||||
"RTP-Info",rtp_info
|
"RTP-Info",rtp_info
|
||||||
});
|
});
|
||||||
|
|
||||||
_enableSendRtp = true;
|
_enableSendRtp = true;
|
||||||
setSocketFlags();
|
setSocketFlags();
|
||||||
|
@ -61,40 +61,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void get_file_path(const char *path, const char *file_name, char *file_path) {
|
|
||||||
strcpy(file_path, path);
|
|
||||||
if (file_path[strlen(file_path) - 1] != '/') {
|
|
||||||
strcat(file_path, "/");
|
|
||||||
}
|
|
||||||
strcat(file_path, file_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FUNC>
|
|
||||||
void for_each_file(const char *path, FUNC &&func){
|
|
||||||
DIR *dir;
|
|
||||||
dirent *dir_info;
|
|
||||||
char file_path[PATH_MAX];
|
|
||||||
if (File::is_file(path)) {
|
|
||||||
func(path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (File::is_dir(path)) {
|
|
||||||
if ((dir = opendir(path)) == NULL) {
|
|
||||||
closedir(dir);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while ((dir_info = readdir(dir)) != NULL) {
|
|
||||||
if (File::is_special_dir(dir_info->d_name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
get_file_path(path, dir_info->d_name, file_path);
|
|
||||||
for_each_file(file_path,std::forward<FUNC>(func));
|
|
||||||
}
|
|
||||||
closedir(dir);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char s_bom[] = "\xEF\xBB\xBF";
|
static const char s_bom[] = "\xEF\xBB\xBF";
|
||||||
|
|
||||||
void add_or_rm_bom(const char *file,bool rm_bom){
|
void add_or_rm_bom(const char *file,bool rm_bom){
|
||||||
@ -159,23 +125,26 @@ int main(int argc, char *argv[]) {
|
|||||||
bool no_filter = filter_set.find("*") != filter_set.end();
|
bool no_filter = filter_set.find("*") != filter_set.end();
|
||||||
//设置日志
|
//设置日志
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>());
|
Logger::Instance().add(std::make_shared<ConsoleChannel>());
|
||||||
path = File::absolutePath(path, "");
|
File::scanDir(path, [&](const string &path, bool isDir) {
|
||||||
for_each_file(path.data(),[&](const char *path){
|
if (isDir) {
|
||||||
if(!no_filter){
|
return true;
|
||||||
|
}
|
||||||
|
if (!no_filter) {
|
||||||
//开启了过滤器
|
//开启了过滤器
|
||||||
auto pos = strstr(path,".");
|
auto pos = strstr(path.data(), ".");
|
||||||
if(pos == nullptr){
|
if (pos == nullptr) {
|
||||||
//没有后缀
|
//没有后缀
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
auto ext = pos + 1;
|
auto ext = pos + 1;
|
||||||
if(filter_set.find(ext) == filter_set.end()){
|
if (filter_set.find(ext) == filter_set.end()) {
|
||||||
//后缀不匹配
|
//后缀不匹配
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//该文件匹配
|
//该文件匹配
|
||||||
process_file(path,rm_bom);
|
process_file(path.data(), rm_bom);
|
||||||
});
|
return true;
|
||||||
|
}, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,6 @@ int main(int argc, char *argv[]) {
|
|||||||
bool no_filter = filter_set.find("*") != filter_set.end();
|
bool no_filter = filter_set.find("*") != filter_set.end();
|
||||||
//设置日志
|
//设置日志
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>());
|
Logger::Instance().add(std::make_shared<ConsoleChannel>());
|
||||||
path = File::absolutePath(path, "");
|
|
||||||
DebugL << path;
|
|
||||||
File::scanDir(path, [&](const string &path, bool isDir) {
|
File::scanDir(path, [&](const string &path, bool isDir) {
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||||
|
Loading…
Reference in New Issue
Block a user