补提rtp app名称自定义相关文件修改
This commit is contained in:
parent
d771530316
commit
eab1dbc606
|
|
@ -20,10 +20,11 @@ typedef struct mk_rtp_server_t *mk_rtp_server;
|
||||||
* 创建GB28181 RTP 服务器
|
* 创建GB28181 RTP 服务器
|
||||||
* @param port 监听端口,0则为随机
|
* @param port 监听端口,0则为随机
|
||||||
* @param tcp_mode tcp模式(0: 不监听端口 1: 监听端口 2: 主动连接到服务端)
|
* @param tcp_mode tcp模式(0: 不监听端口 1: 监听端口 2: 主动连接到服务端)
|
||||||
|
* @param app_name 该端口绑定的app名称,为""使用默认配置 rtp
|
||||||
* @param stream_id 该端口绑定的流id
|
* @param stream_id 该端口绑定的流id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *stream_id);
|
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *app_name, const char *stream_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCP 主动模式时连接到服务器是否成功的回调
|
* TCP 主动模式时连接到服务器是否成功的回调
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ using namespace toolkit;
|
||||||
#include "Rtp/RtpServer.h"
|
#include "Rtp/RtpServer.h"
|
||||||
using namespace mediakit;
|
using namespace mediakit;
|
||||||
|
|
||||||
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *stream_id) {
|
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *app_name, const char *stream_id) {
|
||||||
RtpServer::Ptr *server = new RtpServer::Ptr(new RtpServer);
|
RtpServer::Ptr *server = new RtpServer::Ptr(new RtpServer);
|
||||||
(*server)->start(port, stream_id, (RtpServer::TcpMode)tcp_mode);
|
(*server)->start(port, app_name, stream_id, (RtpServer::TcpMode)tcp_mode);
|
||||||
return (mk_rtp_server)server;
|
return (mk_rtp_server)server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -469,14 +469,14 @@ Value makeMediaSourceJson(MediaSource &media){
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_RTPPROXY)
|
#if defined(ENABLE_RTPPROXY)
|
||||||
uint16_t openRtpServer(uint16_t local_port, const string &stream_id, int tcp_mode, const string &local_ip, bool re_use_port, uint32_t ssrc, int only_track, bool multiplex) {
|
uint16_t openRtpServer(uint16_t local_port, const string &app_name, const string &stream_id, int tcp_mode, const string &local_ip, bool re_use_port, uint32_t ssrc, int only_track, bool multiplex) {
|
||||||
if (s_rtp_server.find(stream_id)) {
|
if (s_rtp_server.find(stream_id)) {
|
||||||
//为了防止RtpProcess所有权限混乱的问题,不允许重复添加相同的stream_id
|
//为了防止RtpProcess所有权限混乱的问题,不允许重复添加相同的stream_id
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto server = s_rtp_server.makeWithAction(stream_id, [&](RtpServer::Ptr server) {
|
auto server = s_rtp_server.makeWithAction(stream_id, [&](RtpServer::Ptr server) {
|
||||||
server->start(local_port, stream_id, (RtpServer::TcpMode)tcp_mode, local_ip.c_str(), re_use_port, ssrc, only_track, multiplex);
|
server->start(local_port, app_name, stream_id, (RtpServer::TcpMode)tcp_mode, local_ip.c_str(), re_use_port, ssrc, only_track, multiplex);
|
||||||
});
|
});
|
||||||
server->setOnDetach([stream_id]() {
|
server->setOnDetach([stream_id]() {
|
||||||
//设置rtp超时移除事件
|
//设置rtp超时移除事件
|
||||||
|
|
@ -1192,7 +1192,7 @@ void installWebApi() {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("stream_id");
|
CHECK_ARGS("stream_id");
|
||||||
|
|
||||||
auto process = RtpSelector::Instance().getProcess(allArgs["stream_id"], false);
|
auto process = RtpSelector::Instance().getProcess(allArgs["app_name"], allArgs["stream_id"], false);
|
||||||
if (!process) {
|
if (!process) {
|
||||||
val["exist"] = false;
|
val["exist"] = false;
|
||||||
return;
|
return;
|
||||||
|
|
@ -1204,6 +1204,7 @@ void installWebApi() {
|
||||||
api_regist("/index/api/openRtpServer",[](API_ARGS_MAP){
|
api_regist("/index/api/openRtpServer",[](API_ARGS_MAP){
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("port", "stream_id");
|
CHECK_ARGS("port", "stream_id");
|
||||||
|
auto app_name = allArgs["app_name"]; // 默认rtp
|
||||||
auto stream_id = allArgs["stream_id"];
|
auto stream_id = allArgs["stream_id"];
|
||||||
auto tcp_mode = allArgs["tcp_mode"].as<int>();
|
auto tcp_mode = allArgs["tcp_mode"].as<int>();
|
||||||
if (allArgs["enable_tcp"].as<int>() && !tcp_mode) {
|
if (allArgs["enable_tcp"].as<int>() && !tcp_mode) {
|
||||||
|
|
@ -1219,7 +1220,8 @@ void installWebApi() {
|
||||||
if (!allArgs["local_ip"].empty()) {
|
if (!allArgs["local_ip"].empty()) {
|
||||||
local_ip = allArgs["local_ip"];
|
local_ip = allArgs["local_ip"];
|
||||||
}
|
}
|
||||||
auto port = openRtpServer(allArgs["port"], stream_id, tcp_mode, local_ip, allArgs["re_use_port"].as<bool>(),
|
auto port = openRtpServer(
|
||||||
|
allArgs["port"], app_name, stream_id, tcp_mode, local_ip, allArgs["re_use_port"].as<bool>(),
|
||||||
allArgs["ssrc"].as<uint32_t>(), only_track);
|
allArgs["ssrc"].as<uint32_t>(), only_track);
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
throw InvalidArgsException("该stream_id已存在");
|
throw InvalidArgsException("该stream_id已存在");
|
||||||
|
|
@ -1231,6 +1233,7 @@ void installWebApi() {
|
||||||
api_regist("/index/api/openRtpServerMultiplex", [](API_ARGS_MAP) {
|
api_regist("/index/api/openRtpServerMultiplex", [](API_ARGS_MAP) {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("port", "stream_id");
|
CHECK_ARGS("port", "stream_id");
|
||||||
|
auto app_name = allArgs["app_name"];
|
||||||
auto stream_id = allArgs["stream_id"];
|
auto stream_id = allArgs["stream_id"];
|
||||||
auto tcp_mode = allArgs["tcp_mode"].as<int>();
|
auto tcp_mode = allArgs["tcp_mode"].as<int>();
|
||||||
if (allArgs["enable_tcp"].as<int>() && !tcp_mode) {
|
if (allArgs["enable_tcp"].as<int>() && !tcp_mode) {
|
||||||
|
|
@ -1246,7 +1249,7 @@ void installWebApi() {
|
||||||
if (!allArgs["local_ip"].empty()) {
|
if (!allArgs["local_ip"].empty()) {
|
||||||
local_ip = allArgs["local_ip"];
|
local_ip = allArgs["local_ip"];
|
||||||
}
|
}
|
||||||
auto port = openRtpServer(allArgs["port"], stream_id, tcp_mode, local_ip, true, 0, only_track,true);
|
auto port = openRtpServer(allArgs["port"], app_name, stream_id, tcp_mode, local_ip, true, 0, only_track, true);
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
throw InvalidArgsException("该stream_id已存在");
|
throw InvalidArgsException("该stream_id已存在");
|
||||||
}
|
}
|
||||||
|
|
@ -1303,6 +1306,7 @@ void installWebApi() {
|
||||||
Value obj;
|
Value obj;
|
||||||
obj["stream_id"] = pr.first;
|
obj["stream_id"] = pr.first;
|
||||||
obj["port"] = pr.second->getPort();
|
obj["port"] = pr.second->getPort();
|
||||||
|
obj["app_name"] = pr.second->getAppName();
|
||||||
val["data"].append(obj);
|
val["data"].append(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1411,7 +1415,7 @@ void installWebApi() {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("stream_id");
|
CHECK_ARGS("stream_id");
|
||||||
//只是暂停流的检查,流媒体服务器做为流负载服务,收流就转发,RTSP/RTMP有自己暂停协议
|
//只是暂停流的检查,流媒体服务器做为流负载服务,收流就转发,RTSP/RTMP有自己暂停协议
|
||||||
auto rtp_process = RtpSelector::Instance().getProcess(allArgs["stream_id"], false);
|
auto rtp_process = RtpSelector::Instance().getProcess(allArgs["app"], allArgs["stream_id"], false);
|
||||||
if (rtp_process) {
|
if (rtp_process) {
|
||||||
rtp_process->setStopCheckRtp(true);
|
rtp_process->setStopCheckRtp(true);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1422,7 +1426,7 @@ void installWebApi() {
|
||||||
api_regist("/index/api/resumeRtpCheck", [](API_ARGS_MAP) {
|
api_regist("/index/api/resumeRtpCheck", [](API_ARGS_MAP) {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("stream_id");
|
CHECK_ARGS("stream_id");
|
||||||
auto rtp_process = RtpSelector::Instance().getProcess(allArgs["stream_id"], false);
|
auto rtp_process = RtpSelector::Instance().getProcess(allArgs["app"], allArgs["stream_id"], false);
|
||||||
if (rtp_process) {
|
if (rtp_process) {
|
||||||
rtp_process->setStopCheckRtp(false);
|
rtp_process->setStopCheckRtp(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,9 @@ void installWebApi();
|
||||||
void unInstallWebApi();
|
void unInstallWebApi();
|
||||||
|
|
||||||
#if defined(ENABLE_RTPPROXY)
|
#if defined(ENABLE_RTPPROXY)
|
||||||
uint16_t openRtpServer(uint16_t local_port, const std::string &stream_id, int tcp_mode, const std::string &local_ip, bool re_use_port, uint32_t ssrc, int only_track, bool multiplex=false);
|
uint16_t openRtpServer(uint16_t local_port, const std::string &app_name, const std::string &stream_id, int tcp_mode, const std::string &local_ip, bool re_use_port, uint32_t ssrc, int only_track, bool multiplex=false);
|
||||||
|
//void connectRtpServer(const std::string &stream_id, const std::string &dst_url, uint16_t dst_port, const std::function<void(const toolkit::SockException &ex)> &cb);
|
||||||
|
//bool closeRtpServer(const std::string &stream_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Json::Value makeMediaSourceJson(mediakit::MediaSource &media);
|
Json::Value makeMediaSourceJson(mediakit::MediaSource &media);
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ const string kAudioMtuSize = RTP_FIELD "audioMtuSize";
|
||||||
const string kRtpMaxSize = RTP_FIELD "rtpMaxSize";
|
const string kRtpMaxSize = RTP_FIELD "rtpMaxSize";
|
||||||
const string kLowLatency = RTP_FIELD "lowLatency";
|
const string kLowLatency = RTP_FIELD "lowLatency";
|
||||||
const string kH264StapA = RTP_FIELD "h264_stap_a";
|
const string kH264StapA = RTP_FIELD "h264_stap_a";
|
||||||
|
const string kRtpAppName = RTP_FIELD "rtpAppName";
|
||||||
|
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
mINI::Instance()[kVideoMtuSize] = 1400;
|
mINI::Instance()[kVideoMtuSize] = 1400;
|
||||||
|
|
@ -269,6 +270,7 @@ static onceToken token([]() {
|
||||||
mINI::Instance()[kRtpMaxSize] = 10;
|
mINI::Instance()[kRtpMaxSize] = 10;
|
||||||
mINI::Instance()[kLowLatency] = 0;
|
mINI::Instance()[kLowLatency] = 0;
|
||||||
mINI::Instance()[kH264StapA] = 1;
|
mINI::Instance()[kH264StapA] = 1;
|
||||||
|
mINI::Instance()[kRtpAppName] = "rtp";
|
||||||
});
|
});
|
||||||
} // namespace Rtp
|
} // namespace Rtp
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue