Commit c70721a5 by xiongziliang

修改rtp pt时,确保不影响其他播放器

parent 2abb5078
...@@ -213,7 +213,7 @@ namespace RTC ...@@ -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(); MS_TRACE();
...@@ -226,6 +226,7 @@ namespace RTC ...@@ -226,6 +226,7 @@ namespace RTC
} }
std::memcpy(EncryptBuffer, *data, *len); std::memcpy(EncryptBuffer, *data, *len);
EncryptBuffer[1] |= (pt & 0x7F);
srtp_err_status_t err = srtp_err_status_t err =
srtp_protect(this->session, static_cast<void*>(EncryptBuffer), reinterpret_cast<int*>(len)); srtp_protect(this->session, static_cast<void*>(EncryptBuffer), reinterpret_cast<int*>(len));
......
...@@ -46,7 +46,7 @@ namespace RTC ...@@ -46,7 +46,7 @@ namespace RTC
~SrtpSession(); ~SrtpSession();
public: 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 DecryptSrtp(uint8_t* data, size_t* len);
bool EncryptRtcp(const uint8_t** data, size_t* len); bool EncryptRtcp(const uint8_t** data, size_t* len);
bool DecryptSrtcp(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 * ...@@ -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; const uint8_t *p = (uint8_t *) buf;
bool ret = false; bool ret = false;
if (_srtp_session_send) { if (_srtp_session_send) {
ret = _srtp_session_send->EncryptRtp(&p, &len); ret = _srtp_session_send->EncryptRtp(&p, &len, pt);
} }
if (ret) { if (ret) {
onSendSockData((char *) p, len, flush); onSendSockData((char *) p, len, flush);
...@@ -467,16 +467,12 @@ void WebRtcTransportImp::onBeforeSortedRtp(const RtpPayloadInfo &info, const Rtp ...@@ -467,16 +467,12 @@ void WebRtcTransportImp::onBeforeSortedRtp(const RtpPayloadInfo &info, const Rtp
} }
void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush){ 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; return;
} }
auto tmp = rtp->getHeader()->pt; sendRtpPacket(rtp->data() + RtpPacket::kRtpTcpHeaderSize, rtp->size() - RtpPacket::kRtpTcpHeaderSize, flush, pt);
//设置pt
rtp->getHeader()->pt = _send_rtp_pt[rtp->type];
sendRtpPacket(rtp->data() + RtpPacket::kRtpTcpHeaderSize, rtp->size() - RtpPacket::kRtpTcpHeaderSize, flush);
//统计rtp发送情况,好做sr汇报 //统计rtp发送情况,好做sr汇报
_rtp_receiver[_send_rtp_pt[rtp->type]].rtcp_context_send->onRtp(rtp->getSeq(), rtp->getStampMS(), rtp->size() - RtpPacket::kRtpTcpHeaderSize); _rtp_receiver[pt].rtcp_context_send->onRtp(rtp->getSeq(), rtp->getStampMS(), rtp->size() - RtpPacket::kRtpTcpHeaderSize);
//还原pt
rtp->getHeader()->pt = tmp;
} }
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
* @param buf rtcp内容 * @param buf rtcp内容
* @param len 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); void sendRtcpPacket(char *buf, size_t len, bool flush);
protected: protected:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论