mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 11:17:09 +08:00
Merge branch 'master' into dev
This commit is contained in:
commit
9cb5d82b04
@ -1 +1 @@
|
||||
Subproject commit 5d74e09b8c84cccc46036ed2ef1a62f670c423d4
|
||||
Subproject commit b11582c38e8dbbb8d93ca9ce33c9a0b0cd58f59a
|
@ -39,6 +39,7 @@ option(ENABLE_FAAC "Enable FAAC" OFF)
|
||||
option(ENABLE_FFMPEG "Enable FFmpeg" OFF)
|
||||
option(ENABLE_HLS "Enable HLS" ON)
|
||||
option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" OFF)
|
||||
option(ENABLE_JEMALLOC_DUMP "Enable jemalloc to dump malloc statistics" OFF)
|
||||
option(ENABLE_MEM_DEBUG "Enable Memory Debug" OFF)
|
||||
option(ENABLE_MP4 "Enable MP4" ON)
|
||||
option(ENABLE_HLS_FMP4 "Enable HLS-FMP4" ON)
|
||||
@ -335,7 +336,11 @@ if(ENABLE_JEMALLOC_STATIC)
|
||||
if(NOT EXISTS ${DEP_ROOT_DIR})
|
||||
file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
|
||||
endif()
|
||||
|
||||
if (ENABLE_JEMALLOC_DUMP)
|
||||
set(ENABLE_JEMALLOC_STAT ON)
|
||||
else ()
|
||||
set(ENABLE_JEMALLOC_STAT OFF)
|
||||
endif ()
|
||||
include(Jemalloc)
|
||||
include_directories(SYSTEM ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
|
||||
link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
|
||||
@ -349,6 +354,12 @@ if(JEMALLOC_FOUND)
|
||||
message(STATUS "found library: ${JEMALLOC_LIBRARIES}")
|
||||
include_directories(${JEMALLOC_INCLUDE_DIR})
|
||||
update_cached_list(MK_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
||||
add_definitions(-DUSE_JEMALLOC)
|
||||
message(STATUS "jemalloc will be used to avoid memory fragmentation")
|
||||
if (ENABLE_JEMALLOC_DUMP)
|
||||
add_definitions(-DENABLE_JEMALLOC_DUMP)
|
||||
message(STATUS "jemalloc will save memory usage statistics when the program exits")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# 查找 openssl 是否安装
|
||||
|
@ -1,21 +1,34 @@
|
||||
# Download and build Jemalloc
|
||||
|
||||
set(JEMALLOC_VERSION 5.2.1)
|
||||
set(JEMALLOC_VERSION 5.3.0)
|
||||
set(JEMALLOC_NAME jemalloc-${JEMALLOC_VERSION})
|
||||
set(JEMALLOC_TAR_PATH ${DEP_ROOT_DIR}/${JEMALLOC_NAME}.tar.bz2)
|
||||
|
||||
list(APPEND jemalloc_CONFIG_ARGS --disable-initial-exec-tls)
|
||||
list(APPEND jemalloc_CONFIG_ARGS --without-export)
|
||||
#list(APPEND jemalloc_CONFIG_ARGS --without-export)
|
||||
if (ENABLE_JEMALLOC_STAT)
|
||||
list(APPEND jemalloc_CONFIG_ARGS --enable-stats)
|
||||
message(STATUS "Jemalloc stats enabled")
|
||||
else ()
|
||||
list(APPEND jemalloc_CONFIG_ARGS --disable-stats)
|
||||
message(STATUS "Jemalloc stats disabled")
|
||||
endif ()
|
||||
list(APPEND jemalloc_CONFIG_ARGS --disable-libdl)
|
||||
#list(APPEND jemalloc_CONFIG_ARGS --disable-cxx)
|
||||
#list(APPEND jemalloc_CONFIG_ARGS --with-jemalloc-prefix=je_)
|
||||
#list(APPEND jemalloc_CONFIG_ARGS --enable-debug)
|
||||
|
||||
if(NOT EXISTS ${JEMALLOC_TAR_PATH})
|
||||
message(STATUS "Downloading ${JEMALLOC_NAME}...")
|
||||
file(DOWNLOAD https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_NAME}.tar.bz2
|
||||
${JEMALLOC_TAR_PATH})
|
||||
set(JEMALLOC_URL https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_NAME}.tar.bz2)
|
||||
message(STATUS "Downloading ${JEMALLOC_NAME} from ${JEMALLOC_URL}")
|
||||
file(DOWNLOAD ${JEMALLOC_URL} ${JEMALLOC_TAR_PATH} SHOW_PROGRESS STATUS JEMALLOC_DOWNLOAD_STATUS LOG JEMALLOC_DOWNLOAD_LOG)
|
||||
list(GET JEMALLOC_DOWNLOAD_STATUS 0 JEMALLOC_DOWNLOAD_STATUS_CODE)
|
||||
if(NOT JEMALLOC_DOWNLOAD_STATUS_CODE EQUAL 0)
|
||||
file(REMOVE ${JEMALLOC_TAR_PATH})
|
||||
message(STATUS "${JEMALLOC_DOWNLOAD_LOG}")
|
||||
message(FATAL_ERROR "${JEMALLOC_NAME} download failed! error is ${JEMALLOC_DOWNLOAD_STATUS}")
|
||||
return()
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
SET( DIR_CONTAINING_JEMALLOC ${DEP_ROOT_DIR}/${JEMALLOC_NAME} )
|
||||
|
@ -244,7 +244,7 @@ forwarded_ip_header=
|
||||
#默认允许所有跨域请求
|
||||
allow_cross_domains=1
|
||||
#允许访问http api和http文件索引的ip地址范围白名单,置空情况下不做限制
|
||||
allow_ip_range=127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255
|
||||
allow_ip_range=::1,127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255
|
||||
|
||||
[multicast]
|
||||
#rtp组播截止组播ip地址
|
||||
|
144
default.pem
144
default.pem
@ -1,89 +1,89 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAjTFnNz2btUHR/K8TegU2n06lXsQuW4AfsMGthBLvnz2zdgL2
|
||||
uVxfRCuleoRpECEV9I80ibTXAJlouRLbnhLHto8gzyLeQue9/DtxTEGcS7y2aMha
|
||||
0wAoUcOBv7tAITSnFepGHXoYgyU7HOCvn96U1bzqLTOhxOCH/xy003dwoEC7+Pjl
|
||||
dsWs/16cpv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G
|
||||
Y29tL0RpZ2lDZXJ0R2xvYmFsUm9vdEcyLmNybDBMBgNVHSAERTBDMDcGCWCGSAGG
|
||||
/WwBAjAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BT
|
||||
MAgGBmeBDAECATANBgkqhkiG9w0BAQsFAAOCAQEAK3Gp6/aGq7aBZsxf/oQ+TD/B
|
||||
SwW3AU4ETK+GQf2kFzYZkby5SFrHdPomunx2HBzViUchGoofGgg7gHW0W3MlQAXW
|
||||
M0r5LUvStcr82QDWYNPaUy4taCQmyaJ+VB+6wxHstSigOlSNF2a6vg4rgexixeiV
|
||||
4YSB03Yqp2t3TeZHM9ESfkus74nQyW7pRGezj+TC44xCagCQQOzzNmzEAP2SnCrJ
|
||||
sNE2DpRVMnL8J6xBRdjmOsC3N6cQuKuRXbzByVBjCqAA8t1L0I+9wXJerLPyErjy
|
||||
rMKWaBFLmfK/AHNF4ZihwPGOc7w6UHczBZXH5RFzJNnww+WnKuTPI0HfnVH8lg==
|
||||
MAgGBmeBDAECATANBgkqhkiG9w0BAQsFAAOCAQEAoBs1eCLKakLtVRPFRjBIJ9LJ
|
||||
L0s8ZWum8U8/1TMVkQMBn+CPb5xnCD0GSA6L/V0ZFrMNqBirrr5B241OesECvxIi
|
||||
98bZ90h9+q/X5eMyOD35f8YTaEMpdnQCnawIwiHx06/0BfiTj+b/XQih+mqt3ZXe
|
||||
xNCJqKexdiB2IWGSKcgahPacWkk/BAQFisKIFYEqHzV974S3FAz/8LIfD58xnsEN
|
||||
GfzyIDkH3JrwYZ8caPTf6ZX9M1GrISN8HnWTtdNCH2xEajRa/h9ZBXjUyFKQrGk2
|
||||
n2hcLrfZSbynEC/pSw/ET7H5nWwckjmAJ1l9fcnbqkU/pf6uMQmnfl0JQjJNSg==
|
||||
-----END CERTIFICATE-----
|
@ -108,7 +108,7 @@ static int cloneFunc(void *ptr) {
|
||||
|
||||
#endif
|
||||
|
||||
void Process::run(const string &cmd, string &log_file) {
|
||||
void Process::run(const string &cmd, string log_file) {
|
||||
kill(2000);
|
||||
#ifdef _WIN32
|
||||
STARTUPINFO si = { 0 };
|
||||
|
@ -26,7 +26,7 @@ class Process {
|
||||
public:
|
||||
Process();
|
||||
~Process();
|
||||
void run(const std::string &cmd, std::string &log_file);
|
||||
void run(const std::string &cmd, std::string log_file);
|
||||
void kill(int max_delay,bool force = false);
|
||||
bool wait(bool block = true);
|
||||
int exit_code();
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
#include "Common/JemallocUtil.h"
|
||||
#include "Common/macros.h"
|
||||
#include "System.h"
|
||||
#include "Util/logger.h"
|
||||
#include "Util/uv_errno.h"
|
||||
#include "System.h"
|
||||
#include "Common/macros.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
@ -55,6 +56,16 @@ string System::execute(const string &cmd) {
|
||||
|
||||
static constexpr int MAX_STACK_FRAMES = 128;
|
||||
|
||||
static void save_jemalloc_stats() {
|
||||
string jemalloc_status = JemallocUtil::get_malloc_stats();
|
||||
if (jemalloc_status.empty()) {
|
||||
return;
|
||||
}
|
||||
ofstream out(StrPrinter << exeDir() << "/jemalloc.json", ios::out | ios::binary | ios::trunc);
|
||||
out << jemalloc_status;
|
||||
out.flush();
|
||||
}
|
||||
|
||||
static void sig_crash(int sig) {
|
||||
signal(sig, SIG_DFL);
|
||||
void *array[MAX_STACK_FRAMES];
|
||||
@ -149,6 +160,12 @@ void System::startDaemon(bool &kill_parent_if_failed) {
|
||||
}
|
||||
|
||||
void System::systemSetup(){
|
||||
|
||||
#ifdef ENABLE_JEMALLOC_DUMP
|
||||
//Save memory report when program exits
|
||||
atexit(save_jemalloc_stats);
|
||||
#endif //ENABLE_JEMALLOC_DUMP
|
||||
|
||||
#if !defined(_WIN32)
|
||||
struct rlimit rlim,rlim_new;
|
||||
if (getrlimit(RLIMIT_CORE, &rlim)==0) {
|
||||
|
74
src/Common/JemallocUtil.cpp
Normal file
74
src/Common/JemallocUtil.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include "JemallocUtil.h"
|
||||
#include "Util/logger.h"
|
||||
#ifdef USE_JEMALLOC
|
||||
#include <iostream>
|
||||
#include <jemalloc/jemalloc.h>
|
||||
#endif
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
void set_profile_active(bool active) {
|
||||
#ifdef USE_JEMALLOC
|
||||
int err = mallctl("prof.active", nullptr, nullptr, (void *)&active, sizeof(active));
|
||||
if (err != 0) {
|
||||
WarnL << "mallctl failed with: " << err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void JemallocUtil::enable_profiling() {
|
||||
set_profile_active(true);
|
||||
}
|
||||
void JemallocUtil::disable_profiling() {
|
||||
set_profile_active(false);
|
||||
}
|
||||
void JemallocUtil::dump(const std::string &file_name) {
|
||||
#ifdef USE_JEMALLOC
|
||||
auto *c_str = file_name.c_str();
|
||||
int err = mallctl("prof.dump", nullptr, nullptr, &c_str, sizeof(const char *));
|
||||
if (err != 0) {
|
||||
std::cerr << "mallctl failed with: " << err << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::string JemallocUtil::get_malloc_stats() {
|
||||
#ifdef USE_JEMALLOC
|
||||
std::string res;
|
||||
malloc_stats_print([](void *opaque, const char *s) { ((std::string *)opaque)->append(s); }, &res, "J");
|
||||
return res;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
void JemallocUtil::some_malloc_stats(const std::function<void(const char *, uint64_t)> &fn) {
|
||||
#ifdef USE_JEMALLOC
|
||||
constexpr std::array<const char *, 8> STATS = {
|
||||
"stats.allocated", "stats.active", "stats.metadata", "stats.metadata_thp",
|
||||
"stats.resident", "stats.mapped", "stats.retained", "stats.zero_reallocs",
|
||||
};
|
||||
|
||||
for (const char *stat : STATS) {
|
||||
size_t value;
|
||||
size_t len = sizeof(value);
|
||||
auto err = mallctl(stat, &value, &len, nullptr, 0);
|
||||
if (err != 0) {
|
||||
ErrorL << "Failed reading " << stat << ": " << err;
|
||||
continue;
|
||||
}
|
||||
fn(stat, value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace mediakit
|
30
src/Common/JemallocUtil.h
Normal file
30
src/Common/JemallocUtil.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef ZLMEDIAKIT_JEMALLOCUTIL_H
|
||||
#define ZLMEDIAKIT_JEMALLOCUTIL_H
|
||||
#include <functional>
|
||||
#include <string>
|
||||
namespace mediakit {
|
||||
class JemallocUtil {
|
||||
public:
|
||||
JemallocUtil() = default;
|
||||
~JemallocUtil() = default;
|
||||
|
||||
static void enable_profiling();
|
||||
|
||||
static void disable_profiling();
|
||||
|
||||
static void dump(const std::string &file_name);
|
||||
static std::string get_malloc_stats();
|
||||
static void some_malloc_stats(const std::function<void(const char *, uint64_t)> &fn);
|
||||
};
|
||||
} // namespace mediakit
|
||||
#endif // ZLMEDIAKIT_JEMALLOCUTIL_H
|
@ -50,7 +50,7 @@ int64_t DeltaStamp::deltaStamp(int64_t stamp) {
|
||||
_last_stamp = stamp;
|
||||
|
||||
// 如果时间戳回退不多,那么返回负值,否则返回加1
|
||||
return -ret < MAX_CTS ? ret : 1;
|
||||
return -ret < MAX_DELTA_STAMP ? ret : 1;
|
||||
}
|
||||
|
||||
void Stamp::setPlayBack(bool playback) {
|
||||
|
@ -194,7 +194,7 @@ static onceToken token([]() {
|
||||
mINI::Instance()[kForbidCacheSuffix] = "";
|
||||
mINI::Instance()[kForwardedIpHeader] = "";
|
||||
mINI::Instance()[kAllowCrossDomains] = 1;
|
||||
mINI::Instance()[kAllowIPRange] = "127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255";
|
||||
mINI::Instance()[kAllowIPRange] = "::1,127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255";
|
||||
});
|
||||
|
||||
} // namespace Http
|
||||
|
@ -61,7 +61,7 @@ bool HttpServerCookie::isExpired() {
|
||||
return _ticker.elapsedTime() > _max_elapsed * 1000;
|
||||
}
|
||||
|
||||
void HttpServerCookie::setAttach(std::shared_ptr<void> attach) {
|
||||
void HttpServerCookie::setAttach(toolkit::Any attach) {
|
||||
_attach = std::move(attach);
|
||||
}
|
||||
|
||||
@ -114,8 +114,7 @@ void HttpCookieManager::onManager() {
|
||||
}
|
||||
}
|
||||
|
||||
HttpServerCookie::Ptr HttpCookieManager::addCookie(const string &cookie_name, const string &uid_in,
|
||||
uint64_t max_elapsed, std::shared_ptr<void> attach, int max_client) {
|
||||
HttpServerCookie::Ptr HttpCookieManager::addCookie(const string &cookie_name, const string &uid_in, uint64_t max_elapsed, toolkit::Any attach, int max_client) {
|
||||
lock_guard<recursive_mutex> lck(_mtx_cookie);
|
||||
auto cookie = _generator.obtain();
|
||||
auto uid = uid_in.empty() ? cookie : uid_in;
|
||||
|
@ -85,14 +85,14 @@ public:
|
||||
/**
|
||||
* 设置附加数据
|
||||
*/
|
||||
void setAttach(std::shared_ptr<void> attach);
|
||||
void setAttach(toolkit::Any attach);
|
||||
|
||||
/*
|
||||
* 获取附加数据
|
||||
*/
|
||||
template <class T>
|
||||
T& getAttach() {
|
||||
return *static_cast<T *>(_attach.get());
|
||||
return _attach.get<T>();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -104,7 +104,7 @@ private:
|
||||
std::string _cookie_uuid;
|
||||
uint64_t _max_elapsed;
|
||||
toolkit::Ticker _ticker;
|
||||
std::shared_ptr<void> _attach;
|
||||
toolkit::Any _attach;
|
||||
std::weak_ptr<HttpCookieManager> _manager;
|
||||
};
|
||||
|
||||
@ -163,7 +163,7 @@ public:
|
||||
*/
|
||||
HttpServerCookie::Ptr addCookie(
|
||||
const std::string &cookie_name, const std::string &uid, uint64_t max_elapsed = COOKIE_DEFAULT_LIFE,
|
||||
std::shared_ptr<void> attach = nullptr,
|
||||
toolkit::Any = toolkit::Any{},
|
||||
int max_client = 1);
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ namespace mediakit {
|
||||
// 每次访问一次该cookie,那么将重新刷新cookie有效期
|
||||
// 假如播放器在60秒内都未访问该cookie,那么将重新触发hls播放鉴权
|
||||
static int kHlsCookieSecond = 60;
|
||||
static int kFindSrcIntervalSecond = 3;
|
||||
static const string kCookieName = "ZL_COOKIE";
|
||||
static const string kHlsSuffix = "/hls.m3u8";
|
||||
static const string kHlsFMP4Suffix = "/hls.fmp4.m3u8";
|
||||
@ -38,6 +39,8 @@ static const string kHlsFMP4Suffix = "/hls.fmp4.m3u8";
|
||||
struct HttpCookieAttachment {
|
||||
// 是否已经查找到过MediaSource
|
||||
bool _find_src = false;
|
||||
// 查找MediaSource计时
|
||||
Ticker _find_src_ticker;
|
||||
//cookie生效作用域,本cookie只对该目录下的文件生效
|
||||
string _path;
|
||||
//上次鉴权失败信息,为空则上次鉴权成功
|
||||
@ -50,29 +53,69 @@ const string &HttpFileManager::getContentType(const char *name) {
|
||||
return HttpConst::getHttpContentType(name);
|
||||
}
|
||||
|
||||
#ifndef ntohll
|
||||
static uint64_t ntohll(uint64_t val) {
|
||||
return (((uint64_t)ntohl(val)) << 32) + ntohl(val >> 32);
|
||||
}
|
||||
#endif
|
||||
namespace {
|
||||
class UInt128 {
|
||||
public:
|
||||
UInt128() = default;
|
||||
|
||||
static uint64_t get_ip_uint64(const std::string &ip) {
|
||||
UInt128(const struct sockaddr_storage &storage) {
|
||||
_family = storage.ss_family;
|
||||
memset(_bytes, 0, 16);
|
||||
switch (storage.ss_family) {
|
||||
case AF_INET: {
|
||||
memcpy(_bytes, &(reinterpret_cast<const struct sockaddr_in &>(storage).sin_addr), 4);
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
memcpy(_bytes, &(reinterpret_cast<const struct sockaddr_in6 &>(storage).sin6_addr), 16);
|
||||
break;
|
||||
}
|
||||
default: CHECK(false, "Invalid socket family"); break;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const UInt128 &that) const { return _family == that._family && !memcmp(_bytes, that._bytes, 16); }
|
||||
|
||||
bool operator<=(const UInt128 &that) const { return *this < that || *this == that; }
|
||||
|
||||
bool operator>=(const UInt128 &that) const { return *this > that || *this == that; }
|
||||
|
||||
bool operator>(const UInt128 &that) const { return that < *this; }
|
||||
|
||||
bool operator<(const UInt128 &that) const {
|
||||
auto sz = _family == AF_INET ? 4 : 16;
|
||||
for (int i = 0; i < sz; ++i) {
|
||||
if (_bytes[i] < that._bytes[i]) {
|
||||
return true;
|
||||
} else if (_bytes[i] > that._bytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
operator bool() const { return _family != -1; }
|
||||
|
||||
bool same_type(const UInt128 &that) const { return _family == that._family; }
|
||||
|
||||
private:
|
||||
int _family = -1;
|
||||
uint8_t _bytes[16];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static UInt128 get_ip_uint64(const std::string &ip) {
|
||||
try {
|
||||
auto storage = SockUtil::make_sockaddr(ip.data(), 0);
|
||||
if (storage.ss_family == AF_INET) {
|
||||
return ntohl(reinterpret_cast<uint32_t &>(reinterpret_cast<struct sockaddr_in &>(storage).sin_addr));
|
||||
}
|
||||
if (storage.ss_family == AF_INET6) {
|
||||
return ntohll(reinterpret_cast<uint64_t &>(reinterpret_cast<struct sockaddr_in6 &>(storage).sin6_addr));
|
||||
}
|
||||
return UInt128(SockUtil::make_sockaddr(ip.data(), 0));
|
||||
} catch (std::exception &ex) {
|
||||
WarnL << ex.what();
|
||||
}
|
||||
return 0;
|
||||
return UInt128();
|
||||
}
|
||||
|
||||
bool HttpFileManager::isIPAllowed(const std::string &ip) {
|
||||
using IPRangs = std::vector<std::pair<uint64_t /*min_ip*/, uint64_t /*max_ip*/>>;
|
||||
using IPRangs = std::vector<std::pair<UInt128 /*min_ip*/, UInt128 /*max_ip*/>>;
|
||||
GET_CONFIG_FUNC(IPRangs, allow_ip_range, Http::kAllowIPRange, [](const string &str) -> IPRangs {
|
||||
IPRangs ret;
|
||||
auto vec = split(str, ",");
|
||||
@ -84,13 +127,17 @@ bool HttpFileManager::isIPAllowed(const std::string &ip) {
|
||||
if (range.size() == 2) {
|
||||
auto ip_min = get_ip_uint64(trim(range[0]));
|
||||
auto ip_max = get_ip_uint64(trim(range[1]));
|
||||
if (ip_min && ip_max) {
|
||||
if (ip_min && ip_max && ip_min.same_type(ip_max)) {
|
||||
ret.emplace_back(ip_min, ip_max);
|
||||
} else {
|
||||
WarnL << "Invalid ip range or family: " << item;
|
||||
}
|
||||
} else if (range.size() == 1) {
|
||||
auto ip = get_ip_uint64(trim(range[0]));
|
||||
if (ip) {
|
||||
ret.emplace_back(ip, ip);
|
||||
} else {
|
||||
WarnL << "Invalid ip: " << item;
|
||||
}
|
||||
} else {
|
||||
WarnL << "Invalid ip range: " << item;
|
||||
@ -104,7 +151,7 @@ bool HttpFileManager::isIPAllowed(const std::string &ip) {
|
||||
}
|
||||
auto ip_int = get_ip_uint64(ip);
|
||||
for (auto &range : allow_ip_range) {
|
||||
if (ip_int >= range.first && ip_int <= range.second) {
|
||||
if (ip_int.same_type(range.first) && ip_int >= range.first && ip_int <= range.second) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -370,7 +417,9 @@ static void canAccessPath(Session &sender, const Parser &parser, const MediaInfo
|
||||
// hls相关信息
|
||||
attach->_hls_data = std::make_shared<HlsCookieData>(media_info, info);
|
||||
}
|
||||
callback(err_msg, HttpCookieManager::Instance().addCookie(kCookieName, uid, life_second, attach));
|
||||
toolkit::Any any;
|
||||
any.set(std::move(attach));
|
||||
callback(err_msg, HttpCookieManager::Instance().addCookie(kCookieName, uid, life_second, std::move(any)));
|
||||
} else {
|
||||
callback(err_msg, nullptr);
|
||||
}
|
||||
@ -488,14 +537,15 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m
|
||||
return;
|
||||
}
|
||||
|
||||
auto src = cookie->getAttach<HttpCookieAttachment>()._hls_data->getMediaSource();
|
||||
auto &attach = cookie->getAttach<HttpCookieAttachment>();
|
||||
auto src = attach._hls_data->getMediaSource();
|
||||
if (src) {
|
||||
// 直接从内存获取m3u8索引文件(而不是从文件系统)
|
||||
response_file(cookie, cb, file_path, parser, src->getIndexFile());
|
||||
return;
|
||||
}
|
||||
if (cookie->getAttach<HttpCookieAttachment>()._find_src) {
|
||||
//查找过MediaSource,但是流已经注销了,不用再查找
|
||||
if (attach._find_src && attach._find_src_ticker.elapsedTime() < kFindSrcIntervalSecond * 1000) {
|
||||
// 最近已经查找过MediaSource了,为了防止频繁查找导致占用全局互斥锁的问题,我们尝试直接从磁盘返回hls索引文件
|
||||
response_file(cookie, cb, file_path, parser);
|
||||
return;
|
||||
}
|
||||
@ -516,6 +566,9 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m
|
||||
// 标记找到MediaSource
|
||||
attach._find_src = true;
|
||||
|
||||
// 重置查找MediaSource计时
|
||||
attach._find_src_ticker.resetTime();
|
||||
|
||||
// m3u8文件可能不存在, 等待m3u8索引文件按需生成
|
||||
hls->getIndexFile([response_file, file_path, cookie, cb, parser](const string &file) {
|
||||
response_file(cookie, cb, file_path, parser, file);
|
||||
|
@ -54,8 +54,11 @@ void FlvPlayer::onResponseCompleted(const SockException &ex) {
|
||||
}
|
||||
|
||||
void FlvPlayer::onResponseBody(const char *buf, size_t size) {
|
||||
if (!_benchmark_mode) {
|
||||
// 性能测试模式不做数据解析,节省cpu
|
||||
FlvSplitter::input(buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
|
||||
return onMetadata(metadata);
|
||||
@ -64,6 +67,7 @@ bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
|
||||
void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) {
|
||||
if (!_play_result && !packet->isConfigFrame()) {
|
||||
_play_result = true;
|
||||
_benchmark_mode = (*this)[Client::kBenchmarkMode].as<int>();
|
||||
onPlayResult(SockException(Err_success, "play http-flv success"));
|
||||
}
|
||||
onRtmpPacket(std::move(packet));
|
||||
|
@ -40,6 +40,7 @@ private:
|
||||
|
||||
private:
|
||||
bool _play_result = false;
|
||||
bool _benchmark_mode = false;
|
||||
};
|
||||
|
||||
using FlvPlayerImp = FlvPlayerBase<FlvPlayer>;
|
||||
|
@ -1,6 +1,6 @@
|
||||
此目录下的所有.cpp文件将被编译成可执行程序(不包含此目录下的子目录).
|
||||
子目录DeviceHK为海康IPC的适配程序,需要先下载海康的SDK才能编译,
|
||||
由于操作麻烦,所以仅把源码放在这仅供参考.
|
||||
由于操作麻烦,所以仅把源码放在这里仅供参考.
|
||||
|
||||
- test_benchmark.cpp
|
||||
|
||||
|
@ -93,8 +93,8 @@
|
||||
var recvOnly = true;
|
||||
var resArr = [];
|
||||
|
||||
var ishttps = 'https:' == document.location.protocol ? true : false;
|
||||
var isLocal = "file:" == document.location.protocol ? true : false;
|
||||
var ishttps = 'https:' === document.location.protocol;
|
||||
var isLocal = "file:" === document.location.protocol;
|
||||
|
||||
const searchParams = new URL(document.location.href).searchParams;
|
||||
let type = searchParams.get('type');
|
||||
@ -105,7 +105,7 @@
|
||||
const apiPath = `/index/api/webrtc?app=${searchParams.get('app') ?? 'live'}&stream=${searchParams.get('stream') ?? 'test'}&type=${type}`;
|
||||
|
||||
if(!ishttps && !isLocal){
|
||||
alert('本demo需要在https的网站访问 ,如果你要推流的话(this demo must access in site of https if you want push stream)');
|
||||
alert('本demo需要在https的网站访问, 如果你要推流的话(this demo must access in site of https if you want to push stream)');
|
||||
}
|
||||
|
||||
const apiHost = isLocal ? "http://127.0.0.1" : `${document.location.protocol}//${window.location.host}`;
|
||||
|
Loading…
Reference in New Issue
Block a user