完善fci相关代码
This commit is contained in:
parent
c57f31d3d0
commit
ec8e518180
|
|
@ -517,44 +517,48 @@ std::shared_ptr<RtcpFB> RtcpFB::create(RTPFBType fmt, const void *fci, size_t fc
|
||||||
return RtcpFB::create_l(RtcpType::RTCP_RTPFB, (int)fmt, fci, fci_len);
|
return RtcpFB::create_l(RtcpType::RTCP_RTPFB, (int)fmt, fci, fci_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void *RtcpFB::getFciPtr() const {
|
||||||
|
return (uint8_t *) &ssrc_media + sizeof(ssrc_media);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RtcpFB::getFciSize() const {
|
||||||
|
auto fci_len = (ssize_t) getSize() - getPaddingSize() - sizeof(RtcpFB);
|
||||||
|
CHECK(fci_len >= 0);
|
||||||
|
return fci_len;
|
||||||
|
}
|
||||||
|
|
||||||
string RtcpFB::dumpString() const {
|
string RtcpFB::dumpString() const {
|
||||||
_StrPrinter printer;
|
_StrPrinter printer;
|
||||||
printer << RtcpHeader::dumpHeader();
|
printer << RtcpHeader::dumpHeader();
|
||||||
printer << "ssrc:" << ssrc << "\r\n";
|
printer << "ssrc:" << ssrc << "\r\n";
|
||||||
printer << "ssrc_media:" << ssrc_media << "\r\n";
|
printer << "ssrc_media:" << ssrc_media << "\r\n";
|
||||||
auto fci_data = (uint8_t *)&ssrc_media + sizeof(ssrc_media);
|
|
||||||
auto fci_len = (ssize_t)getSize() - getPaddingSize() - sizeof(RtcpFB);
|
|
||||||
CHECK(fci_len >= 0);
|
|
||||||
switch ((RtcpType) pt) {
|
switch ((RtcpType) pt) {
|
||||||
case RtcpType::RTCP_PSFB : {
|
case RtcpType::RTCP_PSFB : {
|
||||||
switch ((PSFBType) report_count) {
|
switch ((PSFBType) report_count) {
|
||||||
case PSFBType::RTCP_PSFB_SLI : {
|
case PSFBType::RTCP_PSFB_SLI : {
|
||||||
FCI_SLI *fci = (FCI_SLI *) fci_data;
|
auto &fci = getFci<FCI_SLI>();
|
||||||
fci->check(fci_len);
|
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci.dumpString();
|
||||||
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSFBType::RTCP_PSFB_PLI : {
|
case PSFBType::RTCP_PSFB_PLI : {
|
||||||
CHECK(fci_len == 0);
|
getFciSize();
|
||||||
printer << "fci:" << psfbTypeToStr((PSFBType) report_count);
|
printer << "fci:" << psfbTypeToStr((PSFBType) report_count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PSFBType::RTCP_PSFB_FIR : {
|
case PSFBType::RTCP_PSFB_FIR : {
|
||||||
FCI_FIR *fci = (FCI_FIR *) fci_data;
|
auto &fci = getFci<FCI_FIR>();
|
||||||
fci->check(fci_len);
|
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci.dumpString();
|
||||||
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PSFBType::RTCP_PSFB_REMB : {
|
case PSFBType::RTCP_PSFB_REMB : {
|
||||||
FCI_REMB *fci = (FCI_REMB *) fci_data;
|
auto &fci = getFci<FCI_REMB>();
|
||||||
fci->check(fci_len);
|
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci.dumpString();
|
||||||
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default:{
|
||||||
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << hexdump(fci_data, fci_len);
|
printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << hexdump(getFciPtr(), getFciSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -563,19 +567,17 @@ string RtcpFB::dumpString() const {
|
||||||
case RtcpType::RTCP_RTPFB : {
|
case RtcpType::RTCP_RTPFB : {
|
||||||
switch ((RTPFBType) report_count) {
|
switch ((RTPFBType) report_count) {
|
||||||
case RTPFBType::RTCP_RTPFB_NACK : {
|
case RTPFBType::RTCP_RTPFB_NACK : {
|
||||||
FCI_NACK *fci = (FCI_NACK *) fci_data;
|
auto &fci = getFci<FCI_NACK>();
|
||||||
fci->check(fci_len);
|
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci.dumpString();
|
||||||
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci->dumpString();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RTPFBType::RTCP_RTPFB_TWCC : {
|
case RTPFBType::RTCP_RTPFB_TWCC : {
|
||||||
FCI_TWCC *fci = (FCI_TWCC *) fci_data;
|
auto &fci = getFci<FCI_TWCC>();
|
||||||
fci->check(fci_len);
|
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci.dumpString(getFciSize());
|
||||||
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci->dumpString(fci_len);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << hexdump(fci_data, fci_len);
|
printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << hexdump(getFciPtr(), getFciSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,30 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::shared_ptr<RtcpFB> create(RTPFBType fmt, const void *fci = nullptr, size_t fci_len = 0);
|
static std::shared_ptr<RtcpFB> create(RTPFBType fmt, const void *fci = nullptr, size_t fci_len = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fci转换成某对象指针
|
||||||
|
* @tparam Type 对象类型
|
||||||
|
* @return 对象指针
|
||||||
|
*/
|
||||||
|
template<typename Type>
|
||||||
|
const Type& getFci() const{
|
||||||
|
auto fci_data = getFciPtr();
|
||||||
|
auto fci_len = getFciSize();
|
||||||
|
Type *fci = (Type *) fci_data;
|
||||||
|
fci->check(fci_len);
|
||||||
|
return *fci;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取fci指针
|
||||||
|
*/
|
||||||
|
const void *getFciPtr() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取fci数据长度
|
||||||
|
*/
|
||||||
|
size_t getFciSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* 打印字段详情
|
* 打印字段详情
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue