rtcp: Add possibility for the user to provide SDES items
This commit is contained in:
parent
1707c5eb52
commit
e8586e8550
|
@ -121,6 +121,9 @@ namespace uvgrtp {
|
|||
*/
|
||||
rtp_error_t send_sdes_packet(const std::vector<uvgrtp::frame::rtcp_sdes_item>& items);
|
||||
|
||||
|
||||
rtp_error_t set_sdes_items(const std::vector<uvgrtp::frame::rtcp_sdes_item>& items);
|
||||
|
||||
/**
|
||||
* \brief Send an RTCP APP packet
|
||||
*
|
||||
|
@ -464,7 +467,10 @@ namespace uvgrtp {
|
|||
|
||||
int interval_ms_;
|
||||
|
||||
std::string cname_;
|
||||
std::vector<uvgrtp::frame::rtcp_sdes_item> ourItems_;
|
||||
|
||||
uvgrtp::frame::rtcp_sdes_item cnameItem_;
|
||||
char cname_[255];
|
||||
};
|
||||
}
|
||||
|
||||
|
|
42
src/rtcp.cc
42
src/rtcp.cc
|
@ -63,6 +63,21 @@ uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int flag
|
|||
srtcp_ = nullptr;
|
||||
|
||||
zero_stats(&our_stats);
|
||||
|
||||
if (cname.length() > 255)
|
||||
{
|
||||
LOG_ERROR("Our CName is too long");
|
||||
}
|
||||
else
|
||||
{
|
||||
// items should not have null termination
|
||||
const char* c = cname.c_str();
|
||||
memcpy(cname_, c, cname.length());
|
||||
uint8_t length = cname.length();
|
||||
|
||||
cnameItem_ = { 1, length, (void*)cname_ };
|
||||
ourItems_.push_back(cnameItem_);
|
||||
}
|
||||
}
|
||||
|
||||
uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname,
|
||||
|
@ -78,6 +93,8 @@ uvgrtp::rtcp::~rtcp()
|
|||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
ourItems_.clear();
|
||||
}
|
||||
|
||||
void uvgrtp::rtcp::free_participant(rtcp_participant* participant)
|
||||
|
@ -223,6 +240,31 @@ void uvgrtp::rtcp::rtcp_runner(rtcp* rtcp, int interval)
|
|||
}
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::rtcp::set_sdes_items(const std::vector<uvgrtp::frame::rtcp_sdes_item>& items)
|
||||
{
|
||||
bool hasCname = false;
|
||||
|
||||
for (auto& item : items)
|
||||
{
|
||||
if (item.type == 1)
|
||||
{
|
||||
hasCname = true;
|
||||
LOG_DEBUG("Found CName in sdes items, not adding pregenerated");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ourItems_.clear();
|
||||
if (!hasCname)
|
||||
{
|
||||
ourItems_.push_back(cnameItem_);
|
||||
}
|
||||
|
||||
ourItems_.insert(ourItems_.end(), items.begin(), items.end());
|
||||
|
||||
return RTP_OK;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::rtcp::add_participant(std::string dst_addr, uint16_t dst_port, uint16_t src_port, uint32_t clock_rate)
|
||||
{
|
||||
if (dst_addr == "" || !dst_port || !src_port)
|
||||
|
|
Loading…
Reference in New Issue