mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
get ip from env, for externIP in file 'config.ini' (#1786)
This commit is contained in:
parent
09a8d53150
commit
576056c465
@ -1 +1 @@
|
|||||||
Subproject commit 136b6b2f28193da218f577423db217aeb0f7aa6a
|
Subproject commit 5b30d6d4cb344b368d4a8272ef07e1656fc85021
|
@ -48,6 +48,21 @@ static onceToken token([]() {
|
|||||||
|
|
||||||
static atomic<uint64_t> s_key{0};
|
static atomic<uint64_t> s_key{0};
|
||||||
|
|
||||||
|
static void translateIPFromEnv(std::vector<std::string> &v) {
|
||||||
|
for (auto iter = v.begin(); iter != v.end();) {
|
||||||
|
if (start_with(*iter, "$")) {
|
||||||
|
auto ip = toolkit::getEnv(*iter);
|
||||||
|
if (ip.empty()) {
|
||||||
|
iter = v.erase(iter);
|
||||||
|
} else {
|
||||||
|
*iter++ = ip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WebRtcTransport::WebRtcTransport(const EventPoller::Ptr &poller) {
|
WebRtcTransport::WebRtcTransport(const EventPoller::Ptr &poller) {
|
||||||
_poller = poller;
|
_poller = poller;
|
||||||
_identifier = "zlm_" + to_string(++s_key);
|
_identifier = "zlm_" + to_string(++s_key);
|
||||||
@ -468,8 +483,9 @@ void WebRtcTransportImp::onStartWebRTC() {
|
|||||||
// 系统又要有rid,这里手工生成rid,并为其绑定ssrc
|
// 系统又要有rid,这里手工生成rid,并为其绑定ssrc
|
||||||
std::string rid = "r" + std::to_string(index);
|
std::string rid = "r" + std::to_string(index);
|
||||||
track->rtp_ext_ctx->setRid(ssrc.ssrc, rid);
|
track->rtp_ext_ctx->setRid(ssrc.ssrc, rid);
|
||||||
if(ssrc.rtx_ssrc)
|
if (ssrc.rtx_ssrc) {
|
||||||
track->rtp_ext_ctx->setRid(ssrc.rtx_ssrc, rid);
|
track->rtp_ext_ctx->setRid(ssrc.rtx_ssrc, rid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
@ -478,10 +494,12 @@ void WebRtcTransportImp::onStartWebRTC() {
|
|||||||
|
|
||||||
void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
|
void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
|
||||||
//修改answer sdp的ip、端口信息
|
//修改answer sdp的ip、端口信息
|
||||||
GET_CONFIG_FUNC(std::vector<std::string>, extern_ips, RTC::kExternIP, [](string str){
|
GET_CONFIG_FUNC(std::vector<std::string>, extern_ips, RTC::kExternIP, [](string str) {
|
||||||
std::vector<std::string> ret;
|
std::vector<std::string> ret;
|
||||||
if (str.length())
|
if (str.length()) {
|
||||||
ret = split(str, ",");
|
ret = split(str, ",");
|
||||||
|
}
|
||||||
|
translateIPFromEnv(ret);
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
for (auto &m : sdp.media) {
|
for (auto &m : sdp.media) {
|
||||||
@ -556,15 +574,16 @@ void WebRtcTransportImp::onRtcConfigure(RtcConfigure &configure) const {
|
|||||||
//添加接收端口candidate信息
|
//添加接收端口candidate信息
|
||||||
GET_CONFIG_FUNC(std::vector<std::string>, extern_ips, RTC::kExternIP, [](string str){
|
GET_CONFIG_FUNC(std::vector<std::string>, extern_ips, RTC::kExternIP, [](string str){
|
||||||
std::vector<std::string> ret;
|
std::vector<std::string> ret;
|
||||||
if (str.length())
|
if (str.length()) {
|
||||||
ret = split(str, ",");
|
ret = split(str, ",");
|
||||||
|
}
|
||||||
|
translateIPFromEnv(ret);
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
if (extern_ips.empty()) {
|
if (extern_ips.empty()) {
|
||||||
std::string localIp = SockUtil::get_local_ip();
|
std::string localIp = SockUtil::get_local_ip();
|
||||||
configure.addCandidate(*makeIceCandidate(localIp, local_port, 120, "udp"));
|
configure.addCandidate(*makeIceCandidate(localIp, local_port, 120, "udp"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const uint32_t delta = 10;
|
const uint32_t delta = 10;
|
||||||
uint32_t priority = 100 + delta * extern_ips.size();
|
uint32_t priority = 100 + delta * extern_ips.size();
|
||||||
for (auto ip : extern_ips) {
|
for (auto ip : extern_ips) {
|
||||||
@ -575,7 +594,6 @@ void WebRtcTransportImp::onRtcConfigure(RtcConfigure &configure) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class RtpChannel : public RtpTrackImp, public std::enable_shared_from_this<RtpChannel> {
|
class RtpChannel : public RtpTrackImp, public std::enable_shared_from_this<RtpChannel> {
|
||||||
@ -685,7 +703,7 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
|
|||||||
if (it != _ssrc_to_track.end()) {
|
if (it != _ssrc_to_track.end()) {
|
||||||
auto &track = it->second;
|
auto &track = it->second;
|
||||||
auto rtp_chn = track->getRtpChannel(sr->ssrc);
|
auto rtp_chn = track->getRtpChannel(sr->ssrc);
|
||||||
if(!rtp_chn){
|
if (!rtp_chn) {
|
||||||
WarnL << "未识别的sr rtcp包:" << rtcp->dumpString();
|
WarnL << "未识别的sr rtcp包:" << rtcp->dumpString();
|
||||||
} else {
|
} else {
|
||||||
//InfoL << "接收丢包率,ssrc:" << sr->ssrc << ",loss rate(%):" << rtp_chn->getLossRate();
|
//InfoL << "接收丢包率,ssrc:" << sr->ssrc << ",loss rate(%):" << rtp_chn->getLossRate();
|
||||||
|
Loading…
Reference in New Issue
Block a user