mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-27 04:20:13 +08:00
修改rtp pt时,确保不影响其他播放器
This commit is contained in:
parent
2abb5078f9
commit
c70721a520
@ -213,7 +213,7 @@ namespace RTC
|
||||
}
|
||||
}
|
||||
|
||||
bool SrtpSession::EncryptRtp(const uint8_t** data, size_t* len)
|
||||
bool SrtpSession::EncryptRtp(const uint8_t** data, size_t* len, uint8_t pt)
|
||||
{
|
||||
MS_TRACE();
|
||||
|
||||
@ -226,6 +226,7 @@ namespace RTC
|
||||
}
|
||||
|
||||
std::memcpy(EncryptBuffer, *data, *len);
|
||||
EncryptBuffer[1] |= (pt & 0x7F);
|
||||
|
||||
srtp_err_status_t err =
|
||||
srtp_protect(this->session, static_cast<void*>(EncryptBuffer), reinterpret_cast<int*>(len));
|
||||
|
@ -46,7 +46,7 @@ namespace RTC
|
||||
~SrtpSession();
|
||||
|
||||
public:
|
||||
bool EncryptRtp(const uint8_t** data, size_t* len);
|
||||
bool EncryptRtp(const uint8_t** data, size_t* len, uint8_t pt);
|
||||
bool DecryptSrtp(uint8_t* data, size_t* len);
|
||||
bool EncryptRtcp(const uint8_t** data, size_t* len);
|
||||
bool DecryptSrtcp(uint8_t* data, size_t* len);
|
||||
|
@ -179,11 +179,11 @@ void WebRtcTransport::inputSockData(char *buf, size_t len, RTC::TransportTuple *
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcTransport::sendRtpPacket(char *buf, size_t len, bool flush) {
|
||||
void WebRtcTransport::sendRtpPacket(char *buf, size_t len, bool flush, uint8_t pt) {
|
||||
const uint8_t *p = (uint8_t *) buf;
|
||||
bool ret = false;
|
||||
if (_srtp_session_send) {
|
||||
ret = _srtp_session_send->EncryptRtp(&p, &len);
|
||||
ret = _srtp_session_send->EncryptRtp(&p, &len, pt);
|
||||
}
|
||||
if (ret) {
|
||||
onSendSockData((char *) p, len, flush);
|
||||
@ -467,16 +467,12 @@ void WebRtcTransportImp::onBeforeSortedRtp(const RtpPayloadInfo &info, const Rtp
|
||||
}
|
||||
|
||||
void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush){
|
||||
if (!_send_rtp_pt[rtp->type]) {
|
||||
auto &pt = _send_rtp_pt[rtp->type];
|
||||
if (!pt) {
|
||||
//忽略,对方不支持该编码类型
|
||||
return;
|
||||
}
|
||||
auto tmp = rtp->getHeader()->pt;
|
||||
//设置pt
|
||||
rtp->getHeader()->pt = _send_rtp_pt[rtp->type];
|
||||
sendRtpPacket(rtp->data() + RtpPacket::kRtpTcpHeaderSize, rtp->size() - RtpPacket::kRtpTcpHeaderSize, flush);
|
||||
sendRtpPacket(rtp->data() + RtpPacket::kRtpTcpHeaderSize, rtp->size() - RtpPacket::kRtpTcpHeaderSize, flush, pt);
|
||||
//统计rtp发送情况,好做sr汇报
|
||||
_rtp_receiver[_send_rtp_pt[rtp->type]].rtcp_context_send->onRtp(rtp->getSeq(), rtp->getStampMS(), rtp->size() - RtpPacket::kRtpTcpHeaderSize);
|
||||
//还原pt
|
||||
rtp->getHeader()->pt = tmp;
|
||||
_rtp_receiver[pt].rtcp_context_send->onRtp(rtp->getSeq(), rtp->getStampMS(), rtp->size() - RtpPacket::kRtpTcpHeaderSize);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
* @param buf rtcp内容
|
||||
* @param len rtcp长度
|
||||
*/
|
||||
void sendRtpPacket(char *buf, size_t len, bool flush);
|
||||
void sendRtpPacket(char *buf, size_t len, bool flush, uint8_t pt);
|
||||
void sendRtcpPacket(char *buf, size_t len, bool flush);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user