mpegtsmux: spring cleanup, no functional change

This commit is contained in:
Mathieu Duponchelle 2019-04-30 01:42:59 +02:00 committed by Mathieu Duponchelle
parent 44c701d113
commit a57f4dc8d9
19 changed files with 943 additions and 1036 deletions

View file

@ -19,17 +19,17 @@
* Boston, MA 02110-1301, USA.
*/
#include "atscmux.h"
#include "gstatscmux.h"
GST_DEBUG_CATEGORY (atscmux_debug);
#define GST_CAT_DEFAULT atscmux_debug
GST_DEBUG_CATEGORY (gst_atsc_mux_debug);
#define GST_CAT_DEFAULT gst_atsc_mux_debug
G_DEFINE_TYPE (ATSCMux, atscmux, GST_TYPE_BASE_TSMUX);
G_DEFINE_TYPE (GstATSCMux, gst_atsc_mux, GST_TYPE_BASE_TS_MUX);
#define parent_class atscmux_parent_class
#define parent_class gst_atsc_mux_parent_class
#define ATSCMUX_ST_PS_AUDIO_EAC3 0x87
static GstStaticPadTemplate atscmux_src_factory =
static GstStaticPadTemplate gst_atsc_mux_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
@ -37,7 +37,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
"systemstream = (boolean) true, " "packetsize = (int) 192 ")
);
static GstStaticPadTemplate atscmux_sink_factory =
static GstStaticPadTemplate gst_atsc_mux_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
@ -50,9 +50,11 @@ static GstStaticPadTemplate atscmux_sink_factory =
"audio/x-ac3, framed = (boolean) TRUE;"
"audio/x-eac3, framed = (boolean) TRUE;"));
/* Internals */
static void
atscmux_stream_get_es_descrs (TsMuxStream * stream,
GstMpegtsPMTStream * pmt_stream, BaseTsMux * mpegtsmux)
gst_atsc_mux_stream_get_es_descrs (TsMuxStream * stream,
GstMpegtsPMTStream * pmt_stream, GstBaseTsMux * mpegtsmux)
{
GstMpegtsDescriptor *descriptor;
@ -120,8 +122,8 @@ atscmux_stream_get_es_descrs (TsMuxStream * stream,
}
static TsMuxStream *
atscmux_create_new_stream (guint16 new_pid,
TsMuxStreamType stream_type, BaseTsMux * mpegtsmux)
gst_atsc_mux_create_new_stream (guint16 new_pid,
TsMuxStreamType stream_type, GstBaseTsMux * mpegtsmux)
{
TsMuxStream *ret = tsmux_stream_new (new_pid, stream_type);
@ -132,26 +134,28 @@ atscmux_create_new_stream (guint16 new_pid,
}
tsmux_stream_set_get_es_descriptors_func (ret,
(TsMuxStreamGetESDescriptorsFunc) atscmux_stream_get_es_descrs,
(TsMuxStreamGetESDescriptorsFunc) gst_atsc_mux_stream_get_es_descrs,
mpegtsmux);
return ret;
}
/* GstBaseTsMux implementation */
static TsMux *
atscmux_create_ts_mux (BaseTsMux * mpegtsmux)
gst_atsc_mux_create_ts_mux (GstBaseTsMux * mpegtsmux)
{
TsMux *ret = ((BaseTsMuxClass *) parent_class)->create_ts_mux (mpegtsmux);
TsMux *ret = ((GstBaseTsMuxClass *) parent_class)->create_ts_mux (mpegtsmux);
tsmux_set_new_stream_func (ret,
(TsMuxNewStreamFunc) atscmux_create_new_stream, mpegtsmux);
(TsMuxNewStreamFunc) gst_atsc_mux_create_new_stream, mpegtsmux);
return ret;
}
static guint
atscmux_handle_media_type (BaseTsMux * mux, const gchar * media_type,
BaseTsPadData * ts_data)
gst_atsc_mux_handle_media_type (GstBaseTsMux * mux, const gchar * media_type,
GstBaseTsPadData * ts_data)
{
guint ret = TSMUX_ST_RESERVED;
@ -163,29 +167,29 @@ atscmux_handle_media_type (BaseTsMux * mux, const gchar * media_type,
}
static void
atscmux_class_init (ATSCMuxClass * klass)
gst_atsc_mux_class_init (GstATSCMuxClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
BaseTsMuxClass *mpegtsmux_class = (BaseTsMuxClass *) klass;
GstBaseTsMuxClass *mpegtsmux_class = (GstBaseTsMuxClass *) klass;
GST_DEBUG_CATEGORY_INIT (atscmux_debug, "atscmux", 0, "ATSC muxer");
GST_DEBUG_CATEGORY_INIT (gst_atsc_mux_debug, "atscmux", 0, "ATSC muxer");
gst_element_class_set_static_metadata (gstelement_class,
"ATSC Transport Stream Muxer", "Codec/Muxer",
"Multiplexes media streams into an ATSC-compliant Transport Stream",
"Mathieu Duponchelle <mathieu@centricular.com>");
mpegtsmux_class->create_ts_mux = atscmux_create_ts_mux;
mpegtsmux_class->handle_media_type = atscmux_handle_media_type;
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,
&atscmux_sink_factory);
&gst_atsc_mux_sink_factory);
gst_element_class_add_static_pad_template (gstelement_class,
&atscmux_src_factory);
&gst_atsc_mux_src_factory);
}
static void
atscmux_init (ATSCMux * mux)
gst_atsc_mux_init (GstATSCMux * mux)
{
}

View file

@ -1,7 +1,7 @@
/* ATSC Transport Stream muxer
* Copyright (C) 2019 Mathieu Duponchelle <mathieu@centricular.com>
*
* atscmux.h:
* gstatscmux.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -22,24 +22,24 @@
#ifndef __ATSCMUX_H__
#define __ATSCMUX_H__
#include "basetsmux.h"
#include "gstbasetsmux.h"
G_BEGIN_DECLS
#define GST_TYPE_ATSCMUX (atscmux_get_type())
#define GST_TYPE_ATSCMUX (gst_atsc_mux_get_type())
typedef struct ATSCMux ATSCMux;
typedef struct ATSCMuxClass ATSCMuxClass;
typedef struct GstATSCMux GstATSCMux;
typedef struct GstATSCMuxClass GstATSCMuxClass;
struct ATSCMux {
BaseTsMux parent;
struct GstATSCMux {
GstBaseTsMux parent;
};
struct ATSCMuxClass {
BaseTsMuxClass parent_class;
struct GstATSCMuxClass {
GstBaseTsMuxClass parent_class;
};
GType atscmux_get_type (void);
GType gst_atsc_mux_get_type (void);
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -86,44 +86,29 @@
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
#include <gst/base/gstadapter.h>
#include <glib-object.h>
G_BEGIN_DECLS
#include <tsmux/tsmux.h>
#include "tsmux/tsmux.h"
#define GST_TYPE_BASE_TSMUX (basetsmux_get_type())
#define GST_BASE_TSMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_BASE_TSMUX, BaseTsMux))
#define GST_BASE_TSMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_TSMUX,BaseTsMuxClass))
#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 CLOCK_BASE 9LL
#define CLOCK_FREQ (CLOCK_BASE * 10000) /* 90 kHz PTS clock */
#define CLOCK_FREQ_SCR (CLOCK_FREQ * 300) /* 27 MHz SCR clock */
#define GST_BASE_TS_MUX_NORMAL_PACKET_LENGTH 188
#define GSTTIME_TO_MPEGTIME(time) \
(((time) > 0 ? (gint64) 1 : (gint64) -1) * \
(gint64) gst_util_uint64_scale (ABS(time), CLOCK_BASE, GST_MSECOND/10))
typedef struct GstBaseTsMux GstBaseTsMux;
typedef struct GstBaseTsMuxClass GstBaseTsMuxClass;
typedef struct GstBaseTsPadData GstBaseTsPadData;
/* 27 MHz SCR conversions: */
#define MPEG_SYS_TIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
GST_USECOND, CLOCK_FREQ_SCR / 1000000))
#define GSTTIME_TO_MPEG_SYS_TIME(time) (gst_util_uint64_scale ((time), \
CLOCK_FREQ_SCR / 1000000, GST_USECOND))
typedef GstBuffer * (*GstBaseTsPadDataPrepareFunction) (GstBuffer * buf,
GstBaseTsPadData * data, GstBaseTsMux * mux);
#define NORMAL_TS_PACKET_LENGTH 188
#define M2TS_PACKET_LENGTH 192
typedef void (*GstBaseTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
#define DEFAULT_PROG_ID 0
typedef struct BaseTsMux BaseTsMux;
typedef struct BaseTsMuxClass BaseTsMuxClass;
typedef struct BaseTsPadData BaseTsPadData;
typedef GstBuffer * (*BaseTsPadDataPrepareFunction) (GstBuffer * buf,
BaseTsPadData * data, BaseTsMux * mux);
typedef void (*BaseTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
struct BaseTsMux {
struct GstBaseTsMux {
GstElement parent;
GstPad *srcpad;
@ -160,34 +145,41 @@ struct BaseTsMux {
/* output buffer aggregation */
GstAdapter *out_adapter;
GstBuffer *out_buffer;
#if 0
/* SPN/PTS index handling */
GstIndex *element_index;
gint spn_count;
#endif
};
/**
* BaseTsMuxClass:
* GstBaseTsMuxClass:
* @create_ts_mux: Optional.
* Called in order to create the #TsMux object.
* @handle_media_type: Optional.
* Called in order to determine the stream-type for a given
* @media_type (eg. video/x-h264).
* @allocate_packet: Optional.
* Called when the underlying #TsMux object needs a packet
* to write into.
* @output_packet: Optional.
* Called when the underlying #TsMux object has a packet
* ready to output.
* @reset: Optional.
* Called when the subclass needs to reset.
* @drain: Optional.
* Called at EOS, if the subclass has data it needs to drain.
*/
struct BaseTsMuxClass {
struct GstBaseTsMuxClass {
GstElementClass parent_class;
TsMux * (*create_ts_mux) (BaseTsMux *mux);
guint (*handle_media_type) (BaseTsMux *mux, const gchar *media_type, BaseTsPadData * ts_data);
void (*allocate_packet) (BaseTsMux *mux, GstBuffer **buffer);
gboolean (*output_packet) (BaseTsMux *mux, GstBuffer *buffer, gint64 new_pcr);
void (*reset) (BaseTsMux *mux);
gboolean (*drain) (BaseTsMux *mux);
TsMux * (*create_ts_mux) (GstBaseTsMux *mux);
guint (*handle_media_type) (GstBaseTsMux *mux, const gchar *media_type, GstBaseTsPadData * ts_data);
void (*allocate_packet) (GstBaseTsMux *mux, GstBuffer **buffer);
gboolean (*output_packet) (GstBaseTsMux *mux, GstBuffer *buffer, gint64 new_pcr);
void (*reset) (GstBaseTsMux *mux);
gboolean (*drain) (GstBaseTsMux *mux);
};
void gst_base_tsmux_set_packet_size (BaseTsMux *mux, gsize size);
void gst_base_tsmux_set_automatic_alignment (BaseTsMux *mux, gsize alignment);
void gst_base_ts_mux_set_packet_size (GstBaseTsMux *mux, gsize size);
void gst_base_ts_mux_set_automatic_alignment (GstBaseTsMux *mux, gsize alignment);
struct BaseTsPadData {
struct GstBaseTsPadData {
/* parent */
GstCollectData collect;
@ -197,11 +189,6 @@ struct BaseTsPadData {
/* most recent DTS */
gint64 dts;
#if 0
/* (optional) index writing */
gint element_index_writer_id;
#endif
/* optional codec data available in the caps */
GstBuffer *codec_data;
@ -209,9 +196,9 @@ struct BaseTsPadData {
gpointer prepare_data;
/* handler to prepare input data */
BaseTsPadDataPrepareFunction prepare_func;
GstBaseTsPadDataPrepareFunction prepare_func;
/* handler to free the private data */
BaseTsPadDataFreePrepareDataFunction free_func;
GstBaseTsPadDataFreePrepareDataFunction free_func;
/* program id to which it is attached to (not program pid) */
gint prog_id;
@ -221,7 +208,7 @@ struct BaseTsPadData {
gchar *language;
};
GType basetsmux_get_type (void);
GType gst_base_ts_mux_get_type (void);
G_END_DECLS

View file

@ -84,13 +84,14 @@
#include "config.h"
#endif
#include "basetsmux_aac.h"
#include "gstbasetsmuxaac.h"
#include <string.h>
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
basetsmux_prepare_aac (GstBuffer * buf, BaseTsPadData * data, BaseTsMux * mux)
gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux)
{
guint8 adts_header[7] = { 0, };
gsize out_size = gst_buffer_get_size (buf) + 7;

View file

@ -83,9 +83,9 @@
#ifndef __BASETSMUX_AAC_H__
#define __BASETSMUX_AAC_H__
#include "basetsmux.h"
#include "gstbasetsmux.h"
GstBuffer * basetsmux_prepare_aac (GstBuffer * buf, BaseTsPadData * data,
BaseTsMux * mux);
GstBuffer * gst_base_ts_mux_prepare_aac (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_AAC_H__ */

View file

@ -27,17 +27,17 @@
#endif
#include <stdio.h>
#include "basetsmux_jpeg2000.h"
#include "gstbasetsmuxjpeg2000.h"
#include <string.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbytewriter.h>
#include <gst/gst.h>
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
basetsmux_prepare_jpeg2000 (GstBuffer * buf, BaseTsPadData * data,
BaseTsMux * mux)
gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux)
{
j2k_private_data *private_data = data->prepare_data;
GstByteWriter wr;
@ -127,7 +127,7 @@ basetsmux_prepare_jpeg2000 (GstBuffer * buf, BaseTsPadData * data,
}
void
basetsmux_free_jpeg2000 (gpointer prepare_data)
gst_base_ts_mux_free_jpeg2000 (gpointer prepare_data)
{
/* Free prepare data memory object */
g_free (prepare_data);

View file

@ -25,7 +25,7 @@
#ifndef __BASETSMUX_JPEG2000_H__
#define __BASETSMUX_JPEG2000_H__
#include "basetsmux.h"
#include "gstbasetsmux.h"
/* color specifications for JPEG 2000 stream over MPEG TS */
typedef enum
@ -38,7 +38,7 @@ typedef enum
GST_MPEGTS_JPEG2000_COLORSPEC_CIEXYZ,
GST_MPEGTS_JPEG2000_COLORSPEC_REC2020,
GST_MPEGTS_JPEG2000_COLORSPEC_SMPTE2084
} GstBaseTsJpeg2000ColorSpec;
} GstGstBaseTsJpeg2000ColorSpec;
typedef struct j2k_private_data
@ -55,9 +55,9 @@ typedef struct j2k_private_data
guint8 color_spec;
} j2k_private_data;
GstBuffer *basetsmux_prepare_jpeg2000 (GstBuffer * buf, BaseTsPadData * data,
BaseTsMux * mux);
GstBuffer *gst_base_ts_mux_prepare_jpeg2000 (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux);
void basetsmux_free_jpeg2000 (gpointer prepare_data);
void gst_base_ts_mux_free_jpeg2000 (gpointer prepare_data);
#endif /* __BASETSMUX_JPEG2000_H__ */

View file

@ -84,15 +84,15 @@
#include "config.h"
#endif
#include "basetsmux_opus.h"
#include "gstbasetsmuxopus.h"
#include <string.h>
#include <gst/audio/audio.h>
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
GstBuffer *
basetsmux_prepare_opus (GstBuffer * buf, BaseTsPadData * pad_data,
BaseTsMux * mux)
gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsPadData * pad_data,
GstBaseTsMux * mux)
{
gssize insize = gst_buffer_get_size (buf);
gsize outsize;

View file

@ -83,9 +83,9 @@
#ifndef __BASETSMUX_OPUS_H__
#define __BASETSMUX_OPUS_H__
#include "basetsmux.h"
#include "gstbasetsmux.h"
GstBuffer * basetsmux_prepare_opus (GstBuffer * buf, BaseTsPadData * data,
BaseTsMux * mux);
GstBuffer * gst_base_ts_mux_prepare_opus (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_OPUS_H__ */

View file

@ -84,10 +84,10 @@
#include "config.h"
#endif
#include "basetsmux_ttxt.h"
#include "gstbasetsmuxttxt.h"
#include <string.h>
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
/* from EN 300 472 spec: ITU-R System B Teletext in DVB
*
@ -98,8 +98,8 @@
*/
GstBuffer *
basetsmux_prepare_teletext (GstBuffer * buf, BaseTsPadData * pad_data,
BaseTsMux * mux)
gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsPadData * pad_data,
GstBaseTsMux * mux)
{
GstBuffer *out_buf;
guint8 *data, *odata;

View file

@ -83,9 +83,9 @@
#ifndef __BASETSMUX_TTXT_H__
#define __BASETSMUX_TTXT_H__
#include "basetsmux.h"
#include "gstbasetsmux.h"
GstBuffer * basetsmux_prepare_teletext (GstBuffer * buf, BaseTsPadData * data,
BaseTsMux * mux);
GstBuffer * gst_base_ts_mux_prepare_teletext (GstBuffer * buf, GstBaseTsPadData * data,
GstBaseTsMux * mux);
#endif /* __BASETSMUX_TTXT_H__ */

View file

@ -82,17 +82,19 @@
*
*/
#include "mpegtsmux.h"
#include "gstmpegtsmux.h"
#define MPEGTSMUX_DEFAULT_M2TS FALSE
#define M2TS_PACKET_LENGTH 192
enum
{
PROP_0,
PROP_M2TS_MODE,
};
static GstStaticPadTemplate mpegtsmux_sink_factory =
static GstStaticPadTemplate gst_mpeg_ts_mux_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
@ -129,7 +131,7 @@ static GstStaticPadTemplate mpegtsmux_sink_factory =
"subpicture/x-dvb; application/x-teletext; meta/x-klv, parsed=true;"
"image/x-jpc, profile = (int)[0, 49151];"));
static GstStaticPadTemplate mpegtsmux_src_factory =
static GstStaticPadTemplate gst_mpeg_ts_mux_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
@ -137,59 +139,16 @@ GST_STATIC_PAD_TEMPLATE ("src",
"systemstream = (boolean) true, " "packetsize = (int) { 188, 192} ")
);
GST_DEBUG_CATEGORY (mpegtsmux_debug);
#define GST_CAT_DEFAULT mpegtsmux_debug
GST_DEBUG_CATEGORY (gst_mpeg_ts_mux_debug);
#define GST_CAT_DEFAULT gst_mpeg_ts_mux_debug
G_DEFINE_TYPE (MpegTsMux, mpegtsmux, GST_TYPE_BASE_TSMUX);
#define parent_class mpegtsmux_parent_class
G_DEFINE_TYPE (GstMpegTsMux, gst_mpeg_ts_mux, GST_TYPE_BASE_TS_MUX);
#define parent_class gst_mpeg_ts_mux_parent_class
static void
gst_mpegtsmux_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
MpegTsMux *mux = GST_MPEG_TSMUX (object);
switch (prop_id) {
case PROP_M2TS_MODE:
/* set incase if the output stream need to be of 192 bytes */
mux->m2ts_mode = g_value_get_boolean (value);
gst_base_tsmux_set_packet_size (GST_BASE_TSMUX (mux),
mux->m2ts_mode ? M2TS_PACKET_LENGTH : NORMAL_TS_PACKET_LENGTH);
gst_base_tsmux_set_automatic_alignment (GST_BASE_TSMUX (mux),
mux->m2ts_mode ? 32 : 0);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpegtsmux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
MpegTsMux *mux = GST_MPEG_TSMUX (object);
switch (prop_id) {
case PROP_M2TS_MODE:
g_value_set_boolean (value, mux->m2ts_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpegtsmux_allocate_packet (BaseTsMux * mux, GstBuffer ** buffer)
{
((BaseTsMuxClass *) parent_class)->allocate_packet (mux, buffer);
gst_buffer_set_size (*buffer, NORMAL_TS_PACKET_LENGTH);
}
/* Internals */
static gboolean
new_packet_m2ts (MpegTsMux * mux, GstBuffer * buf, gint64 new_pcr)
new_packet_m2ts (GstMpegTsMux * mux, GstBuffer * buf, gint64 new_pcr)
{
GstBuffer *out_buf;
int chunk_bytes;
@ -272,8 +231,8 @@ new_packet_m2ts (MpegTsMux * mux, GstBuffer * buf, gint64 new_pcr)
GST_LOG_OBJECT (mux, "Outputting a packet of length %d PCR %"
G_GUINT64_FORMAT, M2TS_PACKET_LENGTH, cur_pcr);
((BaseTsMuxClass *) parent_class)->output_packet (GST_BASE_TSMUX (mux),
out_buf, -1);
((GstBaseTsMuxClass *)
parent_class)->output_packet (GST_BASE_TS_MUX (mux), out_buf, -1);
}
}
@ -291,8 +250,8 @@ new_packet_m2ts (MpegTsMux * mux, GstBuffer * buf, gint64 new_pcr)
GST_LOG_OBJECT (mux, "Outputting a packet of length %d PCR %"
G_GUINT64_FORMAT, M2TS_PACKET_LENGTH, new_pcr);
((BaseTsMuxClass *) parent_class)->output_packet (GST_BASE_TSMUX (mux), buf,
-1);
((GstBaseTsMuxClass *) parent_class)->output_packet (GST_BASE_TS_MUX (mux),
buf, -1);
if (new_pcr != mux->previous_pcr) {
mux->previous_pcr = new_pcr;
@ -303,16 +262,26 @@ exit:
return TRUE;
}
/* GstBaseTsMux implementation */
static void
gst_mpeg_ts_mux_allocate_packet (GstBaseTsMux * mux, GstBuffer ** buffer)
{
((GstBaseTsMuxClass *) parent_class)->allocate_packet (mux, buffer);
gst_buffer_set_size (*buffer, GST_BASE_TS_MUX_NORMAL_PACKET_LENGTH);
}
static gboolean
gst_mpegtsmux_output_packet (BaseTsMux * base_tsmux, GstBuffer * buffer,
gst_mpeg_ts_mux_output_packet (GstBaseTsMux * base_tsmux, GstBuffer * buffer,
gint64 new_pcr)
{
MpegTsMux *mux = (MpegTsMux *) base_tsmux;
GstMpegTsMux *mux = GST_MPEG_TS_MUX (base_tsmux);
GstMapInfo map;
if (!mux->m2ts_mode)
return ((BaseTsMuxClass *) parent_class)->output_packet (base_tsmux, buffer,
new_pcr);
return ((GstBaseTsMuxClass *) parent_class)->output_packet (base_tsmux,
buffer, new_pcr);
gst_buffer_set_size (buffer, M2TS_PACKET_LENGTH);
@ -327,9 +296,9 @@ gst_mpegtsmux_output_packet (BaseTsMux * base_tsmux, GstBuffer * buffer,
}
static void
gst_mpegtsmux_reset (BaseTsMux * base_tsmux)
gst_mpeg_ts_mux_reset (GstBaseTsMux * base_tsmux)
{
MpegTsMux *mux = (MpegTsMux *) base_tsmux;
GstMpegTsMux *mux = GST_MPEG_TS_MUX (base_tsmux);
if (mux->adapter)
gst_adapter_clear (mux->adapter);
@ -339,10 +308,56 @@ gst_mpegtsmux_reset (BaseTsMux * base_tsmux)
mux->pcr_rate_num = mux->pcr_rate_den = 1;
}
static void
gst_mpegtsmux_dispose (GObject * object)
static gboolean
gst_mpeg_ts_mux_drain (GstBaseTsMux * mux)
{
MpegTsMux *mux = (MpegTsMux *) object;
return new_packet_m2ts (GST_MPEG_TS_MUX (mux), NULL, -1);
}
/* GObject implementation */
static void
gst_mpeg_ts_mux_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstMpegTsMux *mux = GST_MPEG_TS_MUX (object);
switch (prop_id) {
case PROP_M2TS_MODE:
/* set incase if the output stream need to be of 192 bytes */
mux->m2ts_mode = g_value_get_boolean (value);
gst_base_ts_mux_set_packet_size (GST_BASE_TS_MUX (mux),
mux->m2ts_mode ? M2TS_PACKET_LENGTH :
GST_BASE_TS_MUX_NORMAL_PACKET_LENGTH);
gst_base_ts_mux_set_automatic_alignment (GST_BASE_TS_MUX (mux),
mux->m2ts_mode ? 32 : 0);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpeg_ts_mux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMpegTsMux *mux = GST_MPEG_TS_MUX (object);
switch (prop_id) {
case PROP_M2TS_MODE:
g_value_set_boolean (value, mux->m2ts_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpeg_ts_mux_dispose (GObject * object)
{
GstMpegTsMux *mux = GST_MPEG_TS_MUX (object);
if (mux->adapter) {
g_object_unref (mux->adapter);
@ -352,32 +367,28 @@ gst_mpegtsmux_dispose (GObject * object)
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
static gboolean
gst_mpegtsmux_drain (BaseTsMux * mux)
{
return new_packet_m2ts ((MpegTsMux *) mux, NULL, -1);
}
static void
mpegtsmux_class_init (MpegTsMuxClass * klass)
gst_mpeg_ts_mux_class_init (GstMpegTsMuxClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BaseTsMuxClass *base_tsmux_class = (BaseTsMuxClass *) klass;
GstBaseTsMuxClass *base_tsmux_class = GST_BASE_TS_MUX_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (mpegtsmux_debug, "mpegtsmux", 0,
GST_DEBUG_CATEGORY_INIT (gst_mpeg_ts_mux_debug, "mpegtsmux", 0,
"MPEG Transport Stream muxer");
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_mpegtsmux_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_mpegtsmux_get_property);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_mpegtsmux_dispose);
gobject_class->set_property =
GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_set_property);
gobject_class->get_property =
GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_get_property);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_dispose);
base_tsmux_class->allocate_packet =
GST_DEBUG_FUNCPTR (gst_mpegtsmux_allocate_packet);
GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_allocate_packet);
base_tsmux_class->output_packet =
GST_DEBUG_FUNCPTR (gst_mpegtsmux_output_packet);
base_tsmux_class->reset = GST_DEBUG_FUNCPTR (gst_mpegtsmux_reset);
base_tsmux_class->drain = GST_DEBUG_FUNCPTR (gst_mpegtsmux_drain);
GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_output_packet);
base_tsmux_class->reset = GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_reset);
base_tsmux_class->drain = GST_DEBUG_FUNCPTR (gst_mpeg_ts_mux_drain);
gst_element_class_set_static_metadata (gstelement_class,
"MPEG Transport Stream Muxer", "Codec/Muxer",
@ -385,10 +396,10 @@ mpegtsmux_class_init (MpegTsMuxClass * klass)
"Fluendo <contact@fluendo.com>");
gst_element_class_add_static_pad_template (gstelement_class,
&mpegtsmux_sink_factory);
&gst_mpeg_ts_mux_sink_factory);
gst_element_class_add_static_pad_template (gstelement_class,
&mpegtsmux_src_factory);
&gst_mpeg_ts_mux_src_factory);
g_object_class_install_property (gobject_class, PROP_M2TS_MODE,
g_param_spec_boolean ("m2ts-mode", "M2TS(192 bytes) Mode",
@ -398,7 +409,7 @@ mpegtsmux_class_init (MpegTsMuxClass * klass)
}
static void
mpegtsmux_init (MpegTsMux * mux)
gst_mpeg_ts_mux_init (GstMpegTsMux * mux)
{
mux->m2ts_mode = MPEGTSMUX_DEFAULT_M2TS;
mux->adapter = gst_adapter_new ();

View file

@ -89,19 +89,18 @@
G_BEGIN_DECLS
#include <tsmux/tsmux.h>
#include "basetsmux.h"
#include "gstbasetsmux.h"
#define GST_TYPE_MPEG_TSMUX (mpegtsmux_get_type())
#define GST_MPEG_TSMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MPEG_TSMUX, MpegTsMux))
#define GST_MPEG_TSMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_MPEG_TSMUX,MpegTsMuxClass))
#define GST_TYPE_MPEG_TS_MUX (gst_mpeg_ts_mux_get_type())
#define GST_MPEG_TS_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MPEG_TS_MUX, GstMpegTsMux))
#define GST_MPEG_TS_MUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_MPEG_TS_MUX,GstMpegTsMuxClass))
typedef struct MpegTsMux MpegTsMux;
typedef struct MpegTsMuxClass MpegTsMuxClass;
typedef struct GstMpegTsMux GstMpegTsMux;
typedef struct GstMpegTsMuxClass GstMpegTsMuxClass;
typedef struct MpegTsPadData MpegTsPadData;
struct MpegTsMux {
BaseTsMux parent;
struct GstMpegTsMux {
GstBaseTsMux parent;
/* Properties */
gboolean m2ts_mode;
@ -114,11 +113,11 @@ struct MpegTsMux {
GstAdapter *adapter;
};
struct MpegTsMuxClass {
BaseTsMuxClass parent_class;
struct GstMpegTsMuxClass {
GstBaseTsMuxClass parent_class;
};
GType mpegtsmux_get_type (void);
GType gst_mpeg_ts_mux_get_type (void);
G_END_DECLS

View file

@ -2,8 +2,8 @@
#include "config.h"
#endif
#include "mpegtsmux.h"
#include "atscmux.h"
#include "gstmpegtsmux.h"
#include "gstatscmux.h"
static gboolean
plugin_init (GstPlugin * plugin)
@ -11,11 +11,11 @@ plugin_init (GstPlugin * plugin)
gst_mpegts_initialize ();
if (!gst_element_register (plugin, "mpegtsmux", GST_RANK_PRIMARY,
mpegtsmux_get_type ()))
gst_mpeg_ts_mux_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "atscmux", GST_RANK_PRIMARY,
atscmux_get_type ()))
gst_atsc_mux_get_type ()))
return FALSE;
return TRUE;

View file

@ -1,12 +1,12 @@
tsmux_sources = [
'mpegtsmuxplugin.c',
'basetsmux.c',
'mpegtsmux.c',
'atscmux.c',
'basetsmux_aac.c',
'basetsmux_opus.c',
'basetsmux_ttxt.c',
'basetsmux_jpeg2000.c',
'gstmpegtsmuxplugin.c',
'gstbasetsmux.c',
'gstbasetsmuxaac.c',
'gstbasetsmuxopus.c',
'gstbasetsmuxttxt.c',
'gstbasetsmuxjpeg2000.c',
'gstmpegtsmux.c',
'gstatscmux.c',
'tsmux/tsmux.c',
'tsmux/tsmuxstream.c'
]

View file

@ -88,7 +88,7 @@
#include "tsmux.h"
#include "tsmuxstream.h"
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
/* Maximum total data length for a PAT section is 1024 bytes, minus an
* 8 byte header, then the length of each program entry is 32 bits,

View file

@ -182,7 +182,7 @@ tsmux_put_ts (guint8 **pos, guint8 id, gint64 ts)
tsmux_put16 (pos, ((ts << 1) & 0xfffe) | 0x01);
}
GST_DEBUG_CATEGORY_EXTERN (basetsmux_debug);
GST_DEBUG_CATEGORY_EXTERN (gst_base_ts_mux_debug);
#define TS_DEBUG GST_DEBUG
G_END_DECLS

View file

@ -89,7 +89,7 @@
#include "tsmuxcommon.h"
#include "tsmuxstream.h"
#define GST_CAT_DEFAULT basetsmux_debug
#define GST_CAT_DEFAULT gst_base_ts_mux_debug
static guint8 tsmux_stream_pes_header_length (TsMuxStream * stream);
static void tsmux_stream_write_pes_header (TsMuxStream * stream, guint8 * data);