for rtp server can config pt
This commit is contained in:
parent
559b4d3fe7
commit
6a337adc91
|
|
@ -265,6 +265,28 @@ timeoutSec=15
|
||||||
#该范围同时限制rtsp服务器udp端口范围
|
#该范围同时限制rtsp服务器udp端口范围
|
||||||
port_range=30000-35000
|
port_range=30000-35000
|
||||||
|
|
||||||
|
#rtp h264 负载的pt
|
||||||
|
h264_pt=98
|
||||||
|
|
||||||
|
#rtp h265 负载的pt
|
||||||
|
h265_pt=99
|
||||||
|
|
||||||
|
#rtp ps 负载的pt
|
||||||
|
ps_pt=96
|
||||||
|
|
||||||
|
#rtp ts 负载的pt
|
||||||
|
ts_pt=33
|
||||||
|
|
||||||
|
#rtp opus 负载的pt
|
||||||
|
opus_pt=100
|
||||||
|
|
||||||
|
#rtp g711u 负载的pt
|
||||||
|
g711u_pt=0
|
||||||
|
|
||||||
|
#rtp g711a 负载的pt
|
||||||
|
g711a_pt=8
|
||||||
|
|
||||||
|
|
||||||
[rtc]
|
[rtc]
|
||||||
#rtc播放推流、播放超时时间
|
#rtc播放推流、播放超时时间
|
||||||
timeoutSec=15
|
timeoutSec=15
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
* may be found in the AUTHORS file in the root of the source tree.
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include "Common/config.h"
|
#include "Common/config.h"
|
||||||
#include "Util/util.h"
|
#include "Util/NoticeCenter.h"
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
#include "Util/onceToken.h"
|
#include "Util/onceToken.h"
|
||||||
#include "Util/NoticeCenter.h"
|
#include "Util/util.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
|
|
@ -159,9 +159,7 @@ namespace Shell {
|
||||||
#define SHELL_FIELD "shell."
|
#define SHELL_FIELD "shell."
|
||||||
const string kMaxReqSize = SHELL_FIELD "maxReqSize";
|
const string kMaxReqSize = SHELL_FIELD "maxReqSize";
|
||||||
|
|
||||||
static onceToken token([](){
|
static onceToken token([]() { mINI::Instance()[kMaxReqSize] = 1024; });
|
||||||
mINI::Instance()[kMaxReqSize] = 1024;
|
|
||||||
});
|
|
||||||
} // namespace Shell
|
} // namespace Shell
|
||||||
|
|
||||||
////////////RTSP服务器配置///////////
|
////////////RTSP服务器配置///////////
|
||||||
|
|
@ -193,8 +191,7 @@ static onceToken token([](){
|
||||||
mINI::Instance()[kHandshakeSecond] = 15;
|
mINI::Instance()[kHandshakeSecond] = 15;
|
||||||
mINI::Instance()[kKeepAliveSecond] = 15;
|
mINI::Instance()[kKeepAliveSecond] = 15;
|
||||||
});
|
});
|
||||||
} //namespace RTMP
|
} // namespace Rtmp
|
||||||
|
|
||||||
|
|
||||||
////////////RTP配置///////////
|
////////////RTP配置///////////
|
||||||
namespace Rtp {
|
namespace Rtp {
|
||||||
|
|
@ -210,7 +207,7 @@ static onceToken token([](){
|
||||||
mINI::Instance()[kAudioMtuSize] = 600;
|
mINI::Instance()[kAudioMtuSize] = 600;
|
||||||
mINI::Instance()[kRtpMaxSize] = 10;
|
mINI::Instance()[kRtpMaxSize] = 10;
|
||||||
});
|
});
|
||||||
} //namespace Rtsp
|
} // namespace Rtp
|
||||||
|
|
||||||
////////////组播配置///////////
|
////////////组播配置///////////
|
||||||
namespace MultiCast {
|
namespace MultiCast {
|
||||||
|
|
@ -275,22 +272,34 @@ static onceToken token([](){
|
||||||
});
|
});
|
||||||
} // namespace Hls
|
} // namespace Hls
|
||||||
|
|
||||||
|
|
||||||
////////////Rtp代理相关配置///////////
|
////////////Rtp代理相关配置///////////
|
||||||
namespace RtpProxy {
|
namespace RtpProxy {
|
||||||
#define RTP_PROXY_FIELD "rtp_proxy."
|
#define RTP_PROXY_FIELD "rtp_proxy."
|
||||||
const string kDumpDir = RTP_PROXY_FIELD "dumpDir";
|
const string kDumpDir = RTP_PROXY_FIELD "dumpDir";
|
||||||
const string kTimeoutSec = RTP_PROXY_FIELD "timeoutSec";
|
const string kTimeoutSec = RTP_PROXY_FIELD "timeoutSec";
|
||||||
const string kPortRange = RTP_PROXY_FIELD "port_range";
|
const string kPortRange = RTP_PROXY_FIELD "port_range";
|
||||||
|
const string KH264PT = RTP_PROXY_FIELD "h264_pt";
|
||||||
|
const string KH265PT = RTP_PROXY_FIELD "h265_pt";
|
||||||
|
const string KPSPT = RTP_PROXY_FIELD "ps_pt";
|
||||||
|
const string KTSPT = RTP_PROXY_FIELD "ts_pt";
|
||||||
|
const string KOpusPT = RTP_PROXY_FIELD "opus_pt";
|
||||||
|
const string KG711UPT = RTP_PROXY_FIELD "g711u_pt";
|
||||||
|
const string KG711APT = RTP_PROXY_FIELD "g711a_pt";
|
||||||
|
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
mINI::Instance()[kDumpDir] = "";
|
mINI::Instance()[kDumpDir] = "";
|
||||||
mINI::Instance()[kTimeoutSec] = 15;
|
mINI::Instance()[kTimeoutSec] = 15;
|
||||||
mINI::Instance()[kPortRange] = "30000-35000";
|
mINI::Instance()[kPortRange] = "30000-35000";
|
||||||
|
mINI::Instance()[KH264PT] = 98;
|
||||||
|
mINI::Instance()[KH265PT] = 99;
|
||||||
|
mINI::Instance()[KPSPT] = 96;
|
||||||
|
mINI::Instance()[KTSPT] = 33;
|
||||||
|
mINI::Instance()[KOpusPT] = 100;
|
||||||
|
mINI::Instance()[KG711UPT] = 0;
|
||||||
|
mINI::Instance()[KG711APT] = 8;
|
||||||
});
|
});
|
||||||
} // namespace RtpProxy
|
} // namespace RtpProxy
|
||||||
|
|
||||||
|
|
||||||
namespace Client {
|
namespace Client {
|
||||||
const string kNetAdapter = "net_adapter";
|
const string kNetAdapter = "net_adapter";
|
||||||
const string kRtpType = "rtp_type";
|
const string kRtpType = "rtp_type";
|
||||||
|
|
@ -302,7 +311,7 @@ const string kMediaTimeoutMS = "media_timeout_ms";
|
||||||
const string kBeatIntervalMS = "beat_interval_ms";
|
const string kBeatIntervalMS = "beat_interval_ms";
|
||||||
const string kBenchmarkMode = "benchmark_mode";
|
const string kBenchmarkMode = "benchmark_mode";
|
||||||
const string kWaitTrackReady = "wait_track_ready";
|
const string kWaitTrackReady = "wait_track_ready";
|
||||||
}
|
} // namespace Client
|
||||||
|
|
||||||
} // namespace mediakit
|
} // namespace mediakit
|
||||||
|
|
||||||
|
|
@ -370,13 +379,9 @@ public:
|
||||||
// printf("%s %d\r\n", __FUNCTION__, (int) _is_thread_local);
|
// printf("%s %d\r\n", __FUNCTION__, (int) _is_thread_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *operator new(size_t sz) {
|
void *operator new(size_t sz) { return __real_malloc(sz); }
|
||||||
return __real_malloc(sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete(void *ptr) {
|
void operator delete(void *ptr) { __real_free(ptr); }
|
||||||
__real_free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void addBlock(size_t c) {
|
void addBlock(size_t c) {
|
||||||
if (total_mem) {
|
if (total_mem) {
|
||||||
|
|
@ -410,13 +415,9 @@ public:
|
||||||
ptr->addBlock(1);
|
ptr->addBlock(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~MemThreadInfoLocal() {
|
~MemThreadInfoLocal() { ptr->delBlock(1); }
|
||||||
ptr->delBlock(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
MemThreadInfo *get() const {
|
MemThreadInfo *get() const { return ptr; }
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MemThreadInfo *ptr;
|
MemThreadInfo *ptr;
|
||||||
|
|
@ -465,10 +466,10 @@ public:
|
||||||
#if (defined(__linux__) && !defined(ANDROID)) || defined(__MACH__)
|
#if (defined(__linux__) && !defined(ANDROID)) || defined(__MACH__)
|
||||||
#define MAX_STACK_FRAMES 128
|
#define MAX_STACK_FRAMES 128
|
||||||
#define MEM_WARING
|
#define MEM_WARING
|
||||||
|
#include <execinfo.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <execinfo.h>
|
|
||||||
|
|
||||||
static void print_mem_waring(size_t c) {
|
static void print_mem_waring(size_t c) {
|
||||||
void *array[MAX_STACK_FRAMES];
|
void *array[MAX_STACK_FRAMES];
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,14 @@
|
||||||
* may be found in the AUTHORS file in the root of the source tree.
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef COMMON_CONFIG_H
|
#ifndef COMMON_CONFIG_H
|
||||||
#define COMMON_CONFIG_H
|
#define COMMON_CONFIG_H
|
||||||
|
|
||||||
#include <functional>
|
#include "Util/NoticeCenter.h"
|
||||||
#include "Util/mini.h"
|
#include "Util/mini.h"
|
||||||
#include "Util/onceToken.h"
|
#include "Util/onceToken.h"
|
||||||
#include "Util/NoticeCenter.h"
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
|
|
@ -46,11 +45,14 @@ extern const std::string kBroadcastRecordTs;
|
||||||
|
|
||||||
// 收到http api请求广播
|
// 收到http api请求广播
|
||||||
extern const std::string kBroadcastHttpRequest;
|
extern const std::string kBroadcastHttpRequest;
|
||||||
#define BroadcastHttpRequestArgs const Parser &parser,const HttpSession::HttpResponseInvoker &invoker,bool &consumed,SockInfo &sender
|
#define BroadcastHttpRequestArgs \
|
||||||
|
const Parser &parser, const HttpSession::HttpResponseInvoker &invoker, bool &consumed, SockInfo &sender
|
||||||
|
|
||||||
// 在http文件服务器中,收到http访问文件或目录的广播,通过该事件控制访问http目录的权限
|
// 在http文件服务器中,收到http访问文件或目录的广播,通过该事件控制访问http目录的权限
|
||||||
extern const std::string kBroadcastHttpAccess;
|
extern const std::string kBroadcastHttpAccess;
|
||||||
#define BroadcastHttpAccessArgs const Parser &parser,const std::string &path,const bool &is_dir,const HttpSession::HttpAccessPathInvoker &invoker,SockInfo &sender
|
#define BroadcastHttpAccessArgs \
|
||||||
|
const Parser &parser, const std::string &path, const bool &is_dir, \
|
||||||
|
const HttpSession::HttpAccessPathInvoker &invoker, SockInfo &sender
|
||||||
|
|
||||||
// 在http文件服务器中,收到http访问文件或目录前的广播,通过该事件可以控制http url到文件路径的映射
|
// 在http文件服务器中,收到http访问文件或目录前的广播,通过该事件可以控制http url到文件路径的映射
|
||||||
// 在该事件中通过自行覆盖path参数,可以做到譬如根据虚拟主机或者app选择不同http根目录的目的
|
// 在该事件中通过自行覆盖path参数,可以做到譬如根据虚拟主机或者app选择不同http根目录的目的
|
||||||
|
|
@ -64,7 +66,9 @@ extern const std::string kBroadcastOnGetRtspRealm;
|
||||||
// 请求认证用户密码事件,user_name为用户名,must_no_encrypt如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
// 请求认证用户密码事件,user_name为用户名,must_no_encrypt如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
||||||
// 获取到密码后请调用invoker并输入对应类型的密码和密码类型,invoker执行时会匹配密码
|
// 获取到密码后请调用invoker并输入对应类型的密码和密码类型,invoker执行时会匹配密码
|
||||||
extern const std::string kBroadcastOnRtspAuth;
|
extern const std::string kBroadcastOnRtspAuth;
|
||||||
#define BroadcastOnRtspAuthArgs const MediaInfo &args,const std::string &realm,const std::string &user_name,const bool &must_no_encrypt,const RtspSession::onAuth &invoker,SockInfo &sender
|
#define BroadcastOnRtspAuthArgs \
|
||||||
|
const MediaInfo &args, const std::string &realm, const std::string &user_name, const bool &must_no_encrypt, \
|
||||||
|
const RtspSession::onAuth &invoker, SockInfo &sender
|
||||||
|
|
||||||
// 推流鉴权结果回调对象
|
// 推流鉴权结果回调对象
|
||||||
// 如果err为空则代表鉴权成功
|
// 如果err为空则代表鉴权成功
|
||||||
|
|
@ -72,7 +76,8 @@ using PublishAuthInvoker = std::function<void(const std::string &err, const Prot
|
||||||
|
|
||||||
// 收到rtsp/rtmp推流事件广播,通过该事件控制推流鉴权
|
// 收到rtsp/rtmp推流事件广播,通过该事件控制推流鉴权
|
||||||
extern const std::string kBroadcastMediaPublish;
|
extern const std::string kBroadcastMediaPublish;
|
||||||
#define BroadcastMediaPublishArgs const MediaOriginType &type, const MediaInfo &args, const Broadcast::PublishAuthInvoker &invoker,SockInfo &sender
|
#define BroadcastMediaPublishArgs \
|
||||||
|
const MediaOriginType &type, const MediaInfo &args, const Broadcast::PublishAuthInvoker &invoker, SockInfo &sender
|
||||||
|
|
||||||
// 播放鉴权结果回调对象
|
// 播放鉴权结果回调对象
|
||||||
// 如果err为空则代表鉴权成功
|
// 如果err为空则代表鉴权成功
|
||||||
|
|
@ -84,11 +89,14 @@ extern const std::string kBroadcastMediaPlayed;
|
||||||
|
|
||||||
// shell登录鉴权
|
// shell登录鉴权
|
||||||
extern const std::string kBroadcastShellLogin;
|
extern const std::string kBroadcastShellLogin;
|
||||||
#define BroadcastShellLoginArgs const std::string &user_name,const std::string &passwd,const Broadcast::AuthInvoker &invoker,SockInfo &sender
|
#define BroadcastShellLoginArgs \
|
||||||
|
const std::string &user_name, const std::string &passwd, const Broadcast::AuthInvoker &invoker, SockInfo &sender
|
||||||
|
|
||||||
// 停止rtsp/rtmp/http-flv会话后流量汇报事件广播
|
// 停止rtsp/rtmp/http-flv会话后流量汇报事件广播
|
||||||
extern const std::string kBroadcastFlowReport;
|
extern const std::string kBroadcastFlowReport;
|
||||||
#define BroadcastFlowReportArgs const MediaInfo &args,const uint64_t &totalBytes,const uint64_t &totalDuration,const bool &isPlayer, SockInfo &sender
|
#define BroadcastFlowReportArgs \
|
||||||
|
const MediaInfo &args, const uint64_t &totalBytes, const uint64_t &totalDuration, const bool &isPlayer, \
|
||||||
|
SockInfo &sender
|
||||||
|
|
||||||
// 未找到流后会广播该事件,请在监听该事件后去拉流或其他方式产生流,这样就能按需拉流了
|
// 未找到流后会广播该事件,请在监听该事件后去拉流或其他方式产生流,这样就能按需拉流了
|
||||||
extern const std::string kBroadcastNotFoundStream;
|
extern const std::string kBroadcastNotFoundStream;
|
||||||
|
|
@ -117,18 +125,14 @@ extern const std::string kBroadcastReloadConfig;
|
||||||
#define LISTEN_RELOAD_KEY(arg, key, ...) \
|
#define LISTEN_RELOAD_KEY(arg, key, ...) \
|
||||||
do { \
|
do { \
|
||||||
static ::toolkit::onceToken s_token_listen([]() { \
|
static ::toolkit::onceToken s_token_listen([]() { \
|
||||||
::toolkit::NoticeCenter::Instance().addListener(ReloadConfigTag, \
|
::toolkit::NoticeCenter::Instance().addListener( \
|
||||||
Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs) { \
|
ReloadConfigTag, Broadcast::kBroadcastReloadConfig, [](BroadcastReloadConfigArgs) { __VA_ARGS__; }); \
|
||||||
__VA_ARGS__; \
|
|
||||||
}); \
|
|
||||||
}); \
|
}); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define GET_CONFIG(type, arg, key) \
|
#define GET_CONFIG(type, arg, key) \
|
||||||
static type arg = ::toolkit::mINI::Instance()[key]; \
|
static type arg = ::toolkit::mINI::Instance()[key]; \
|
||||||
LISTEN_RELOAD_KEY(arg, key, { \
|
LISTEN_RELOAD_KEY(arg, key, { RELOAD_KEY(arg, key); });
|
||||||
RELOAD_KEY(arg, key); \
|
|
||||||
});
|
|
||||||
|
|
||||||
#define GET_CONFIG_FUNC(type, arg, key, ...) \
|
#define GET_CONFIG_FUNC(type, arg, key, ...) \
|
||||||
static type arg; \
|
static type arg; \
|
||||||
|
|
@ -199,7 +203,6 @@ extern const std::string kUnreadyFrameCache;
|
||||||
extern const std::string kContinuePushMS;
|
extern const std::string kContinuePushMS;
|
||||||
} // namespace General
|
} // namespace General
|
||||||
|
|
||||||
|
|
||||||
////////////HTTP配置///////////
|
////////////HTTP配置///////////
|
||||||
namespace Http {
|
namespace Http {
|
||||||
// http 文件发送缓存大小
|
// http 文件发送缓存大小
|
||||||
|
|
@ -252,8 +255,7 @@ extern const std::string kModifyStamp;
|
||||||
extern const std::string kHandshakeSecond;
|
extern const std::string kHandshakeSecond;
|
||||||
// 维持链接超时时间,默认15秒
|
// 维持链接超时时间,默认15秒
|
||||||
extern const std::string kKeepAliveSecond;
|
extern const std::string kKeepAliveSecond;
|
||||||
} //namespace RTMP
|
} // namespace Rtmp
|
||||||
|
|
||||||
|
|
||||||
////////////RTP配置///////////
|
////////////RTP配置///////////
|
||||||
namespace Rtp {
|
namespace Rtp {
|
||||||
|
|
@ -263,7 +265,7 @@ extern const std::string kVideoMtuSize;
|
||||||
extern const std::string kAudioMtuSize;
|
extern const std::string kAudioMtuSize;
|
||||||
// rtp包最大长度限制, 单位KB
|
// rtp包最大长度限制, 单位KB
|
||||||
extern const std::string kRtpMaxSize;
|
extern const std::string kRtpMaxSize;
|
||||||
} //namespace Rtsp
|
} // namespace Rtp
|
||||||
|
|
||||||
////////////组播配置///////////
|
////////////组播配置///////////
|
||||||
namespace MultiCast {
|
namespace MultiCast {
|
||||||
|
|
@ -322,6 +324,20 @@ extern const std::string kTimeoutSec;
|
||||||
// 随机端口范围,最少确保36个端口
|
// 随机端口范围,最少确保36个端口
|
||||||
// 该范围同时限制rtsp服务器udp端口范围
|
// 该范围同时限制rtsp服务器udp端口范围
|
||||||
extern const std::string kPortRange;
|
extern const std::string kPortRange;
|
||||||
|
// rtp server h264的pt
|
||||||
|
extern const std::string KH264PT;
|
||||||
|
// rtp server h265的pt
|
||||||
|
extern const std::string KH265PT;
|
||||||
|
// rtp server ps 的pt
|
||||||
|
extern const std::string KPSPT;
|
||||||
|
// rtp server ts 的pt
|
||||||
|
extern const std::string KTSPT;
|
||||||
|
// rtp server opus 的pt
|
||||||
|
extern const std::string KOpusPT;
|
||||||
|
// rtp server g711u 的pt
|
||||||
|
extern const std::string KG711UPT;
|
||||||
|
// rtp server g711a 的pt
|
||||||
|
extern const std::string KG711APT;
|
||||||
} // namespace RtpProxy
|
} // namespace RtpProxy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -351,7 +367,7 @@ extern const std::string kBeatIntervalMS;
|
||||||
extern const std::string kBenchmarkMode;
|
extern const std::string kBenchmarkMode;
|
||||||
// 播放器在触发播放成功事件时,是否等待所有track ready时再回调
|
// 播放器在触发播放成功事件时,是否等待所有track ready时再回调
|
||||||
extern const std::string kWaitTrackReady;
|
extern const std::string kWaitTrackReady;
|
||||||
}
|
} // namespace Client
|
||||||
} // namespace mediakit
|
} // namespace mediakit
|
||||||
|
|
||||||
#endif /* COMMON_CONFIG_H */
|
#endif /* COMMON_CONFIG_H */
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
|
|
||||||
#if defined(ENABLE_RTPPROXY)
|
#if defined(ENABLE_RTPPROXY)
|
||||||
#include "GB28181Process.h"
|
#include "GB28181Process.h"
|
||||||
#include "Util/File.h"
|
|
||||||
#include "Http/HttpTSPlayer.h"
|
|
||||||
#include "Extension/CommonRtp.h"
|
#include "Extension/CommonRtp.h"
|
||||||
#include "Extension/H264Rtp.h"
|
|
||||||
#include "Extension/Factory.h"
|
#include "Extension/Factory.h"
|
||||||
#include "Extension/Opus.h"
|
|
||||||
#include "Extension/G711.h"
|
#include "Extension/G711.h"
|
||||||
|
#include "Extension/H264Rtp.h"
|
||||||
#include "Extension/H265.h"
|
#include "Extension/H265.h"
|
||||||
|
#include "Extension/Opus.h"
|
||||||
|
#include "Http/HttpTSPlayer.h"
|
||||||
|
#include "Util/File.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
|
|
@ -66,6 +66,14 @@ void GB28181Process::onRtpSorted(RtpPacket::Ptr rtp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
||||||
|
GET_CONFIG(uint32_t, h264_pt, RtpProxy::KH264PT);
|
||||||
|
GET_CONFIG(uint32_t, h265_pt, RtpProxy::KH265PT);
|
||||||
|
GET_CONFIG(uint32_t, ps_pt, RtpProxy::KPSPT);
|
||||||
|
GET_CONFIG(uint32_t, ts_pt, RtpProxy::KTSPT);
|
||||||
|
GET_CONFIG(uint32_t, opus_pt, RtpProxy::KOpusPT);
|
||||||
|
GET_CONFIG(uint32_t, g711u_pt, RtpProxy::KG711UPT);
|
||||||
|
GET_CONFIG(uint32_t, g711a_pt, RtpProxy::KG711APT);
|
||||||
|
|
||||||
RtpHeader *header = (RtpHeader *)data;
|
RtpHeader *header = (RtpHeader *)data;
|
||||||
auto pt = header->pt;
|
auto pt = header->pt;
|
||||||
auto &ref = _rtp_receiver[pt];
|
auto &ref = _rtp_receiver[pt];
|
||||||
|
|
@ -74,64 +82,41 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
||||||
// 防止pt类型太多导致内存溢出
|
// 防止pt类型太多导致内存溢出
|
||||||
throw std::invalid_argument("rtp pt类型不得超过2种!");
|
throw std::invalid_argument("rtp pt类型不得超过2种!");
|
||||||
}
|
}
|
||||||
switch (pt) {
|
if (pt == opus_pt) {
|
||||||
case 100: {
|
|
||||||
// opus负载
|
// opus负载
|
||||||
ref = std::make_shared<RtpReceiverImp>(48000,[this](RtpPacket::Ptr rtp) {
|
ref = std::make_shared<RtpReceiverImp>(48000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
onRtpSorted(std::move(rtp));
|
|
||||||
});
|
|
||||||
|
|
||||||
auto track = std::make_shared<OpusTrack>();
|
auto track = std::make_shared<OpusTrack>();
|
||||||
_interface->addTrack(track);
|
_interface->addTrack(track);
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
break;
|
} else if (pt == h265_pt) {
|
||||||
}
|
|
||||||
|
|
||||||
case 99: {
|
|
||||||
// H265负载
|
// H265负载
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000,[this](RtpPacket::Ptr rtp) {
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
onRtpSorted(std::move(rtp));
|
|
||||||
});
|
|
||||||
|
|
||||||
auto track = std::make_shared<H265Track>();
|
auto track = std::make_shared<H265Track>();
|
||||||
_interface->addTrack(track);
|
_interface->addTrack(track);
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
break;
|
} else if (pt == h264_pt) {
|
||||||
}
|
|
||||||
case 98: {
|
|
||||||
// H264负载
|
// H264负载
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000,[this](RtpPacket::Ptr rtp) {
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
onRtpSorted(std::move(rtp));
|
|
||||||
});
|
|
||||||
|
|
||||||
auto track = std::make_shared<H264Track>();
|
auto track = std::make_shared<H264Track>();
|
||||||
_interface->addTrack(track);
|
_interface->addTrack(track);
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
break;
|
} else if (pt == g711u_pt || pt == g711a_pt) {
|
||||||
}
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
// CodecG711U
|
// CodecG711U
|
||||||
case 8: {
|
|
||||||
// CodecG711A
|
// CodecG711A
|
||||||
ref = std::make_shared<RtpReceiverImp>(8000,[this](RtpPacket::Ptr rtp) {
|
ref = std::make_shared<RtpReceiverImp>(8000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
onRtpSorted(std::move(rtp));
|
|
||||||
});
|
|
||||||
|
|
||||||
auto track = std::make_shared<G711Track>(pt == 0 ? CodecG711U : CodecG711A, 8000, 1, 16);
|
auto track = std::make_shared<G711Track>(pt == 0 ? CodecG711U : CodecG711A, 8000, 1, 16);
|
||||||
_interface->addTrack(track);
|
_interface->addTrack(track);
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
break;
|
} else {
|
||||||
}
|
if (pt != ts_pt && pt != ps_pt) {
|
||||||
|
|
||||||
default: {
|
|
||||||
if (pt != 33 && pt != 96) {
|
|
||||||
WarnL << "rtp payload type未识别(" << (int)pt << "),已按ts或ps负载处理";
|
WarnL << "rtp payload type未识别(" << (int)pt << "),已按ts或ps负载处理";
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000,[this](RtpPacket::Ptr rtp) {
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
onRtpSorted(std::move(rtp));
|
|
||||||
});
|
|
||||||
|
|
||||||
// ts或ps负载
|
// ts或ps负载
|
||||||
_rtp_decoder[pt] = std::make_shared<CommonRtpDecoder>(CodecInvalid, 32 * 1024);
|
_rtp_decoder[pt] = std::make_shared<CommonRtpDecoder>(CodecInvalid, 32 * 1024);
|
||||||
|
|
@ -145,10 +130,7 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 设置frame回调
|
// 设置frame回调
|
||||||
_rtp_decoder[pt]->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame) {
|
_rtp_decoder[pt]->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame) {
|
||||||
onRtpDecode(frame);
|
onRtpDecode(frame);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue