mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-03-11 16:40:53 +08:00
Merge branch 'master' into dev
This commit is contained in:
Submodule 3rdpart/ZLToolKit updated: 9a545d7d09...6a8bdfc80d
@@ -193,6 +193,12 @@ if(UNIX)
|
||||
"-Wall;-Wextra"
|
||||
"-Wno-unused-function;-Wno-unused-parameter;-Wno-unused-variable"
|
||||
"-Wno-error=extra;-Wno-error=missing-field-initializers;-Wno-error=type-limits")
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(COMPILE_OPTIONS_DEFAULT ${COMPILE_OPTIONS_DEFAULT} "-g3")
|
||||
else()
|
||||
set(COMPILE_OPTIONS_DEFAULT ${COMPILE_OPTIONS_DEFAULT} "-g0")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if (MSVC)
|
||||
set(COMPILE_OPTIONS_DEFAULT
|
||||
|
||||
@@ -289,7 +289,7 @@ sslport=0
|
||||
# rtmp是否直接代理模式
|
||||
directProxy=1
|
||||
#h265 rtmp打包采用增强型rtmp标准还是国内拓展标准
|
||||
enhanced=1
|
||||
enhanced=0
|
||||
|
||||
[rtp]
|
||||
#音频mtu大小,该参数限制rtp最大字节数,推荐不要超过1400
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
%bcond_with cxx_api
|
||||
|
||||
Name: ZLMediaKit
|
||||
Version: 5.0.0
|
||||
Version: 8.0.0
|
||||
Release: 1%{?dist}
|
||||
Summary: A lightweight, high performance and stable stream server and client framework based on C++11.
|
||||
|
||||
|
||||
@@ -944,25 +944,29 @@ void installWebApi() {
|
||||
|
||||
//批量断开tcp连接,比如说可以断开rtsp、rtmp播放器等
|
||||
//测试url http://127.0.0.1/index/api/kick_sessions?local_port=1935
|
||||
api_regist("/index/api/kick_sessions",[](API_ARGS_MAP){
|
||||
api_regist("/index/api/kick_sessions", [](API_ARGS_MAP) {
|
||||
CHECK_SECRET();
|
||||
uint16_t local_port = allArgs["local_port"].as<uint16_t>();
|
||||
string peer_ip = allArgs["peer_ip"];
|
||||
size_t count_hit = 0;
|
||||
|
||||
list<Session::Ptr> session_list;
|
||||
SessionMap::Instance().for_each_session([&](const string &id,const Session::Ptr &session){
|
||||
if(local_port != 0 && local_port != session->get_local_port()){
|
||||
SessionMap::Instance().for_each_session([&](const string &id, const Session::Ptr &session) {
|
||||
if (local_port != 0 && local_port != session->get_local_port()) {
|
||||
return;
|
||||
}
|
||||
if(!peer_ip.empty() && peer_ip != session->get_peer_ip()){
|
||||
if (!peer_ip.empty() && peer_ip != session->get_peer_ip()) {
|
||||
return;
|
||||
}
|
||||
if (session->getIdentifier() == sender.getIdentifier()) {
|
||||
// 忽略本http链接
|
||||
return;
|
||||
}
|
||||
session_list.emplace_back(session);
|
||||
++count_hit;
|
||||
});
|
||||
|
||||
for(auto &session : session_list){
|
||||
for (auto &session : session_list) {
|
||||
session->safeShutdown();
|
||||
}
|
||||
val["count_hit"] = (Json::UInt64)count_hit;
|
||||
|
||||
@@ -346,6 +346,11 @@ int start_main(int argc,char *argv[]) {
|
||||
uint16_t srtPort = mINI::Instance()[SRT::kPort];
|
||||
#endif //defined(ENABLE_SRT)
|
||||
|
||||
installWebApi();
|
||||
InfoL << "已启动http api 接口";
|
||||
installWebHook();
|
||||
InfoL << "已启动http hook 接口";
|
||||
|
||||
try {
|
||||
auto &secret = mINI::Instance()[API::kSecret];
|
||||
if (secret == "035c73f7-bb6b-4889-a715-d9eb2d1925cc" || secret.empty()) {
|
||||
@@ -403,11 +408,6 @@ int start_main(int argc,char *argv[]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
installWebApi();
|
||||
InfoL << "已启动http api 接口";
|
||||
installWebHook();
|
||||
InfoL << "已启动http hook 接口";
|
||||
|
||||
//设置退出信号处理函数
|
||||
static semaphore sem;
|
||||
signal(SIGINT, [](int) {
|
||||
|
||||
@@ -244,8 +244,8 @@ AVFrame *FFmpegFrame::get() const {
|
||||
|
||||
void FFmpegFrame::fillPicture(AVPixelFormat target_format, int target_width, int target_height) {
|
||||
assert(_data == nullptr);
|
||||
_data = new char[av_image_get_buffer_size(target_format, target_width, target_height, 1)];
|
||||
av_image_fill_arrays(_frame->data, _frame->linesize, (uint8_t *) _data, target_format, target_width, target_height,1);
|
||||
_data = new char[av_image_get_buffer_size(target_format, target_width, target_height, 32)];
|
||||
av_image_fill_arrays(_frame->data, _frame->linesize, (uint8_t *) _data, target_format, target_width, target_height, 32);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -673,7 +673,7 @@ FFmpegFrame::Ptr FFmpegSws::inputFrame(const FFmpegFrame::Ptr &frame, int &ret,
|
||||
auto out = std::make_shared<FFmpegFrame>();
|
||||
if (!out->get()->data[0]) {
|
||||
if (data) {
|
||||
av_image_fill_arrays(out->get()->data, out->get()->linesize, data, _target_format, target_width, target_height, 1);
|
||||
av_image_fill_arrays(out->get()->data, out->get()->linesize, data, _target_format, target_width, target_height, 32);
|
||||
} else {
|
||||
out->fillPicture(_target_format, target_width, target_height);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ static onceToken token([]() {
|
||||
mINI::Instance()[kHandshakeSecond] = 15;
|
||||
mINI::Instance()[kKeepAliveSecond] = 15;
|
||||
mINI::Instance()[kDirectProxy] = 1;
|
||||
mINI::Instance()[kEnhanced] = 1;
|
||||
mINI::Instance()[kEnhanced] = 0;
|
||||
});
|
||||
} // namespace Rtmp
|
||||
|
||||
|
||||
@@ -124,29 +124,18 @@ ssize_t HttpSession::onRecvHeader(const char *header, size_t len) {
|
||||
}
|
||||
|
||||
//// body size明确指定且小于最大值的情况 ////
|
||||
auto body = std::make_shared<std::string>();
|
||||
// 预留一定的内存buffer,防止频繁的内存拷贝
|
||||
body->reserve(content_len);
|
||||
|
||||
_on_recv_body = [this, body, content_len, it](const char *data, size_t len) mutable {
|
||||
body->append(data, len);
|
||||
if (body->size() < content_len) {
|
||||
// 未收满数据
|
||||
return true;
|
||||
}
|
||||
|
||||
_on_recv_body = [this, it](const char *data, size_t len) mutable {
|
||||
// 收集body完毕
|
||||
_parser.setContent(std::move(*body));
|
||||
_parser.setContent(std::string(data, len));
|
||||
(this->*(it->second))();
|
||||
_parser.clear();
|
||||
|
||||
// 后续是header
|
||||
setContentLen(0);
|
||||
// _on_recv_body置空
|
||||
return false;
|
||||
};
|
||||
|
||||
// 声明后续都是body;Http body在本对象缓冲,不通过HttpRequestSplitter保存
|
||||
return -1;
|
||||
// 声明body长度,通过HttpRequestSplitter缓存然后一次性回调到_on_recv_body
|
||||
return content_len;
|
||||
}
|
||||
|
||||
void HttpSession::onRecvContent(const char *data, size_t len) {
|
||||
|
||||
@@ -46,11 +46,7 @@ RtpSession::RtpSession(const Socket::Ptr &sock)
|
||||
}
|
||||
}
|
||||
|
||||
RtpSession::~RtpSession() {
|
||||
if (_process) {
|
||||
RtpSelector::Instance().delProcess(_stream_id, _process.get());
|
||||
}
|
||||
}
|
||||
RtpSession::~RtpSession() = default;
|
||||
|
||||
void RtpSession::onRecv(const Buffer::Ptr &data) {
|
||||
if (_is_udp) {
|
||||
@@ -62,6 +58,9 @@ void RtpSession::onRecv(const Buffer::Ptr &data) {
|
||||
|
||||
void RtpSession::onError(const SockException &err) {
|
||||
WarnP(this) << _stream_id << " " << err;
|
||||
if (_process) {
|
||||
RtpSelector::Instance().delProcess(_stream_id, _process.get());
|
||||
}
|
||||
}
|
||||
|
||||
void RtpSession::onManager() {
|
||||
|
||||
Reference in New Issue
Block a user