Compare commits

...

2 Commits

Author SHA1 Message Date
xia-chu
444aeceacc rtp推流时打印ssrc
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
2025-04-20 14:54:20 +08:00
xia-chu
dd1e8ef430 web hook 忽略返回值为null的值 2025-04-20 14:50:56 +08:00
3 changed files with 11 additions and 7 deletions

View File

@ -339,6 +339,10 @@ static mINI jsonToMini(const Value &obj) {
mINI ret; mINI ret;
if (obj.isObject()) { if (obj.isObject()) {
for (auto it = obj.begin(); it != obj.end(); ++it) { for (auto it = obj.begin(); it != obj.end(); ++it) {
if (it->isNull()) {
// 忽略null修复wvp传null覆盖Protocol配置的问题
continue;
}
try { try {
auto str = (*it).asString(); auto str = (*it).asString();
ret[it.name()] = std::move(str); ret[it.name()] = std::move(str);

View File

@ -107,6 +107,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
if (!_auth_err.empty()) { if (!_auth_err.empty()) {
throw toolkit::SockException(toolkit::Err_other, _auth_err); throw toolkit::SockException(toolkit::Err_other, _auth_err);
} }
auto header = (RtpHeader *) data;
if (_sock != sock) { if (_sock != sock) {
// 第一次运行本函数 [AUTO-TRANSLATED:a1d7ac17] // 第一次运行本函数 [AUTO-TRANSLATED:a1d7ac17]
// First time running this function // First time running this function
@ -114,7 +115,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
_sock = sock; _sock = sock;
_addr.reset(new sockaddr_storage(*((sockaddr_storage *)addr))); _addr.reset(new sockaddr_storage(*((sockaddr_storage *)addr)));
if (first) { if (first) {
emitOnPublish(); emitOnPublish(ntohl(header->ssrc));
_cache_ticker.resetTime(); _cache_ticker.resetTime();
} }
} }
@ -131,7 +132,6 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
_process = std::make_shared<GB28181Process>(_media_info, this); _process = std::make_shared<GB28181Process>(_media_info, this);
} }
auto header = (RtpHeader *) data;
onRtp(ntohs(header->seq), ntohl(header->stamp), 0/*不发送sr,所以可以设置为0*/ , 90000/*ps/ts流时间戳按照90K采样率*/, len); onRtp(ntohs(header->seq), ntohl(header->stamp), 0/*不发送sr,所以可以设置为0*/ , 90000/*ps/ts流时间戳按照90K采样率*/, len);
GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir); GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir);
@ -271,15 +271,15 @@ string RtpProcess::getIdentifier() const {
return _media_info.stream; return _media_info.stream;
} }
void RtpProcess::emitOnPublish() { void RtpProcess::emitOnPublish(uint32_t ssrc) {
weak_ptr<RtpProcess> weak_self = shared_from_this(); weak_ptr<RtpProcess> weak_self = shared_from_this();
Broadcast::PublishAuthInvoker invoker = [weak_self](const string &err, const ProtocolOption &option) { Broadcast::PublishAuthInvoker invoker = [weak_self, ssrc](const string &err, const ProtocolOption &option) {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
if (!strong_self) { if (!strong_self) {
return; return;
} }
auto poller = strong_self->getOwnerPoller(MediaSource::NullMediaSource()); auto poller = strong_self->getOwnerPoller(MediaSource::NullMediaSource());
poller->async([weak_self, err, option]() { poller->async([weak_self, err, option, ssrc]() {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
if (!strong_self) { if (!strong_self) {
return; return;
@ -293,7 +293,7 @@ void RtpProcess::emitOnPublish() {
} }
strong_self->_muxer->setMediaListener(strong_self); strong_self->_muxer->setMediaListener(strong_self);
strong_self->doCachedFunc(); strong_self->doCachedFunc();
InfoP(strong_self) << "允许RTP推流"; InfoP(strong_self) << "允许RTP推流ssrc: " << printSSRC(ssrc);
} else { } else {
strong_self->_auth_err = err; strong_self->_auth_err = err;
WarnP(strong_self) << "禁止RTP推流:" << err; WarnP(strong_self) << "禁止RTP推流:" << err;

View File

@ -122,7 +122,7 @@ protected:
private: private:
RtpProcess(const MediaTuple &tuple); RtpProcess(const MediaTuple &tuple);
void emitOnPublish(); void emitOnPublish(uint32_t ssrc);
void doCachedFunc(); void doCachedFunc();
bool alive(); bool alive();
void onManager(); void onManager();