Commit a1cadd11 authored by Mathieu Duponchelle's avatar Mathieu Duponchelle 🐸 Committed by Mathieu Duponchelle

mpegtsmux: aggregator port

parent a57f4dc8
......@@ -34,7 +34,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpegts, "
"systemstream = (boolean) true, " "packetsize = (int) 192 ")
"systemstream = (boolean) true, " "packetsize = (int) 188 ")
);
static GstStaticPadTemplate gst_atsc_mux_sink_factory =
......@@ -155,7 +155,7 @@ gst_atsc_mux_create_ts_mux (GstBaseTsMux * mpegtsmux)
static guint
gst_atsc_mux_handle_media_type (GstBaseTsMux * mux, const gchar * media_type,
GstBaseTsPadData * ts_data)
GstBaseTsMuxPad * pad)
{
guint ret = TSMUX_ST_RESERVED;
......@@ -182,11 +182,11 @@ gst_atsc_mux_class_init (GstATSCMuxClass * klass)
mpegtsmux_class->create_ts_mux = gst_atsc_mux_create_ts_mux;
mpegtsmux_class->handle_media_type = gst_atsc_mux_handle_media_type;
gst_element_class_add_static_pad_template (gstelement_class,
&gst_atsc_mux_sink_factory);
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
&gst_atsc_mux_sink_factory, GST_TYPE_BASE_TS_MUX_PAD);
gst_element_class_add_static_pad_template (gstelement_class,
&gst_atsc_mux_src_factory);
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
&gst_atsc_mux_src_factory, GST_TYPE_AGGREGATOR_PAD);
}
static void
......
This diff is collapsed.
......@@ -86,34 +86,82 @@
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
#include <gst/base/gstadapter.h>
#include <glib-object.h>
#include <gst/base/gstaggregator.h>
G_BEGIN_DECLS
#include "tsmux/tsmux.h"
#define GST_TYPE_BASE_TS_MUX (gst_base_ts_mux_get_type())
#define GST_BASE_TS_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_BASE_TS_MUX, GstBaseTsMux))
#define GST_BASE_TS_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BASE_TS_MUX, GstBaseTsMuxClass))
#define GST_BASE_TS_MUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_TS_MUX,GstBaseTsMuxClass))
#define GST_BASE_TS_MUX_NORMAL_PACKET_LENGTH 188
#define GST_TYPE_BASE_TS_MUX_PAD (gst_base_ts_mux_pad_get_type())
#define GST_BASE_TS_MUX_PAD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_TS_MUX_PAD, GstBaseTsMuxPad))
#define GST_BASE_TS_MUX_PAD_CAST(obj) ((GstBaseTsMuxPad *)(obj))
#define GST_BASE_TS_MUX_PAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_TS_MUX_PAD, GstBaseTsMuxPadClass))
#define GST_IS_BASE_TS_MUX_PAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_TS_MUX_PAD))
#define GST_IS_BASE_TS_MUX_PAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_TS_MUX_PAD))
#define GST_BASE_TS_MUX_PAD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_TS_MUX_PAD,GstBaseTsMuxPadClass))
typedef struct _GstBaseTsMuxPad GstBaseTsMuxPad;
typedef struct _GstBaseTsMuxPadClass GstBaseTsMuxPadClass;
typedef struct _GstBaseTsMuxPadPrivate GstBaseTsMuxPadPrivate;
typedef struct GstBaseTsMux GstBaseTsMux;
typedef struct GstBaseTsMuxClass GstBaseTsMuxClass;
typedef struct GstBaseTsPadData GstBaseTsPadData;
typedef GstBuffer * (*GstBaseTsPadDataPrepareFunction) (GstBuffer * buf,
GstBaseTsPadData * data, GstBaseTsMux * mux);
typedef GstBuffer * (*GstBaseTsMuxPadPrepareFunction) (GstBuffer * buf,
GstBaseTsMuxPad * data, GstBaseTsMux * mux);
typedef void (*GstBaseTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
typedef void (*GstBaseTsMuxPadFreePrepareDataFunction) (gpointer prepare_data);
struct GstBaseTsMux {
GstElement parent;
struct _GstBaseTsMuxPad
{
GstAggregatorPad parent;
gint pid;
TsMuxStream *stream;
/* most recent DTS */
gint64 dts;
/* optional codec data available in the caps */
GstBuffer *codec_data;
/* Opaque data pointer to a structure used by the prepare function */
gpointer prepare_data;
/* handler to prepare input data */
GstBaseTsMuxPadPrepareFunction prepare_func;
/* handler to free the private data */
GstBaseTsMuxPadFreePrepareDataFunction free_func;
GstPad *srcpad;
/* program id to which it is attached to (not program pid) */
gint prog_id;
/* program this stream belongs to */
TsMuxProgram *prog;
GstCollectPads *collect;
gchar *language;
};
struct _GstBaseTsMuxPadClass
{
GstAggregatorPadClass parent_class;
};
GType gst_base_ts_mux_pad_get_type (void);
#define GST_TYPE_BASE_TS_MUX (gst_base_ts_mux_get_type())
#define GST_BASE_TS_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_BASE_TS_MUX, GstBaseTsMux))
#define GST_BASE_TS_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BASE_TS_MUX, GstBaseTsMuxClass))
#define GST_BASE_TS_MUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_TS_MUX,GstBaseTsMuxClass))
#define GST_BASE_TS_MUX_NORMAL_PACKET_LENGTH 188
struct GstBaseTsMux {
GstAggregator parent;
TsMux *tsmux;
GHashTable *programs;
......@@ -166,10 +214,10 @@ struct GstBaseTsMux {
* Called at EOS, if the subclass has data it needs to drain.
*/
struct GstBaseTsMuxClass {
GstElementClass parent_class;
GstAggregatorClass parent_class;
TsMux * (*create_ts_mux) (GstBaseTsMux *mux);
guint (*handle_media_type) (GstBaseTsMux *mux, const gchar *media_type, GstBaseTsPadData * ts_data);
guint (*handle_media_type) (GstBaseTsMux *mux, const gchar *media_type, GstBaseTsMuxPad * pad);
void (*allocate_packet) (GstBaseTsMux *mux, GstBuffer **buffer);
gboolean (*output_packet) (GstBaseTsMux *mux, GstBuffer *buffer, gint64 new_pcr);
void (*reset) (GstBaseTsMux *mux);
......@@ -179,6 +227,11 @@ struct GstBaseTsMuxClass {
void gst_base_ts_mux_set_packet_size (GstBaseTsMux *mux, gsize size);
void gst_base_ts_mux_set_automatic_alignment (GstBaseTsMux *mux, gsize alignment);
typedef GstBuffer * (*GstBaseTsPadDataPrepareFunction) (GstBuffer * buf,
GstBaseTsPadData * data, GstBaseTsMux * mux);
typedef void (*GstBaseTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
struct GstBaseTsPadData {
/* parent */
GstCollectData collect;
......@@ -210,7 +263,6 @@ struct GstBaseTsPadData {
GType gst_base_ts_mux_get_type (void);
G_END_DECLS
#endif
......@@ -90,7 +90,7 @@
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux)
{
guint8 adts_header[7] = { 0, };
......@@ -106,7 +106,7 @@ gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
gst_buffer_copy_into (out_buf, buf,
GST_BUFFER_COPY_METADATA | GST_BUFFER_COPY_TIMESTAMPS, 0, 0);
gst_buffer_map (data->codec_data, &codec_data_map, GST_MAP_READ);
gst_buffer_map (pad->codec_data, &codec_data_map, GST_MAP_READ);
/* Generate ADTS header */
obj_type = GST_READ_UINT8 (codec_data_map.data) >> 3;
......@@ -149,7 +149,7 @@ gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
/* Now copy complete frame */
gst_buffer_fill (out_buf, out_offset, buf_map.data, buf_map.size);
gst_buffer_unmap (data->codec_data, &codec_data_map);
gst_buffer_unmap (pad->codec_data, &codec_data_map);
gst_buffer_unmap (buf, &buf_map);
return out_buf;
......
......@@ -85,7 +85,7 @@
#include "gstbasetsmux.h"
GstBuffer * gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
GstBuffer * gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_AAC_H__ */
......@@ -36,10 +36,10 @@
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsPadData * data,
gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux)
{
j2k_private_data *private_data = data->prepare_data;
j2k_private_data *private_data = pad->prepare_data;
GstByteWriter wr;
GstBuffer *out_buf = NULL;
guint8 *elsm_header = NULL;
......
......@@ -55,7 +55,7 @@ typedef struct j2k_private_data
guint8 color_spec;
} j2k_private_data;
GstBuffer *gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsPadData * data,
GstBuffer *gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux);
void gst_base_ts_mux_free_jpeg2000 (gpointer prepare_data);
......
......@@ -91,7 +91,7 @@
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsPadData * pad_data,
gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux)
{
gssize insize = gst_buffer_get_size (buf);
......
......@@ -85,7 +85,7 @@
#include "gstbasetsmux.h"
GstBuffer * gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsPadData * data,
GstBuffer * gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_OPUS_H__ */
......@@ -98,7 +98,7 @@
*/
GstBuffer *
gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsPadData * pad_data,
gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux)
{
GstBuffer *out_buf;
......
......@@ -85,7 +85,7 @@
#include "gstbasetsmux.h"
GstBuffer * gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsPadData * data,
GstBuffer * gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsMuxPad * pad,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_TTXT_H__ */
......@@ -395,11 +395,11 @@ gst_mpeg_ts_mux_class_init (GstMpegTsMuxClass * klass)
"Multiplexes media streams into an MPEG Transport Stream",
"Fluendo <contact@fluendo.com>");
gst_element_class_add_static_pad_template (gstelement_class,
&gst_mpeg_ts_mux_sink_factory);
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
&gst_mpeg_ts_mux_sink_factory, GST_TYPE_BASE_TS_MUX_PAD);
gst_element_class_add_static_pad_template (gstelement_class,
&gst_mpeg_ts_mux_src_factory);
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
&gst_mpeg_ts_mux_src_factory, GST_TYPE_AGGREGATOR_PAD);
g_object_class_install_property (gobject_class, PROP_M2TS_MODE,
g_param_spec_boolean ("m2ts-mode", "M2TS(192 bytes) Mode",
......
......@@ -1085,7 +1085,7 @@ pad_stream (TsMux * mux, TsMuxStream * stream, gint64 cur_ts, gint64 * cur_pcr)
GST_LOG ("Transport stream bitrate: %" G_GUINT64_FORMAT, bitrate);
if (bitrate < mux->bitrate) {
GST_LOG_OBJECT (mux, "Padding transport stream");
GST_LOG ("Padding transport stream");
if (!tsmux_get_buffer (mux, &buf)) {
ret = FALSE;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment