mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
兼容ssrc为0的rtp推流
This commit is contained in:
parent
618b028da4
commit
f76109c629
@ -1 +1 @@
|
||||
Subproject commit 1f87bc42900e88d5443fb63bfb82523a2ac3ea33
|
||||
Subproject commit 34b42499ce9ee055b5c7cac9a270239984d0e839
|
@ -36,8 +36,8 @@ bool RtpSelector::inputRtp(const char *data, int data_len,const struct sockaddr
|
||||
_last_rtp_time.resetTime();
|
||||
onManager();
|
||||
}
|
||||
auto ssrc = getSSRC(data,data_len);
|
||||
if(!ssrc){
|
||||
uint32_t ssrc = 0;
|
||||
if(!getSSRC(data,data_len,ssrc)){
|
||||
WarnL << "get ssrc from rtp failed:" << data_len;
|
||||
return false;
|
||||
}
|
||||
@ -48,12 +48,13 @@ bool RtpSelector::inputRtp(const char *data, int data_len,const struct sockaddr
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t RtpSelector::getSSRC(const char *data, int data_len) {
|
||||
bool RtpSelector::getSSRC(const char *data,int data_len, uint32_t &ssrc){
|
||||
if(data_len < 12){
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
uint32_t *ssrc_ptr = (uint32_t *)(data + 8);
|
||||
return ntohl(*ssrc_ptr);
|
||||
ssrc = ntohl(*ssrc_ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
RtpProcess::Ptr RtpSelector::getProcess(uint32_t ssrc,bool makeNew) {
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
static RtpSelector &Instance();
|
||||
bool inputRtp(const char *data,int data_len,const struct sockaddr *addr ,uint32_t *dts_out = nullptr );
|
||||
static uint32_t getSSRC(const char *data,int data_len);
|
||||
static bool getSSRC(const char *data,int data_len, uint32_t &ssrc);
|
||||
RtpProcess::Ptr getProcess(uint32_t ssrc,bool makeNew);
|
||||
void delProcess(uint32_t ssrc,const RtpProcess *ptr);
|
||||
private:
|
||||
|
@ -36,7 +36,7 @@ RtpSession::RtpSession(const Socket::Ptr &sock) : TcpSession(sock) {
|
||||
}
|
||||
RtpSession::~RtpSession() {
|
||||
DebugP(this);
|
||||
if(_ssrc){
|
||||
if(_process){
|
||||
RtpSelector::Instance().delProcess(_ssrc,_process.get());
|
||||
}
|
||||
}
|
||||
@ -66,11 +66,13 @@ void RtpSession::onManager() {
|
||||
}
|
||||
|
||||
void RtpSession::onRtpPacket(const char *data, uint64_t len) {
|
||||
if(!_ssrc){
|
||||
_ssrc = RtpSelector::getSSRC(data + 2,len - 2);
|
||||
if (!_process) {
|
||||
if (!RtpSelector::getSSRC(data + 2, len - 2, _ssrc)) {
|
||||
return;
|
||||
}
|
||||
_process = RtpSelector::Instance().getProcess(_ssrc, true);
|
||||
}
|
||||
_process->inputRtp(data + 2,len - 2,&addr);
|
||||
_process->inputRtp(data + 2, len - 2, &addr);
|
||||
_ticker.resetTime();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user