mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
rtph264pay: Clean up _payload_nal_fragment
This commit is contained in:
parent
d97c3f045c
commit
5051569713
1 changed files with 15 additions and 22 deletions
|
@ -897,19 +897,16 @@ gst_rtp_h264_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
|
||||||
gboolean delta_unit, gboolean discont, guint8 nal_header)
|
gboolean delta_unit, gboolean discont, guint8 nal_header)
|
||||||
{
|
{
|
||||||
GstRtpH264Pay *rtph264pay;
|
GstRtpH264Pay *rtph264pay;
|
||||||
GstFlowReturn ret;
|
guint mtu, size, payload_len, pos;
|
||||||
guint payload_len, mtu;
|
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint8 *payload;
|
guint8 *payload;
|
||||||
GstBufferList *list = NULL;
|
GstBufferList *list = NULL;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
guint size = gst_buffer_get_size (paybuf);
|
int ii = 0, start = 1, end = 0;
|
||||||
|
|
||||||
guint fragment_size;
|
|
||||||
int ii = 0, start = 1, end = 0, pos = 0;
|
|
||||||
|
|
||||||
rtph264pay = GST_RTP_H264_PAY (basepayload);
|
rtph264pay = GST_RTP_H264_PAY (basepayload);
|
||||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (rtph264pay);
|
mtu = GST_RTP_BASE_PAYLOAD_MTU (rtph264pay);
|
||||||
|
size = gst_buffer_get_size (paybuf);
|
||||||
|
|
||||||
if (gst_rtp_buffer_calc_packet_len (size, 0, 0) <= mtu) {
|
if (gst_rtp_buffer_calc_packet_len (size, 0, 0) <= mtu) {
|
||||||
/* We don't need to fragment this packet */
|
/* We don't need to fragment this packet */
|
||||||
|
@ -919,27 +916,23 @@ gst_rtp_h264_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
|
||||||
end_of_au, delta_unit, discont);
|
end_of_au, delta_unit, discont);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (basepayload,
|
/* Start at the NALU payload */
|
||||||
"NAL Unit DOES NOT fit in one packet datasize=%d mtu=%d", size, mtu);
|
pos = 1;
|
||||||
|
|
||||||
pos++;
|
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
GST_DEBUG_OBJECT (basepayload,
|
||||||
|
"using FU-A fragmentation for NAL Unit: datasize=%u mtu=%u", size, mtu);
|
||||||
GST_DEBUG_OBJECT (basepayload, "Using FU-A fragmentation for data size=%d",
|
|
||||||
size);
|
|
||||||
|
|
||||||
/* We keep 2 bytes for FU indicator and FU Header */
|
/* We keep 2 bytes for FU indicator and FU Header */
|
||||||
payload_len = gst_rtp_buffer_calc_payload_len (mtu - 2, 0, 0);
|
payload_len = gst_rtp_buffer_calc_payload_len (mtu - 2, 0, 0);
|
||||||
|
|
||||||
list = gst_buffer_list_new_sized ((size / payload_len) + 1);
|
list = gst_buffer_list_new_sized ((size / payload_len) + 1);
|
||||||
|
|
||||||
while (end == 0) {
|
while (end == 0) {
|
||||||
fragment_size = size < payload_len ? size : payload_len;
|
guint fragment_size = size < payload_len ? size : payload_len;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (basepayload,
|
GST_DEBUG_OBJECT (basepayload,
|
||||||
"Inside FU-A fragmentation fragment_size=%d iteration=%d", fragment_size,
|
"creating FU-A packet fragment_size=%u iteration=%d",
|
||||||
ii);
|
fragment_size, ii);
|
||||||
|
|
||||||
/* use buffer lists
|
/* use buffer lists
|
||||||
* create buffer without payload containing only the RTP header
|
* create buffer without payload containing only the RTP header
|
||||||
|
@ -953,7 +946,6 @@ gst_rtp_h264_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
|
||||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||||
|
|
||||||
if (fragment_size == size) {
|
if (fragment_size == size) {
|
||||||
GST_DEBUG_OBJECT (basepayload, "end size=%d iteration=%d", size, ii);
|
|
||||||
end = 1;
|
end = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,16 +981,17 @@ gst_rtp_h264_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
|
||||||
/* add the buffer to the buffer list */
|
/* add the buffer to the buffer list */
|
||||||
gst_buffer_list_add (list, outbuf);
|
gst_buffer_list_add (list, outbuf);
|
||||||
|
|
||||||
|
|
||||||
size -= fragment_size;
|
size -= fragment_size;
|
||||||
pos += fragment_size;
|
pos += fragment_size;
|
||||||
ii++;
|
ii++;
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_rtp_base_payload_push_list (basepayload, list);
|
GST_DEBUG_OBJECT (rtph264pay,
|
||||||
|
"sending FU-A fragments: n=%d datasize=%u mtu=%u", ii, size, mtu);
|
||||||
|
|
||||||
gst_buffer_unref (paybuf);
|
gst_buffer_unref (paybuf);
|
||||||
return ret;
|
return gst_rtp_base_payload_push_list (basepayload, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
Loading…
Reference in a new issue