Implement RTP_SLICE

This commit is contained in:
Aaro Altonen 2020-10-22 14:38:59 +03:00
parent 9154f5554f
commit e185160f94
3 changed files with 29 additions and 23 deletions

View File

@ -33,7 +33,7 @@ namespace uvg_rtp {
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if one the parameters is invalid */
rtp_error_t push_h26x_frame(uint8_t *data, size_t data_len);
rtp_error_t push_h26x_frame(uint8_t *data, size_t data_len, int flags);
protected:
/* Each H26x class overrides this function with their custom NAL pushing function */

View File

@ -90,23 +90,27 @@ rtp_error_t uvg_rtp::formats::h265::push_nal_unit(uint8_t *data, size_t data_len
if (data_len - 3 <= payload_size) {
/* If there is more data coming in (possibly another small packet)
* create entry to "aggr_pkt_info_" to construct an aggregation packet */
if (more) {
aggr_pkt_info_.nalus.push_back(std::make_pair(data_len, data));
return RTP_NOT_READY;
} else {
if (aggr_pkt_info_.nalus.empty()) {
/* if (more) { */
/* aggr_pkt_info_.nalus.push_back(std::make_pair(data_len, data)); */
/* return RTP_NOT_READY; */
/* } else { */
/* if (aggr_pkt_info_.nalus.empty()) { */
if ((ret = fqueue_->enqueue_message(data, data_len)) != RTP_OK) {
LOG_ERROR("Failed to enqueue Single NAL Unit packet!");
return ret;
}
if (more)
return RTP_NOT_READY;
return fqueue_->flush_queue();
} else {
(void)make_aggregation_pkt();
ret = fqueue_->flush_queue();
clear_aggregation_info();
return ret;
}
}
/* } else { */
/* (void)make_aggregation_pkt(); */
/* ret = fqueue_->flush_queue(); */
/* clear_aggregation_info(); */
/* return ret; */
/* } */
/* } */
} else {
/* If smaller NALUs were queued before this NALU,
* send them in an aggregation packet before proceeding with fragmentation */

View File

@ -230,7 +230,7 @@ end:
return -1;
}
rtp_error_t uvg_rtp::formats::h26x::push_h26x_frame(uint8_t *data, size_t data_len)
rtp_error_t uvg_rtp::formats::h26x::push_h26x_frame(uint8_t *data, size_t data_len, int flags)
{
/* find first start code */
uint8_t start_len = 0;
@ -240,15 +240,19 @@ rtp_error_t uvg_rtp::formats::h26x::push_h26x_frame(uint8_t *data, size_t data_l
rtp_error_t ret = RTP_GENERIC_ERROR;
size_t payload_size = rtp_ctx_->get_payload_size();
if (data_len < payload_size) {
if (data_len < payload_size || flags & RTP_SLICE) {
r_off = (offset < 0) ? 0 : offset;
if ((ret = fqueue_->enqueue_message(data + r_off, data_len - r_off)) != RTP_OK) {
LOG_ERROR("Failed to enqueue Single NAL Unit packet!");
return ret;
}
if (data_len > payload_size) {
return push_nal_unit(data + r_off, data_len, false);
} else {
if ((ret = fqueue_->enqueue_message(data + r_off, data_len - r_off)) != RTP_OK) {
LOG_ERROR("Failed to enqueue Single NAL Unit packet!");
return ret;
}
return fqueue_->flush_queue();
return fqueue_->flush_queue();
}
}
while (offset != -1) {
@ -296,8 +300,6 @@ uvg_rtp::formats::h26x::~h26x()
rtp_error_t uvg_rtp::formats::h26x::push_media_frame(uint8_t *data, size_t data_len, int flags)
{
(void)flags;
rtp_error_t ret;
if (!data || !data_len)
@ -308,5 +310,5 @@ rtp_error_t uvg_rtp::formats::h26x::push_media_frame(uint8_t *data, size_t data_
return ret;
}
return push_h26x_frame(data, data_len);
return push_h26x_frame(data, data_len, flags);
}