summaryrefslogtreecommitdiffstats
path: root/gst/avi/gstavimux.c
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
commit5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch)
tree74a5b1eaf3a324b520e64e87404fd0b3018a7829 /gst/avi/gstavimux.c
parent1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff)
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'gst/avi/gstavimux.c')
-rw-r--r--gst/avi/gstavimux.c1241
1 files changed, 639 insertions, 602 deletions
diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c
index a064378f..f5287db0 100644
--- a/gst/avi/gstavimux.c
+++ b/gst/avi/gstavimux.c
@@ -45,138 +45,126 @@
#endif
/* AviMux signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_BIGFILE,
};
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-msvideo")
-);
-
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-msvideo")
+ );
+
static GstStaticPadTemplate video_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "video_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (
- "video/x-raw-yuv, "
- "format = (fourcc) { YUY2, I420 }, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]; "
- "video/x-jpeg, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]; "
- "video/x-divx, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "divxversion = (int) [ 3, 5 ]; "
- "video/x-xvid, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]; "
- "video/x-3ivx, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]; "
- "video/x-msmpeg, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "msmpegversion = (int) [ 41, 43 ]; "
- "video/mpeg, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "mpegversion = (int) 1, "
- "systemstream = (boolean) FALSE; "
- "video/x-h263, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]; "
- "video/x-dv, "
- "width = (int) 720, "
- "height = (int) { 576, 480 }, "
- "systemstream = (boolean) FALSE; "
- "video/x-huffyuv, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ]"
- )
-);
-
+ GST_STATIC_PAD_TEMPLATE ("video_%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS ("video/x-raw-yuv, "
+ "format = (fourcc) { YUY2, I420 }, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ]; "
+ "video/x-jpeg, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ]; "
+ "video/x-divx, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "divxversion = (int) [ 3, 5 ]; "
+ "video/x-xvid, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ]; "
+ "video/x-3ivx, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ]; "
+ "video/x-msmpeg, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "msmpegversion = (int) [ 41, 43 ]; "
+ "video/mpeg, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "mpegversion = (int) 1, "
+ "systemstream = (boolean) FALSE; "
+ "video/x-h263, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ]; "
+ "video/x-dv, "
+ "width = (int) 720, "
+ "height = (int) { 576, 480 }, "
+ "systemstream = (boolean) FALSE; "
+ "video/x-huffyuv, "
+ "width = (int) [ 16, 4096 ], " "height = (int) [ 16, 4096 ]")
+ );
+
static GstStaticPadTemplate audio_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "audio_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) LITTLE_ENDIAN, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 3 ], "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-vorbis, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-ac3, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-
-static void gst_avimux_base_init (gpointer g_class);
-static void gst_avimux_class_init (GstAviMuxClass *klass);
-static void gst_avimux_init (GstAviMux *avimux);
-
-static void gst_avimux_loop (GstElement *element);
-static gboolean gst_avimux_handle_event (GstPad *pad,
- GstEvent *event);
-static GstPad* gst_avimux_request_new_pad (GstElement *element,
- GstPadTemplate *templ,
- const gchar *name);
-static void gst_avimux_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_avimux_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn gst_avimux_change_state (GstElement *element);
+ GST_STATIC_PAD_TEMPLATE ("audio_%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) LITTLE_ENDIAN, "
+ "signed = (boolean) { TRUE, FALSE }, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "rate = (int) [ 1000, 96000 ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/mpeg, "
+ "mpegversion = (int) 1, "
+ "layer = (int) [ 1, 3 ], "
+ "rate = (int) [ 1000, 96000 ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-vorbis, "
+ "rate = (int) [ 1000, 96000 ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-ac3, "
+ "rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+static void gst_avimux_base_init (gpointer g_class);
+static void gst_avimux_class_init (GstAviMuxClass * klass);
+static void gst_avimux_init (GstAviMux * avimux);
+
+static void gst_avimux_loop (GstElement * element);
+static gboolean gst_avimux_handle_event (GstPad * pad, GstEvent * event);
+static GstPad *gst_avimux_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
+static void gst_avimux_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_avimux_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_avimux_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_avimux_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_avimux_get_type (void)
+gst_avimux_get_type (void)
{
static GType avimux_type = 0;
if (!avimux_type) {
static const GTypeInfo avimux_info = {
- sizeof(GstAviMuxClass),
+ sizeof (GstAviMuxClass),
gst_avimux_base_init,
NULL,
- (GClassInitFunc)gst_avimux_class_init,
+ (GClassInitFunc) gst_avimux_class_init,
NULL,
NULL,
- sizeof(GstAviMux),
+ sizeof (GstAviMux),
0,
- (GInstanceInitFunc)gst_avimux_init,
+ (GInstanceInitFunc) gst_avimux_init,
};
- avimux_type = g_type_register_static(GST_TYPE_ELEMENT, "GstAviMux", &avimux_info, 0);
+ avimux_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAviMux", &avimux_info, 0);
}
return avimux_type;
}
@@ -185,12 +173,11 @@ static void
gst_avimux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- static GstElementDetails gst_avimux_details = GST_ELEMENT_DETAILS (
- "Avi multiplexer",
- "Codec/Muxer",
- "Muxes audio and video into an avi stream",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
- );
+ static GstElementDetails gst_avimux_details =
+ GST_ELEMENT_DETAILS ("Avi multiplexer",
+ "Codec/Muxer",
+ "Muxes audio and video into an avi stream",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
@@ -203,20 +190,19 @@ gst_avimux_base_init (gpointer g_class)
}
static void
-gst_avimux_class_init (GstAviMuxClass *klass)
+gst_avimux_class_init (GstAviMuxClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BIGFILE,
- g_param_spec_boolean("bigfile","Bigfile Support",
- "Support for openDML-2.0 (big) AVI files",
- 0,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIGFILE,
+ g_param_spec_boolean ("bigfile", "Bigfile Support",
+ "Support for openDML-2.0 (big) AVI files", 0, G_PARAM_READWRITE));
gstelement_class->request_new_pad = gst_avimux_request_new_pad;
@@ -227,26 +213,27 @@ gst_avimux_class_init (GstAviMuxClass *klass)
}
static const GstEventMask *
-gst_avimux_get_event_masks (GstPad *pad)
+gst_avimux_get_event_masks (GstPad * pad)
{
static const GstEventMask gst_avimux_sink_event_masks[] = {
- { GST_EVENT_EOS, 0 },
- { 0, }
+ {GST_EVENT_EOS, 0},
+ {0,}
};
return gst_avimux_sink_event_masks;
}
-static void
-gst_avimux_init (GstAviMux *avimux)
+static void
+gst_avimux_init (GstAviMux * avimux)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (avimux);
- avimux->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
+ avimux->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
gst_element_add_pad (GST_ELEMENT (avimux), avimux->srcpad);
- GST_FLAG_SET (GST_ELEMENT(avimux), GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (GST_ELEMENT (avimux), GST_ELEMENT_EVENT_AWARE);
avimux->audiosinkpad = NULL;
avimux->audio_pad_connected = FALSE;
@@ -259,15 +246,15 @@ gst_avimux_init (GstAviMux *avimux)
avimux->num_frames = 0;
/* audio/video/AVI header initialisation */
- memset(&(avimux->avi_hdr),0,sizeof(gst_riff_avih));
- memset(&(avimux->vids_hdr),0,sizeof(gst_riff_strh));
- memset(&(avimux->vids),0,sizeof(gst_riff_strf_vids));
- memset(&(avimux->auds_hdr),0,sizeof(gst_riff_strh));
- memset(&(avimux->auds),0,sizeof(gst_riff_strf_auds));
- avimux->vids_hdr.type = GST_MAKE_FOURCC('v','i','d','s');
+ memset (&(avimux->avi_hdr), 0, sizeof (gst_riff_avih));
+ memset (&(avimux->vids_hdr), 0, sizeof (gst_riff_strh));
+ memset (&(avimux->vids), 0, sizeof (gst_riff_strf_vids));
+ memset (&(avimux->auds_hdr), 0, sizeof (gst_riff_strh));
+ memset (&(avimux->auds), 0, sizeof (gst_riff_strf_auds));
+ avimux->vids_hdr.type = GST_MAKE_FOURCC ('v', 'i', 'd', 's');
avimux->vids_hdr.rate = 1000000;
avimux->avi_hdr.max_bps = 10000000;
- avimux->auds_hdr.type = GST_MAKE_FOURCC('a','u','d','s');
+ avimux->auds_hdr.type = GST_MAKE_FOURCC ('a', 'u', 'd', 's');
avimux->vids_hdr.quality = 0xFFFFFFFF;
avimux->auds_hdr.quality = 0xFFFFFFFF;
@@ -277,33 +264,34 @@ gst_avimux_init (GstAviMux *avimux)
avimux->enable_large_avi = TRUE;
- gst_element_set_loop_function(GST_ELEMENT(avimux), gst_avimux_loop);
+ gst_element_set_loop_function (GST_ELEMENT (avimux), gst_avimux_loop);
}
static GstPadLinkReturn
-gst_avimux_vidsinkconnect (GstPad *pad, const GstCaps *vscaps)
+gst_avimux_vidsinkconnect (GstPad * pad, const GstCaps * vscaps)
{
GstAviMux *avimux;
GstStructure *structure;
- const gchar* mimetype;
+ const gchar *mimetype;
gdouble fps = 0.;
gboolean ret;
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
GST_DEBUG ("avimux: video sinkconnect triggered on %s",
- gst_pad_get_name (pad));
+ gst_pad_get_name (pad));
structure = gst_caps_get_structure (vscaps, 0);
mimetype = gst_structure_get_name (structure);
/* global */
- avimux->vids.size = sizeof(gst_riff_strf_vids);
- avimux->vids.planes = 1;
+ avimux->vids.size = sizeof (gst_riff_strf_vids);
+ avimux->vids.planes = 1;
ret = gst_structure_get_int (structure, "width", &avimux->vids.width);
ret &= gst_structure_get_int (structure, "height", &avimux->vids.height);
ret &= gst_structure_get_double (structure, "framerate", &fps);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
if (fps != 0.)
avimux->vids_hdr.scale = avimux->vids_hdr.rate / fps;
@@ -313,13 +301,12 @@ gst_avimux_vidsinkconnect (GstPad *pad, const GstCaps *vscaps)
gst_structure_get_fourcc (structure, "format", &format);
avimux->vids.compression = format;
- switch (format)
- {
- case GST_MAKE_FOURCC('Y','U','Y','2'):
- avimux->vids.bit_cnt = 16;
+ switch (format) {
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ avimux->vids.bit_cnt = 16;
break;
- case GST_MAKE_FOURCC('I','4','2','0'):
- avimux->vids.bit_cnt = 12;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ avimux->vids.bit_cnt = 12;
break;
}
} else {
@@ -328,47 +315,49 @@ gst_avimux_vidsinkconnect (GstPad *pad, const GstCaps *vscaps)
/* find format */
if (!strcmp (mimetype, "video/x-huffyuv")) {
- avimux->vids.compression = GST_MAKE_FOURCC('H','F','Y','U');
+ avimux->vids.compression = GST_MAKE_FOURCC ('H', 'F', 'Y', 'U');
} else if (!strcmp (mimetype, "video/x-jpeg")) {
- avimux->vids.compression = GST_MAKE_FOURCC('M','J','P','G');
+ avimux->vids.compression = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
} else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion;
+
gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
case 3:
- avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','3');
+ avimux->vids.compression = GST_MAKE_FOURCC ('D', 'I', 'V', '3');
break;
case 4:
- avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','X');
+ avimux->vids.compression = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
break;
case 5:
- avimux->vids.compression = GST_MAKE_FOURCC('D','X','5','0');
- break;
+ avimux->vids.compression = GST_MAKE_FOURCC ('D', 'X', '5', '0');
+ break;
}
} else if (!strcmp (mimetype, "video/x-xvid")) {
- avimux->vids.compression = GST_MAKE_FOURCC('X','V','I','D');
+ avimux->vids.compression = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
} else if (!strcmp (mimetype, "video/x-3ivx")) {
- avimux->vids.compression = GST_MAKE_FOURCC('3','I','V','2');
+ avimux->vids.compression = GST_MAKE_FOURCC ('3', 'I', 'V', '2');
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
gint msmpegversion;
+
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
- avimux->vids.compression = GST_MAKE_FOURCC('M','P','G','4');
+ avimux->vids.compression = GST_MAKE_FOURCC ('M', 'P', 'G', '4');
break;
case 42:
- avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','2');
+ avimux->vids.compression = GST_MAKE_FOURCC ('M', 'P', '4', '2');
break;
case 43:
- avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','3');
+ avimux->vids.compression = GST_MAKE_FOURCC ('M', 'P', '4', '3');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
- avimux->vids.compression = GST_MAKE_FOURCC('D','V','S','D');
+ avimux->vids.compression = GST_MAKE_FOURCC ('D', 'V', 'S', 'D');
} else if (!strcmp (mimetype, "video/x-h263")) {
- avimux->vids.compression = GST_MAKE_FOURCC('H','2','6','3');
+ avimux->vids.compression = GST_MAKE_FOURCC ('H', '2', '6', '3');
} else if (!strcmp (mimetype, "video/mpeg")) {
- avimux->vids.compression = GST_MAKE_FOURCC('M','P','E','G');
+ avimux->vids.compression = GST_MAKE_FOURCC ('M', 'P', 'E', 'G');
}
if (!avimux->vids.compression) {
@@ -385,17 +374,17 @@ gst_avimux_vidsinkconnect (GstPad *pad, const GstCaps *vscaps)
}
static GstPadLinkReturn
-gst_avimux_audsinkconnect (GstPad *pad, const GstCaps *vscaps)
+gst_avimux_audsinkconnect (GstPad * pad, const GstCaps * vscaps)
{
GstAviMux *avimux;
GstStructure *structure;
- const gchar* mimetype;
+ const gchar *mimetype;
int i;
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
GST_DEBUG ("avimux: audio sinkconnect triggered on %s",
- gst_pad_get_name (pad));
+ gst_pad_get_name (pad));
structure = gst_caps_get_structure (vscaps, 0);
mimetype = gst_structure_get_name (structure);
@@ -407,7 +396,7 @@ gst_avimux_audsinkconnect (GstPad *pad, const GstCaps *vscaps)
avimux->auds.rate = i;
if (!strcmp (mimetype, "audio/x-raw-int")) {
- avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
+ avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
gst_structure_get_int (structure, "width", &i);
avimux->auds.blockalign = i;
@@ -419,18 +408,20 @@ gst_avimux_audsinkconnect (GstPad *pad, const GstCaps *vscaps)
avimux->auds.blockalign *= avimux->auds.channels;
avimux->auds.av_bps = avimux->auds.blockalign * avimux->auds.rate;
} else if (!strcmp (mimetype, "audio/mpeg") ||
- !strcmp (mimetype, "audio/x-vorbis") ||
- !strcmp (mimetype, "audio/x-ac3")) {
+ !strcmp (mimetype, "audio/x-vorbis") ||
+ !strcmp (mimetype, "audio/x-ac3")) {
avimux->auds.format = 0;
if (!strcmp (mimetype, "audio/mpeg")) {
gint layer = 3;
+
gst_structure_get_int (structure, "layer", &layer);
switch (layer) {
case 3:
avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL3;
break;
- case 1: case 2:
+ case 1:
+ case 2:
avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL12;
break;
}
@@ -449,31 +440,24 @@ gst_avimux_audsinkconnect (GstPad *pad, const GstCaps *vscaps)
}
}
- avimux->auds_hdr.rate = avimux->auds.blockalign * avimux->auds.rate;
+ avimux->auds_hdr.rate = avimux->auds.blockalign * avimux->auds.rate;
avimux->auds_hdr.samplesize = avimux->auds.blockalign;
avimux->auds_hdr.scale = avimux->auds.blockalign;
return GST_PAD_LINK_OK;
}
static void
-gst_avimux_pad_link (GstPad *pad,
- GstPad *peer,
- gpointer data)
+gst_avimux_pad_link (GstPad * pad, GstPad * peer, gpointer data)
{
- GstAviMux *avimux = GST_AVIMUX(data);
+ GstAviMux *avimux = GST_AVIMUX (data);
const gchar *padname = gst_pad_get_name (pad);
- if (pad == avimux->audiosinkpad)
- {
+ if (pad == avimux->audiosinkpad) {
avimux->audio_pad_connected = TRUE;
- }
- else if (pad == avimux->videosinkpad)
- {
+ } else if (pad == avimux->videosinkpad) {
avimux->video_pad_connected = TRUE;
- }
- else
- {
- g_warning("Unknown padname '%s'", padname);
+ } else {
+ g_warning ("Unknown padname '%s'", padname);
return;
}
@@ -481,36 +465,28 @@ gst_avimux_pad_link (GstPad *pad,
}
static void
-gst_avimux_pad_unlink (GstPad *pad,
- GstPad *peer,
- gpointer data)
+gst_avimux_pad_unlink (GstPad * pad, GstPad * peer, gpointer data)
{
- GstAviMux *avimux = GST_AVIMUX(data);
+ GstAviMux *avimux = GST_AVIMUX (data);
const gchar *padname = gst_pad_get_name (pad);
- if (pad == avimux->audiosinkpad)
- {
+ if (pad == avimux->audiosinkpad) {
avimux->audio_pad_connected = FALSE;
avimux->audiosinkpad = NULL;
- }
- else if (pad == avimux->videosinkpad)
- {
+ } else if (pad == avimux->videosinkpad) {
avimux->video_pad_connected = FALSE;
avimux->videosinkpad = NULL;
- }
- else
- {
- g_warning("Unknown padname '%s'", padname);
+ } else {
+ g_warning ("Unknown padname '%s'", padname);
return;
}
GST_DEBUG ("pad '%s' unlinked", padname);
}
-static GstPad*
-gst_avimux_request_new_pad (GstElement *element,
- GstPadTemplate *templ,
- const gchar *req_name)
+static GstPad *
+gst_avimux_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * req_name)
{
GstAviMux *avimux;
GstPad *newpad;
@@ -528,29 +504,27 @@ gst_avimux_request_new_pad (GstElement *element,
avimux = GST_AVIMUX (element);
if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
- g_return_val_if_fail(avimux->audiosinkpad == NULL, NULL);
+ g_return_val_if_fail (avimux->audiosinkpad == NULL, NULL);
newpad = gst_pad_new_from_template (templ, "audio_00");
gst_pad_set_link_function (newpad, gst_avimux_audsinkconnect);
avimux->audiosinkpad = newpad;
- }
- else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
- g_return_val_if_fail(avimux->videosinkpad == NULL, NULL);
+ } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
+ g_return_val_if_fail (avimux->videosinkpad == NULL, NULL);
newpad = gst_pad_new_from_template (templ, "video_00");
gst_pad_set_link_function (newpad, gst_avimux_vidsinkconnect);
avimux->videosinkpad = newpad;
- }
- else {
+ } else {
g_warning ("avimux: this is not our template!\n");
return NULL;
}
- g_signal_connect(newpad, "linked",
- G_CALLBACK(gst_avimux_pad_link), (gpointer)avimux);
- g_signal_connect(newpad, "unlinked",
- G_CALLBACK(gst_avimux_pad_unlink), (gpointer)avimux);
+ g_signal_connect (newpad, "linked",
+ G_CALLBACK (gst_avimux_pad_link), (gpointer) avimux);
+ g_signal_connect (newpad, "unlinked",
+ G_CALLBACK (gst_avimux_pad_unlink), (gpointer) avimux);
gst_element_add_pad (element, newpad);
- gst_pad_set_event_mask_function(newpad, gst_avimux_get_event_masks);
-
+ gst_pad_set_event_mask_function (newpad, gst_avimux_get_event_masks);
+
return newpad;
}
@@ -559,215 +533,301 @@ gst_avimux_request_new_pad (GstElement *element,
/* DISCLAIMER: this function is ugly. So be it (i.e. it makes the rest easier) */
static GstBuffer *
-gst_avimux_riff_get_avi_header (GstAviMux *avimux)
+gst_avimux_riff_get_avi_header (GstAviMux * avimux)
{
GstBuffer *buffer;
guint8 *buffdata;
guint16 temp16;
guint32 temp32;
- buffer = gst_buffer_new();
+ buffer = gst_buffer_new ();
/* first, let's see what actually needs to be in the buffer */
- GST_BUFFER_SIZE(buffer) = 0;
- GST_BUFFER_SIZE(buffer) += 32 + sizeof(gst_riff_avih); /* avi header */
- if (avimux->video_pad_connected)
- { /* we have video */
- GST_BUFFER_SIZE(buffer) += 28 + sizeof(gst_riff_strh) + sizeof(gst_riff_strf_vids); /* vid hdr */
- GST_BUFFER_SIZE(buffer) += 24; /* odml header */
+ GST_BUFFER_SIZE (buffer) = 0;
+ GST_BUFFER_SIZE (buffer) += 32 + sizeof (gst_riff_avih); /* avi header */
+ if (avimux->video_pad_connected) { /* we have video */
+ GST_BUFFER_SIZE (buffer) += 28 + sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids); /* vid hdr */
+ GST_BUFFER_SIZE (buffer) += 24; /* odml header */
}
- if (avimux->audio_pad_connected)
- { /* we have audio */
- GST_BUFFER_SIZE(buffer) += 28 + sizeof(gst_riff_strh) + sizeof(gst_riff_strf_auds); /* aud hdr */
+ if (avimux->audio_pad_connected) { /* we have audio */
+ GST_BUFFER_SIZE (buffer) += 28 + sizeof (gst_riff_strh) + sizeof (gst_riff_strf_auds); /* aud hdr */
}
/* this is the "riff size" */
- avimux->header_size = GST_BUFFER_SIZE(buffer);
- GST_BUFFER_SIZE(buffer) += 12; /* avi data header */
+ avimux->header_size = GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_SIZE (buffer) += 12; /* avi data header */
/* allocate the buffer */
- buffdata = GST_BUFFER_DATA(buffer) = g_malloc(GST_BUFFER_SIZE(buffer));
+ buffdata = GST_BUFFER_DATA (buffer) = g_malloc (GST_BUFFER_SIZE (buffer));
/* avi header metadata */
- memcpy(buffdata, "RIFF", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->header_size + avimux->idx_size + avimux->data_size);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "AVI ", 4); buffdata += 4;
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->header_size - 4*5);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "hdrl", 4); buffdata += 4;
- memcpy(buffdata, "avih", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_avih));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "RIFF", 4);
+ buffdata += 4;
+ temp32 =
+ LE_FROM_GUINT32 (avimux->header_size + avimux->idx_size +
+ avimux->data_size);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "AVI ", 4);
+ buffdata += 4;
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->header_size - 4 * 5);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "hdrl", 4);
+ buffdata += 4;
+ memcpy (buffdata, "avih", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (gst_riff_avih));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the AVI header itself */
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.us_frame);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.max_bps);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.pad_gran);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.flags);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.tot_frames);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.init_frames);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.streams);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.bufsize);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.width);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.height);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.scale);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.rate);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.start);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->avi_hdr.length);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
-
- if (avimux->video_pad_connected)
- {
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.us_frame);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.max_bps);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.pad_gran);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.flags);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.tot_frames);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.init_frames);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.streams);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.bufsize);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.width);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.height);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.scale);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.rate);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.start);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->avi_hdr.length);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+
+ if (avimux->video_pad_connected) {
/* video header metadata */
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strh) + sizeof(gst_riff_strf_vids) + 4*5);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "strl", 4); buffdata += 4;
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 =
+ LE_FROM_GUINT32 (sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids) +
+ 4 * 5);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "strl", 4);
+ buffdata += 4;
/* generic header */
- memcpy(buffdata, "strh", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strh));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "strh", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (gst_riff_strh));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the actual header */
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.type);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.fcc_handler);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.flags);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.priority);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.init_frames);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.scale);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.rate);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.start);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.length);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.bufsize);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.quality);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids_hdr.samplesize);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.type);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.fcc_handler);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.flags);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.priority);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.init_frames);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.scale);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.rate);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.start);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.length);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.bufsize);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.quality);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids_hdr.samplesize);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the video header */
- memcpy(buffdata, "strf", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strf_vids));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "strf", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (gst_riff_strf_vids));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the actual header */
- temp32 = LE_FROM_GUINT32(avimux->vids.size);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.width);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.height);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp16 = LE_FROM_GUINT16(avimux->vids.planes);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
- temp16 = LE_FROM_GUINT16(avimux->vids.bit_cnt);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
- temp32 = LE_FROM_GUINT32(avimux->vids.compression);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.image_size);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.xpels_meter);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.ypels_meter);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.num_colors);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->vids.imp_colors);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.size);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.width);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.height);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp16 = LE_FROM_GUINT16 (avimux->vids.planes);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
+ temp16 = LE_FROM_GUINT16 (avimux->vids.bit_cnt);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.compression);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.image_size);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.xpels_meter);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.ypels_meter);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.num_colors);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->vids.imp_colors);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
}
- if (avimux->audio_pad_connected)
- {
+ if (avimux->audio_pad_connected) {
/* audio header */
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strh) + sizeof(gst_riff_strf_auds) + 4*5);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "strl", 4); buffdata += 4;
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 =
+ LE_FROM_GUINT32 (sizeof (gst_riff_strh) + sizeof (gst_riff_strf_auds) +
+ 4 * 5);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "strl", 4);
+ buffdata += 4;
/* generic header */
- memcpy(buffdata, "strh", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strh));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "strh", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (gst_riff_strh));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the actual header */
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.type);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.fcc_handler);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.flags);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.priority);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.init_frames);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.scale);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.rate);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.start);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.length);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.bufsize);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.quality);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds_hdr.samplesize);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.type);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.fcc_handler);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.flags);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.priority);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.init_frames);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.scale);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.rate);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.start);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.length);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.bufsize);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.quality);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds_hdr.samplesize);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the audio header */
- memcpy(buffdata, "strf", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(gst_riff_strf_auds));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "strf", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (gst_riff_strf_auds));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
/* the actual header */
- temp16 = LE_FROM_GUINT16(avimux->auds.format);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
- temp16 = LE_FROM_GUINT16(avimux->auds.channels);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
- temp32 = LE_FROM_GUINT32(avimux->auds.rate);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->auds.av_bps);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp16 = LE_FROM_GUINT16(avimux->auds.blockalign);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
- temp16 = LE_FROM_GUINT16(avimux->auds.size);
- memcpy(buffdata, &temp16, 2); buffdata += 2;
+ temp16 = LE_FROM_GUINT16 (avimux->auds.format);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
+ temp16 = LE_FROM_GUINT16 (avimux->auds.channels);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
+ temp32 = LE_FROM_GUINT32 (avimux->auds.rate);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->auds.av_bps);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp16 = LE_FROM_GUINT16 (avimux->auds.blockalign);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
+ temp16 = LE_FROM_GUINT16 (avimux->auds.size);
+ memcpy (buffdata, &temp16, 2);
+ buffdata += 2;
}
- if (avimux->video_pad_connected)
- {
+ if (avimux->video_pad_connected) {
/* odml header */
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(guint32)+4*3);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "odml", 4); buffdata += 4;
- memcpy(buffdata, "dmlh", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(sizeof(guint32));
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->total_frames);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (guint32) + 4 * 3);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "odml", 4);
+ buffdata += 4;
+ memcpy (buffdata, "dmlh", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (sizeof (guint32));
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->total_frames);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
}
/* avi data header */
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(avimux->data_size);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "movi", 4);
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (avimux->data_size);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "movi", 4);
return buffer;
}
@@ -779,18 +839,23 @@ gst_avimux_riff_get_avix_header (guint32 datax_size)
guint8 *buffdata;
guint32 temp32;
- buffer = gst_buffer_new();
- GST_BUFFER_SIZE(buffer) = 24;
- buffdata = GST_BUFFER_DATA(buffer) = g_malloc(GST_BUFFER_SIZE(buffer));
-
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(datax_size+4*4);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "AVIX", 4); buffdata += 4;
- memcpy(buffdata, "LIST", 4); buffdata += 4;
- temp32 = LE_FROM_GUINT32(datax_size);
- memcpy(buffdata, &temp32, 4); buffdata += 4;
- memcpy(buffdata, "movi", 4);
+ buffer = gst_buffer_new ();
+ GST_BUFFER_SIZE (buffer) = 24;
+ buffdata = GST_BUFFER_DATA (buffer) = g_malloc (GST_BUFFER_SIZE (buffer));
+
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (datax_size + 4 * 4);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "AVIX", 4);
+ buffdata += 4;
+ memcpy (buffdata, "LIST", 4);
+ buffdata += 4;
+ temp32 = LE_FROM_GUINT32 (datax_size);
+ memcpy (buffdata, &temp32, 4);
+ buffdata += 4;
+ memcpy (buffdata, "movi", 4);
return buffer;
}
@@ -801,12 +866,12 @@ gst_avimux_riff_get_video_header (guint32 video_frame_size)
GstBuffer *buffer;
guint32 temp32;
- buffer = gst_buffer_new();
- GST_BUFFER_DATA(buffer) = g_malloc(8);
- GST_BUFFER_SIZE(buffer) = 8;
- memcpy(GST_BUFFER_DATA(buffer), "00db", 4);
- temp32 = LE_FROM_GUINT32(video_frame_size);
- memcpy(GST_BUFFER_DATA(buffer)+4, &temp32, 4);
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = g_malloc (8);
+ GST_BUFFER_SIZE (buffer) = 8;
+ memcpy (GST_BUFFER_DATA (buffer), "00db", 4);
+ temp32 = LE_FROM_GUINT32 (video_frame_size);
+ memcpy (GST_BUFFER_DATA (buffer) + 4, &temp32, 4);
return buffer;
}
@@ -817,12 +882,12 @@ gst_avimux_riff_get_audio_header (guint32 audio_sample_size)
GstBuffer *buffer;
guint32 temp32;
- buffer = gst_buffer_new();
- GST_BUFFER_DATA(buffer) = g_malloc(8);
- GST_BUFFER_SIZE(buffer) = 8;
- memcpy(GST_BUFFER_DATA(buffer), "01wb", 4);
- temp32 = LE_FROM_GUINT32(audio_sample_size);
- memcpy(GST_BUFFER_DATA(buffer)+4, &temp32, 4);
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = g_malloc (8);
+ GST_BUFFER_SIZE (buffer) = 8;
+ memcpy (GST_BUFFER_DATA (buffer), "01wb", 4);
+ temp32 = LE_FROM_GUINT32 (audio_sample_size);
+ memcpy (GST_BUFFER_DATA (buffer) + 4, &temp32, 4);
return buffer;
}
@@ -830,73 +895,70 @@ gst_avimux_riff_get_audio_header (guint32 audio_sample_size)
/* some other usable functions (thankyou xawtv ;-) ) */
static void
-gst_avimux_add_index (GstAviMux *avimux, guchar *code, guint32 flags, guint32 size)
+gst_avimux_add_index (GstAviMux * avimux, guchar * code, guint32 flags,
+ guint32 size)
{
- if (avimux->idx_index == avimux->idx_count)
- {
+ if (avimux->idx_index == avimux->idx_count) {
avimux->idx_count += 256;
- avimux->idx = realloc(avimux->idx, avimux->idx_count*sizeof(gst_riff_index_entry));
+ avimux->idx =
+ realloc (avimux->idx,
+ avimux->idx_count * sizeof (gst_riff_index_entry));
}
- memcpy(&(avimux->idx[avimux->idx_index].id), code, 4);
- avimux->idx[avimux->idx_index].flags = LE_FROM_GUINT32(flags);
- avimux->idx[avimux->idx_index].offset = LE_FROM_GUINT32(avimux->idx_offset);
- avimux->idx[avimux->idx_index].size = LE_FROM_GUINT32(size);
+ memcpy (&(avimux->idx[avimux->idx_index].id), code, 4);
+ avimux->idx[avimux->idx_index].flags = LE_FROM_GUINT32 (flags);
+ avimux->idx[avimux->idx_index].offset = LE_FROM_GUINT32 (avimux->idx_offset);
+ avimux->idx[avimux->idx_index].size = LE_FROM_GUINT32 (size);
avimux->idx_index++;
}
static void
-gst_avimux_write_index (GstAviMux *avimux)
+gst_avimux_write_index (GstAviMux * avimux)
{
GstBuffer *buffer;
guint32 temp32;
- buffer = gst_buffer_new();
- GST_BUFFER_SIZE(buffer) = 8;
- GST_BUFFER_DATA(buffer) = g_malloc(8);
- memcpy(GST_BUFFER_DATA(buffer), "idx1", 4);
- temp32 = LE_FROM_GUINT32(avimux->idx_index * sizeof(gst_riff_index_entry));
- memcpy(GST_BUFFER_DATA(buffer)+4, &temp32, 4);
- gst_pad_push(avimux->srcpad, GST_DATA (buffer));
+ buffer = gst_buffer_new ();
+ GST_BUFFER_SIZE (buffer) = 8;
+ GST_BUFFER_DATA (buffer) = g_malloc (8);
+ memcpy (GST_BUFFER_DATA (buffer), "idx1", 4);
+ temp32 = LE_FROM_GUINT32 (avimux->idx_index * sizeof (gst_riff_index_entry));
+ memcpy (GST_BUFFER_DATA (buffer) + 4, &temp32, 4);
+ gst_pad_push (avimux->srcpad, GST_DATA (buffer));
- buffer = gst_buffer_new();
- GST_BUFFER_SIZE(buffer) = avimux->idx_index * sizeof(gst_riff_index_entry);
- GST_BUFFER_DATA(buffer) = (unsigned char*) avimux->idx;
- avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
- avimux->total_data += GST_BUFFER_SIZE(buffer);
- gst_pad_push(avimux->srcpad, GST_DATA (buffer));
+ buffer = gst_buffer_new ();
+ GST_BUFFER_SIZE (buffer) = avimux->idx_index * sizeof (gst_riff_index_entry);
+ GST_BUFFER_DATA (buffer) = (unsigned char *) avimux->idx;
+ avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
+ avimux->total_data += GST_BUFFER_SIZE (buffer);
+ gst_pad_push (avimux->srcpad, GST_DATA (buffer));
- avimux->idx_size += avimux->idx_index * sizeof(gst_riff_index_entry) + 8;
+ avimux->idx_size += avimux->idx_index * sizeof (gst_riff_index_entry) + 8;
/* update header */
avimux->avi_hdr.flags |= GST_RIFF_AVIH_HASINDEX;
}
static void
-gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
+gst_avimux_bigfile (GstAviMux * avimux, gboolean last)
{
GstBuffer *header;
GstEvent *event;
-
- if (avimux->is_bigfile)
- {
+
+ if (avimux->is_bigfile) {
/* sarch back */
- event = gst_event_new_seek (GST_FORMAT_BYTES |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- avimux->avix_start);
+ event = gst_event_new_seek (GST_FORMAT_BYTES |
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, avimux->avix_start);
/* if the event succeeds */
- gst_pad_push(avimux->srcpad, GST_DATA(event));
+ gst_pad_push (avimux->srcpad, GST_DATA (event));
/* rewrite AVIX header */
- header = gst_avimux_riff_get_avix_header(avimux->datax_size);
- gst_pad_push(avimux->srcpad, GST_DATA (header));
+ header = gst_avimux_riff_get_avix_header (avimux->datax_size);
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
/* go back to current location */
- event = gst_event_new_seek (GST_FORMAT_BYTES |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- avimux->total_data);
- gst_pad_push(avimux->srcpad, GST_DATA(event));
+ event = gst_event_new_seek (GST_FORMAT_BYTES |
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, avimux->total_data);
+ gst_pad_push (avimux->srcpad, GST_DATA (event));
}
avimux->avix_start = avimux->total_data;
@@ -907,21 +969,21 @@ gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
avimux->numx_frames = 0;
avimux->datax_size = 0;
- header = gst_avimux_riff_get_avix_header(0);
- avimux->total_data += GST_BUFFER_SIZE(header);
- gst_pad_push(avimux->srcpad, GST_DATA (header));
+ header = gst_avimux_riff_get_avix_header (0);
+ avimux->total_data += GST_BUFFER_SIZE (header);
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
}
/* enough header blabla now, let's go on to actually writing the headers */
static void
-gst_avimux_start_file (GstAviMux *avimux)
+gst_avimux_start_file (GstAviMux * avimux)
{
GstBuffer *header;
avimux->total_data = 0;
avimux->total_frames = 0;
- avimux->data_size = 4; /* ? */
+ avimux->data_size = 4; /* ? */
avimux->datax_size = 0;
avimux->num_frames = 0;
avimux->numx_frames = 0;
@@ -930,41 +992,39 @@ gst_avimux_start_file (GstAviMux *avimux)
avimux->avix_start = 0;
avimux->idx_index = 0;
- avimux->idx_offset = 0; /* see 10 lines below */
+ avimux->idx_offset = 0; /* see 10 lines below */
avimux->idx_size = 0;
avimux->idx_count = 0;
avimux->idx = NULL;
/* header */
- avimux->avi_hdr.streams = (avimux->video_pad_connected?1:0) + (avimux->audio_pad_connected?1:0);
+ avimux->avi_hdr.streams =
+ (avimux->video_pad_connected ? 1 : 0) +
+ (avimux->audio_pad_connected ? 1 : 0);
avimux->is_bigfile = FALSE;
- header = gst_avimux_riff_get_avi_header(avimux);
- avimux->total_data += GST_BUFFER_SIZE(header);
+ header = gst_avimux_riff_get_avi_header (avimux);
+ avimux->total_data += GST_BUFFER_SIZE (header);
avimux->idx_offset = avimux->total_data;
- gst_pad_push(avimux->srcpad, GST_DATA (header));
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
avimux->write_header = FALSE;
avimux->restart = FALSE;
}
static void
-gst_avimux_stop_file (GstAviMux *avimux)
+gst_avimux_stop_file (GstAviMux * avimux)
{
GstEvent *event;
GstBuffer *header;
/* if bigfile, rewrite header, else write indexes */
- if (avimux->video_pad_connected)
- {
- if (avimux->is_bigfile)
- {
- gst_avimux_bigfile(avimux, TRUE);
+ if (avimux->video_pad_connected) {
+ if (avimux->is_bigfile) {
+ gst_avimux_bigfile (avimux, TRUE);
avimux->idx_size = 0;
- }
- else
- {
- gst_avimux_write_index(avimux);
+ } else {
+ gst_avimux_write_index (avimux);
}
}
@@ -974,7 +1034,8 @@ gst_avimux_stop_file (GstAviMux *avimux)
avimux->vids_hdr.length = avimux->num_frames;
}
if (avimux->audio_pad_connected) {
- avimux->auds_hdr.length = (avimux->audio_time * avimux->auds.rate)/GST_SECOND;
+ avimux->auds_hdr.length =
+ (avimux->audio_time * avimux->auds.rate) / GST_SECOND;
}
/* set rate and everything having to do with that */
@@ -983,68 +1044,68 @@ gst_avimux_stop_file (GstAviMux *avimux)
/* calculate bps if needed */
if (!avimux->auds.av_bps) {
if (avimux->audio_time) {
- avimux->auds_hdr.rate = (GST_SECOND * avimux->audio_size) / avimux->audio_time;
+ avimux->auds_hdr.rate =
+ (GST_SECOND * avimux->audio_size) / avimux->audio_time;
} else {
- GST_ELEMENT_ERROR (avimux, STREAM, MUX,
- (_("No or invalid input audio, AVI stream will be corrupt.")), (NULL));
- avimux->auds_hdr.rate = 0;
+ GST_ELEMENT_ERROR (avimux, STREAM, MUX,
+ (_("No or invalid input audio, AVI stream will be corrupt.")),
+ (NULL));
+ avimux->auds_hdr.rate = 0;
}
avimux->auds.av_bps = avimux->auds_hdr.rate * avimux->auds_hdr.scale;
}
avimux->avi_hdr.max_bps += avimux->auds.av_bps;
}
if (avimux->video_pad_connected) {
- avimux->avi_hdr.max_bps += ((avimux->vids.bit_cnt+7)/8) *
- (1000000. / avimux->avi_hdr.us_frame) *
- avimux->vids.image_size;
+ avimux->avi_hdr.max_bps += ((avimux->vids.bit_cnt + 7) / 8) *
+ (1000000. / avimux->avi_hdr.us_frame) * avimux->vids.image_size;
}
/* seek and rewrite the header */
- header = gst_avimux_riff_get_avi_header(avimux);
- event = gst_event_new_seek (GST_FORMAT_BYTES |
- GST_SEEK_METHOD_SET, 0);
- gst_pad_push(avimux->srcpad, GST_DATA(event));
- gst_pad_push(avimux->srcpad, GST_DATA (header));
+ header = gst_avimux_riff_get_avi_header (avimux);
+ event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0);
+ gst_pad_push (avimux->srcpad, GST_DATA (event));
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
event = gst_event_new_seek (GST_FORMAT_BYTES |
- GST_SEEK_METHOD_SET, avimux->total_data);
- gst_pad_push(avimux->srcpad, GST_DATA(event));
+ GST_SEEK_METHOD_SET, avimux->total_data);
+ gst_pad_push (avimux->srcpad, GST_DATA (event));
avimux->write_header = TRUE;
}
static void
-gst_avimux_restart_file (GstAviMux *avimux)
+gst_avimux_restart_file (GstAviMux * avimux)
{
GstEvent *event;
- gst_avimux_stop_file(avimux);
+ gst_avimux_stop_file (avimux);
- event = gst_event_new(GST_EVENT_EOS);
- gst_pad_push(avimux->srcpad, GST_DATA(event));
+ event = gst_event_new (GST_EVENT_EOS);
+ gst_pad_push (avimux->srcpad, GST_DATA (event));
- gst_avimux_start_file(avimux);
+ gst_avimux_start_file (avimux);
}
/* handle events (search) */
static gboolean
-gst_avimux_handle_event (GstPad *pad, GstEvent *event)
+gst_avimux_handle_event (GstPad * pad, GstEvent * event)
{
GstAviMux *avimux;
GstEventType type;
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
-
+
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
case GST_EVENT_EOS:
/* is this allright? */
if (pad == avimux->videosinkpad) {
- avimux->video_pad_eos = TRUE;
+ avimux->video_pad_eos = TRUE;
} else if (pad == avimux->audiosinkpad) {
- avimux->audio_pad_eos = TRUE;
+ avimux->audio_pad_eos = TRUE;
} else {
- g_warning("Unknown pad for EOS!");
+ g_warning ("Unknown pad for EOS!");
}
break;
default:
@@ -1057,19 +1118,17 @@ gst_avimux_handle_event (GstPad *pad, GstEvent *event)
/* fill the internal queue for each available pad */
static void
-gst_avimux_fill_queue (GstAviMux *avimux)
+gst_avimux_fill_queue (GstAviMux * avimux)
{
GstBuffer *buffer;
while (!avimux->audio_buffer_queue &&
- avimux->audiosinkpad &&
- avimux->audio_pad_connected &&
- GST_PAD_IS_USABLE(avimux->audiosinkpad) &&
- !avimux->audio_pad_eos)
- {
- buffer = GST_BUFFER (gst_pad_pull(avimux->audiosinkpad));
- if (GST_IS_EVENT(buffer)) {
- gst_avimux_handle_event(avimux->audiosinkpad, GST_EVENT(buffer));
+ avimux->audiosinkpad &&
+ avimux->audio_pad_connected &&
+ GST_PAD_IS_USABLE (avimux->audiosinkpad) && !avimux->audio_pad_eos) {
+ buffer = GST_BUFFER (gst_pad_pull (avimux->audiosinkpad));
+ if (GST_IS_EVENT (buffer)) {
+ gst_avimux_handle_event (avimux->audiosinkpad, GST_EVENT (buffer));
} else {
avimux->audio_buffer_queue = buffer;
break;
@@ -1077,14 +1136,12 @@ gst_avimux_fill_queue (GstAviMux *avimux)
}
while (!avimux->video_buffer_queue &&
- avimux->videosinkpad &&
- avimux->video_pad_connected &&
- GST_PAD_IS_USABLE(avimux->videosinkpad) &&
- !avimux->video_pad_eos)
- {
- buffer = GST_BUFFER (gst_pad_pull(avimux->videosinkpad));
- if (GST_IS_EVENT(buffer)) {
- gst_avimux_handle_event(avimux->videosinkpad, GST_EVENT(buffer));
+ avimux->videosinkpad &&
+ avimux->video_pad_connected &&
+ GST_PAD_IS_USABLE (avimux->videosinkpad) && !avimux->video_pad_eos) {
+ buffer = GST_BUFFER (gst_pad_pull (avimux->videosinkpad));
+ if (GST_IS_EVENT (buffer)) {
+ gst_avimux_handle_event (avimux->videosinkpad, GST_EVENT (buffer));
} else {
avimux->video_buffer_queue = buffer;
break;
@@ -1095,49 +1152,45 @@ gst_avimux_fill_queue (GstAviMux *avimux)
/* send extra 'padding' data */
static void
-gst_avimux_send_pad_data (GstAviMux *avimux,
- gulong num_bytes)
+gst_avimux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
{
GstBuffer *buffer;
- buffer = gst_buffer_new();
- GST_BUFFER_SIZE(buffer) = num_bytes;
- GST_BUFFER_DATA(buffer) = g_malloc(num_bytes);
- memset(GST_BUFFER_DATA(buffer), 0, num_bytes);
+ buffer = gst_buffer_new ();
+ GST_BUFFER_SIZE (buffer) = num_bytes;
+ GST_BUFFER_DATA (buffer) = g_malloc (num_bytes);
+ memset (GST_BUFFER_DATA (buffer), 0, num_bytes);
- gst_pad_push(avimux->srcpad, GST_DATA (buffer));
+ gst_pad_push (avimux->srcpad, GST_DATA (buffer));
}
/* do audio buffer */
static void
-gst_avimux_do_audio_buffer (GstAviMux *avimux)
+gst_avimux_do_audio_buffer (GstAviMux * avimux)
{
GstBuffer *data = avimux->audio_buffer_queue, *header;
gulong total_size, pad_bytes = 0;
/* write a audio header + index entry */
- if (GST_BUFFER_SIZE(data) & 1) {
- pad_bytes = 2 - (GST_BUFFER_SIZE(data) & 1);
+ if (GST_BUFFER_SIZE (data) & 1) {
+ pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
}
- header = gst_avimux_riff_get_audio_header(GST_BUFFER_SIZE(data));
- total_size = GST_BUFFER_SIZE(header) + GST_BUFFER_SIZE(data) + pad_bytes;
+ header = gst_avimux_riff_get_audio_header (GST_BUFFER_SIZE (data));
+ total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
- if (avimux->is_bigfile)
- {
+ if (avimux->is_bigfile) {
avimux->datax_size += total_size;
- }
- else
- {
+ } else {
avimux->data_size += total_size;
- avimux->audio_size += GST_BUFFER_SIZE(data);
- avimux->audio_time += GST_BUFFER_DURATION(data);
- gst_avimux_add_index(avimux, "01wb", 0x0, GST_BUFFER_SIZE(data));
+ avimux->audio_size += GST_BUFFER_SIZE (data);
+ avimux->audio_time += GST_BUFFER_DURATION (data);
+ gst_avimux_add_index (avimux, "01wb", 0x0, GST_BUFFER_SIZE (data));
}
- gst_pad_push(avimux->srcpad, GST_DATA (header));
- gst_pad_push(avimux->srcpad, GST_DATA (data));
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
+ gst_pad_push (avimux->srcpad, GST_DATA (data));
if (pad_bytes) {
- gst_avimux_send_pad_data(avimux, pad_bytes);
+ gst_avimux_send_pad_data (avimux, pad_bytes);
}
avimux->total_data += total_size;
avimux->idx_offset += total_size;
@@ -1148,49 +1201,47 @@ gst_avimux_do_audio_buffer (GstAviMux *avimux)
/* do video buffer */
static void
-gst_avimux_do_video_buffer (GstAviMux *avimux)
+gst_avimux_do_video_buffer (GstAviMux * avimux)
{
GstBuffer *data = avimux->video_buffer_queue, *header;
gulong total_size, pad_bytes = 0;
if (avimux->restart)
- gst_avimux_restart_file(avimux);
+ gst_avimux_restart_file (avimux);
/* write a video header + index entry */
- if ((avimux->is_bigfile?avimux->datax_size:avimux->data_size)+GST_BUFFER_SIZE(data)>1024*1024*2000)
- {
+ if ((avimux->is_bigfile ? avimux->datax_size : avimux->data_size) +
+ GST_BUFFER_SIZE (data) > 1024 * 1024 * 2000) {
if (avimux->enable_large_avi)
- gst_avimux_bigfile(avimux, FALSE);
+ gst_avimux_bigfile (avimux, FALSE);
else
- gst_avimux_restart_file(avimux);
+ gst_avimux_restart_file (avimux);
}
- if (GST_BUFFER_SIZE(data) & 1) {
- pad_bytes = 2 - (GST_BUFFER_SIZE(data) & 1);
+ if (GST_BUFFER_SIZE (data) & 1) {
+ pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
}
- header = gst_avimux_riff_get_video_header(GST_BUFFER_SIZE(data));
- total_size = GST_BUFFER_SIZE(header) + GST_BUFFER_SIZE(data) + pad_bytes;
+ header = gst_avimux_riff_get_video_header (GST_BUFFER_SIZE (data));
+ total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
avimux->total_frames++;
- if (avimux->is_bigfile)
- {
+ if (avimux->is_bigfile) {
avimux->datax_size += total_size;
avimux->numx_frames++;
- }
- else
- {
+ } else {
guint flags = 0x2;
+
if (GST_BUFFER_FLAG_IS_SET (data, GST_BUFFER_KEY_UNIT))
flags |= 0x10;
avimux->data_size += total_size;
avimux->num_frames++;
- gst_avimux_add_index(avimux, "00db", flags, GST_BUFFER_SIZE(data));
+ gst_avimux_add_index (avimux, "00db", flags, GST_BUFFER_SIZE (data));
}
- gst_pad_push(avimux->srcpad, GST_DATA (header));
- gst_pad_push(avimux->srcpad, GST_DATA (data));
+ gst_pad_push (avimux->srcpad, GST_DATA (header));
+ gst_pad_push (avimux->srcpad, GST_DATA (data));
if (pad_bytes) {
- gst_avimux_send_pad_data(avimux, pad_bytes);
+ gst_avimux_send_pad_data (avimux, pad_bytes);
}
avimux->total_data += total_size;
avimux->idx_offset += total_size;
@@ -1201,31 +1252,24 @@ gst_avimux_do_video_buffer (GstAviMux *avimux)
/* take the oldest buffer in our internal queue and push-it */
static gboolean
-gst_avimux_do_one_buffer (GstAviMux *avimux)
+gst_avimux_do_one_buffer (GstAviMux * avimux)
{
- if (avimux->video_buffer_queue &&
- avimux->audio_buffer_queue)
- {
- if (GST_BUFFER_TIMESTAMP(avimux->video_buffer_queue) <=
- GST_BUFFER_TIMESTAMP(avimux->audio_buffer_queue))
- gst_avimux_do_video_buffer(avimux);
+ if (avimux->video_buffer_queue && avimux->audio_buffer_queue) {
+ if (GST_BUFFER_TIMESTAMP (avimux->video_buffer_queue) <=
+ GST_BUFFER_TIMESTAMP (avimux->audio_buffer_queue))
+ gst_avimux_do_video_buffer (avimux);
else
- gst_avimux_do_audio_buffer(avimux);
- }
- else if (avimux->video_buffer_queue ||
- avimux->audio_buffer_queue)
- {
+ gst_avimux_do_audio_buffer (avimux);
+ } else if (avimux->video_buffer_queue || avimux->audio_buffer_queue) {
if (avimux->video_buffer_queue)
- gst_avimux_do_video_buffer(avimux);
+ gst_avimux_do_video_buffer (avimux);
else
- gst_avimux_do_audio_buffer(avimux);
- }
- else {
+ gst_avimux_do_audio_buffer (avimux);
+ } else {
/* simply finish off the file and send EOS */
- gst_avimux_stop_file(avimux);
- gst_pad_push(avimux->srcpad,
- GST_DATA(gst_event_new(GST_EVENT_EOS)));
- gst_element_set_eos(GST_ELEMENT(avimux));
+ gst_avimux_stop_file (avimux);
+ gst_pad_push (avimux->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (GST_ELEMENT (avimux));
return FALSE;
}
@@ -1234,38 +1278,35 @@ gst_avimux_do_one_buffer (GstAviMux *avimux)
static void
-gst_avimux_loop (GstElement *element)
+gst_avimux_loop (GstElement * element)
{
GstAviMux *avimux;
- avimux = GST_AVIMUX(element);
+ avimux = GST_AVIMUX (element);
/* first fill queue (some elements only set caps when
* flowing data), then write header */
- gst_avimux_fill_queue(avimux);
-
+ gst_avimux_fill_queue (avimux);
+
if (avimux->write_header)
- gst_avimux_start_file(avimux);
+ gst_avimux_start_file (avimux);
- gst_avimux_do_one_buffer(avimux);
+ gst_avimux_do_one_buffer (avimux);
}
static void
-gst_avimux_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_avimux_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstAviMux *avimux;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AVIMUX(object));
- avimux = GST_AVIMUX(object);
+ g_return_if_fail (GST_IS_AVIMUX (object));
+ avimux = GST_AVIMUX (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_BIGFILE:
- g_value_set_boolean(value, avimux->enable_large_avi);
+ g_value_set_boolean (value, avimux->enable_large_avi);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1274,21 +1315,18 @@ gst_avimux_get_property (GObject *object,
}
static void
-gst_avimux_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_avimux_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstAviMux *avimux;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AVIMUX(object));
- avimux = GST_AVIMUX(object);
+ g_return_if_fail (GST_IS_AVIMUX (object));
+ avimux = GST_AVIMUX (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_BIGFILE:
- avimux->enable_large_avi = g_value_get_boolean(value);
+ avimux->enable_large_avi = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1297,14 +1335,14 @@ gst_avimux_set_property (GObject *object,
}
static GstElementStateReturn
-gst_avimux_change_state (GstElement *element)
+gst_avimux_change_state (GstElement * element)
{
GstAviMux *avimux;
gint transition = GST_STATE_TRANSITION (element);
- g_return_val_if_fail(GST_IS_AVIMUX(element), GST_STATE_FAILURE);
-
- avimux = GST_AVIMUX(element);
+ g_return_val_if_fail (GST_IS_AVIMUX (element), GST_STATE_FAILURE);
+
+ avimux = GST_AVIMUX (element);
switch (transition) {
case GST_STATE_PAUSED_TO_PLAYING:
@@ -1317,4 +1355,3 @@ gst_avimux_change_state (GstElement *element)
return GST_STATE_SUCCESS;
}
-