mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-21 01:13:37 +08:00
修正SDES rtcp对象命名
This commit is contained in:
parent
c25da5a222
commit
8548753c28
@ -422,19 +422,19 @@ vector<ReportItem*> RtcpRR::getItemList() {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SdesItem::net2Host() {
|
||||
void SdesChunk::net2Host() {
|
||||
ssrc = ntohl(ssrc);
|
||||
}
|
||||
|
||||
size_t SdesItem::totalBytes() const{
|
||||
size_t SdesChunk::totalBytes() const{
|
||||
return alignSize(minSize() + txt_len);
|
||||
}
|
||||
|
||||
size_t SdesItem::minSize() {
|
||||
return sizeof(SdesItem) - sizeof(text);
|
||||
size_t SdesChunk::minSize() {
|
||||
return sizeof(SdesChunk) - sizeof(text);
|
||||
}
|
||||
|
||||
string SdesItem::dumpString() const{
|
||||
string SdesChunk::dumpString() const{
|
||||
_StrPrinter printer;
|
||||
printer << "ssrc:" << ssrc << "\r\n";
|
||||
printer << "type:" << sdesTypeToStr((SdesType) type) << "\r\n";
|
||||
@ -448,18 +448,18 @@ string SdesItem::dumpString() const{
|
||||
std::shared_ptr<RtcpSdes> RtcpSdes::create(const std::vector<string> &item_text) {
|
||||
size_t item_total_size = 0;
|
||||
for (auto &text : item_text) {
|
||||
//统计所有SdesItem对象占用的空间
|
||||
item_total_size += alignSize(SdesItem::minSize() + (0xFF & text.size()));
|
||||
//统计所有SdesChunk对象占用的空间
|
||||
item_total_size += alignSize(SdesChunk::minSize() + (0xFF & text.size()));
|
||||
}
|
||||
auto real_size = sizeof(RtcpSdes) - sizeof(SdesItem) + item_total_size;
|
||||
auto real_size = sizeof(RtcpSdes) - sizeof(SdesChunk) + item_total_size;
|
||||
auto bytes = alignSize(real_size);
|
||||
auto ptr = (RtcpSdes *) new char[bytes];
|
||||
auto item_ptr = &ptr->items;
|
||||
auto item_ptr = &ptr->chunks;
|
||||
for (auto &text : item_text) {
|
||||
item_ptr->txt_len = (0xFF & text.size());
|
||||
//确保赋值\0为RTCP_SDES_END
|
||||
memcpy(item_ptr->text, text.data(), item_ptr->txt_len + 1);
|
||||
item_ptr = (SdesItem *) ((char *) item_ptr + item_ptr->totalBytes());
|
||||
item_ptr = (SdesChunk *) ((char *) item_ptr + item_ptr->totalBytes());
|
||||
}
|
||||
|
||||
setupHeader(ptr, RtcpType::RTCP_SDES, item_text.size(), bytes);
|
||||
@ -472,7 +472,7 @@ std::shared_ptr<RtcpSdes> RtcpSdes::create(const std::vector<string> &item_text)
|
||||
string RtcpSdes::dumpString() const {
|
||||
_StrPrinter printer;
|
||||
printer << RtcpHeader::dumpHeader();
|
||||
auto items = ((RtcpSdes *)this)->getItemList();
|
||||
auto items = ((RtcpSdes *) this)->getChunkList();
|
||||
auto i = 0;
|
||||
for (auto &item : items) {
|
||||
printer << "---- item:" << i++ << " ----\r\n";
|
||||
@ -482,24 +482,24 @@ string RtcpSdes::dumpString() const {
|
||||
}
|
||||
|
||||
void RtcpSdes::net2Host(size_t size) {
|
||||
static const size_t kMinSize = sizeof(RtcpSdes) - sizeof(items);
|
||||
static const size_t kMinSize = sizeof(RtcpSdes) - sizeof(chunks);
|
||||
CHECK_MIN_SIZE(size, kMinSize);
|
||||
SdesItem *ptr = &items;
|
||||
SdesChunk *ptr = &chunks;
|
||||
int item_count = 0;
|
||||
for(int i = 0; i < (int)report_count && (char *)(ptr) + SdesItem::minSize() <= (char *)(this) + size; ++i){
|
||||
for(int i = 0; i < (int)report_count && (char *)(ptr) + SdesChunk::minSize() <= (char *)(this) + size; ++i){
|
||||
ptr->net2Host();
|
||||
ptr = (SdesItem *) ((char *) ptr + ptr->totalBytes());
|
||||
ptr = (SdesChunk *) ((char *) ptr + ptr->totalBytes());
|
||||
++item_count;
|
||||
}
|
||||
CHECK_REPORT_COUNT(item_count);
|
||||
}
|
||||
|
||||
vector<SdesItem *> RtcpSdes::getItemList() {
|
||||
vector<SdesItem *> ret;
|
||||
SdesItem *ptr = &items;
|
||||
vector<SdesChunk *> RtcpSdes::getChunkList() {
|
||||
vector<SdesChunk *> ret;
|
||||
SdesChunk *ptr = &chunks;
|
||||
for (int i = 0; i < (int) report_count; ++i) {
|
||||
ret.emplace_back(ptr);
|
||||
ptr = (SdesItem *) ((char *) ptr + ptr->totalBytes());
|
||||
ptr = (SdesChunk *) ((char *) ptr + ptr->totalBytes());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -477,8 +477,8 @@ SDES items 定义
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
//Source description item
|
||||
class SdesItem {
|
||||
//Source description Chunk
|
||||
class SdesChunk {
|
||||
public:
|
||||
friend class RtcpSdes;
|
||||
|
||||
@ -523,21 +523,21 @@ public:
|
||||
friend class RtcpHeader;
|
||||
|
||||
//可能有很多个
|
||||
SdesItem items;
|
||||
SdesChunk chunks;
|
||||
|
||||
public:
|
||||
/**
|
||||
* 创建SDES包,只赋值了RtcpHeader以及SdesItem对象的length和text部分
|
||||
* @param item_text SdesItem列表,只赋值length和text部分
|
||||
* 创建SDES包,只赋值了RtcpHeader以及SdesChunk对象的length和text部分
|
||||
* @param item_text SdesChunk列表,只赋值length和text部分
|
||||
* @return SDES包
|
||||
*/
|
||||
static std::shared_ptr<RtcpSdes> create(const std::vector<string> &item_text);
|
||||
|
||||
/**
|
||||
* 获取SdesItem对象指针列表
|
||||
* 获取SdesChunk对象指针列表
|
||||
* 使用net2Host转换成主机字节序后才可使用此函数
|
||||
*/
|
||||
vector<SdesItem*> getItemList();
|
||||
vector<SdesChunk*> getChunkList();
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -633,8 +633,8 @@ void RtspPlayer::onBeforeRtpSorted(const RtpPacket::Ptr &rtp, int track_idx){
|
||||
auto ssrc = rtp->getSSRC();
|
||||
auto rtcp = rtcp_ctx->createRtcpRR(ssrc + 1, ssrc);
|
||||
auto rtcp_sdes = RtcpSdes::create({SERVER_NAME});
|
||||
rtcp_sdes->items.type = (uint8_t) SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->items.ssrc = htonl(ssrc);
|
||||
rtcp_sdes->chunks.type = (uint8_t) SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->chunks.ssrc = htonl(ssrc);
|
||||
send_rtcp(this, track_idx, std::move(rtcp));
|
||||
send_rtcp(this, track_idx, RtcpHeader::toBuffer(rtcp_sdes));
|
||||
ticker.resetTime();
|
||||
|
@ -378,8 +378,8 @@ void RtspPusher::updateRtcpContext(const RtpPacket::Ptr &rtp){
|
||||
auto ssrc = rtp->getSSRC();
|
||||
auto rtcp = rtcp_ctx->createRtcpSR(ssrc + 1);
|
||||
auto rtcp_sdes = RtcpSdes::create({SERVER_NAME});
|
||||
rtcp_sdes->items.type = (uint8_t) SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->items.ssrc = htonl(ssrc);
|
||||
rtcp_sdes->chunks.type = (uint8_t) SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->chunks.ssrc = htonl(ssrc);
|
||||
send_rtcp(this, track_index, std::move(rtcp));
|
||||
send_rtcp(this, track_index, RtcpHeader::toBuffer(rtcp_sdes));
|
||||
}
|
||||
|
@ -1153,8 +1153,8 @@ void RtspSession::updateRtcpContext(const RtpPacket::Ptr &rtp){
|
||||
auto ssrc = rtp->getSSRC();
|
||||
auto rtcp = _push_src ? rtcp_ctx->createRtcpRR(ssrc + 1, ssrc) : rtcp_ctx->createRtcpSR(ssrc);
|
||||
auto rtcp_sdes = RtcpSdes::create({SERVER_NAME});
|
||||
rtcp_sdes->items.type = (uint8_t)SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->items.ssrc = htonl(ssrc);
|
||||
rtcp_sdes->chunks.type = (uint8_t)SdesType::RTCP_SDES_CNAME;
|
||||
rtcp_sdes->chunks.ssrc = htonl(ssrc);
|
||||
send_rtcp(this, track_index, std::move(rtcp));
|
||||
send_rtcp(this, track_index, RtcpHeader::toBuffer(rtcp_sdes));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ std::shared_ptr<Buffer> makeRtcpRR() {
|
||||
std::shared_ptr<Buffer> makeRtcpSDES() {
|
||||
auto rtcp = RtcpSdes::create({"zlmediakit", "", "https://github.com/xia-chu/ZLMediaKit", "1213642868@qq.com", "123456789012345678"});
|
||||
auto i = 5;
|
||||
auto items = rtcp->getItemList();
|
||||
auto items = rtcp->getChunkList();
|
||||
items[0]->type = (uint8_t)SdesType::RTCP_SDES_CNAME;
|
||||
items[0]->ssrc = htonl(i++);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user