1.1 --- a/gst-gmyth/concatmux/gstconcatmux.c Wed May 02 21:38:04 2007 +0100
1.2 +++ b/gst-gmyth/concatmux/gstconcatmux.c Thu Jun 14 18:22:32 2007 +0100
1.3 @@ -42,7 +42,7 @@
1.4
1.5 #include <string.h>
1.6
1.7 -GST_DEBUG_CATEGORY_STATIC (gst_concat_mux_debug);
1.8 +GST_DEBUG_CATEGORY_STATIC(gst_concat_mux_debug);
1.9 #define GST_CAT_DEFAULT gst_concat_mux_debug
1.10
1.11 #define GST_TYPE_CONCAT_MUX (gst_concat_mux_get_type())
1.12 @@ -63,18 +63,18 @@
1.13 {
1.14 GstElement element;
1.15
1.16 - /* Caps */
1.17 + /* Caps */
1.18 GstCaps *sink_caps;
1.19
1.20 - /* pad */
1.21 + /* pad */
1.22 GstPad *srcpad;
1.23 GstPad *sinkpad;
1.24
1.25 - /* sinkpads */
1.26 + /* sinkpads */
1.27 GSList *sinks;
1.28 gint numpads;
1.29
1.30 - /* offset in stream */
1.31 + /* offset in stream */
1.32 guint64 offset;
1.33 guint64 timeoffset;
1.34 guint64 start_time;
1.35 @@ -91,85 +91,88 @@
1.36
1.37 /* elementfactory information */
1.38 static const GstElementDetails gst_concat_mux_details =
1.39 -GST_ELEMENT_DETAILS ("Concat muxer",
1.40 - "Codec/Muxer",
1.41 - "mux concat streams",
1.42 - "Renato Filho <renato.filho@indt.org>");
1.43 +GST_ELEMENT_DETAILS("Concat muxer",
1.44 + "Codec/Muxer",
1.45 + "mux concat streams",
1.46 + "Renato Filho <renato.filho@indt.org>");
1.47
1.48 -static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
1.49 - GST_PAD_SRC,
1.50 - GST_PAD_ALWAYS,
1.51 - GST_STATIC_CAPS_ANY
1.52 - );
1.53 +static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE("src",
1.54 + GST_PAD_SRC,
1.55 + GST_PAD_ALWAYS,
1.56 + GST_STATIC_CAPS_ANY);
1.57
1.58 -static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
1.59 - GST_PAD_SINK,
1.60 - GST_PAD_REQUEST,
1.61 - GST_STATIC_CAPS_ANY
1.62 - );
1.63 +static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE("sink_%d",
1.64 + GST_PAD_SINK,
1.65 + GST_PAD_REQUEST,
1.66 + GST_STATIC_CAPS_ANY);
1.67
1.68 -static void gst_concat_mux_base_init (gpointer g_class);
1.69 -static void gst_concat_mux_class_init (GstConcatMuxClass * klass);
1.70 -static void gst_concat_mux_init (GstConcatMux * concat_mux);
1.71 +static void gst_concat_mux_base_init(gpointer g_class);
1.72 +static void gst_concat_mux_class_init(GstConcatMuxClass * klass);
1.73 +static void gst_concat_mux_init(GstConcatMux * concat_mux);
1.74
1.75 -static void gst_concat_mux_finalize (GObject * object);
1.76 +static void gst_concat_mux_finalize(GObject * object);
1.77
1.78 -static gboolean gst_concat_mux_handle_src_event (GstPad * pad,
1.79 - GstEvent * event);
1.80 -static gboolean gst_concat_mux_handle_sink_event (GstPad * pad,
1.81 - GstEvent * event);
1.82 +static gboolean gst_concat_mux_handle_src_event(GstPad * pad,
1.83 + GstEvent * event);
1.84 +static gboolean gst_concat_mux_handle_sink_event(GstPad * pad,
1.85 + GstEvent * event);
1.86
1.87 -static GstPad *gst_concat_mux_request_new_pad (GstElement * element,
1.88 - GstPadTemplate * templ, const gchar * name);
1.89 -static GstStateChangeReturn gst_concat_mux_change_state (GstElement *
1.90 - element, GstStateChange transition);
1.91 +static GstPad *gst_concat_mux_request_new_pad(GstElement * element,
1.92 + GstPadTemplate * templ,
1.93 + const gchar * name);
1.94 +static GstStateChangeReturn gst_concat_mux_change_state(GstElement * element,
1.95 + GstStateChange
1.96 + transition);
1.97
1.98 -static GstFlowReturn gst_concat_mux_chain (GstPad * pad, GstBuffer * buf);
1.99 -static void gst_concat_mux_clear (GstConcatMux *mux);
1.100 +static GstFlowReturn gst_concat_mux_chain(GstPad * pad, GstBuffer * buf);
1.101 +static void gst_concat_mux_clear(GstConcatMux * mux);
1.102
1.103
1.104 static GstElementClass *parent_class = NULL;
1.105
1.106 GType
1.107 -gst_concat_mux_get_type (void)
1.108 +gst_concat_mux_get_type(void)
1.109 {
1.110 static GType concat_mux_type = 0;
1.111
1.112 - if (!concat_mux_type) {
1.113 - static const GTypeInfo concat_mux_info = {
1.114 - sizeof (GstConcatMuxClass),
1.115 - gst_concat_mux_base_init,
1.116 - NULL,
1.117 - (GClassInitFunc) gst_concat_mux_class_init,
1.118 - NULL,
1.119 - NULL,
1.120 - sizeof (GstConcatMux),
1.121 - 0,
1.122 - (GInstanceInitFunc) gst_concat_mux_init,
1.123 - };
1.124 + if (!concat_mux_type)
1.125 + {
1.126 + static const GTypeInfo concat_mux_info = {
1.127 + sizeof(GstConcatMuxClass),
1.128 + gst_concat_mux_base_init,
1.129 + NULL,
1.130 + (GClassInitFunc) gst_concat_mux_class_init,
1.131 + NULL,
1.132 + NULL,
1.133 + sizeof(GstConcatMux),
1.134 + 0,
1.135 + (GInstanceInitFunc) gst_concat_mux_init,
1.136 + };
1.137
1.138 - concat_mux_type =
1.139 - g_type_register_static (GST_TYPE_ELEMENT, "GstConcatMux",
1.140 - &concat_mux_info, 0);
1.141 - }
1.142 + concat_mux_type =
1.143 + g_type_register_static(GST_TYPE_ELEMENT, "GstConcatMux",
1.144 + &concat_mux_info, 0);
1.145 + }
1.146 return concat_mux_type;
1.147 }
1.148
1.149 static void
1.150 -gst_concat_mux_base_init (gpointer g_class)
1.151 +gst_concat_mux_base_init(gpointer g_class)
1.152 {
1.153 - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
1.154 + GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
1.155
1.156 - gst_element_class_add_pad_template (element_class,
1.157 - gst_static_pad_template_get (&src_factory));
1.158 - gst_element_class_add_pad_template (element_class,
1.159 - gst_static_pad_template_get (&sink_factory));
1.160 + gst_element_class_add_pad_template(element_class,
1.161 + gst_static_pad_template_get
1.162 + (&src_factory));
1.163 + gst_element_class_add_pad_template(element_class,
1.164 + gst_static_pad_template_get
1.165 + (&sink_factory));
1.166
1.167 - gst_element_class_set_details (element_class, &gst_concat_mux_details);
1.168 + gst_element_class_set_details(element_class, &gst_concat_mux_details);
1.169 }
1.170
1.171 static void
1.172 -gst_concat_mux_class_init (GstConcatMuxClass * klass)
1.173 +gst_concat_mux_class_init(GstConcatMuxClass * klass)
1.174 {
1.175 GObjectClass *gobject_class;
1.176 GstElementClass *gstelement_class;
1.177 @@ -177,7 +180,7 @@
1.178 gobject_class = (GObjectClass *) klass;
1.179 gstelement_class = (GstElementClass *) klass;
1.180
1.181 - parent_class = g_type_class_peek_parent (klass);
1.182 + parent_class = g_type_class_peek_parent(klass);
1.183
1.184 gobject_class->finalize = gst_concat_mux_finalize;
1.185
1.186 @@ -186,285 +189,304 @@
1.187 }
1.188
1.189 static void
1.190 -gst_concat_mux_init (GstConcatMux * concat_mux)
1.191 +gst_concat_mux_init(GstConcatMux * concat_mux)
1.192 {
1.193 - GstElementClass *klass = GST_ELEMENT_GET_CLASS (concat_mux);
1.194 + GstElementClass *klass = GST_ELEMENT_GET_CLASS(concat_mux);
1.195
1.196 concat_mux->srcpad =
1.197 - gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
1.198 - "src"), "src");
1.199 - gst_pad_set_event_function (concat_mux->srcpad,
1.200 - gst_concat_mux_handle_src_event);
1.201 - gst_element_add_pad (GST_ELEMENT (concat_mux), concat_mux->srcpad);
1.202 + gst_pad_new_from_template(gst_element_class_get_pad_template(klass,
1.203 + "src"),
1.204 + "src");
1.205 + gst_pad_set_event_function(concat_mux->srcpad,
1.206 + gst_concat_mux_handle_src_event);
1.207 + gst_element_add_pad(GST_ELEMENT(concat_mux), concat_mux->srcpad);
1.208 }
1.209
1.210 static void
1.211 -gst_concat_mux_finalize (GObject * object)
1.212 +gst_concat_mux_finalize(GObject * object)
1.213 {
1.214 GstConcatMux *concat_mux;
1.215
1.216 - concat_mux = GST_CONCAT_MUX (object);
1.217 - gst_concat_mux_clear (GST_CONCAT_MUX (object));
1.218 + concat_mux = GST_CONCAT_MUX(object);
1.219 + gst_concat_mux_clear(GST_CONCAT_MUX(object));
1.220
1.221 - G_OBJECT_CLASS (parent_class)->finalize (object);
1.222 + G_OBJECT_CLASS(parent_class)->finalize(object);
1.223 }
1.224
1.225 static void
1.226 -gst_concat_mux_free_pad (gpointer data,
1.227 - gpointer user_data)
1.228 +gst_concat_mux_free_pad(gpointer data, gpointer user_data)
1.229 {
1.230 - GMutex *mux;
1.231 + GMutex *mux;
1.232
1.233 - mux = gst_pad_get_element_private (GST_PAD (data));
1.234 - g_mutex_unlock (mux);
1.235 - g_mutex_free (mux);
1.236 - gst_object_unref (GST_OBJECT (data));
1.237 + mux = gst_pad_get_element_private(GST_PAD(data));
1.238 + g_mutex_unlock(mux);
1.239 + g_mutex_free(mux);
1.240 + gst_object_unref(GST_OBJECT(data));
1.241 }
1.242
1.243 static void
1.244 -gst_concat_mux_clear (GstConcatMux *mux)
1.245 +gst_concat_mux_clear(GstConcatMux * mux)
1.246 {
1.247 mux->resync = TRUE;
1.248 mux->timeoffset = 0;
1.249 mux->offset = 0;
1.250 mux->negotiated = FALSE;
1.251 mux->done = TRUE;
1.252 - if (mux->sinks != NULL) {
1.253 - g_slist_foreach (mux->sinks, gst_concat_mux_free_pad, mux);
1.254 - g_slist_free (mux->sinks);
1.255 - mux->sinks = NULL;
1.256 - }
1.257 + if (mux->sinks != NULL)
1.258 + {
1.259 + g_slist_foreach(mux->sinks, gst_concat_mux_free_pad, mux);
1.260 + g_slist_free(mux->sinks);
1.261 + mux->sinks = NULL;
1.262 + }
1.263 }
1.264
1.265
1.266 static GstPadLinkReturn
1.267 -gst_concat_mux_sinkconnect (GstPad * pad, GstPad * peer)
1.268 +gst_concat_mux_sinkconnect(GstPad * pad, GstPad * peer)
1.269 {
1.270 gchar *pad_name = NULL;
1.271 GstConcatMux *concat_mux;
1.272
1.273 - concat_mux = GST_CONCAT_MUX (gst_pad_get_parent (pad));
1.274 + concat_mux = GST_CONCAT_MUX(gst_pad_get_parent(pad));
1.275
1.276 - if (concat_mux->sink_caps != NULL) {
1.277 - GstCaps *peer_caps = gst_pad_get_caps (peer);
1.278 - GstCaps *intersect;
1.279 + if (concat_mux->sink_caps != NULL)
1.280 + {
1.281 + GstCaps *peer_caps = gst_pad_get_caps(peer);
1.282 + GstCaps *intersect;
1.283
1.284 - intersect = gst_caps_intersect (concat_mux->sink_caps, peer_caps);
1.285 - if (intersect == NULL) {
1.286 - gst_caps_unref (peer_caps);
1.287 - return GST_PAD_LINK_NOFORMAT;
1.288 - }
1.289 - gst_caps_unref (peer_caps);
1.290 - gst_caps_unref (intersect);
1.291 - } else {
1.292 - concat_mux->sink_caps = gst_pad_get_caps (pad);
1.293 - }
1.294 + intersect = gst_caps_intersect(concat_mux->sink_caps, peer_caps);
1.295 + if (intersect == NULL)
1.296 + {
1.297 + gst_caps_unref(peer_caps);
1.298 + return GST_PAD_LINK_NOFORMAT;
1.299 + }
1.300 + gst_caps_unref(peer_caps);
1.301 + gst_caps_unref(intersect);
1.302 + }
1.303 + else
1.304 + {
1.305 + concat_mux->sink_caps = gst_pad_get_caps(pad);
1.306 + }
1.307
1.308 - pad_name = gst_pad_get_name (pad);
1.309 + pad_name = gst_pad_get_name(pad);
1.310
1.311 - GST_DEBUG_OBJECT (concat_mux, "sinkconnect triggered on %s", pad_name);
1.312 + GST_DEBUG_OBJECT(concat_mux, "sinkconnect triggered on %s", pad_name);
1.313
1.314 - g_free (pad_name);
1.315 + g_free(pad_name);
1.316
1.317 - gst_object_unref (concat_mux);
1.318 + gst_object_unref(concat_mux);
1.319
1.320 return GST_PAD_LINK_OK;
1.321 }
1.322
1.323 static GstPad *
1.324 -gst_concat_mux_request_new_pad (GstElement * element,
1.325 - GstPadTemplate * templ, const gchar * req_name)
1.326 +gst_concat_mux_request_new_pad(GstElement * element,
1.327 + GstPadTemplate * templ, const gchar * req_name)
1.328 {
1.329 GstConcatMux *concat_mux;
1.330 GstPad *newpad;
1.331 - GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
1.332 + GstElementClass *klass = GST_ELEMENT_GET_CLASS(element);
1.333 GMutex *mutex;
1.334
1.335 - g_return_val_if_fail (templ != NULL, NULL);
1.336 + g_return_val_if_fail(templ != NULL, NULL);
1.337
1.338 - if (templ->direction != GST_PAD_SINK) {
1.339 - g_warning ("concat_mux: request pad that is not a SINK pad\n");
1.340 - return NULL;
1.341 - }
1.342 + if (templ->direction != GST_PAD_SINK)
1.343 + {
1.344 + g_warning("concat_mux: request pad that is not a SINK pad\n");
1.345 + return NULL;
1.346 + }
1.347
1.348 - g_return_val_if_fail (GST_IS_CONCAT_MUX (element), NULL);
1.349 + g_return_val_if_fail(GST_IS_CONCAT_MUX(element), NULL);
1.350
1.351 - concat_mux = GST_CONCAT_MUX (element);
1.352 + concat_mux = GST_CONCAT_MUX(element);
1.353
1.354 - if (templ == gst_element_class_get_pad_template (klass, "sink_%d")) {
1.355 - gchar *name;
1.356 + if (templ == gst_element_class_get_pad_template(klass, "sink_%d"))
1.357 + {
1.358 + gchar *name;
1.359
1.360 - /* create new pad with the name */
1.361 - name = g_strdup_printf ("sink_%02d", concat_mux->numpads);
1.362 - g_debug ("NEw pad %s", name);
1.363 - newpad = gst_pad_new_from_template (templ, name);
1.364 - g_free (name);
1.365 - concat_mux->sinks = g_slist_append (concat_mux->sinks, newpad);
1.366 - g_debug ("New sink %p / %d", newpad, g_slist_length (concat_mux->sinks));
1.367 - concat_mux->numpads++;
1.368 - } else {
1.369 - g_warning ("concat_mux: this is not our template!\n");
1.370 - return NULL;
1.371 - }
1.372 + /* create new pad with the name */
1.373 + name = g_strdup_printf("sink_%02d", concat_mux->numpads);
1.374 + g_debug("NEw pad %s", name);
1.375 + newpad = gst_pad_new_from_template(templ, name);
1.376 + g_free(name);
1.377 + concat_mux->sinks = g_slist_append(concat_mux->sinks, newpad);
1.378 + g_debug("New sink %p / %d", newpad, g_slist_length(concat_mux->sinks));
1.379 + concat_mux->numpads++;
1.380 + }
1.381 + else
1.382 + {
1.383 + g_warning("concat_mux: this is not our template!\n");
1.384 + return NULL;
1.385 + }
1.386
1.387 - mutex = g_mutex_new ();
1.388 + mutex = g_mutex_new();
1.389
1.390 - if (concat_mux->sinkpad == NULL) {
1.391 - concat_mux->sinkpad = newpad;
1.392 - }
1.393 - else {
1.394 - g_mutex_lock (mutex);
1.395 - }
1.396 + if (concat_mux->sinkpad == NULL)
1.397 + {
1.398 + concat_mux->sinkpad = newpad;
1.399 + }
1.400 + else
1.401 + {
1.402 + g_mutex_lock(mutex);
1.403 + }
1.404
1.405 - gst_pad_set_element_private (newpad, mutex);
1.406 - /* setup some pad functions */
1.407 - gst_pad_set_link_function (newpad, gst_concat_mux_sinkconnect);
1.408 - gst_pad_set_event_function (newpad, gst_concat_mux_handle_sink_event);
1.409 - gst_pad_set_chain_function (newpad, gst_concat_mux_chain);
1.410 + gst_pad_set_element_private(newpad, mutex);
1.411 + /* setup some pad functions */
1.412 + gst_pad_set_link_function(newpad, gst_concat_mux_sinkconnect);
1.413 + gst_pad_set_event_function(newpad, gst_concat_mux_handle_sink_event);
1.414 + gst_pad_set_chain_function(newpad, gst_concat_mux_chain);
1.415
1.416 - /* add the pad to the element */
1.417 - gst_element_add_pad (element, newpad);
1.418 + /* add the pad to the element */
1.419 + gst_element_add_pad(element, newpad);
1.420
1.421 return newpad;
1.422 }
1.423
1.424 /* handle events */
1.425 static gboolean
1.426 -gst_concat_mux_handle_src_event (GstPad * pad, GstEvent * event)
1.427 +gst_concat_mux_handle_src_event(GstPad * pad, GstEvent * event)
1.428 {
1.429 GstConcatMux *concat_mux;
1.430 GstEventType type;
1.431
1.432 - concat_mux = GST_CONCAT_MUX (gst_pad_get_parent (pad));
1.433 + concat_mux = GST_CONCAT_MUX(gst_pad_get_parent(pad));
1.434
1.435 - type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
1.436 + type = event ? GST_EVENT_TYPE(event) : GST_EVENT_UNKNOWN;
1.437
1.438 - switch (type) {
1.439 - case GST_EVENT_SEEK:
1.440 - /* disable seeking for now */
1.441 - return FALSE;
1.442 - default:
1.443 - break;
1.444 - }
1.445 + switch (type)
1.446 + {
1.447 + case GST_EVENT_SEEK:
1.448 + /* disable seeking for now */
1.449 + return FALSE;
1.450 + default:
1.451 + break;
1.452 + }
1.453
1.454 - gst_object_unref (concat_mux);
1.455 + gst_object_unref(concat_mux);
1.456
1.457 - return gst_pad_event_default (pad, event);
1.458 + return gst_pad_event_default(pad, event);
1.459 }
1.460
1.461 /* handle events */
1.462 static gboolean
1.463 -gst_concat_mux_handle_sink_event (GstPad * pad, GstEvent * event)
1.464 +gst_concat_mux_handle_sink_event(GstPad * pad, GstEvent * event)
1.465 {
1.466 GstConcatMux *mux;
1.467 GstEventType type;
1.468
1.469 - mux = GST_CONCAT_MUX (gst_pad_get_parent (pad));
1.470 + mux = GST_CONCAT_MUX(gst_pad_get_parent(pad));
1.471
1.472 - type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
1.473 + type = event ? GST_EVENT_TYPE(event) : GST_EVENT_UNKNOWN;
1.474
1.475 - switch (type) {
1.476 - case GST_EVENT_EOS:
1.477 - {
1.478 - mux->resync = TRUE;
1.479 - g_debug ("sink EOS %p / %d", pad, g_slist_length (mux->sinks));
1.480 - /* mark pad eos */
1.481 - mux->sinks = g_slist_remove (mux->sinks, pad);
1.482 - g_debug ("sink len %d", g_slist_length (mux->sinks));
1.483 - if (g_slist_length (mux->sinks) != 0) {
1.484 - GMutex *mutex;
1.485 - mux->sinkpad = mux->sinks->data;
1.486 - mutex = (GMutex *) gst_pad_get_element_private (mux->sinkpad);
1.487 - g_mutex_unlock (mutex);
1.488 - g_debug ("sink pad %p", mux->sinkpad);
1.489 - return TRUE;
1.490 - }
1.491 + switch (type)
1.492 + {
1.493 + case GST_EVENT_EOS:
1.494 + {
1.495 + mux->resync = TRUE;
1.496 + g_debug("sink EOS %p / %d", pad, g_slist_length(mux->sinks));
1.497 + /* mark pad eos */
1.498 + mux->sinks = g_slist_remove(mux->sinks, pad);
1.499 + g_debug("sink len %d", g_slist_length(mux->sinks));
1.500 + if (g_slist_length(mux->sinks) != 0)
1.501 + {
1.502 + GMutex *mutex;
1.503 + mux->sinkpad = mux->sinks->data;
1.504 + mutex = (GMutex *) gst_pad_get_element_private(mux->sinkpad);
1.505 + g_mutex_unlock(mutex);
1.506 + g_debug("sink pad %p", mux->sinkpad);
1.507 + return TRUE;
1.508 + }
1.509
1.510 - g_debug ("sink list is empty");
1.511 - }
1.512 - default:
1.513 - break;
1.514 - }
1.515 + g_debug("sink list is empty");
1.516 + }
1.517 + default:
1.518 + break;
1.519 + }
1.520
1.521 - gst_object_unref (mux);
1.522 + gst_object_unref(mux);
1.523
1.524 - return gst_pad_event_default (pad, event);
1.525 + return gst_pad_event_default(pad, event);
1.526 }
1.527
1.528 static GstFlowReturn
1.529 -gst_concat_mux_chain (GstPad * pad, GstBuffer * buf)
1.530 +gst_concat_mux_chain(GstPad * pad, GstBuffer * buf)
1.531 {
1.532 - GstConcatMux *mux = (GstConcatMux *) GST_PAD_PARENT (pad);
1.533 + GstConcatMux *mux = (GstConcatMux *) GST_PAD_PARENT(pad);
1.534 GstBuffer *databuf = NULL;
1.535 GstFlowReturn ret = GST_FLOW_OK;
1.536 GMutex *mutex;
1.537
1.538
1.539 - mutex = (GMutex*) gst_pad_get_element_private (pad);
1.540 + mutex = (GMutex *) gst_pad_get_element_private(pad);
1.541
1.542 - g_mutex_lock (mutex);
1.543 - if (mux->done) {
1.544 - g_debug ("DONE pad %p", pad);
1.545 - g_mutex_unlock (mutex);
1.546 - return GST_FLOW_OK;
1.547 - }
1.548 + g_mutex_lock(mutex);
1.549 + if (mux->done)
1.550 + {
1.551 + g_debug("DONE pad %p", pad);
1.552 + g_mutex_unlock(mutex);
1.553 + return GST_FLOW_OK;
1.554 + }
1.555
1.556 - databuf = gst_buffer_make_metadata_writable (buf);
1.557 + databuf = gst_buffer_make_metadata_writable(buf);
1.558
1.559 - if (!mux->negotiated) {
1.560 - /*
1.561 - GstCaps *newcaps;
1.562 - newcaps = gst_pad_get_caps (mux->sinkpad);
1.563 + if (!mux->negotiated)
1.564 + {
1.565 + /*
1.566 + GstCaps *newcaps;
1.567 + newcaps = gst_pad_get_caps (mux->sinkpad);
1.568
1.569 - g_debug ("CAPS: %s",gst_caps_to_string (newcaps));
1.570 + g_debug ("CAPS: %s",gst_caps_to_string (newcaps));
1.571
1.572 - if (!gst_pad_set_caps (mux->srcpad, newcaps))
1.573 - goto nego_error;
1.574 - */
1.575 - mux->negotiated = TRUE;
1.576 - }
1.577 + if (!gst_pad_set_caps (mux->srcpad, newcaps))
1.578 + goto nego_error;
1.579 + */
1.580 + mux->negotiated = TRUE;
1.581 + }
1.582
1.583 - /*
1.584 - g_debug ("Running [%s]\n"
1.585 - "\tTOFFSET [%"G_GUINT64_FORMAT"]\n"
1.586 - "\tB_TSTAMP [%"G_GUINT64_FORMAT"]\n"
1.587 - "\tB_DURATION [%"G_GUINT64_FORMAT"]\n"
1.588 - "\tOFFSET [%"G_GUINT64_FORMAT"]\n"
1.589 - "\tB_OFFSET [%"G_GUINT64_FORMAT"]",
1.590 - gst_element_get_name (mux),
1.591 - mux->timeoffset,
1.592 - GST_BUFFER_TIMESTAMP (databuf),
1.593 - GST_BUFFER_DURATION (databuf),
1.594 - mux->offset,
1.595 - GST_BUFFER_OFFSET (databuf));
1.596 - */
1.597 + /*
1.598 + g_debug ("Running [%s]\n"
1.599 + "\tTOFFSET [%"G_GUINT64_FORMAT"]\n"
1.600 + "\tB_TSTAMP [%"G_GUINT64_FORMAT"]\n"
1.601 + "\tB_DURATION [%"G_GUINT64_FORMAT"]\n"
1.602 + "\tOFFSET [%"G_GUINT64_FORMAT"]\n"
1.603 + "\tB_OFFSET [%"G_GUINT64_FORMAT"]",
1.604 + gst_element_get_name (mux),
1.605 + mux->timeoffset,
1.606 + GST_BUFFER_TIMESTAMP (databuf),
1.607 + GST_BUFFER_DURATION (databuf),
1.608 + mux->offset,
1.609 + GST_BUFFER_OFFSET (databuf));
1.610 + */
1.611
1.612
1.613 - if (mux->resync) {
1.614 - g_debug ("RESYNC [%s]", gst_element_get_name (mux));
1.615 - mux->timeoffset += GST_BUFFER_TIMESTAMP (databuf);
1.616 - GST_BUFFER_TIMESTAMP (databuf) = mux->timeoffset;
1.617 - mux->timeoffset += GST_BUFFER_DURATION (databuf);
1.618 + if (mux->resync)
1.619 + {
1.620 + g_debug("RESYNC [%s]", gst_element_get_name(mux));
1.621 + mux->timeoffset += GST_BUFFER_TIMESTAMP(databuf);
1.622 + GST_BUFFER_TIMESTAMP(databuf) = mux->timeoffset;
1.623 + mux->timeoffset += GST_BUFFER_DURATION(databuf);
1.624
1.625 - mux->offset += GST_BUFFER_OFFSET (databuf);
1.626 - GST_BUFFER_OFFSET (databuf) = mux->offset;
1.627 - mux->offset += GST_BUFFER_SIZE (databuf);
1.628 - mux->resync = FALSE;
1.629 - } else {
1.630 + mux->offset += GST_BUFFER_OFFSET(databuf);
1.631 + GST_BUFFER_OFFSET(databuf) = mux->offset;
1.632 + mux->offset += GST_BUFFER_SIZE(databuf);
1.633 + mux->resync = FALSE;
1.634 + }
1.635 + else
1.636 + {
1.637
1.638 - GST_BUFFER_TIMESTAMP (databuf) = mux->timeoffset;
1.639 - mux->timeoffset += GST_BUFFER_DURATION (databuf);
1.640 + GST_BUFFER_TIMESTAMP(databuf) = mux->timeoffset;
1.641 + mux->timeoffset += GST_BUFFER_DURATION(databuf);
1.642
1.643 - GST_BUFFER_OFFSET (databuf) = mux->offset;
1.644 - mux->offset += GST_BUFFER_SIZE (databuf);
1.645 - }
1.646 + GST_BUFFER_OFFSET(databuf) = mux->offset;
1.647 + mux->offset += GST_BUFFER_SIZE(databuf);
1.648 + }
1.649
1.650 - gst_buffer_set_caps (databuf, GST_PAD_CAPS (pad));
1.651 - ret = gst_pad_push (mux->srcpad, databuf);
1.652 + gst_buffer_set_caps(databuf, GST_PAD_CAPS(pad));
1.653 + ret = gst_pad_push(mux->srcpad, databuf);
1.654
1.655 - //gst_buffer_unref (buf);
1.656 + //gst_buffer_unref (buf);
1.657
1.658 - g_mutex_unlock (mutex);
1.659 + g_mutex_unlock(mutex);
1.660 return ret;
1.661 /*
1.662 nego_error:
1.663 @@ -474,69 +496,71 @@
1.664 return GST_FLOW_NOT_NEGOTIATED;
1.665 }
1.666 */
1.667 - /*
1.668 -no_caps:
1.669 - {
1.670 + /*
1.671 + no_caps:
1.672 + {
1.673 GST_WARNING_OBJECT (mux, "no caps on the incoming buffer %p", best->buffer);
1.674 GST_ELEMENT_ERROR (mux, CORE, NEGOTIATION, (NULL), (NULL));
1.675 ret = GST_FLOW_NOT_NEGOTIATED;
1.676 goto beach;
1.677 - }
1.678 + }
1.679 */
1.680 }
1.681
1.682 static GstStateChangeReturn
1.683 -gst_concat_mux_change_state (GstElement * element, GstStateChange transition)
1.684 +gst_concat_mux_change_state(GstElement * element, GstStateChange transition)
1.685 {
1.686 GstConcatMux *concat_mux;
1.687 GstStateChangeReturn ret;
1.688
1.689 - concat_mux = GST_CONCAT_MUX (element);
1.690 + concat_mux = GST_CONCAT_MUX(element);
1.691
1.692 - switch (transition) {
1.693 - case GST_STATE_CHANGE_READY_TO_PAUSED:
1.694 - concat_mux->done = FALSE;
1.695 - concat_mux->resync = TRUE;
1.696 - GST_DEBUG_OBJECT (concat_mux, "starting collect pads");
1.697 - break;
1.698 - case GST_STATE_CHANGE_PAUSED_TO_READY:
1.699 - GST_DEBUG_OBJECT (concat_mux, "stopping collect pads");
1.700 - gst_concat_mux_clear (concat_mux);
1.701 - break;
1.702 - default:
1.703 - break;
1.704 - }
1.705 + switch (transition)
1.706 + {
1.707 + case GST_STATE_CHANGE_READY_TO_PAUSED:
1.708 + concat_mux->done = FALSE;
1.709 + concat_mux->resync = TRUE;
1.710 + GST_DEBUG_OBJECT(concat_mux, "starting collect pads");
1.711 + break;
1.712 + case GST_STATE_CHANGE_PAUSED_TO_READY:
1.713 + GST_DEBUG_OBJECT(concat_mux, "stopping collect pads");
1.714 + gst_concat_mux_clear(concat_mux);
1.715 + break;
1.716 + default:
1.717 + break;
1.718 + }
1.719
1.720 - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
1.721 + ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
1.722 if (ret == GST_STATE_CHANGE_FAILURE)
1.723 - return ret;
1.724 + return ret;
1.725
1.726 - switch (transition) {
1.727 - default:
1.728 - break;
1.729 - }
1.730 + switch (transition)
1.731 + {
1.732 + default:
1.733 + break;
1.734 + }
1.735
1.736 return ret;
1.737 }
1.738
1.739 gboolean
1.740 -gst_concat_mux_plugin_init (GstPlugin * plugin)
1.741 +gst_concat_mux_plugin_init(GstPlugin * plugin)
1.742 {
1.743 #ifdef ENABLE_NLS
1.744 - setlocale (LC_ALL, "");
1.745 - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1.746 + setlocale(LC_ALL, "");
1.747 + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
1.748 #endif /* ENABLE_NLS */
1.749
1.750 - GST_DEBUG_CATEGORY_INIT (gst_concat_mux_debug, "concatmux", 0,
1.751 - "concat muxer");
1.752 -
1.753 - return gst_element_register (plugin, "concatmux", GST_RANK_NONE,
1.754 - GST_TYPE_CONCAT_MUX);
1.755 + GST_DEBUG_CATEGORY_INIT(gst_concat_mux_debug, "concatmux", 0,
1.756 + "concat muxer");
1.757 +
1.758 + return gst_element_register(plugin, "concatmux", GST_RANK_NONE,
1.759 + GST_TYPE_CONCAT_MUX);
1.760 }
1.761
1.762 -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
1.763 - GST_VERSION_MINOR,
1.764 - "concatmux",
1.765 - "Concat streamers",
1.766 - gst_concat_mux_plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
1.767 -
1.768 +GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
1.769 + GST_VERSION_MINOR,
1.770 + "concatmux",
1.771 + "Concat streamers",
1.772 + gst_concat_mux_plugin_init, VERSION, GST_LICENSE,
1.773 + GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)