mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
完善rtp ext处理相关逻辑
This commit is contained in:
parent
bda378c340
commit
a84bcec4aa
@ -1412,7 +1412,8 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
|
||||
RtpExtType::csrc_audio_level,
|
||||
RtpExtType::abs_send_time,
|
||||
RtpExtType::transport_cc,
|
||||
RtpExtType::sdes_mid,
|
||||
//rtx重传rtp时,忽略sdes_mid类型的rtp ext,实测发现Firefox在接收rtx时,如果存在sdes_mid的ext,将导致无法播放
|
||||
//RtpExtType::sdes_mid,
|
||||
RtpExtType::sdes_rtp_stream_id,
|
||||
RtpExtType::sdes_repaired_rtp_stream_id
|
||||
};
|
||||
@ -1425,7 +1426,8 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
|
||||
extmap = {
|
||||
RtpExtType::abs_send_time,
|
||||
RtpExtType::transport_cc,
|
||||
RtpExtType::sdes_mid,
|
||||
//rtx重传rtp时,忽略sdes_mid类型的rtp ext,实测发现Firefox在接收rtx时,如果存在sdes_mid的ext,将导致无法播放
|
||||
//RtpExtType::sdes_mid,
|
||||
RtpExtType::sdes_rtp_stream_id,
|
||||
RtpExtType::sdes_repaired_rtp_stream_id,
|
||||
RtpExtType::video_timing,
|
||||
|
@ -668,24 +668,30 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
static void setExtType(RtpExt &ext, uint8_t tp) {}
|
||||
static void setExtType(RtpExt &ext, RtpExtType tp) {
|
||||
ext.setType(tp);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
static void changeRtpExtId(const RtpHeader *header, const Type &map) {
|
||||
void WebRtcTransportImp::changeRtpExtId(const RtpHeader *header, bool is_recv, bool is_rtx) const{
|
||||
auto ext_map = RtpExt::getExtValue(header);
|
||||
for (auto &pr : ext_map) {
|
||||
auto it = map.find((typename Type::key_type) (pr.first));
|
||||
if (it == map.end()) {
|
||||
WarnL << "未处理的rtp ext, 类型不识别:" << (int) pr.first;
|
||||
if (is_recv) {
|
||||
auto it = _rtp_ext_id_to_type.find(pr.first);
|
||||
if (it == _rtp_ext_id_to_type.end()) {
|
||||
WarnL << "接收rtp时,忽略不识别的rtp ext, id=" << (int) pr.first;
|
||||
pr.second.clearExt();
|
||||
continue;
|
||||
}
|
||||
setExtType(pr.second, it->first);
|
||||
setExtType(pr.second, it->second);
|
||||
pr.second.setType(it->second);
|
||||
//重新赋值ext id为 ext type,作为后面处理ext的统一中间类型
|
||||
pr.second.setExtId((uint8_t) it->second);
|
||||
} else {
|
||||
pr.second.setType((RtpExtType) pr.first);
|
||||
auto it = _rtp_ext_type_to_id.find((RtpExtType) pr.first);
|
||||
if (it == _rtp_ext_type_to_id.end()) {
|
||||
WarnL << "发送rtp时, 忽略不被客户端支持rtp ext:" << pr.second.dumpString();
|
||||
pr.second.clearExt();
|
||||
continue;
|
||||
}
|
||||
//重新赋值ext id为客户端sdp声明的类型
|
||||
pr.second.setExtId(it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,7 +732,7 @@ void WebRtcTransportImp::onRtp_l(const char *buf, size_t len, bool rtx) {
|
||||
info->rtcp_context_recv->onRtp(seq, stamp_ms, len);
|
||||
}
|
||||
//修改ext id至统一
|
||||
changeRtpExtId(rtp, _rtp_ext_id_to_type);
|
||||
changeRtpExtId(rtp, true);
|
||||
//解析并排序rtp
|
||||
info->receiver->inputRtp(info->media->type, info->plan_rtp->sample_rate, (uint8_t *) buf, len);
|
||||
return;
|
||||
@ -808,14 +814,15 @@ void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool r
|
||||
void WebRtcTransportImp::onBeforeEncryptRtp(const char *buf, size_t &len, void *ctx) {
|
||||
auto pr = (pair<bool/*rtx*/, RtpPayloadInfo *> *) ctx;
|
||||
auto header = (RtpHeader *) buf;
|
||||
changeRtpExtId(header, _rtp_ext_type_to_id);
|
||||
|
||||
if (!pr->first || !pr->second->plan_rtx) {
|
||||
//普通的rtp,或者不支持rtx, 修改目标pt和ssrc
|
||||
changeRtpExtId(header, false, false);
|
||||
header->pt = pr->second->plan_rtp->pt;
|
||||
header->ssrc = htonl(pr->second->answer_ssrc_rtp);
|
||||
} else {
|
||||
//重传的rtp, rtx
|
||||
changeRtpExtId(header, false, true);
|
||||
header->pt = pr->second->plan_rtx->pt;
|
||||
if (pr->second->answer_ssrc_rtx) {
|
||||
//有rtx单独的ssrc,有些情况下,浏览器支持rtx,但是未指定rtx单独的ssrc
|
||||
|
@ -338,6 +338,7 @@ private:
|
||||
SdpAttrCandidate::Ptr getIceCandidate() const;
|
||||
bool canSendRtp() const;
|
||||
bool canRecvRtp() const;
|
||||
void changeRtpExtId(const RtpHeader *header, bool is_recv, bool is_rtx = false) const;
|
||||
|
||||
class RtpPayloadInfo {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user