diff options
Diffstat (limited to 'ext/mplex')
-rw-r--r-- | ext/mplex/gstmplex.cc | 232 | ||||
-rw-r--r-- | ext/mplex/gstmplexibitstream.cc | 37 | ||||
-rw-r--r-- | ext/mplex/gstmplexjob.cc | 101 | ||||
-rw-r--r-- | ext/mplex/gstmplexoutputstream.cc | 11 |
4 files changed, 171 insertions, 210 deletions
diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index 06d199bb..8f2c9385 100644 --- a/ext/mplex/gstmplex.cc +++ b/ext/mplex/gstmplex.cc @@ -28,74 +28,55 @@ #include "gstmplexibitstream.hh" #include "gstmplexjob.hh" -static GstStaticPadTemplate src_templ = -GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "video/mpeg, " - "systemstream = (boolean) true" - ) -); +static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/mpeg, " "systemstream = (boolean) true") + ); static GstStaticPadTemplate video_sink_templ = -GST_STATIC_PAD_TEMPLATE ( - "video_%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS ( - "video/mpeg, " - "mpegversion = (int) [ 1, 2 ], " - "systemstream = (boolean) false" - ) -); +GST_STATIC_PAD_TEMPLATE ("video_%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false") + ); static GstStaticPadTemplate audio_sink_templ = -GST_STATIC_PAD_TEMPLATE ( - "audio_%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS ( - "audio/mpeg, " - "mpegversion = (int) 1, " - "layer = (int) [ 1, 2 ]; " - "audio/x-ac3; " - "audio/x-dts; " - "audio/x-raw-int, " - "endianness = (int) BYTE_ORDER, " - "signed = (boolean) TRUE, " - "width = (int) { 16, 20, 24 }, " - "depth = (int) { 16, 20, 24 }, " - "rate = (int) { 48000, 96000 }, " - "channels = (int) [ 1, 6 ]" - ) -); + GST_STATIC_PAD_TEMPLATE ("audio_%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) [ 1, 2 ]; " + "audio/x-ac3; " + "audio/x-dts; " + "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) TRUE, " + "width = (int) { 16, 20, 24 }, " + "depth = (int) { 16, 20, 24 }, " + "rate = (int) { 48000, 96000 }, " "channels = (int) [ 1, 6 ]") + ); /* FIXME: subtitles */ -static void gst_mplex_base_init (GstMplexClass *klass); -static void gst_mplex_class_init (GstMplexClass *klass); -static void gst_mplex_init (GstMplex *enc); -static void gst_mplex_dispose (GObject *object); +static void gst_mplex_base_init (GstMplexClass * klass); +static void gst_mplex_class_init (GstMplexClass * klass); +static void gst_mplex_init (GstMplex * enc); +static void gst_mplex_dispose (GObject * object); -static void gst_mplex_loop (GstElement *element); +static void gst_mplex_loop (GstElement * element); -static GstPad *gst_mplex_request_new_pad (GstElement *element, - GstPadTemplate *templ, - const gchar *name); +static GstPad *gst_mplex_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * name); -static GstElementStateReturn - gst_mplex_change_state (GstElement *element); +static GstElementStateReturn gst_mplex_change_state (GstElement * element); -static void gst_mplex_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gst_mplex_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); +static void gst_mplex_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); +static void gst_mplex_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); static GstElementClass *parent_class = NULL; @@ -106,7 +87,7 @@ gst_mplex_get_type (void) if (!gst_mplex_type) { static const GTypeInfo gst_mplex_info = { - sizeof (GstMplexClass), + sizeof (GstMplexClass), (GBaseInitFunc) gst_mplex_base_init, NULL, (GClassInitFunc) gst_mplex_class_init, @@ -119,38 +100,35 @@ gst_mplex_get_type (void) gst_mplex_type = g_type_register_static (GST_TYPE_ELEMENT, - "GstMplex", - &gst_mplex_info, - (GTypeFlags) 0); + "GstMplex", &gst_mplex_info, (GTypeFlags) 0); } return gst_mplex_type; } static void -gst_mplex_base_init (GstMplexClass *klass) +gst_mplex_base_init (GstMplexClass * klass) { static GstElementDetails gst_mplex_details = { "mplex video multiplexer", "Codec/Muxer", "High-quality MPEG/DVD/SVCD/VCD video/audio multiplexer", "Andrew Stevens <andrew.stevens@nexgo.de>\n" - "Ronald Bultje <rbultje@ronald.bitfreak.net>" + "Ronald Bultje <rbultje@ronald.bitfreak.net>" }; GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_templ)); + gst_static_pad_template_get (&src_templ)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&video_sink_templ)); + gst_static_pad_template_get (&video_sink_templ)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&audio_sink_templ)); - gst_element_class_set_details (element_class, - &gst_mplex_details); + gst_static_pad_template_get (&audio_sink_templ)); + gst_element_class_set_details (element_class, &gst_mplex_details); } static void -gst_mplex_class_init (GstMplexClass *klass) +gst_mplex_class_init (GstMplexClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -171,26 +149,28 @@ gst_mplex_class_init (GstMplexClass *klass) } static void -gst_mplex_dispose (GObject *object) +gst_mplex_dispose (GObject * object) { GstMplex *mplex = GST_MPLEX (object); if (mplex->mux) { delete mplex->mux; + mplex->mux = NULL; } delete mplex->job; } static void -gst_mplex_init (GstMplex *mplex) +gst_mplex_init (GstMplex * mplex) { GstElement *element = GST_ELEMENT (mplex); GST_FLAG_SET (element, GST_ELEMENT_EVENT_AWARE); - mplex->srcpad = gst_pad_new_from_template ( - gst_element_get_pad_template (element, "src"), "src"); + mplex->srcpad = + gst_pad_new_from_template (gst_element_get_pad_template (element, "src"), + "src"); gst_element_add_pad (element, mplex->srcpad); mplex->job = new GstMplexJob (); @@ -202,7 +182,7 @@ gst_mplex_init (GstMplex *mplex) } static void -gst_mplex_loop (GstElement *element) +gst_mplex_loop (GstElement * element) { GstMplex *mplex = GST_MPLEX (element); @@ -211,7 +191,7 @@ gst_mplex_loop (GstElement *element) const GList *item; for (item = gst_element_get_pad_list (element); - item != NULL; item = item->next) { + item != NULL; item = item->next) { StreamKind type; GstMplexIBitStream *inputstream; JobStream *jobstream; @@ -222,15 +202,16 @@ gst_mplex_loop (GstElement *element) /* skip our source pad */ if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC) - continue; + continue; /* create inputstream, assure we've got caps */ inputstream = new GstMplexIBitStream (pad); /* skip unnegotiated pads */ if (!(caps = GST_PAD_CAPS (pad))) { - delete inputstream; - continue; + delete inputstream; + + continue; } /* get format */ @@ -238,40 +219,41 @@ gst_mplex_loop (GstElement *element) mime = gst_structure_get_name (structure); if (!strcmp (mime, "video/mpeg")) { - VideoParams *params; + VideoParams *params; - type = MPEG_VIDEO; + type = MPEG_VIDEO; - params = VideoParams::Default (mplex->job->mux_format); - mplex->job->video_param.push_back (params); - mplex->job->video_tracks++; + params = VideoParams::Default (mplex->job->mux_format); + mplex->job->video_param.push_back (params); + mplex->job->video_tracks++; } else if (!strcmp (mime, "audio/mpeg")) { - type = MPEG_AUDIO; - mplex->job->audio_tracks++; + type = MPEG_AUDIO; + mplex->job->audio_tracks++; } else if (!strcmp (mime, "audio/x-ac3")) { - type = AC3_AUDIO; - mplex->job->audio_tracks++; + type = AC3_AUDIO; + mplex->job->audio_tracks++; } else if (!strcmp (mime, "audio/x-dts")) { - type = DTS_AUDIO; - mplex->job->audio_tracks++; + type = DTS_AUDIO; + mplex->job->audio_tracks++; } else if (!strcmp (mime, "audio/x-raw-int")) { - LpcmParams *params; - gint bits, chans, rate; + LpcmParams *params; + gint bits, chans, rate; - type = LPCM_AUDIO; + type = LPCM_AUDIO; - /* set LPCM params */ - gst_structure_get_int (structure, "depth", &bits); - gst_structure_get_int (structure, "rate", &rate); - gst_structure_get_int (structure, "channels", &chans); - params = LpcmParams::Checked (rate, chans, bits); + /* set LPCM params */ + gst_structure_get_int (structure, "depth", &bits); + gst_structure_get_int (structure, "rate", &rate); + gst_structure_get_int (structure, "channels", &chans); + params = LpcmParams::Checked (rate, chans, bits); - mplex->job->lpcm_param.push_back (params); - mplex->job->audio_tracks++; - mplex->job->lpcm_tracks++; + mplex->job->lpcm_param.push_back (params); + mplex->job->audio_tracks++; + mplex->job->lpcm_tracks++; } else { - delete inputstream; - continue; + delete inputstream; + + continue; } jobstream = new JobStream (inputstream, type); @@ -280,7 +262,7 @@ gst_mplex_loop (GstElement *element) if (!mplex->job->video_tracks && !mplex->job->audio_tracks) { GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL), - ("no input video or audio tracks set up before loop function")); + ("no input video or audio tracks set up before loop function")); return; } @@ -293,8 +275,7 @@ gst_mplex_loop (GstElement *element) } static GstPadLinkReturn -gst_mplex_sink_link (GstPad *pad, - const GstCaps *caps) +gst_mplex_sink_link (GstPad * pad, const GstCaps * caps) { GstStructure *structure = gst_caps_get_structure (caps, 0); const gchar *mime = gst_structure_get_name (structure); @@ -318,9 +299,8 @@ gst_mplex_sink_link (GstPad *pad, } static GstPad * -gst_mplex_request_new_pad (GstElement *element, - GstPadTemplate *templ, - const gchar *name) +gst_mplex_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * name) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); GstMplex *mplex = GST_MPLEX (element); @@ -345,25 +325,21 @@ gst_mplex_request_new_pad (GstElement *element, } static void -gst_mplex_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_mplex_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GST_MPLEX (object)->job->getProperty (prop_id, value); } static void -gst_mplex_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gst_mplex_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) { GST_MPLEX (object)->job->setProperty (prop_id, value); } static GstElementStateReturn -gst_mplex_change_state (GstElement *element) +gst_mplex_change_state (GstElement * element) { GstMplex *mplex = GST_MPLEX (element); @@ -385,24 +361,16 @@ gst_mplex_change_state (GstElement *element) } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { if (!gst_library_load ("gstbytestream")) return FALSE; - return gst_element_register (plugin, "mplex", - GST_RANK_NONE, - GST_TYPE_MPLEX); + return gst_element_register (plugin, "mplex", GST_RANK_NONE, GST_TYPE_MPLEX); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "mplex", - "High-quality MPEG/DVD/SVCD/VCD video/audio multiplexer", - plugin_init, - VERSION, - "GPL", - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "mplex", + "High-quality MPEG/DVD/SVCD/VCD video/audio multiplexer", + plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN) diff --git a/ext/mplex/gstmplexibitstream.cc b/ext/mplex/gstmplexibitstream.cc index 6ed78206..612866f5 100644 --- a/ext/mplex/gstmplexibitstream.cc +++ b/ext/mplex/gstmplexibitstream.cc @@ -31,9 +31,8 @@ * Class init/exit functions. */ -GstMplexIBitStream::GstMplexIBitStream (GstPad *_pad, - guint buf_size) : - IBitStream () +GstMplexIBitStream::GstMplexIBitStream (GstPad * _pad, guint buf_size): +IBitStream () { guint8 *data; @@ -54,8 +53,7 @@ GstMplexIBitStream::GstMplexIBitStream (GstPad *_pad, if (!ReadIntoBuffer () && buffered == 0) { GST_ELEMENT_ERROR (gst_pad_get_parent (_pad), RESOURCE, READ, (NULL), - ("Failed to read from input pad %s", - gst_pad_get_name (pad))); + ("Failed to read from input pad %s", gst_pad_get_name (pad))); } } @@ -68,28 +66,30 @@ GstMplexIBitStream::~GstMplexIBitStream (void) * Read data. */ -size_t -GstMplexIBitStream::ReadStreamBytes (uint8_t *buf, - size_t size) +size_t GstMplexIBitStream::ReadStreamBytes (uint8_t * buf, size_t size) { - guint8 *data; - guint read; + guint8 * + data; + guint + read; if (eos) return 0; if ((read = gst_bytestream_peek_bytes (bs, &data, size)) != size) { - GstEvent *event; - guint pending; + GstEvent * + event; + guint + pending; gst_bytestream_get_status (bs, &pending, &event); if (event) { switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS: - eos = TRUE; - break; - default: - break; + case GST_EVENT_EOS: + eos = TRUE; + break; + default: + break; } gst_event_unref (event); } @@ -105,8 +105,7 @@ GstMplexIBitStream::ReadStreamBytes (uint8_t *buf, * Are we at EOS? */ -bool -GstMplexIBitStream::EndOfStream (void) +bool GstMplexIBitStream::EndOfStream (void) { return eos; } diff --git a/ext/mplex/gstmplexjob.cc b/ext/mplex/gstmplexjob.cc index 09ebe53f..8ff23bda 100644 --- a/ext/mplex/gstmplexjob.cc +++ b/ext/mplex/gstmplexjob.cc @@ -26,7 +26,8 @@ #include "gstmplexjob.hh" -enum { +enum +{ ARG_0, ARG_FORMAT, ARG_MUX_BITRATE, @@ -36,7 +37,7 @@ enum { ARG_SEGMENT_SIZE, ARG_PACKETS_PER_PACK, ARG_SECTOR_SIZE - /* FILL ME */ + /* FILL ME */ }; /* @@ -53,22 +54,21 @@ gst_mplex_format_get_type (void) if (!mplex_format_type) { static const GEnumValue mplex_formats[] = { - { 0, "0", "Generic MPEG-1" }, - { 1, "1", "Standard VCD" }, - { 2, "2", "User VCD" }, - { 3, "3", "Generic MPEG-2" }, - { 4, "4", "Standard SVCD" }, - { 5, "5", "User SVCD" }, - { 6, "6", "VCD Stills sequences" }, - { 7, "7", "SVCD Stills sequences" }, - { 8, "8", "DVD MPEG-2 for dvdauthor" }, - { 9, "9", "DVD MPEG-2" }, - { 0, NULL, NULL }, + {0, "0", "Generic MPEG-1"}, + {1, "1", "Standard VCD"}, + {2, "2", "User VCD"}, + {3, "3", "Generic MPEG-2"}, + {4, "4", "Standard SVCD"}, + {5, "5", "User SVCD"}, + {6, "6", "VCD Stills sequences"}, + {7, "7", "SVCD Stills sequences"}, + {8, "8", "DVD MPEG-2 for dvdauthor"}, + {9, "9", "DVD MPEG-2"}, + {0, NULL, NULL}, }; mplex_format_type = - g_enum_register_static ("GstMplexFormat", - mplex_formats); + g_enum_register_static ("GstMplexFormat", mplex_formats); } return mplex_format_type; @@ -78,8 +78,8 @@ gst_mplex_format_get_type (void) * Class init functions. */ -GstMplexJob::GstMplexJob (void) : - MultiplexJob () +GstMplexJob::GstMplexJob (void): +MultiplexJob () { /* blabla */ } @@ -89,58 +89,57 @@ GstMplexJob::GstMplexJob (void) : */ void -GstMplexJob::initProperties (GObjectClass *klass) +GstMplexJob::initProperties (GObjectClass * klass) { /* encoding profile */ g_object_class_install_property (klass, ARG_FORMAT, - g_param_spec_enum ("format", "Format", "Encoding profile format", - GST_TYPE_MPLEX_FORMAT, 0, - (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_enum ("format", "Format", "Encoding profile format", + GST_TYPE_MPLEX_FORMAT, 0, (GParamFlags) G_PARAM_READWRITE)); /* total stream datarate. Normally, this shouldn't be needed, but * some DVD/VCD/SVCD players really need strict values to handle * the created files correctly. */ g_object_class_install_property (klass, ARG_MUX_BITRATE, - g_param_spec_int ("mux-bitrate", "Mux. bitrate", - "Bitrate of output stream in kbps (0 = autodetect)", - 0, 15 * 1024, 0, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_int ("mux-bitrate", "Mux. bitrate", + "Bitrate of output stream in kbps (0 = autodetect)", + 0, 15 * 1024, 0, (GParamFlags) G_PARAM_READWRITE)); #if 0 - { "video-buffer", 1, 0, 'b' }, + { + "video-buffer", 1, 0, 'b'}, #endif - - /* some boolean stuff for headers */ - g_object_class_install_property (klass, ARG_VBR, - g_param_spec_boolean ("vbr", "VBR", - "Whether the input video stream is variable bitrate", - FALSE, (GParamFlags) G_PARAM_READWRITE)); + /* some boolean stuff for headers */ + g_object_class_install_property (klass, ARG_VBR, + g_param_spec_boolean ("vbr", "VBR", + "Whether the input video stream is variable bitrate", + FALSE, (GParamFlags) G_PARAM_READWRITE)); g_object_class_install_property (klass, ARG_SYSTEM_HEADERS, - g_param_spec_boolean ("system-headers", "System headers", - "Create system header in every pack for generic formats", - FALSE, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_boolean ("system-headers", "System headers", + "Create system header in every pack for generic formats", + FALSE, (GParamFlags) G_PARAM_READWRITE)); g_object_class_install_property (klass, ARG_SPLIT_SEQUENCE, - g_param_spec_boolean ("split-sequence", "Split sequence", - "Simply split a sequence across files " - "(rather than building run-out/run-in)", - FALSE, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_boolean ("split-sequence", "Split sequence", + "Simply split a sequence across files " + "(rather than building run-out/run-in)", + FALSE, (GParamFlags) G_PARAM_READWRITE)); /* size of a segment (followed by EOS) */ g_object_class_install_property (klass, ARG_SEGMENT_SIZE, - g_param_spec_int ("max-segment-size", "Max. segment size", - "Max. size per segment/file in MB (0 = unlimited)", - 0, 10 * 1024, 0, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_int ("max-segment-size", "Max. segment size", + "Max. size per segment/file in MB (0 = unlimited)", + 0, 10 * 1024, 0, (GParamFlags) G_PARAM_READWRITE)); /* packets per pack (generic formats) */ g_object_class_install_property (klass, ARG_PACKETS_PER_PACK, - g_param_spec_int ("packets-per-pack", "Packets per pack", - "Number of packets per pack for generic formats", - 1, 100, 1, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_int ("packets-per-pack", "Packets per pack", + "Number of packets per pack for generic formats", + 1, 100, 1, (GParamFlags) G_PARAM_READWRITE)); /* size of one sector */ g_object_class_install_property (klass, ARG_SECTOR_SIZE, - g_param_spec_int ("sector-size", "Sector size", - "Specify sector size in bytes for generic formats", - 256, 16384, 2048, (GParamFlags) G_PARAM_READWRITE)); + g_param_spec_int ("sector-size", "Sector size", + "Specify sector size in bytes for generic formats", + 256, 16384, 2048, (GParamFlags) G_PARAM_READWRITE)); } /* @@ -148,8 +147,7 @@ GstMplexJob::initProperties (GObjectClass *klass) */ void -GstMplexJob::getProperty (guint prop_id, - GValue *value) +GstMplexJob::getProperty (guint prop_id, GValue * value) { switch (prop_id) { case ARG_FORMAT: @@ -182,8 +180,7 @@ GstMplexJob::getProperty (guint prop_id, } void -GstMplexJob::setProperty (guint prop_id, - const GValue *value) +GstMplexJob::setProperty (guint prop_id, const GValue * value) { switch (prop_id) { case ARG_FORMAT: @@ -193,7 +190,7 @@ GstMplexJob::setProperty (guint prop_id, /* data_rate expects bytes (don't ask me why the property itself is * in bits, I'm just staying compatible to mjpegtools options), and * rounded up to 50-bytes. */ - data_rate = ((g_value_get_int (value) * 1000 / 8 + 49) / 50 ) * 50; + data_rate = ((g_value_get_int (value) * 1000 / 8 + 49) / 50) * 50; break; case ARG_VBR: VBR = g_value_get_boolean (value); diff --git a/ext/mplex/gstmplexoutputstream.cc b/ext/mplex/gstmplexoutputstream.cc index c0a2976d..206c13ec 100644 --- a/ext/mplex/gstmplexoutputstream.cc +++ b/ext/mplex/gstmplexoutputstream.cc @@ -31,9 +31,8 @@ * Class init functions. */ -GstMplexOutputStream::GstMplexOutputStream (GstElement *_element, - GstPad *_pad) : - OutputStream () +GstMplexOutputStream::GstMplexOutputStream (GstElement * _element, GstPad * _pad): +OutputStream () { element = _element; pad = _pad; @@ -63,8 +62,7 @@ GstMplexOutputStream::Close (void) * Get size of current segment. */ -off_t -GstMplexOutputStream::SegmentSize (void) +off_t GstMplexOutputStream::SegmentSize (void) { return size; } @@ -88,8 +86,7 @@ GstMplexOutputStream::NextSegment (void) */ void -GstMplexOutputStream::Write (guint8 *data, - guint len) +GstMplexOutputStream::Write (guint8 * data, guint len) { GstBuffer *buf; |