rtph265pay: Extract sending a single packet into _payload_nal_single

Align with rtph264pay
This commit is contained in:
Olivier Crête 2019-06-13 16:22:57 -04:00 committed by Nicolas Dufresne
parent b841fd4c8a
commit 378c422e0c

View file

@ -129,6 +129,9 @@ static gboolean gst_rtp_h265_pay_sink_event (GstRTPBasePayload * payload,
GstEvent * event); GstEvent * event);
static GstStateChangeReturn gst_rtp_h265_pay_change_state (GstElement * static GstStateChangeReturn gst_rtp_h265_pay_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
static GstFlowReturn gst_rtp_h265_pay_payload_nal_single (GstRTPBasePayload *
basepayload, GstBuffer * paybuf, GstClockTime dts, GstClockTime pts,
gboolean marker);
#define gst_rtp_h265_pay_parent_class parent_class #define gst_rtp_h265_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpH265Pay, gst_rtp_h265_pay, GST_TYPE_RTP_BASE_PAYLOAD); G_DEFINE_TYPE (GstRtpH265Pay, gst_rtp_h265_pay, GST_TYPE_RTP_BASE_PAYLOAD);
@ -997,33 +1000,8 @@ gst_rtp_h265_pay_payload_nal (GstRTPBasePayload * basepayload,
"NAL Unit fit in one packet datasize=%d mtu=%d", size, mtu); "NAL Unit fit in one packet datasize=%d mtu=%d", size, mtu);
/* will fit in one packet */ /* will fit in one packet */
/* use buffer lists ret = gst_rtp_h265_pay_payload_nal_single (basepayload, paybuf, dts, pts,
* create buffer without payload containing only the RTP header marker);
* (memory block at index 0) */
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
/* Mark the end of a frame */
gst_rtp_buffer_set_marker (&rtp, marker);
/* timestamp the outbuffer */
GST_BUFFER_PTS (outbuf) = pts;
GST_BUFFER_DTS (outbuf) = dts;
/* insert payload memory block */
gst_rtp_copy_video_meta (rtph265pay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
outlist = gst_buffer_list_new ();
/* add the buffer to the buffer list */
gst_buffer_list_add (outlist, outbuf);
gst_rtp_buffer_unmap (&rtp);
/* push the list to the next element in the pipe */
ret = gst_rtp_base_payload_push_list (basepayload, outlist);
} else { } else {
/* fragmentation Units */ /* fragmentation Units */
guint fragment_size; guint fragment_size;
@ -1101,6 +1079,45 @@ gst_rtp_h265_pay_payload_nal (GstRTPBasePayload * basepayload,
return ret; return ret;
} }
static GstFlowReturn
gst_rtp_h265_pay_payload_nal_single (GstRTPBasePayload * basepayload,
GstBuffer * paybuf, GstClockTime dts, GstClockTime pts, gboolean marker)
{
GstBufferList *outlist;
GstBuffer *outbuf;
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
/* use buffer lists
* create buffer without payload containing only the RTP header
* (memory block at index 0) */
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
/* Mark the end of a frame */
gst_rtp_buffer_set_marker (&rtp, marker);
/* timestamp the outbuffer */
GST_BUFFER_PTS (outbuf) = pts;
GST_BUFFER_DTS (outbuf) = dts;
/* insert payload memory block */
gst_rtp_copy_video_meta (basepayload, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
outlist = gst_buffer_list_new ();
/* add the buffer to the buffer list */
gst_buffer_list_add (outlist, outbuf);
gst_rtp_buffer_unmap (&rtp);
/* push the list to the next element in the pipe */
return gst_rtp_base_payload_push_list (basepayload, outlist);
}
static GstFlowReturn static GstFlowReturn
gst_rtp_h265_pay_handle_buffer (GstRTPBasePayload * basepayload, gst_rtp_h265_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer) GstBuffer * buffer)