/**
* SECTION:element-rtpac3pay
+ * @title: rtpac3pay
* @see_also: rtpac3depay
*
* Payload AC3 audio into RTP packets according to RFC 4184.
* For detailed information see: http://www.rfc-editor.org/rfc/rfc4184.txt
*
- * <refsect2>
- * <title>Example pipeline</title>
+ * ## Example pipeline
* |[
* gst-launch-1.0 -v audiotestsrc ! avenc_ac3 ! rtpac3pay ! udpsink
* ]| This example pipeline will encode and payload AC3 stream. Refer to
* the rtpac3depay example to depayload and decode the RTP stream.
- * </refsect2>
+ *
*/
#ifdef HAVE_CONFIG_H
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/audio/audio.h>
#include "gstrtpac3pay.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY_STATIC (rtpac3pay_debug);
#define GST_CAT_DEFAULT (rtpac3pay_debug)
gstelement_class->change_state = gst_rtp_ac3_pay_change_state;
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_ac3_pay_src_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_ac3_pay_sink_template));
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_ac3_pay_src_template);
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_ac3_pay_sink_template);
gst_element_class_set_static_metadata (gstelement_class,
"RTP AC3 audio payloader", "Codec/Payloader/Network/RTP",
guint payload_len;
guint packet_len;
GstRTPBuffer rtp = { NULL, };
+ GstBuffer *payload_buffer;
/* this will be the total length of the packet */
packet_len = gst_rtp_buffer_calc_packet_len (2 + avail, 0, 0);
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
/* create buffer to hold the payload */
- outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
+ outbuf =
+ gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+ (rtpac3pay), 2, 0, 0);
if (FT == 0) {
/* check if it all fits */
payload[1] = NF;
payload_len -= 2;
- gst_adapter_copy (rtpac3pay->adapter, &payload[2], 0, payload_len);
- gst_adapter_flush (rtpac3pay->adapter, payload_len);
-
- avail -= payload_len;
- if (avail == 0)
+ if (avail == payload_len)
gst_rtp_buffer_set_marker (&rtp, TRUE);
gst_rtp_buffer_unmap (&rtp);
- GST_BUFFER_TIMESTAMP (outbuf) = rtpac3pay->first_ts;
+ payload_buffer =
+ gst_adapter_take_buffer_fast (rtpac3pay->adapter, payload_len);
+
+ gst_rtp_copy_audio_meta (rtpac3pay, outbuf, payload_buffer);
+
+ outbuf = gst_buffer_append (outbuf, payload_buffer);
+
+ avail -= payload_len;
+
+ GST_BUFFER_PTS (outbuf) = rtpac3pay->first_ts;
GST_BUFFER_DURATION (outbuf) = rtpac3pay->duration;
ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpac3pay), outbuf);
gst_buffer_map (buffer, &map, GST_MAP_READ);
duration = GST_BUFFER_DURATION (buffer);
- timestamp = GST_BUFFER_TIMESTAMP (buffer);
+ timestamp = GST_BUFFER_PTS (buffer);
if (GST_BUFFER_IS_DISCONT (buffer)) {
GST_DEBUG_OBJECT (rtpac3pay, "DISCONT");
gst_rtp_ac3_pay_reset (rtpac3pay);
}
- /* count the amount of incomming packets */
+ /* count the amount of incoming packets */
NF = 0;
left = map.size;
p = map.data;