mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
复用代码
This commit is contained in:
parent
2ae97a66ea
commit
4f42f508d5
@ -1 +1 @@
|
|||||||
Subproject commit 8611e88c2eda178973662dcfe180691ff1d8ba35
|
Subproject commit f564c7ed27f141a3b5f08d239970b24d700a1244
|
@ -298,12 +298,6 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//字符串是否以xx结尾
|
|
||||||
static bool end_of(const string &str, const string &substr){
|
|
||||||
auto pos = str.rfind(substr);
|
|
||||||
return pos != string::npos && pos == str.size() - substr.size();
|
|
||||||
};
|
|
||||||
|
|
||||||
//拦截hls的播放请求
|
//拦截hls的播放请求
|
||||||
static bool emitHlsPlayed(const Parser &parser, const MediaInfo &mediaInfo, const HttpSession::HttpAccessPathInvoker &invoker,TcpSession &sender){
|
static bool emitHlsPlayed(const Parser &parser, const MediaInfo &mediaInfo, const HttpSession::HttpAccessPathInvoker &invoker,TcpSession &sender){
|
||||||
//访问的hls.m3u8结尾,我们转换成kBroadcastMediaPlayed事件
|
//访问的hls.m3u8结尾,我们转换成kBroadcastMediaPlayed事件
|
||||||
@ -488,7 +482,7 @@ static string pathCat(const string &a, const string &b){
|
|||||||
* @param cb 回调对象
|
* @param cb 回调对象
|
||||||
*/
|
*/
|
||||||
static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo &mediaInfo, const string &strFile, const HttpFileManager::invoker &cb) {
|
static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo &mediaInfo, const string &strFile, const HttpFileManager::invoker &cb) {
|
||||||
bool is_hls = end_of(strFile, kHlsSuffix);
|
bool is_hls = end_with(strFile, kHlsSuffix);
|
||||||
bool file_exist = File::is_file(strFile.data());
|
bool file_exist = File::is_file(strFile.data());
|
||||||
if (!is_hls && !file_exist) {
|
if (!is_hls && !file_exist) {
|
||||||
//文件不存在且不是hls,那么直接返回404
|
//文件不存在且不是hls,那么直接返回404
|
||||||
|
@ -17,12 +17,6 @@ using namespace toolkit;
|
|||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
//字符串是否以xx结尾
|
|
||||||
static bool end_of(const string &str, const string &substr){
|
|
||||||
auto pos = str.rfind(substr);
|
|
||||||
return pos != string::npos && pos == str.size() - substr.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller,const string &url_in) {
|
PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller,const string &url_in) {
|
||||||
static auto releasePlayer = [](PlayerBase *ptr){
|
static auto releasePlayer = [](PlayerBase *ptr){
|
||||||
onceToken token(nullptr,[&](){
|
onceToken token(nullptr,[&](){
|
||||||
@ -54,7 +48,7 @@ PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller,const st
|
|||||||
return PlayerBase::Ptr(new RtmpPlayerImp(poller),releasePlayer);
|
return PlayerBase::Ptr(new RtmpPlayerImp(poller),releasePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strcasecmp("http",prefix.data()) == 0 || strcasecmp("https",prefix.data()) == 0) && end_of(url, ".m3u8")) {
|
if ((strcasecmp("http",prefix.data()) == 0 || strcasecmp("https",prefix.data()) == 0) && end_with(url, ".m3u8")) {
|
||||||
return PlayerBase::Ptr(new HlsPlayerImp(poller),releasePlayer);
|
return PlayerBase::Ptr(new HlsPlayerImp(poller),releasePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +126,6 @@ void RtspSession::onRecv(const Buffer::Ptr &buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//字符串是否以xx结尾
|
|
||||||
static inline bool end_of(const string &str, const string &substr){
|
|
||||||
auto pos = str.rfind(substr);
|
|
||||||
return pos != string::npos && pos == str.size() - substr.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RtspSession::onWholeRtspPacket(Parser &parser) {
|
void RtspSession::onWholeRtspPacket(Parser &parser) {
|
||||||
string method = parser.Method(); //提取出请求命令字
|
string method = parser.Method(); //提取出请求命令字
|
||||||
_cseq = atoi(parser["CSeq"].data());
|
_cseq = atoi(parser["CSeq"].data());
|
||||||
@ -224,7 +218,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto full_url = parser.FullUrl();
|
auto full_url = parser.FullUrl();
|
||||||
if(end_of(full_url,".sdp")){
|
if(end_with(full_url,".sdp")){
|
||||||
//去除.sdp后缀,防止EasyDarwin推流器强制添加.sdp后缀
|
//去除.sdp后缀,防止EasyDarwin推流器强制添加.sdp后缀
|
||||||
full_url = full_url.substr(0,full_url.length() - 4);
|
full_url = full_url.substr(0,full_url.length() - 4);
|
||||||
_media_info.parse(full_url);
|
_media_info.parse(full_url);
|
||||||
|
Loading…
Reference in New Issue
Block a user