1.1 --- a/gst-gmyth/concatmux/gstconcatmux.c Thu Jun 14 18:19:52 2007 +0100
1.2 +++ b/gst-gmyth/concatmux/gstconcatmux.c Thu Jun 14 18:21:08 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)
2.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Thu Jun 14 18:19:52 2007 +0100
2.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Thu Jun 14 18:21:08 2007 +0100
2.3 @@ -84,7 +84,7 @@
2.4 #include <string.h>
2.5 #include <unistd.h>
2.6
2.7 -GST_DEBUG_CATEGORY_STATIC (mythtvsrc_debug);
2.8 +GST_DEBUG_CATEGORY_STATIC(mythtvsrc_debug);
2.9 #define GST_CAT_DEFAULT mythtvsrc_debug
2.10
2.11 #define GST_GMYTHTV_ID_NUM 1
2.12 @@ -108,17 +108,17 @@
2.13 #define INTERNAL_BUFFER_SIZE (90*1024)
2.14
2.15 static const GstElementDetails gst_mythtv_src_details =
2.16 -GST_ELEMENT_DETAILS ("MythTV client source",
2.17 - "Source/Network",
2.18 - "Control and receive data as a client over the network "
2.19 - "via raw socket connections using the MythTV protocol",
2.20 - "Rosfran Borges <rosfran.borges@indt.org.br>");
2.21 +GST_ELEMENT_DETAILS("MythTV client source",
2.22 + "Source/Network",
2.23 + "Control and receive data as a client over the network "
2.24 + "via raw socket connections using the MythTV protocol",
2.25 + "Rosfran Borges <rosfran.borges@indt.org.br>");
2.26
2.27 -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
2.28 - GST_PAD_SRC,
2.29 - GST_PAD_ALWAYS,
2.30 - GST_STATIC_CAPS_ANY );
2.31 - /* GST_STATIC_CAPS ("video/x-nuv")); */
2.32 +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE("src",
2.33 + GST_PAD_SRC,
2.34 + GST_PAD_ALWAYS,
2.35 + GST_STATIC_CAPS_ANY);
2.36 + /* GST_STATIC_CAPS ("video/x-nuv")); */
2.37
2.38 enum
2.39 {
2.40 @@ -136,71 +136,73 @@
2.41 PROP_GMYTHTV_MAX_TRY
2.42 };
2.43
2.44 -static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src);
2.45 +static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src);
2.46
2.47 -static void gst_mythtv_src_finalize (GObject * gobject);
2.48 +static void gst_mythtv_src_finalize(GObject * gobject);
2.49
2.50 -static GstFlowReturn gst_mythtv_src_create (GstPushSrc * psrc,
2.51 - GstBuffer ** outbuf);
2.52 +static GstFlowReturn gst_mythtv_src_create(GstPushSrc * psrc,
2.53 + GstBuffer ** outbuf);
2.54
2.55 -static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
2.56 -static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
2.57 -static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
2.58 -static gboolean gst_mythtv_src_is_seekable (GstBaseSrc * push_src);
2.59 +static gboolean gst_mythtv_src_start(GstBaseSrc * bsrc);
2.60 +static gboolean gst_mythtv_src_stop(GstBaseSrc * bsrc);
2.61 +static gboolean gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size);
2.62 +static gboolean gst_mythtv_src_is_seekable(GstBaseSrc * push_src);
2.63
2.64 -static gboolean gst_mythtv_src_do_seek (GstBaseSrc * base,
2.65 - GstSegment * segment);
2.66 +static gboolean gst_mythtv_src_do_seek(GstBaseSrc * base,
2.67 + GstSegment * segment);
2.68
2.69 static GstStateChangeReturn
2.70 -gst_mythtv_src_change_state (GstElement * element, GstStateChange transition);
2.71 +gst_mythtv_src_change_state(GstElement * element, GstStateChange transition);
2.72
2.73 -static void gst_mythtv_src_set_property (GObject * object, guint prop_id,
2.74 - const GValue * value, GParamSpec * pspec);
2.75 -static void gst_mythtv_src_get_property (GObject * object, guint prop_id,
2.76 - GValue * value, GParamSpec * pspec);
2.77 +static void gst_mythtv_src_set_property(GObject * object, guint prop_id,
2.78 + const GValue * value,
2.79 + GParamSpec * pspec);
2.80 +static void gst_mythtv_src_get_property(GObject * object, guint prop_id,
2.81 + GValue * value, GParamSpec * pspec);
2.82
2.83 -static void gst_mythtv_src_uri_handler_init (gpointer g_iface,
2.84 - gpointer iface_data);
2.85 +static void gst_mythtv_src_uri_handler_init(gpointer g_iface,
2.86 + gpointer iface_data);
2.87
2.88 -static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query);
2.89 +static gboolean gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query);
2.90
2.91 -static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
2.92 +static gboolean gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event);
2.93
2.94 -static GMythFileReadResult do_read_request_response (GstMythtvSrc * src, guint size,
2.95 - GByteArray * data_ptr);
2.96 +static GMythFileReadResult do_read_request_response(GstMythtvSrc * src,
2.97 + guint size,
2.98 + GByteArray * data_ptr);
2.99
2.100 static void
2.101 -_urihandler_init (GType type)
2.102 +_urihandler_init(GType type)
2.103 {
2.104 static const GInterfaceInfo urihandler_info = {
2.105 - gst_mythtv_src_uri_handler_init,
2.106 - NULL,
2.107 - NULL
2.108 + gst_mythtv_src_uri_handler_init,
2.109 + NULL,
2.110 + NULL
2.111 };
2.112
2.113 - g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
2.114 + g_type_add_interface_static(type, GST_TYPE_URI_HANDLER, &urihandler_info);
2.115
2.116 - GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
2.117 + GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
2.118 }
2.119
2.120 -GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
2.121 - GST_TYPE_PUSH_SRC, _urihandler_init)
2.122 +GST_BOILERPLATE_FULL(GstMythtvSrc, gst_mythtv_src, GstPushSrc,
2.123 + GST_TYPE_PUSH_SRC, _urihandler_init)
2.124 + static void gst_mythtv_src_base_init(gpointer g_class)
2.125 +{
2.126 + GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
2.127
2.128 - static void gst_mythtv_src_base_init (gpointer g_class)
2.129 -{
2.130 - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
2.131 + gst_element_class_add_pad_template(element_class,
2.132 + gst_static_pad_template_get
2.133 + (&srctemplate));
2.134
2.135 - gst_element_class_add_pad_template (element_class,
2.136 - gst_static_pad_template_get (&srctemplate));
2.137 -
2.138 - gst_element_class_set_details (element_class, &gst_mythtv_src_details);
2.139 + gst_element_class_set_details(element_class, &gst_mythtv_src_details);
2.140
2.141 element_class->change_state = gst_mythtv_src_change_state;
2.142
2.143 }
2.144
2.145 static void
2.146 -gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
2.147 +gst_mythtv_src_class_init(GstMythtvSrcClass * klass)
2.148 {
2.149 GObjectClass *gobject_class;
2.150 GstPushSrcClass *gstpushsrc_class;
2.151 @@ -215,60 +217,64 @@
2.152 gobject_class->finalize = gst_mythtv_src_finalize;
2.153
2.154 g_object_class_install_property
2.155 - (gobject_class, PROP_LOCATION,
2.156 - g_param_spec_string ("location", "Location",
2.157 - "The location. In the form:"
2.158 - "\n\t\t\tmyth://a.com/file.nuv"
2.159 - "\n\t\t\tmyth://a.com:23223/file.nuv "
2.160 - "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
2.161 - "", G_PARAM_READWRITE));
2.162 + (gobject_class, PROP_LOCATION,
2.163 + g_param_spec_string("location", "Location",
2.164 + "The location. In the form:"
2.165 + "\n\t\t\tmyth://a.com/file.nuv"
2.166 + "\n\t\t\tmyth://a.com:23223/file.nuv "
2.167 + "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
2.168 + "", G_PARAM_READWRITE));
2.169
2.170 g_object_class_install_property
2.171 - (gobject_class, PROP_GMYTHTV_VERSION,
2.172 - g_param_spec_int ("mythtv-version", "mythtv-version",
2.173 - "Change MythTV version", 26, 30, 26, G_PARAM_READWRITE));
2.174 + (gobject_class, PROP_GMYTHTV_VERSION,
2.175 + g_param_spec_int("mythtv-version", "mythtv-version",
2.176 + "Change MythTV version", 26, 30, 26,
2.177 + G_PARAM_READWRITE));
2.178
2.179 g_object_class_install_property
2.180 - (gobject_class, PROP_GMYTHTV_LIVEID,
2.181 - g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
2.182 - "Change MythTV version",
2.183 - 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
2.184 + (gobject_class, PROP_GMYTHTV_LIVEID,
2.185 + g_param_spec_int("mythtv-live-id", "mythtv-live-id",
2.186 + "Change MythTV version",
2.187 + 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
2.188
2.189 g_object_class_install_property
2.190 - (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
2.191 - g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
2.192 - "Sets the MythTV chain ID (from TV Chain)", "", G_PARAM_READWRITE));
2.193 + (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
2.194 + g_param_spec_string("mythtv-live-chainid", "mythtv-live-chainid",
2.195 + "Sets the MythTV chain ID (from TV Chain)", "",
2.196 + G_PARAM_READWRITE));
2.197
2.198 g_object_class_install_property
2.199 - (gobject_class, PROP_GMYTHTV_LIVE,
2.200 - g_param_spec_boolean ("mythtv-live", "mythtv-live",
2.201 - "Enable MythTV Live TV content streaming", FALSE, G_PARAM_READWRITE));
2.202 + (gobject_class, PROP_GMYTHTV_LIVE,
2.203 + g_param_spec_boolean("mythtv-live", "mythtv-live",
2.204 + "Enable MythTV Live TV content streaming", FALSE,
2.205 + G_PARAM_READWRITE));
2.206
2.207 g_object_class_install_property
2.208 - (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
2.209 - g_param_spec_boolean ("mythtv-enable-timing-position",
2.210 - "mythtv-enable-timing-position",
2.211 - "Enable MythTV Live TV content size continuous updating", FALSE,
2.212 - G_PARAM_READWRITE));
2.213 + (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
2.214 + g_param_spec_boolean("mythtv-enable-timing-position",
2.215 + "mythtv-enable-timing-position",
2.216 + "Enable MythTV Live TV content size continuous updating",
2.217 + FALSE, G_PARAM_READWRITE));
2.218
2.219 g_object_class_install_property
2.220 - (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
2.221 - g_param_spec_string ("mythtv-channel", "mythtv-channel",
2.222 - "Change MythTV channel number",
2.223 - "", G_PARAM_READWRITE));
2.224 + (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
2.225 + g_param_spec_string("mythtv-channel", "mythtv-channel",
2.226 + "Change MythTV channel number",
2.227 + "", G_PARAM_READWRITE));
2.228
2.229 g_object_class_install_property
2.230 - (gobject_class, PROP_GMYTHTV_MAX_TRY,
2.231 - g_param_spec_int ("max-try", "max-try",
2.232 - "Set the max try for get MythTV free recorder",
2.233 - 0, G_MAXINT, 10, G_PARAM_READWRITE));
2.234 + (gobject_class, PROP_GMYTHTV_MAX_TRY,
2.235 + g_param_spec_int("max-try", "max-try",
2.236 + "Set the max try for get MythTV free recorder",
2.237 + 0, G_MAXINT, 10, G_PARAM_READWRITE));
2.238
2.239
2.240 #ifndef GST_DISABLE_GST_DEBUG
2.241 g_object_class_install_property
2.242 - (gobject_class, PROP_GMYTHTV_DBG,
2.243 - g_param_spec_boolean ("mythtv-debug", "mythtv-debug",
2.244 - "Enable MythTV debug messages", FALSE, G_PARAM_READWRITE));
2.245 + (gobject_class, PROP_GMYTHTV_DBG,
2.246 + g_param_spec_boolean("mythtv-debug", "mythtv-debug",
2.247 + "Enable MythTV debug messages", FALSE,
2.248 + G_PARAM_READWRITE));
2.249 #endif
2.250
2.251 gstbasesrc_class->start = gst_mythtv_src_start;
2.252 @@ -279,12 +285,12 @@
2.253 gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
2.254 gstpushsrc_class->create = gst_mythtv_src_create;
2.255
2.256 - GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
2.257 - "MythTV Client Source");
2.258 + GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0,
2.259 + "MythTV Client Source");
2.260 }
2.261
2.262 static void
2.263 -gst_mythtv_src_init (GstMythtvSrc * this, GstMythtvSrcClass * g_class)
2.264 +gst_mythtv_src_init(GstMythtvSrc * this, GstMythtvSrcClass * g_class)
2.265 {
2.266 this->file = NULL;
2.267
2.268 @@ -308,7 +314,7 @@
2.269 this->enable_timing_position = FALSE;
2.270 this->update_prog_chain = FALSE;
2.271
2.272 - this->user_agent = g_strdup ("mythtvsrc");
2.273 + this->user_agent = g_strdup("mythtvsrc");
2.274 this->update_prog_chain = FALSE;
2.275
2.276 this->channel_name = NULL;
2.277 @@ -319,114 +325,132 @@
2.278
2.279 this->wait_to_transfer = 0;
2.280
2.281 - gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES);
2.282 + gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES);
2.283
2.284 - gst_pad_set_event_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
2.285 - gst_mythtv_src_handle_event);
2.286 - gst_pad_set_query_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
2.287 - gst_mythtv_src_handle_query);
2.288 + gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.289 + gst_mythtv_src_handle_event);
2.290 + gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.291 + gst_mythtv_src_handle_query);
2.292
2.293 }
2.294
2.295 static void
2.296 -gst_mythtv_src_clear (GstMythtvSrc *mythtv_src)
2.297 +gst_mythtv_src_clear(GstMythtvSrc * mythtv_src)
2.298 {
2.299 mythtv_src->unique_setup = FALSE;
2.300
2.301 - if (mythtv_src->spawn_livetv) {
2.302 - g_object_unref (mythtv_src->spawn_livetv);
2.303 - mythtv_src->spawn_livetv = NULL;
2.304 - }
2.305 + if (mythtv_src->spawn_livetv)
2.306 + {
2.307 + g_object_unref(mythtv_src->spawn_livetv);
2.308 + mythtv_src->spawn_livetv = NULL;
2.309 + }
2.310
2.311 - if (mythtv_src->file) {
2.312 - g_object_unref (mythtv_src->file);
2.313 - mythtv_src->file = NULL;
2.314 - }
2.315 + if (mythtv_src->file)
2.316 + {
2.317 + g_object_unref(mythtv_src->file);
2.318 + mythtv_src->file = NULL;
2.319 + }
2.320
2.321 - if (mythtv_src->backend_info) {
2.322 - g_object_unref (mythtv_src->backend_info);
2.323 - mythtv_src->backend_info = NULL;
2.324 - }
2.325 + if (mythtv_src->backend_info)
2.326 + {
2.327 + g_object_unref(mythtv_src->backend_info);
2.328 + mythtv_src->backend_info = NULL;
2.329 + }
2.330
2.331 - if (mythtv_src->bytes_queue) {
2.332 - g_byte_array_free (mythtv_src->bytes_queue, TRUE);
2.333 - mythtv_src->bytes_queue = NULL;
2.334 - }
2.335 + if (mythtv_src->bytes_queue)
2.336 + {
2.337 + g_byte_array_free(mythtv_src->bytes_queue, TRUE);
2.338 + mythtv_src->bytes_queue = NULL;
2.339 + }
2.340 }
2.341
2.342 static void
2.343 -gst_mythtv_src_finalize (GObject * gobject)
2.344 +gst_mythtv_src_finalize(GObject * gobject)
2.345 {
2.346 - GstMythtvSrc *this = GST_MYTHTV_SRC (gobject);
2.347 + GstMythtvSrc *this = GST_MYTHTV_SRC(gobject);
2.348
2.349 - gst_mythtv_src_clear (this);
2.350 + gst_mythtv_src_clear(this);
2.351
2.352 - if (this->uri_name) {
2.353 - g_free (this->uri_name);
2.354 - this->uri_name = NULL;
2.355 - }
2.356 + if (this->uri_name)
2.357 + {
2.358 + g_free(this->uri_name);
2.359 + this->uri_name = NULL;
2.360 + }
2.361
2.362 - if (this->user_agent) {
2.363 - g_free (this->user_agent);
2.364 - this->user_agent = NULL;
2.365 - }
2.366 + if (this->user_agent)
2.367 + {
2.368 + g_free(this->user_agent);
2.369 + this->user_agent = NULL;
2.370 + }
2.371
2.372 - G_OBJECT_CLASS (parent_class)->finalize (gobject);
2.373 + G_OBJECT_CLASS(parent_class)->finalize(gobject);
2.374 }
2.375
2.376 static GMythFileReadResult
2.377 -do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr)
2.378 +do_read_request_response(GstMythtvSrc * src, guint size,
2.379 + GByteArray * data_ptr)
2.380 {
2.381 gint read = 0;
2.382 guint sizetoread = size;
2.383 gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
2.384 GMythFileReadResult result;
2.385
2.386 - GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread);
2.387 + GST_LOG_OBJECT(src, "Starting: Reading %d bytes...", sizetoread);
2.388
2.389 - /* Loop sending the Myth File Transfer request:
2.390 - * Retry whilst authentication fails and we supply it. */
2.391 + /* Loop sending the Myth File Transfer request:
2.392 + * Retry whilst authentication fails and we supply it. */
2.393
2.394 - while (sizetoread == size && --max_iters > 0) {
2.395 - /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
2.396 - if ( IS_GMYTH_FILE_LOCAL(src->file) )
2.397 - result = gmyth_file_local_read ( GMYTH_FILE_LOCAL(src->file),
2.398 - data_ptr, sizetoread, src->live_tv);
2.399 - else if ( IS_GMYTH_FILE_TRANSFER(src->file) )
2.400 - result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(src->file),
2.401 - data_ptr, sizetoread, src->live_tv );
2.402 + while (sizetoread == size && --max_iters > 0)
2.403 + {
2.404 + /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
2.405 + if (IS_GMYTH_FILE_LOCAL(src->file))
2.406 + result = gmyth_file_local_read(GMYTH_FILE_LOCAL(src->file),
2.407 + data_ptr, sizetoread, src->live_tv);
2.408 + else if (IS_GMYTH_FILE_TRANSFER(src->file))
2.409 + result = gmyth_file_transfer_read(GMYTH_FILE_TRANSFER(src->file),
2.410 + data_ptr, sizetoread, src->live_tv);
2.411
2.412 - if (data_ptr->len > 0) {
2.413 - read += data_ptr->len;
2.414 - sizetoread -= data_ptr->len;
2.415 - } else if (data_ptr->len <= 0) {
2.416 - if (src->live_tv == FALSE) {
2.417 - result = GMYTH_FILE_READ_EOF;
2.418 - goto eos;
2.419 - } else {
2.420 - if (result == GMYTH_FILE_READ_ERROR) { /* -314 */
2.421 - GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!");
2.422 - goto done;
2.423 - } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315 */
2.424 - GST_INFO_OBJECT (src,
2.425 - "[LiveTV] FileTransfer - Go to athe next program chain!");
2.426 - src->update_prog_chain = TRUE;
2.427 - continue;
2.428 - }
2.429 - goto done;
2.430 - }
2.431 + if (data_ptr->len > 0)
2.432 + {
2.433 + read += data_ptr->len;
2.434 + sizetoread -= data_ptr->len;
2.435 + }
2.436 + else if (data_ptr->len <= 0)
2.437 + {
2.438 + if (src->live_tv == FALSE)
2.439 + {
2.440 + result = GMYTH_FILE_READ_EOF;
2.441 + goto eos;
2.442 + }
2.443 + else
2.444 + {
2.445 + if (result == GMYTH_FILE_READ_ERROR)
2.446 + { /* -314 */
2.447 + GST_INFO_OBJECT(src, "[LiveTV] FileTransfer READ_ERROR!");
2.448 + goto done;
2.449 + }
2.450 + else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)
2.451 + { /* -315 */
2.452 + GST_INFO_OBJECT(src,
2.453 + "[LiveTV] FileTransfer - Go to athe next program chain!");
2.454 + src->update_prog_chain = TRUE;
2.455 + continue;
2.456 + }
2.457 + goto done;
2.458 + }
2.459
2.460 - } /* else if (data_ptr->len == 0)
2.461 - goto done;*/
2.462 + } /* else if (data_ptr->len == 0)
2.463 + goto done; */
2.464
2.465 - if (read == sizetoread)
2.466 - goto done;
2.467 - }
2.468 + if (read == sizetoread)
2.469 + goto done;
2.470 + }
2.471
2.472 - if ((read < 0 && !src->live_tv) || max_iters == 0) {
2.473 - result = GMYTH_FILE_READ_EOF;
2.474 - goto eos;
2.475 - }
2.476 + if ((read < 0 && !src->live_tv) || max_iters == 0)
2.477 + {
2.478 + result = GMYTH_FILE_READ_EOF;
2.479 + goto eos;
2.480 + }
2.481
2.482 goto done;
2.483
2.484 @@ -438,471 +462,532 @@
2.485 }
2.486
2.487 static GstFlowReturn
2.488 -gst_mythtv_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
2.489 +gst_mythtv_src_create(GstPushSrc * psrc, GstBuffer ** outbuf)
2.490 {
2.491 GstMythtvSrc *src;
2.492 GstFlowReturn ret = GST_FLOW_OK;
2.493 guint buffer_size_inter = 0;
2.494
2.495 - src = GST_MYTHTV_SRC (psrc);
2.496 + src = GST_MYTHTV_SRC(psrc);
2.497
2.498 - /* The caller should know the number of bytes and not read beyond EOS. */
2.499 - if (G_UNLIKELY (src->eos))
2.500 - goto eos;
2.501 - GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
2.502 - src->read_offset, MAX_READ_SIZE);
2.503 + /* The caller should know the number of bytes and not read beyond EOS. */
2.504 + if (G_UNLIKELY(src->eos))
2.505 + goto eos;
2.506 + GST_DEBUG_OBJECT(src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
2.507 + src->read_offset, MAX_READ_SIZE);
2.508
2.509 - GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.",
2.510 - (gint) src->buffer_remain, src->bytes_queue->len);
2.511 + GST_DEBUG_OBJECT(src, "Create: buffer_remain: %d, buffer_size = %d.",
2.512 + (gint) src->buffer_remain, src->bytes_queue->len);
2.513
2.514 program_chain_changed:
2.515 - /* just get from the byte array, no network effort... */
2.516 - if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) {
2.517 - GByteArray *buffer;
2.518 - GMythFileReadResult result = GMYTH_FILE_READ_OK;
2.519 -
2.520 - buffer = NULL;
2.521 - buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
2.522 + /* just get from the byte array, no network effort... */
2.523 + if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE)
2.524 + {
2.525 + GByteArray *buffer;
2.526 + GMythFileReadResult result = GMYTH_FILE_READ_OK;
2.527
2.528 - if (buffer_size_inter > REQUEST_MAX_SIZE)
2.529 - buffer_size_inter = REQUEST_MAX_SIZE;
2.530 + buffer = NULL;
2.531 + buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
2.532
2.533 - buffer = g_byte_array_new ();
2.534 + if (buffer_size_inter > REQUEST_MAX_SIZE)
2.535 + buffer_size_inter = REQUEST_MAX_SIZE;
2.536
2.537 - result = do_read_request_response (src, buffer_size_inter, buffer);
2.538 + buffer = g_byte_array_new();
2.539
2.540 - /* got the next program info? */
2.541 - if (G_UNLIKELY (src->update_prog_chain) || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) {
2.542 - GST_DEBUG_OBJECT (src, "Update PROGRAM CHAIN!!! buffer_size = %d.",
2.543 - src->bytes_queue->len);
2.544 - gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.545 - gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM, NULL));
2.546 + result = do_read_request_response(src, buffer_size_inter, buffer);
2.547 +
2.548 + /* got the next program info? */
2.549 + if (G_UNLIKELY(src->update_prog_chain)
2.550 + || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
2.551 + {
2.552 + GST_DEBUG_OBJECT(src, "Update PROGRAM CHAIN!!! buffer_size = %d.",
2.553 + src->bytes_queue->len);
2.554 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
2.555 + gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM,
2.556 + NULL));
2.557 /*
2.558 gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.559 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
2.560 */
2.561 - src->update_prog_chain = FALSE;
2.562 - src->eos = FALSE;
2.563 + src->update_prog_chain = FALSE;
2.564 + src->eos = FALSE;
2.565
2.566 - if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
2.567 - /*
2.568 - if (buffer != NULL) {
2.569 - g_byte_array_free (buffer, TRUE);
2.570 - buffer = NULL;
2.571 - }
2.572 - goto program_chain_changed; */
2.573 - } else if (result == GMYTH_FILE_READ_OK) {
2.574 - /* remove wasteful, NUV file header data */
2.575 - /* buffer = g_byte_array_remove_range( buffer, 0, 512 ); */
2.576 - /* TODO: need to send a new segment event to NUVDemux? */
2.577 - //gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.578 - // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
2.579 + if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)
2.580 + {
2.581 + /*
2.582 + if (buffer != NULL) {
2.583 + g_byte_array_free (buffer, TRUE);
2.584 + buffer = NULL;
2.585 + }
2.586 + goto program_chain_changed; */
2.587 + }
2.588 + else if (result == GMYTH_FILE_READ_OK)
2.589 + {
2.590 + /* remove wasteful, NUV file header data */
2.591 + /* buffer = g_byte_array_remove_range( buffer, 0, 512 ); */
2.592 + /* TODO: need to send a new segment event to NUVDemux? */
2.593 + //gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.594 + // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
2.595
2.596 - /* goto change_progchain; */
2.597 - }
2.598 + /* goto change_progchain; */
2.599 + }
2.600
2.601 - } /* */
2.602 + } /* */
2.603
2.604 - if (G_UNLIKELY (buffer->len < 0)) {
2.605 -
2.606 - if (buffer != NULL) {
2.607 - g_byte_array_free (buffer, TRUE);
2.608 - buffer = NULL;
2.609 - }
2.610 -
2.611 - if (src->live_tv || ( result == GMYTH_FILE_READ_NEXT_PROG_CHAIN ))
2.612 - goto change_progchain;
2.613 - else
2.614 - goto read_error;
2.615 - } else if (G_UNLIKELY (buffer->len == 0)) {
2.616 -
2.617 - if (buffer != NULL) {
2.618 - g_byte_array_free (buffer, TRUE);
2.619 - buffer = NULL;
2.620 - }
2.621 -
2.622 - if (!src->live_tv)
2.623 - goto done;
2.624 - else
2.625 - goto program_chain_changed;
2.626 - }
2.627 + if (G_UNLIKELY(buffer->len < 0))
2.628 + {
2.629
2.630 - src->bytes_queue =
2.631 - g_byte_array_append (src->bytes_queue, buffer->data, buffer->len);
2.632 - if (buffer->len > buffer_size_inter)
2.633 - GST_WARNING_OBJECT (src,
2.634 - "INCREASED buffer size! Backend sent more than we ask him... (%d)",
2.635 - abs (buffer->len - buffer_size_inter));
2.636 + if (buffer != NULL)
2.637 + {
2.638 + g_byte_array_free(buffer, TRUE);
2.639 + buffer = NULL;
2.640 + }
2.641
2.642 - src->buffer_remain += buffer->len;
2.643 + if (src->live_tv || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
2.644 + goto change_progchain;
2.645 + else
2.646 + goto read_error;
2.647 + }
2.648 + else if (G_UNLIKELY(buffer->len == 0))
2.649 + {
2.650
2.651 - if (buffer != NULL) {
2.652 - g_byte_array_free (buffer, TRUE);
2.653 - buffer = NULL;
2.654 - }
2.655 + if (buffer != NULL)
2.656 + {
2.657 + g_byte_array_free(buffer, TRUE);
2.658 + buffer = NULL;
2.659 + }
2.660
2.661 - /*
2.662 - GST_DEBUG_OBJECT (src,
2.663 - "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "
2.664 - "OFFSET = %llu, CONTENT SIZE = %llu.", read,
2.665 - src->bytes_read, src->read_offset, src->content_size);
2.666 - */
2.667 - }
2.668 + if (!src->live_tv)
2.669 + goto done;
2.670 + else
2.671 + goto program_chain_changed;
2.672 + }
2.673 +
2.674 + src->bytes_queue =
2.675 + g_byte_array_append(src->bytes_queue, buffer->data, buffer->len);
2.676 + if (buffer->len > buffer_size_inter)
2.677 + GST_WARNING_OBJECT(src,
2.678 + "INCREASED buffer size! Backend sent more than we ask him... (%d)",
2.679 + abs(buffer->len - buffer_size_inter));
2.680 +
2.681 + src->buffer_remain += buffer->len;
2.682 +
2.683 + if (buffer != NULL)
2.684 + {
2.685 + g_byte_array_free(buffer, TRUE);
2.686 + buffer = NULL;
2.687 + }
2.688 +
2.689 + /*
2.690 + GST_DEBUG_OBJECT (src,
2.691 + "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "
2.692 + "OFFSET = %llu, CONTENT SIZE = %llu.", read,
2.693 + src->bytes_read, src->read_offset, src->content_size);
2.694 + */
2.695 + }
2.696
2.697 guint buffer_size =
2.698 - (src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
2.699 + (src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
2.700
2.701 - *outbuf = gst_buffer_new ();
2.702 + *outbuf = gst_buffer_new();
2.703
2.704 - /*
2.705 - GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
2.706 - (buffer_size_inter ==
2.707 - 0) ? "NO, got from buffer" : "YES, go see the backend's log file",
2.708 - src->buffer_remain);
2.709 - */
2.710 + /*
2.711 + GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
2.712 + (buffer_size_inter ==
2.713 + 0) ? "NO, got from buffer" : "YES, go see the backend's log file",
2.714 + src->buffer_remain);
2.715 + */
2.716
2.717 - GST_BUFFER_SIZE (*outbuf) = buffer_size;
2.718 - GST_BUFFER_MALLOCDATA (*outbuf) = g_malloc0 (GST_BUFFER_SIZE (*outbuf));
2.719 - GST_BUFFER_DATA (*outbuf) = GST_BUFFER_MALLOCDATA (*outbuf);
2.720 - g_memmove (GST_BUFFER_DATA ((*outbuf)), src->bytes_queue->data,
2.721 - GST_BUFFER_SIZE (*outbuf));
2.722 - GST_BUFFER_OFFSET (*outbuf) = src->read_offset;
2.723 - GST_BUFFER_OFFSET_END (*outbuf) =
2.724 - src->read_offset + GST_BUFFER_SIZE (*outbuf);
2.725 + GST_BUFFER_SIZE(*outbuf) = buffer_size;
2.726 + GST_BUFFER_MALLOCDATA(*outbuf) = g_malloc0(GST_BUFFER_SIZE(*outbuf));
2.727 + GST_BUFFER_DATA(*outbuf) = GST_BUFFER_MALLOCDATA(*outbuf);
2.728 + g_memmove(GST_BUFFER_DATA((*outbuf)), src->bytes_queue->data,
2.729 + GST_BUFFER_SIZE(*outbuf));
2.730 + GST_BUFFER_OFFSET(*outbuf) = src->read_offset;
2.731 + GST_BUFFER_OFFSET_END(*outbuf) =
2.732 + src->read_offset + GST_BUFFER_SIZE(*outbuf);
2.733
2.734 - src->buffer_remain -= GST_BUFFER_SIZE (*outbuf);
2.735 + src->buffer_remain -= GST_BUFFER_SIZE(*outbuf);
2.736
2.737 - src->read_offset += GST_BUFFER_SIZE (*outbuf);
2.738 - src->bytes_read += GST_BUFFER_SIZE (*outbuf);
2.739 - //GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
2.740 - // GST_BUFFER_SIZE (*outbuf));
2.741 + src->read_offset += GST_BUFFER_SIZE(*outbuf);
2.742 + src->bytes_read += GST_BUFFER_SIZE(*outbuf);
2.743 + //GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
2.744 + // GST_BUFFER_SIZE (*outbuf));
2.745
2.746 - /* flushs the newly buffer got from byte array */
2.747 + /* flushs the newly buffer got from byte array */
2.748 src->bytes_queue =
2.749 - g_byte_array_remove_range (src->bytes_queue, 0, buffer_size);
2.750 + g_byte_array_remove_range(src->bytes_queue, 0, buffer_size);
2.751
2.752 - if ( G_UNLIKELY (src->eos) || ( !src->live_tv
2.753 - && ( src->bytes_read >= src->content_size ) ) )
2.754 - goto eos;
2.755 + if (G_UNLIKELY(src->eos) || (!src->live_tv
2.756 + && (src->bytes_read >= src->content_size)))
2.757 + goto eos;
2.758
2.759 done:
2.760 {
2.761 - const gchar *reason = gst_flow_get_name (ret);
2.762 - return ret;
2.763 + const gchar *reason = gst_flow_get_name(ret);
2.764 + return ret;
2.765 }
2.766 eos:
2.767 {
2.768 - const gchar *reason = gst_flow_get_name (ret);
2.769 + const gchar *reason = gst_flow_get_name(ret);
2.770
2.771 - GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
2.772 - return GST_FLOW_UNEXPECTED;
2.773 + GST_DEBUG_OBJECT(src, "pausing task, reason %s", reason);
2.774 + return GST_FLOW_UNEXPECTED;
2.775 }
2.776 - /* ERRORS */
2.777 + /* ERRORS */
2.778 read_error:
2.779 {
2.780 - GST_ELEMENT_ERROR (src, RESOURCE, READ,
2.781 - (NULL), ("Could not read any bytes (%i, %s)", read, src->uri_name));
2.782 - return GST_FLOW_ERROR;
2.783 + GST_ELEMENT_ERROR(src, RESOURCE, READ,
2.784 + (NULL), ("Could not read any bytes (%i, %s)", read,
2.785 + src->uri_name));
2.786 + return GST_FLOW_ERROR;
2.787 }
2.788 change_progchain:
2.789 {
2.790 - GST_ELEMENT_ERROR (src, RESOURCE, READ,
2.791 - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
2.792 - src->uri_name));
2.793 + GST_ELEMENT_ERROR(src, RESOURCE, READ,
2.794 + (NULL),
2.795 + ("Seek failed, go to the next program info... (%i, %s)",
2.796 + read, src->uri_name));
2.797
2.798 /* TODO: need to send a new segment event to NUVDemux? */
2.799 - gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.800 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
2.801 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
2.802 + gst_event_new_new_segment(TRUE, 1.0, GST_FORMAT_TIME,
2.803 + 0, -1, 0));
2.804
2.805 - goto program_chain_changed;
2.806 + goto program_chain_changed;
2.807 }
2.808
2.809 }
2.810
2.811 gint64
2.812 -gst_mythtv_src_get_position (GstMythtvSrc * src)
2.813 +gst_mythtv_src_get_position(GstMythtvSrc * src)
2.814 {
2.815
2.816 gint64 size_tmp = 0;
2.817 guint max_tries = 2;
2.818
2.819 - if (src->live_tv == TRUE && (abs (src->content_size - src->bytes_read) <
2.820 - GMYTHTV_TRANSFER_MAX_BUFFER)) {
2.821 + if (src->live_tv == TRUE && (abs(src->content_size - src->bytes_read) <
2.822 + GMYTHTV_TRANSFER_MAX_BUFFER))
2.823 + {
2.824
2.825 - get_file_pos:
2.826 - g_usleep (10);
2.827 - size_tmp = gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
2.828 - if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
2.829 - src->content_size = size_tmp;
2.830 - else if (size_tmp > 0 && --max_tries > 0)
2.831 - goto get_file_pos;
2.832 - GST_LOG_OBJECT (src, "GET_POSITION: file_position = %lld", size_tmp);
2.833 - /* sets the last content size amount before it can be updated */
2.834 - src->prev_content_size = src->content_size;
2.835 - }
2.836 + get_file_pos:
2.837 + g_usleep(10);
2.838 + size_tmp =
2.839 + gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
2.840 + if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
2.841 + src->content_size = size_tmp;
2.842 + else if (size_tmp > 0 && --max_tries > 0)
2.843 + goto get_file_pos;
2.844 + GST_LOG_OBJECT(src, "GET_POSITION: file_position = %lld", size_tmp);
2.845 + /* sets the last content size amount before it can be updated */
2.846 + src->prev_content_size = src->content_size;
2.847 + }
2.848
2.849 return src->content_size;
2.850
2.851 }
2.852
2.853 static gboolean
2.854 -gst_mythtv_src_do_seek (GstBaseSrc * base, GstSegment * segment)
2.855 +gst_mythtv_src_do_seek(GstBaseSrc * base, GstSegment * segment)
2.856 {
2.857 - GstMythtvSrc *src = GST_MYTHTV_SRC (base);
2.858 + GstMythtvSrc *src = GST_MYTHTV_SRC(base);
2.859 gint64 new_offset = -1;
2.860 gint64 actual_seek = segment->start;
2.861 gboolean ret = TRUE;
2.862
2.863 - GST_LOG_OBJECT (src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
2.864 + GST_LOG_OBJECT(src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
2.865
2.866 - if (segment->format == GST_FORMAT_TIME) {
2.867 - goto done;
2.868 - }
2.869 - GST_LOG_OBJECT (src,
2.870 - "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
2.871 - actual_seek, src->read_offset);
2.872 - /* verify if it needs to seek */
2.873 - if (src->read_offset != actual_seek) {
2.874 -
2.875 - /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
2.876 - if ( IS_GMYTH_FILE_LOCAL(src->file) )
2.877 - new_offset =
2.878 - gmyth_file_local_seek ( GMYTH_FILE_LOCAL(src->file), segment->start, G_SEEK_SET);
2.879 - else if ( IS_GMYTH_FILE_TRANSFER(src->file) )
2.880 - new_offset =
2.881 - gmyth_file_transfer_seek ( GMYTH_FILE_TRANSFER(src->file), segment->start, SEEK_SET);
2.882 + if (segment->format == GST_FORMAT_TIME)
2.883 + {
2.884 + goto done;
2.885 + }
2.886 + GST_LOG_OBJECT(src,
2.887 + "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
2.888 + actual_seek, src->read_offset);
2.889 + /* verify if it needs to seek */
2.890 + if (src->read_offset != actual_seek)
2.891 + {
2.892
2.893 - GST_LOG_OBJECT (src,
2.894 - "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
2.895 - segment->start, src->read_offset, new_offset);
2.896 - if (G_UNLIKELY (new_offset < 0)) {
2.897 - ret = FALSE;
2.898 - if (!src->live_tv)
2.899 - goto eos;
2.900 - }
2.901 + /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
2.902 + if (IS_GMYTH_FILE_LOCAL(src->file))
2.903 + new_offset =
2.904 + gmyth_file_local_seek(GMYTH_FILE_LOCAL(src->file), segment->start,
2.905 + G_SEEK_SET);
2.906 + else if (IS_GMYTH_FILE_TRANSFER(src->file))
2.907 + new_offset =
2.908 + gmyth_file_transfer_seek(GMYTH_FILE_TRANSFER(src->file),
2.909 + segment->start, SEEK_SET);
2.910
2.911 - src->read_offset = new_offset;
2.912 + GST_LOG_OBJECT(src,
2.913 + "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
2.914 + segment->start, src->read_offset, new_offset);
2.915 + if (G_UNLIKELY(new_offset < 0))
2.916 + {
2.917 + ret = FALSE;
2.918 + if (!src->live_tv)
2.919 + goto eos;
2.920 + }
2.921
2.922 - if (ret == FALSE) {
2.923 - GST_INFO_OBJECT (src, "Failed to set the SEEK on segment!");
2.924 - }
2.925 + src->read_offset = new_offset;
2.926
2.927 - }
2.928 + if (ret == FALSE)
2.929 + {
2.930 + GST_INFO_OBJECT(src, "Failed to set the SEEK on segment!");
2.931 + }
2.932 +
2.933 + }
2.934
2.935 done:
2.936 return ret;
2.937
2.938 eos:
2.939 {
2.940 - GST_DEBUG_OBJECT (src, "EOS found on seeking!!!");
2.941 - return FALSE;
2.942 + GST_DEBUG_OBJECT(src, "EOS found on seeking!!!");
2.943 + return FALSE;
2.944 }
2.945
2.946 }
2.947
2.948 /* create a socket for connecting to remote server */
2.949 static gboolean
2.950 -gst_mythtv_src_start (GstBaseSrc * bsrc)
2.951 +gst_mythtv_src_start(GstBaseSrc * bsrc)
2.952 {
2.953 - GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
2.954 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.955
2.956 - GString *chain_id_local = NULL;
2.957 + GString *chain_id_local = NULL;
2.958 GMythURI *gmyth_uri = NULL;
2.959 gboolean ret = TRUE;
2.960 GstMessage *msg;
2.961
2.962 - if (src->unique_setup == FALSE) {
2.963 - src->unique_setup = TRUE;
2.964 - } else {
2.965 - goto done;
2.966 - }
2.967 -
2.968 - gmyth_uri = gmyth_uri_new_with_value (src->uri_name);
2.969 - src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name);
2.970 - src->live_tv = gmyth_uri_is_livetv( gmyth_uri );
2.971 - /* testing UPnP... */
2.972 - /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */
2.973 - if ( src->live_tv ) {
2.974 - src->spawn_livetv = gmyth_livetv_new (src->backend_info);
2.975 -
2.976 - gchar* ch = gmyth_uri_get_channel_name( gmyth_uri );
2.977 - if ( ch != NULL )
2.978 - src->channel_name = ch;
2.979 -
2.980 - if (src->channel_name != NULL) {
2.981 - gboolean result;
2.982 - result = gmyth_livetv_channel_name_setup (src->spawn_livetv, src->channel_name);
2.983 - if (result == FALSE) {
2.984 - GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
2.985 - ret = FALSE;
2.986 - goto init_failed;
2.987 - }
2.988 + if (src->unique_setup == FALSE)
2.989 + {
2.990 + src->unique_setup = TRUE;
2.991 + }
2.992 + else
2.993 + {
2.994 + goto done;
2.995 + }
2.996
2.997 - } else {
2.998 - if (gmyth_livetv_setup (src->spawn_livetv) == FALSE) {
2.999 - GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
2.1000 - ret = FALSE;
2.1001 - goto init_failed;
2.1002 - }
2.1003 - }
2.1004 + gmyth_uri = gmyth_uri_new_with_value(src->uri_name);
2.1005 + src->backend_info = gmyth_backend_info_new_with_uri(src->uri_name);
2.1006 + src->live_tv = gmyth_uri_is_livetv(gmyth_uri);
2.1007 + /* testing UPnP... */
2.1008 + /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */
2.1009 + if (src->live_tv)
2.1010 + {
2.1011 + src->spawn_livetv = gmyth_livetv_new(src->backend_info);
2.1012
2.1013 - /* testing change channel... */
2.1014 - /* gmyth_recorder_change_channel( src->spawn_livetv->recorder, CHANNEL_DIRECTION_UP ); */
2.1015 + gchar *ch = gmyth_uri_get_channel_name(gmyth_uri);
2.1016 + if (ch != NULL)
2.1017 + src->channel_name = ch;
2.1018
2.1019 - src->file = GMYTH_FILE( gmyth_livetv_create_file_transfer (src->spawn_livetv) );
2.1020 + if (src->channel_name != NULL)
2.1021 + {
2.1022 + gboolean result;
2.1023 + result =
2.1024 + gmyth_livetv_channel_name_setup(src->spawn_livetv,
2.1025 + src->channel_name);
2.1026 + if (result == FALSE)
2.1027 + {
2.1028 + GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
2.1029 + ret = FALSE;
2.1030 + goto init_failed;
2.1031 + }
2.1032
2.1033 - if (NULL == src->file) {
2.1034 - GST_INFO_OBJECT (src, "[LiveTV] FileTransfer equals to NULL");
2.1035 - ret = FALSE;
2.1036 - goto init_failed;
2.1037 - }
2.1038 -
2.1039 - /* Check if the file is local to this specific client renderer */
2.1040 - if ( gmyth_uri_is_local_file(gmyth_uri) )
2.1041 - ret = gmyth_file_local_open( GMYTH_FILE_LOCAL(src->file) );
2.1042 - else
2.1043 - ret = gmyth_file_transfer_open( GMYTH_FILE_TRANSFER(src->file), src->spawn_livetv->uri != NULL ?
2.1044 - gmyth_uri_get_path(src->spawn_livetv->uri) :
2.1045 - src->spawn_livetv->proginfo->pathname->str );
2.1046 -
2.1047 - /* sets the mythtvsrc "location" property */
2.1048 - g_object_set (src, "location", gmyth_file_get_uri (src->file), NULL);
2.1049 + }
2.1050 + else
2.1051 + {
2.1052 + if (gmyth_livetv_setup(src->spawn_livetv) == FALSE)
2.1053 + {
2.1054 + GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
2.1055 + ret = FALSE;
2.1056 + goto init_failed;
2.1057 + }
2.1058 + }
2.1059
2.1060 - if ( !ret )
2.1061 + /* testing change channel... */
2.1062 + /* gmyth_recorder_change_channel( src->spawn_livetv->recorder, CHANNEL_DIRECTION_UP ); */
2.1063 +
2.1064 + src->file =
2.1065 + GMYTH_FILE(gmyth_livetv_create_file_transfer(src->spawn_livetv));
2.1066 +
2.1067 + if (NULL == src->file)
2.1068 {
2.1069 - GST_INFO_OBJECT (src, "Error: couldn't open the FileTransfer from LiveTV source!" );
2.1070 - g_object_unref( src->file );
2.1071 - src->file = NULL;
2.1072 - goto init_failed;
2.1073 + GST_INFO_OBJECT(src, "[LiveTV] FileTransfer equals to NULL");
2.1074 + ret = FALSE;
2.1075 + goto init_failed;
2.1076 }
2.1077 - } else {
2.1078 -
2.1079 - /* Check if the file is local to this specific client renderer, and tries to open
2.1080 - * a local connection
2.1081 - */
2.1082 - if ( gmyth_uri_is_local_file(gmyth_uri) )
2.1083 - {
2.1084 - src->file = GMYTH_FILE(gmyth_file_local_new(src->backend_info));
2.1085 - ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( src->file ) );
2.1086 - } else {
2.1087 - src->file = GMYTH_FILE(gmyth_file_transfer_new(src->backend_info));
2.1088 - ret = gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(src->file), src->uri_name );
2.1089 - }
2.1090
2.1091 - } /* if (else) - recorded FileTransfer */
2.1092 + /* Check if the file is local to this specific client renderer */
2.1093 + if (gmyth_uri_is_local_file(gmyth_uri))
2.1094 + ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
2.1095 + else
2.1096 + ret =
2.1097 + gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
2.1098 + src->spawn_livetv->uri !=
2.1099 + NULL ? gmyth_uri_get_path(src->
2.1100 + spawn_livetv->
2.1101 + uri) : src->
2.1102 + spawn_livetv->proginfo->pathname->str);
2.1103
2.1104 - if (NULL == src->file) {
2.1105 - GST_INFO_OBJECT (src, "FileTransfer is NULL");
2.1106 - goto init_failed;
2.1107 - }
2.1108 - /*GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file); */
2.1109 + /* sets the mythtvsrc "location" property */
2.1110 + g_object_set(src, "location", gmyth_file_get_uri(src->file), NULL);
2.1111
2.1112 - if (ret == FALSE) {
2.1113 + if (!ret)
2.1114 + {
2.1115 + GST_INFO_OBJECT(src,
2.1116 + "Error: couldn't open the FileTransfer from LiveTV source!");
2.1117 + g_object_unref(src->file);
2.1118 + src->file = NULL;
2.1119 + goto init_failed;
2.1120 + }
2.1121 + }
2.1122 + else
2.1123 + {
2.1124 +
2.1125 + /* Check if the file is local to this specific client renderer, and tries to open
2.1126 + * a local connection
2.1127 + */
2.1128 + if (gmyth_uri_is_local_file(gmyth_uri))
2.1129 + {
2.1130 + src->file = GMYTH_FILE(gmyth_file_local_new(src->backend_info));
2.1131 + ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
2.1132 + }
2.1133 + else
2.1134 + {
2.1135 + src->file = GMYTH_FILE(gmyth_file_transfer_new(src->backend_info));
2.1136 + ret =
2.1137 + gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
2.1138 + src->uri_name);
2.1139 + }
2.1140 +
2.1141 + } /* if (else) - recorded FileTransfer */
2.1142 +
2.1143 + if (NULL == src->file)
2.1144 + {
2.1145 + GST_INFO_OBJECT(src, "FileTransfer is NULL");
2.1146 + goto init_failed;
2.1147 + }
2.1148 + /*GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file); */
2.1149 +
2.1150 + if (ret == FALSE)
2.1151 + {
2.1152 #ifndef GST_DISABLE_GST_DEBUG
2.1153 - if (src->mythtv_msgs_dbg)
2.1154 - GST_INFO_OBJECT (src,
2.1155 - "MythTV FileTransfer request failed when setting up socket connection!");
2.1156 + if (src->mythtv_msgs_dbg)
2.1157 + GST_INFO_OBJECT(src,
2.1158 + "MythTV FileTransfer request failed when setting up socket connection!");
2.1159 #endif
2.1160 - goto begin_req_failed;
2.1161 - }
2.1162 + goto begin_req_failed;
2.1163 + }
2.1164
2.1165 - GST_INFO_OBJECT (src,
2.1166 - "MythTV FileTransfer filesize = %lld, content_size = %lld!",
2.1167 - gmyth_file_get_filesize( src->file ), src->content_size);
2.1168 + GST_INFO_OBJECT(src,
2.1169 + "MythTV FileTransfer filesize = %lld, content_size = %lld!",
2.1170 + gmyth_file_get_filesize(src->file), src->content_size);
2.1171
2.1172 - src->content_size = gmyth_file_get_filesize (src->file);
2.1173 + src->content_size = gmyth_file_get_filesize(src->file);
2.1174
2.1175 - msg = gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_BYTES, src->content_size);
2.1176 - gst_element_post_message (GST_ELEMENT (src), msg);
2.1177 + msg =
2.1178 + gst_message_new_duration(GST_OBJECT(src), GST_FORMAT_BYTES,
2.1179 + src->content_size);
2.1180 + gst_element_post_message(GST_ELEMENT(src), msg);
2.1181
2.1182
2.1183 src->do_start = FALSE;
2.1184
2.1185 - /* this is used for the buffer cache */
2.1186 - src->bytes_queue = g_byte_array_sized_new (INTERNAL_BUFFER_SIZE);
2.1187 + /* this is used for the buffer cache */
2.1188 + src->bytes_queue = g_byte_array_sized_new(INTERNAL_BUFFER_SIZE);
2.1189 src->buffer_remain = 0;
2.1190 -
2.1191 - gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
2.1192 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
2.1193 - src->content_size, 0));
2.1194 +
2.1195 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(src)),
2.1196 + gst_event_new_new_segment(TRUE, 1.0, GST_FORMAT_TIME, 0,
2.1197 + src->content_size, 0));
2.1198
2.1199 done:
2.1200 - if (gmyth_uri != NULL)
2.1201 + if (gmyth_uri != NULL)
2.1202 {
2.1203 - g_object_unref (gmyth_uri);
2.1204 - gmyth_uri = NULL;
2.1205 + g_object_unref(gmyth_uri);
2.1206 + gmyth_uri = NULL;
2.1207 }
2.1208
2.1209 - if (chain_id_local != NULL) {
2.1210 - g_string_free (chain_id_local, TRUE);
2.1211 - chain_id_local = NULL;
2.1212 - }
2.1213 -
2.1214 - return TRUE;
2.1215 -
2.1216 - /* ERRORS */
2.1217 -init_failed:
2.1218 - if (gmyth_uri != NULL)
2.1219 + if (chain_id_local != NULL)
2.1220 {
2.1221 - g_object_unref (gmyth_uri);
2.1222 - gmyth_uri = NULL;
2.1223 + g_string_free(chain_id_local, TRUE);
2.1224 + chain_id_local = NULL;
2.1225 }
2.1226
2.1227 - if (src->spawn_livetv != NULL) {
2.1228 - g_object_unref (src->spawn_livetv);
2.1229 - src->spawn_livetv = NULL;
2.1230 - }
2.1231 -
2.1232 - GST_ELEMENT_ERROR (src, LIBRARY, INIT,
2.1233 - (NULL), ("Could not initialize MythTV library (%i, %s)", ret,
2.1234 - src->uri_name));
2.1235 + return TRUE;
2.1236
2.1237 -
2.1238 - gst_mythtv_src_clear (src);
2.1239 -
2.1240 - return FALSE;
2.1241 -begin_req_failed:
2.1242 - if (gmyth_uri != NULL)
2.1243 + /* ERRORS */
2.1244 +init_failed:
2.1245 + if (gmyth_uri != NULL)
2.1246 {
2.1247 - g_object_unref (gmyth_uri);
2.1248 - gmyth_uri = NULL;
2.1249 + g_object_unref(gmyth_uri);
2.1250 + gmyth_uri = NULL;
2.1251 }
2.1252
2.1253 - GST_ELEMENT_ERROR (src, LIBRARY, INIT,
2.1254 - (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret,
2.1255 - src->uri_name));
2.1256 - return FALSE;
2.1257 + if (src->spawn_livetv != NULL)
2.1258 + {
2.1259 + g_object_unref(src->spawn_livetv);
2.1260 + src->spawn_livetv = NULL;
2.1261 + }
2.1262 +
2.1263 + GST_ELEMENT_ERROR(src, LIBRARY, INIT,
2.1264 + (NULL), ("Could not initialize MythTV library (%i, %s)",
2.1265 + ret, src->uri_name));
2.1266 +
2.1267 +
2.1268 + gst_mythtv_src_clear(src);
2.1269 +
2.1270 + return FALSE;
2.1271 +begin_req_failed:
2.1272 + if (gmyth_uri != NULL)
2.1273 + {
2.1274 + g_object_unref(gmyth_uri);
2.1275 + gmyth_uri = NULL;
2.1276 + }
2.1277 +
2.1278 + GST_ELEMENT_ERROR(src, LIBRARY, INIT,
2.1279 + (NULL),
2.1280 + ("Could not begin request sent to MythTV server (%i, %s)",
2.1281 + ret, src->uri_name));
2.1282 + return FALSE;
2.1283
2.1284 }
2.1285
2.1286 static gboolean
2.1287 -gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
2.1288 +gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size)
2.1289 {
2.1290 - GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
2.1291 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.1292 gboolean ret = TRUE;
2.1293
2.1294 - GST_LOG_OBJECT (src, "Differs from previous content size: %d (max.: %d)",
2.1295 - abs (src->content_size - src->prev_content_size),
2.1296 - GMYTHTV_TRANSFER_MAX_BUFFER);
2.1297 + GST_LOG_OBJECT(src, "Differs from previous content size: %d (max.: %d)",
2.1298 + abs(src->content_size - src->prev_content_size),
2.1299 + GMYTHTV_TRANSFER_MAX_BUFFER);
2.1300
2.1301 - if (src->live_tv) {
2.1302 - ret = FALSE;
2.1303 - } else if (src->live_tv && src->enable_timing_position
2.1304 - && (abs (src->content_size - src->bytes_read) <
2.1305 - GMYTHTV_TRANSFER_MAX_BUFFER)) {
2.1306 + if (src->live_tv)
2.1307 + {
2.1308 + ret = FALSE;
2.1309 + }
2.1310 + else if (src->live_tv && src->enable_timing_position
2.1311 + && (abs(src->content_size - src->bytes_read) <
2.1312 + GMYTHTV_TRANSFER_MAX_BUFFER))
2.1313 + {
2.1314
2.1315 - gint64 new_offset =
2.1316 - gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
2.1317 - if (new_offset > 0 && new_offset > src->content_size) {
2.1318 - src->content_size = new_offset;
2.1319 - } else if (new_offset < src->content_size) {
2.1320 - src->update_prog_chain = TRUE;
2.1321 - }
2.1322 + gint64 new_offset =
2.1323 + gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
2.1324 + if (new_offset > 0 && new_offset > src->content_size)
2.1325 + {
2.1326 + src->content_size = new_offset;
2.1327 + }
2.1328 + else if (new_offset < src->content_size)
2.1329 + {
2.1330 + src->update_prog_chain = TRUE;
2.1331 + }
2.1332
2.1333 - }
2.1334 + }
2.1335
2.1336 *size = src->content_size;
2.1337 - GST_LOG_OBJECT (src, "Content size = %lld", src->content_size);
2.1338 + GST_LOG_OBJECT(src, "Content size = %lld", src->content_size);
2.1339
2.1340 return ret;
2.1341
2.1342 @@ -911,312 +996,328 @@
2.1343 /* close the socket and associated resources
2.1344 * used both to recover from errors and go to NULL state */
2.1345 static gboolean
2.1346 -gst_mythtv_src_stop (GstBaseSrc * bsrc)
2.1347 +gst_mythtv_src_stop(GstBaseSrc * bsrc)
2.1348 {
2.1349 - GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
2.1350 -
2.1351 - gst_mythtv_src_clear (src);
2.1352 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.1353
2.1354 - /* src->eos = FALSE; */
2.1355 + gst_mythtv_src_clear(src);
2.1356 +
2.1357 + /* src->eos = FALSE; */
2.1358
2.1359 return TRUE;
2.1360 }
2.1361
2.1362 static gboolean
2.1363 -gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event)
2.1364 +gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event)
2.1365 {
2.1366 - GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad));
2.1367 + GstMythtvSrc *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad));
2.1368 gint64 cont_size = 0;
2.1369 gboolean ret = FALSE;
2.1370
2.1371 - switch (GST_EVENT_TYPE (event)) {
2.1372 - case GST_EVENT_EOS:
2.1373 - GST_WARNING_OBJECT (src, "Got EOS event");
2.1374 + switch (GST_EVENT_TYPE(event))
2.1375 + {
2.1376 + case GST_EVENT_EOS:
2.1377 + GST_WARNING_OBJECT(src, "Got EOS event");
2.1378
2.1379 - if (src->live_tv) {
2.1380 - cont_size = gst_mythtv_src_get_position (src);
2.1381 - if (cont_size > src->content_size) {
2.1382 - src->content_size = cont_size;
2.1383 - src->eos = FALSE;
2.1384 - } else {
2.1385 - src->eos = TRUE;
2.1386 - gst_element_set_state (GST_ELEMENT (src), GST_STATE_NULL);
2.1387 - gst_element_set_locked_state (GST_ELEMENT (src), FALSE);
2.1388 - }
2.1389 - }
2.1390 - break;
2.1391 - default:
2.1392 - ret = gst_pad_event_default (pad, event);
2.1393 - }
2.1394 + if (src->live_tv)
2.1395 + {
2.1396 + cont_size = gst_mythtv_src_get_position(src);
2.1397 + if (cont_size > src->content_size)
2.1398 + {
2.1399 + src->content_size = cont_size;
2.1400 + src->eos = FALSE;
2.1401 + }
2.1402 + else
2.1403 + {
2.1404 + src->eos = TRUE;
2.1405 + gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
2.1406 + gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
2.1407 + }
2.1408 + }
2.1409 + break;
2.1410 + default:
2.1411 + ret = gst_pad_event_default(pad, event);
2.1412 + }
2.1413
2.1414 return ret;
2.1415 }
2.1416
2.1417 static gboolean
2.1418 -gst_mythtv_src_is_seekable (GstBaseSrc * push_src)
2.1419 +gst_mythtv_src_is_seekable(GstBaseSrc * push_src)
2.1420 {
2.1421 return TRUE;
2.1422 }
2.1423
2.1424 static gboolean
2.1425 -gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query)
2.1426 +gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query)
2.1427 {
2.1428 gboolean res = FALSE;
2.1429 - GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
2.1430 + GstMythtvSrc *myth = GST_MYTHTV_SRC(gst_pad_get_parent(pad));
2.1431 GstFormat formt;
2.1432
2.1433
2.1434 - switch (GST_QUERY_TYPE (query)) {
2.1435 - case GST_QUERY_POSITION:
2.1436 - {
2.1437 - gst_query_parse_position (query, &formt, NULL);
2.1438 - if (formt == GST_FORMAT_BYTES) {
2.1439 - gst_query_set_position (query, formt, myth->read_offset);
2.1440 - GST_DEBUG_OBJECT (myth, "POS %" G_GINT64_FORMAT, myth->read_offset);
2.1441 - res = TRUE;
2.1442 - } else if (formt == GST_FORMAT_TIME) {
2.1443 - res = gst_pad_query_default (pad, query);
2.1444 - }
2.1445 - break;
2.1446 - }
2.1447 - case GST_QUERY_DURATION:
2.1448 - {
2.1449 - gst_query_parse_duration (query, &formt, NULL);
2.1450 - if (formt == GST_FORMAT_BYTES) {
2.1451 - gint64 size = myth->content_size;
2.1452 - gst_query_set_duration (query, GST_FORMAT_BYTES, 10);
2.1453 - GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, size);
2.1454 - res = TRUE;
2.1455 - } else if (formt == GST_FORMAT_TIME) {
2.1456 - res = gst_pad_query_default (pad, query);
2.1457 - }
2.1458 - break;
2.1459 - }
2.1460 - default:
2.1461 - {
2.1462 - res = gst_pad_query_default (pad, query);
2.1463 - break;
2.1464 - }
2.1465 - }
2.1466 + switch (GST_QUERY_TYPE(query))
2.1467 + {
2.1468 + case GST_QUERY_POSITION:
2.1469 + {
2.1470 + gst_query_parse_position(query, &formt, NULL);
2.1471 + if (formt == GST_FORMAT_BYTES)
2.1472 + {
2.1473 + gst_query_set_position(query, formt, myth->read_offset);
2.1474 + GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
2.1475 + myth->read_offset);
2.1476 + res = TRUE;
2.1477 + }
2.1478 + else if (formt == GST_FORMAT_TIME)
2.1479 + {
2.1480 + res = gst_pad_query_default(pad, query);
2.1481 + }
2.1482 + break;
2.1483 + }
2.1484 + case GST_QUERY_DURATION:
2.1485 + {
2.1486 + gst_query_parse_duration(query, &formt, NULL);
2.1487 + if (formt == GST_FORMAT_BYTES)
2.1488 + {
2.1489 + gint64 size = myth->content_size;
2.1490 + gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
2.1491 + GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
2.1492 + res = TRUE;
2.1493 + }
2.1494 + else if (formt == GST_FORMAT_TIME)
2.1495 + {
2.1496 + res = gst_pad_query_default(pad, query);
2.1497 + }
2.1498 + break;
2.1499 + }
2.1500 + default:
2.1501 + {
2.1502 + res = gst_pad_query_default(pad, query);
2.1503 + break;
2.1504 + }
2.1505 + }
2.1506
2.1507 - gst_object_unref (myth);
2.1508 + gst_object_unref(myth);
2.1509
2.1510 return res;
2.1511 }
2.1512
2.1513 static GstStateChangeReturn
2.1514 -gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
2.1515 +gst_mythtv_src_change_state(GstElement * element, GstStateChange transition)
2.1516 {
2.1517 GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
2.1518 - GstMythtvSrc *src = GST_MYTHTV_SRC (element);
2.1519 + GstMythtvSrc *src = GST_MYTHTV_SRC(element);
2.1520
2.1521 - g_debug ("MYTHSRC: state_changed");
2.1522 + switch (transition)
2.1523 + {
2.1524 + case GST_STATE_CHANGE_NULL_TO_READY:
2.1525 + break;
2.1526 + case GST_STATE_CHANGE_READY_TO_PAUSED:
2.1527 + case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
2.1528 + if (src->live_tv)
2.1529 + {
2.1530 + if (!gmyth_recorder_send_frontend_ready_command(src->spawn_livetv->
2.1531 + recorder))
2.1532 + GST_WARNING_OBJECT(src,
2.1533 + "Couldn't send the FRONTEND_READY message to the backend!");
2.1534 + else
2.1535 + GST_DEBUG_OBJECT(src, "FRONTEND_READY was sent to the backend");
2.1536 + }
2.1537 + break;
2.1538 + default:
2.1539 + break;
2.1540 + }
2.1541
2.1542 - switch (transition) {
2.1543 - case GST_STATE_CHANGE_NULL_TO_READY:
2.1544 - break;
2.1545 - case GST_STATE_CHANGE_READY_TO_PAUSED:
2.1546 - case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
2.1547 - if (src->live_tv) {
2.1548 - if (!gmyth_recorder_send_frontend_ready_command (src->spawn_livetv->
2.1549 - recorder))
2.1550 - GST_WARNING_OBJECT (src,
2.1551 - "Couldn't send the FRONTEND_READY message to the backend!");
2.1552 - else
2.1553 - GST_DEBUG_OBJECT (src, "FRONTEND_READY was sent to the backend");
2.1554 - }
2.1555 - break;
2.1556 - default:
2.1557 - break;
2.1558 - }
2.1559
2.1560 + ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
2.1561 + if (ret == GST_STATE_CHANGE_FAILURE)
2.1562 + return ret;
2.1563
2.1564 - g_debug ("MYTHSRC: state_changed 1");
2.1565
2.1566 - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
2.1567 - if (ret == GST_STATE_CHANGE_FAILURE)
2.1568 - return ret;
2.1569 + switch (transition)
2.1570 + {
2.1571 + case GST_STATE_CHANGE_READY_TO_NULL:
2.1572 + gst_mythtv_src_clear(src);
2.1573 + break;
2.1574 + case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
2.1575 + case GST_STATE_CHANGE_PAUSED_TO_READY:
2.1576 + break;
2.1577 + default:
2.1578 + break;
2.1579 + }
2.1580
2.1581 -
2.1582 - g_debug ("MYTHSRC: state_changed2");
2.1583 -
2.1584 - switch (transition) {
2.1585 - case GST_STATE_CHANGE_READY_TO_NULL:
2.1586 - gst_mythtv_src_clear (src);
2.1587 - break;
2.1588 - case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
2.1589 - case GST_STATE_CHANGE_PAUSED_TO_READY:
2.1590 - break;
2.1591 - default:
2.1592 - break;
2.1593 - }
2.1594 -
2.1595 - g_debug ("MYTHSRC: state_changed: DONE");
2.1596 return ret;
2.1597 }
2.1598
2.1599 static void
2.1600 -gst_mythtv_src_set_property (GObject * object, guint prop_id,
2.1601 - const GValue * value, GParamSpec * pspec)
2.1602 +gst_mythtv_src_set_property(GObject * object, guint prop_id,
2.1603 + const GValue * value, GParamSpec * pspec)
2.1604 {
2.1605 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
2.1606 + GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
2.1607
2.1608 - GST_OBJECT_LOCK (mythtvsrc);
2.1609 - switch (prop_id) {
2.1610 - case PROP_LOCATION:
2.1611 - {
2.1612 - if (!g_value_get_string (value)) {
2.1613 - GST_WARNING ("location property cannot be NULL");
2.1614 - break;
2.1615 - }
2.1616 + GST_OBJECT_LOCK(mythtvsrc);
2.1617 + switch (prop_id)
2.1618 + {
2.1619 + case PROP_LOCATION:
2.1620 + {
2.1621 + if (!g_value_get_string(value))
2.1622 + {
2.1623 + GST_WARNING("location property cannot be NULL");
2.1624 + break;
2.1625 + }
2.1626
2.1627 - if (mythtvsrc->uri_name != NULL) {
2.1628 - g_free (mythtvsrc->uri_name);
2.1629 - mythtvsrc->uri_name = NULL;
2.1630 - }
2.1631 - mythtvsrc->uri_name = g_value_dup_string (value);
2.1632 + if (mythtvsrc->uri_name != NULL)
2.1633 + {
2.1634 + g_free(mythtvsrc->uri_name);
2.1635 + mythtvsrc->uri_name = NULL;
2.1636 + }
2.1637 + mythtvsrc->uri_name = g_value_dup_string(value);
2.1638
2.1639 - break;
2.1640 - }
2.1641 + break;
2.1642 + }
2.1643 #ifndef GST_DISABLE_GST_DEBUG
2.1644 - case PROP_GMYTHTV_DBG:
2.1645 - {
2.1646 - mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean (value);
2.1647 - break;
2.1648 - }
2.1649 + case PROP_GMYTHTV_DBG:
2.1650 + {
2.1651 + mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean(value);
2.1652 + break;
2.1653 + }
2.1654 #endif
2.1655 - case PROP_GMYTHTV_VERSION:
2.1656 - {
2.1657 - mythtvsrc->mythtv_version = g_value_get_int (value);
2.1658 - break;
2.1659 - }
2.1660 - case PROP_GMYTHTV_LIVEID:
2.1661 - {
2.1662 - mythtvsrc->live_tv_id = g_value_get_int (value);
2.1663 - break;
2.1664 - }
2.1665 - case PROP_GMYTHTV_LIVE:
2.1666 - {
2.1667 - mythtvsrc->live_tv = g_value_get_boolean (value);
2.1668 - break;
2.1669 - }
2.1670 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.1671 - {
2.1672 - mythtvsrc->enable_timing_position = g_value_get_boolean (value);
2.1673 - break;
2.1674 - }
2.1675 - case PROP_GMYTHTV_LIVE_CHAINID:
2.1676 - {
2.1677 - if (!g_value_get_string (value)) {
2.1678 - GST_WARNING ("MythTV Live chainid property cannot be NULL");
2.1679 - break;
2.1680 - }
2.1681 + case PROP_GMYTHTV_VERSION:
2.1682 + {
2.1683 + mythtvsrc->mythtv_version = g_value_get_int(value);
2.1684 + break;
2.1685 + }
2.1686 + case PROP_GMYTHTV_LIVEID:
2.1687 + {
2.1688 + mythtvsrc->live_tv_id = g_value_get_int(value);
2.1689 + break;
2.1690 + }
2.1691 + case PROP_GMYTHTV_LIVE:
2.1692 + {
2.1693 + mythtvsrc->live_tv = g_value_get_boolean(value);
2.1694 + break;
2.1695 + }
2.1696 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.1697 + {
2.1698 + mythtvsrc->enable_timing_position = g_value_get_boolean(value);
2.1699 + break;
2.1700 + }
2.1701 + case PROP_GMYTHTV_LIVE_CHAINID:
2.1702 + {
2.1703 + if (!g_value_get_string(value))
2.1704 + {
2.1705 + GST_WARNING("MythTV Live chainid property cannot be NULL");
2.1706 + break;
2.1707 + }
2.1708
2.1709 - if (mythtvsrc->live_chain_id != NULL) {
2.1710 - g_free (mythtvsrc->live_chain_id);
2.1711 - mythtvsrc->live_chain_id = NULL;
2.1712 - }
2.1713 - mythtvsrc->live_chain_id = g_value_dup_string (value);
2.1714 - break;
2.1715 - }
2.1716 - case PROP_GMYTHTV_CHANNEL_NUM:
2.1717 - {
2.1718 - mythtvsrc->channel_name = g_value_dup_string (value);
2.1719 - break;
2.1720 - }
2.1721 - case PROP_GMYTHTV_MAX_TRY:
2.1722 - {
2.1723 - mythtvsrc->max_try = g_value_get_int (value);
2.1724 - break;
2.1725 - }
2.1726 - default:
2.1727 - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2.1728 - break;
2.1729 - }
2.1730 + if (mythtvsrc->live_chain_id != NULL)
2.1731 + {
2.1732 + g_free(mythtvsrc->live_chain_id);
2.1733 + mythtvsrc->live_chain_id = NULL;
2.1734 + }
2.1735 + mythtvsrc->live_chain_id = g_value_dup_string(value);
2.1736 + break;
2.1737 + }
2.1738 + case PROP_GMYTHTV_CHANNEL_NUM:
2.1739 + {
2.1740 + mythtvsrc->channel_name = g_value_dup_string(value);
2.1741 + break;
2.1742 + }
2.1743 + case PROP_GMYTHTV_MAX_TRY:
2.1744 + {
2.1745 + mythtvsrc->max_try = g_value_get_int(value);
2.1746 + break;
2.1747 + }
2.1748 + default:
2.1749 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
2.1750 + break;
2.1751 + }
2.1752
2.1753 - GST_OBJECT_UNLOCK (mythtvsrc);
2.1754 + GST_OBJECT_UNLOCK(mythtvsrc);
2.1755 }
2.1756
2.1757 static void
2.1758 -gst_mythtv_src_get_property (GObject * object, guint prop_id,
2.1759 - GValue * value, GParamSpec * pspec)
2.1760 +gst_mythtv_src_get_property(GObject * object, guint prop_id,
2.1761 + GValue * value, GParamSpec * pspec)
2.1762 {
2.1763 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
2.1764 + GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
2.1765
2.1766 - GST_OBJECT_LOCK (mythtvsrc);
2.1767 - switch (prop_id) {
2.1768 - case PROP_LOCATION:
2.1769 - {
2.1770 - g_value_set_string (value, mythtvsrc->uri_name);
2.1771 - break;
2.1772 - }
2.1773 + GST_OBJECT_LOCK(mythtvsrc);
2.1774 + switch (prop_id)
2.1775 + {
2.1776 + case PROP_LOCATION:
2.1777 + {
2.1778 + g_value_set_string(value, mythtvsrc->uri_name);
2.1779 + break;
2.1780 + }
2.1781 #ifndef GST_DISABLE_GST_DEBUG
2.1782 - case PROP_GMYTHTV_DBG:
2.1783 - g_value_set_boolean (value, mythtvsrc->mythtv_msgs_dbg);
2.1784 - break;
2.1785 + case PROP_GMYTHTV_DBG:
2.1786 + g_value_set_boolean(value, mythtvsrc->mythtv_msgs_dbg);
2.1787 + break;
2.1788 #endif
2.1789 - case PROP_GMYTHTV_VERSION:
2.1790 - {
2.1791 - g_value_set_int (value, mythtvsrc->mythtv_version);
2.1792 - break;
2.1793 - }
2.1794 - case PROP_GMYTHTV_LIVEID:
2.1795 - {
2.1796 - g_value_set_int (value, mythtvsrc->live_tv_id);
2.1797 - break;
2.1798 - }
2.1799 - case PROP_GMYTHTV_LIVE:
2.1800 - g_value_set_boolean (value, mythtvsrc->live_tv);
2.1801 - break;
2.1802 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.1803 - g_value_set_boolean (value, mythtvsrc->enable_timing_position);
2.1804 - break;
2.1805 - case PROP_GMYTHTV_LIVE_CHAINID:
2.1806 - {
2.1807 - g_value_set_string (value, mythtvsrc->live_chain_id);
2.1808 - break;
2.1809 - }
2.1810 - case PROP_GMYTHTV_CHANNEL_NUM:
2.1811 - {
2.1812 - g_value_set_string (value, mythtvsrc->channel_name);
2.1813 - break;
2.1814 - }
2.1815 - case PROP_GMYTHTV_MAX_TRY:
2.1816 - {
2.1817 - g_value_set_int (value, mythtvsrc->max_try);
2.1818 - break;
2.1819 - }
2.1820 + case PROP_GMYTHTV_VERSION:
2.1821 + {
2.1822 + g_value_set_int(value, mythtvsrc->mythtv_version);
2.1823 + break;
2.1824 + }
2.1825 + case PROP_GMYTHTV_LIVEID:
2.1826 + {
2.1827 + g_value_set_int(value, mythtvsrc->live_tv_id);
2.1828 + break;
2.1829 + }
2.1830 + case PROP_GMYTHTV_LIVE:
2.1831 + g_value_set_boolean(value, mythtvsrc->live_tv);
2.1832 + break;
2.1833 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.1834 + g_value_set_boolean(value, mythtvsrc->enable_timing_position);
2.1835 + break;
2.1836 + case PROP_GMYTHTV_LIVE_CHAINID:
2.1837 + {
2.1838 + g_value_set_string(value, mythtvsrc->live_chain_id);
2.1839 + break;
2.1840 + }
2.1841 + case PROP_GMYTHTV_CHANNEL_NUM:
2.1842 + {
2.1843 + g_value_set_string(value, mythtvsrc->channel_name);
2.1844 + break;
2.1845 + }
2.1846 + case PROP_GMYTHTV_MAX_TRY:
2.1847 + {
2.1848 + g_value_set_int(value, mythtvsrc->max_try);
2.1849 + break;
2.1850 + }
2.1851
2.1852 - default:
2.1853 - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2.1854 - break;
2.1855 - }
2.1856 - GST_OBJECT_UNLOCK (mythtvsrc);
2.1857 + default:
2.1858 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
2.1859 + break;
2.1860 + }
2.1861 + GST_OBJECT_UNLOCK(mythtvsrc);
2.1862 }
2.1863
2.1864 static gboolean
2.1865 -plugin_init (GstPlugin * plugin)
2.1866 +plugin_init(GstPlugin * plugin)
2.1867 {
2.1868 - return gst_element_register (plugin, "mythtvsrc", GST_RANK_NONE,
2.1869 - GST_TYPE_MYTHTV_SRC);
2.1870 + return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE,
2.1871 + GST_TYPE_MYTHTV_SRC);
2.1872 }
2.1873
2.1874 -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
2.1875 - GST_VERSION_MINOR,
2.1876 - "mythtv",
2.1877 - "lib MythTV src",
2.1878 - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
2.1879 +GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
2.1880 + GST_VERSION_MINOR,
2.1881 + "mythtv",
2.1882 + "lib MythTV src",
2.1883 + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
2.1884 + GST_PACKAGE_ORIGIN);
2.1885
2.1886
2.1887 /*** GSTURIHANDLER INTERFACE *************************************************/
2.1888 static guint
2.1889 -gst_mythtv_src_uri_get_type (void)
2.1890 +gst_mythtv_src_uri_get_type(void)
2.1891 {
2.1892 return GST_URI_SRC;
2.1893 }
2.1894
2.1895 static gchar **
2.1896 -gst_mythtv_src_uri_get_protocols (void)
2.1897 +gst_mythtv_src_uri_get_protocols(void)
2.1898 {
2.1899 static gchar *protocols[] = { "myth", "myths", NULL };
2.1900
2.1901 @@ -1224,33 +1325,34 @@
2.1902 }
2.1903
2.1904 static const gchar *
2.1905 -gst_mythtv_src_uri_get_uri (GstURIHandler * handler)
2.1906 +gst_mythtv_src_uri_get_uri(GstURIHandler * handler)
2.1907 {
2.1908 - GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
2.1909 + GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
2.1910
2.1911 return src->uri_name;
2.1912 }
2.1913
2.1914 static gboolean
2.1915 -gst_mythtv_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
2.1916 +gst_mythtv_src_uri_set_uri(GstURIHandler * handler, const gchar * uri)
2.1917 {
2.1918 - GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
2.1919 + GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
2.1920
2.1921 gchar *protocol;
2.1922
2.1923 - protocol = gst_uri_get_protocol (uri);
2.1924 - if ((strcmp (protocol, "myth") != 0) && (strcmp (protocol, "myths") != 0)) {
2.1925 - g_free (protocol);
2.1926 - return FALSE;
2.1927 - }
2.1928 - g_free (protocol);
2.1929 - g_object_set (src, "location", uri, NULL);
2.1930 + protocol = gst_uri_get_protocol(uri);
2.1931 + if ((strcmp(protocol, "myth") != 0) && (strcmp(protocol, "myths") != 0))
2.1932 + {
2.1933 + g_free(protocol);
2.1934 + return FALSE;
2.1935 + }
2.1936 + g_free(protocol);
2.1937 + g_object_set(src, "location", uri, NULL);
2.1938
2.1939 return TRUE;
2.1940 }
2.1941
2.1942 static void
2.1943 -gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
2.1944 +gst_mythtv_src_uri_handler_init(gpointer g_iface, gpointer iface_data)
2.1945 {
2.1946 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
2.1947
2.1948 @@ -1261,9 +1363,9 @@
2.1949 }
2.1950
2.1951 void
2.1952 -size_header_handler (void *userdata, const char *value)
2.1953 +size_header_handler(void *userdata, const char *value)
2.1954 {
2.1955 - GstMythtvSrc *src = GST_MYTHTV_SRC (userdata);
2.1956 + GstMythtvSrc *src = GST_MYTHTV_SRC(userdata);
2.1957
2.1958 - GST_DEBUG_OBJECT (src, "content size = %lld bytes", src->content_size);
2.1959 + GST_DEBUG_OBJECT(src, "content size = %lld bytes", src->content_size);
2.1960 }
3.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.h Thu Jun 14 18:19:52 2007 +0100
3.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.h Thu Jun 14 18:21:08 2007 +0100
3.3 @@ -33,7 +33,6 @@
3.4 #include <gmyth/gmyth_backendinfo.h>
3.5
3.6 G_BEGIN_DECLS
3.7 -
3.8 #define GST_TYPE_MYTHTV_SRC \
3.9 (gst_mythtv_src_get_type())
3.10 #define GST_MYTHTV_SRC(obj) \
3.11 @@ -44,24 +43,25 @@
3.12 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MYTHTV_SRC))
3.13 #define GST_IS_MYTHTV_SRC_CLASS(klass) \
3.14 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MYTHTV_SRC))
3.15 -
3.16 typedef struct _GstMythtvSrc GstMythtvSrc;
3.17 typedef struct _GstMythtvSrcClass GstMythtvSrcClass;
3.18
3.19 -typedef enum {
3.20 +typedef enum
3.21 +{
3.22 GST_MYTHTV_SRC_FILE_TRANSFER,
3.23 GST_MYTHTV_SRC_NEXT_PROGRAM_CHAIN,
3.24 GST_MYTHTV_SRC_INVALID_DATA
3.25 } GstMythtvState;
3.26
3.27 -struct _GstMythtvSrc {
3.28 +struct _GstMythtvSrc
3.29 +{
3.30 GstPushSrc element;
3.31
3.32 - /* MythFileTransfer */
3.33 + /* MythFileTransfer */
3.34 GMythFile *file;
3.35
3.36 GMythLiveTV *spawn_livetv;
3.37 -
3.38 +
3.39 GMythBackendInfo *backend_info;
3.40
3.41 GstMythtvState state;
3.42 @@ -97,37 +97,37 @@
3.43
3.44 gint live_tv_id;
3.45
3.46 - gchar* channel_name;
3.47 + gchar *channel_name;
3.48
3.49 guint mode;
3.50
3.51 - /* MythTV capabilities */
3.52 + /* MythTV capabilities */
3.53 GstCaps *mythtv_caps;
3.54
3.55 GByteArray *bytes_queue;
3.56
3.57 #ifndef GST_DISABLE_GST_DEBUG
3.58 - /* enable Myth TV debug messages */
3.59 + /* enable Myth TV debug messages */
3.60 gboolean mythtv_msgs_dbg;
3.61 #endif
3.62
3.63 gboolean update_prog_chain;
3.64
3.65 - /* stablish a maximum iteration value to the IS_RECORDING message */
3.66 + /* stablish a maximum iteration value to the IS_RECORDING message */
3.67 guint wait_to_transfer;
3.68
3.69 - /* max try number to get freerecorder */
3.70 + /* max try number to get freerecorder */
3.71 gint max_try;
3.72 gint try_number;
3.73
3.74 };
3.75
3.76 -struct _GstMythtvSrcClass {
3.77 +struct _GstMythtvSrcClass
3.78 +{
3.79 GstPushSrcClass parent_class;
3.80 };
3.81
3.82 -GType gst_mythtv_src_get_type (void);
3.83 +GType gst_mythtv_src_get_type(void);
3.84
3.85 G_END_DECLS
3.86 -
3.87 #endif /* __GST_MYTHTV_SRC_H__ */
4.1 --- a/gst-gmyth/nuvdemux/gstnuvdemux.c Thu Jun 14 18:19:52 2007 +0100
4.2 +++ b/gst-gmyth/nuvdemux/gstnuvdemux.c Thu Jun 14 18:21:08 2007 +0100
4.3 @@ -58,112 +58,112 @@
4.4
4.5 #define GST_NUV_DEMUX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemuxPrivate))
4.6
4.7 -GST_DEBUG_CATEGORY_STATIC (nuvdemux_debug);
4.8 +GST_DEBUG_CATEGORY_STATIC(nuvdemux_debug);
4.9 #define GST_CAT_DEFAULT nuvdemux_debug
4.10 #define GST_FLOW_ERROR_NO_DATA -101
4.11 #define GST_FLOW_ERROR_EOS -102
4.12
4.13 enum
4.14 {
4.15 - NUV_PUSH_MODE = 0,
4.16 - NUV_PULL_MODE
4.17 + NUV_PUSH_MODE = 0,
4.18 + NUV_PULL_MODE
4.19 };
4.20
4.21 -GST_DEBUG_CATEGORY_EXTERN (GST_CAT_EVENT);
4.22 +GST_DEBUG_CATEGORY_EXTERN(GST_CAT_EVENT);
4.23
4.24 static const GstElementDetails gst_nuv_demux_details =
4.25 -GST_ELEMENT_DETAILS ("Nuv demuxer",
4.26 - "Codec/Demuxer",
4.27 - "Demultiplex a .nuv file into audio and video",
4.28 - "Renato Araujo Oliveira Filho <renato.filho@indt.org.br>,"
4.29 - "Rosfran Borges <rosfran.borges@indt.org.br>");
4.30 +GST_ELEMENT_DETAILS("Nuv demuxer",
4.31 + "Codec/Demuxer",
4.32 + "Demultiplex a .nuv file into audio and video",
4.33 + "Renato Araujo Oliveira Filho <renato.filho@indt.org.br>,"
4.34 + "Rosfran Borges <rosfran.borges@indt.org.br>");
4.35
4.36
4.37 /* file header */
4.38 typedef struct
4.39 {
4.40 - gchar id[12]; /* "NuppelVideo\0" or "MythTVVideo\0" */
4.41 - gchar version[5]; /* "x.xx\0" */
4.42 + gchar id[12]; /* "NuppelVideo\0" or "MythTVVideo\0" */
4.43 + gchar version[5]; /* "x.xx\0" */
4.44
4.45 - gint i_width;
4.46 - gint i_height;
4.47 - gint i_width_desired;
4.48 - gint i_height_desired;
4.49 + gint i_width;
4.50 + gint i_height;
4.51 + gint i_width_desired;
4.52 + gint i_height_desired;
4.53
4.54 - gchar i_mode; /* P progressive, I interlaced */
4.55 + gchar i_mode; /* P progressive, I interlaced */
4.56
4.57 - gdouble d_aspect; /* 1.0 squared pixel */
4.58 - gdouble d_fps;
4.59 - //fps num/denom
4.60 - gint i_fpsn;
4.61 - gint i_fpsd;
4.62 + gdouble d_aspect; /* 1.0 squared pixel */
4.63 + gdouble d_fps;
4.64 + //fps num/denom
4.65 + gint i_fpsn;
4.66 + gint i_fpsd;
4.67
4.68 - gint i_video_blocks; /* 0 no video, -1 unknown */
4.69 - gint i_audio_blocks;
4.70 - gint i_text_blocks;
4.71 + gint i_video_blocks; /* 0 no video, -1 unknown */
4.72 + gint i_audio_blocks;
4.73 + gint i_text_blocks;
4.74
4.75 - gint i_keyframe_distance;
4.76 + gint i_keyframe_distance;
4.77
4.78 } nuv_header;
4.79
4.80 /* frame header */
4.81 typedef struct
4.82 {
4.83 - gchar i_type; /* A: audio, V: video, S: sync; T: test
4.84 - R: Seekpoint (string:RTjjjjjjjj)
4.85 - D: Extra data for codec */
4.86 - gchar i_compression; /* V: 0 uncompressed
4.87 - 1 RTJpeg
4.88 - 2 RTJpeg+lzo
4.89 - N black frame
4.90 - L copy last
4.91 - A: 0 uncompressed (44100 1-bits, 2ch)
4.92 - 1 lzo
4.93 - 2 layer 2
4.94 - 3 layer 3
4.95 - F flac
4.96 - S shorten
4.97 - N null frame loudless
4.98 - L copy last
4.99 - S: B audio and vdeo sync point
4.100 - A audio sync info (timecode == effective
4.101 - dsp frequency*100)
4.102 - V next video sync (timecode == next video
4.103 - frame num)
4.104 - S audio,video,text correlation */
4.105 - gchar i_keyframe; /* 0 keyframe, else no no key frame */
4.106 - guint8 i_filters; /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
4.107 - 0x02: gauss 5 pixel (8,1,1,1,1)/12
4.108 - 0x04: cartoon filter */
4.109 + gchar i_type; /* A: audio, V: video, S: sync; T: test
4.110 + R: Seekpoint (string:RTjjjjjjjj)
4.111 + D: Extra data for codec */
4.112 + gchar i_compression; /* V: 0 uncompressed
4.113 + 1 RTJpeg
4.114 + 2 RTJpeg+lzo
4.115 + N black frame
4.116 + L copy last
4.117 + A: 0 uncompressed (44100 1-bits, 2ch)
4.118 + 1 lzo
4.119 + 2 layer 2
4.120 + 3 layer 3
4.121 + F flac
4.122 + S shorten
4.123 + N null frame loudless
4.124 + L copy last
4.125 + S: B audio and vdeo sync point
4.126 + A audio sync info (timecode == effective
4.127 + dsp frequency*100)
4.128 + V next video sync (timecode == next video
4.129 + frame num)
4.130 + S audio,video,text correlation */
4.131 + gchar i_keyframe; /* 0 keyframe, else no no key frame */
4.132 + guint8 i_filters; /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
4.133 + 0x02: gauss 5 pixel (8,1,1,1,1)/12
4.134 + 0x04: cartoon filter */
4.135
4.136 - gint32 i_timecode; /* ms */
4.137 + gint32 i_timecode; /* ms */
4.138
4.139 - gint i_length; /* V,A,T: length of following data
4.140 - S: length of packet correl */
4.141 + gint i_length; /* V,A,T: length of following data
4.142 + S: length of packet correl */
4.143 } nuv_frame_header;
4.144
4.145
4.146 /* FIXME Not sure of this one */
4.147 typedef struct
4.148 {
4.149 - gint i_version;
4.150 - guint32 i_video_fcc;
4.151 + gint i_version;
4.152 + guint32 i_video_fcc;
4.153
4.154 - guint32 i_audio_fcc;
4.155 - gint i_audio_sample_rate;
4.156 - gint i_audio_bits_per_sample;
4.157 - gint i_audio_channels;
4.158 - gint i_audio_compression_ratio;
4.159 - gint i_audio_quality;
4.160 - gint i_rtjpeg_quality;
4.161 - gint i_rtjpeg_luma_filter;
4.162 - gint i_rtjpeg_chroma_filter;
4.163 - gint i_lavc_bitrate;
4.164 - gint i_lavc_qmin;
4.165 - gint i_lavc_qmax;
4.166 - gint i_lavc_maxqdiff;
4.167 - gint64 i_seekable_offset;
4.168 - gint64 i_keyframe_adjust_offset;
4.169 + guint32 i_audio_fcc;
4.170 + gint i_audio_sample_rate;
4.171 + gint i_audio_bits_per_sample;
4.172 + gint i_audio_channels;
4.173 + gint i_audio_compression_ratio;
4.174 + gint i_audio_quality;
4.175 + gint i_rtjpeg_quality;
4.176 + gint i_rtjpeg_luma_filter;
4.177 + gint i_rtjpeg_chroma_filter;
4.178 + gint i_lavc_bitrate;
4.179 + gint i_lavc_qmin;
4.180 + gint i_lavc_qmax;
4.181 + gint i_lavc_maxqdiff;
4.182 + gint64 i_seekable_offset;
4.183 + gint64 i_keyframe_adjust_offset;
4.184
4.185 } nuv_extended_header;
4.186
4.187 @@ -174,7 +174,8 @@
4.188
4.189 } frame_index_data;
4.190
4.191 -typedef enum {
4.192 +typedef enum
4.193 +{
4.194 GST_NUV_DEMUX_START,
4.195 GST_NUV_DEMUX_HEADER_DATA,
4.196 GST_NUV_DEMUX_EXTRA_DATA,
4.197 @@ -187,125 +188,132 @@
4.198 GST_NUV_DEMUX_INVALID_DATA
4.199 } GstNuvDemuxState;
4.200
4.201 -struct _GstNuvDemuxPrivate {
4.202 - /* used for indicate the mode */
4.203 - guint mode;
4.204 +struct _GstNuvDemuxPrivate
4.205 +{
4.206 + /* used for indicate the mode */
4.207 + guint mode;
4.208
4.209 - /* used on push mode */
4.210 - GstAdapter *adapter;
4.211 + /* used on push mode */
4.212 + GstAdapter *adapter;
4.213
4.214 - /* pads */
4.215 - GstPad *sinkpad;
4.216 - GstPad *src_video_pad;
4.217 - GstPad *src_audio_pad;
4.218 + /* pads */
4.219 + GstPad *sinkpad;
4.220 + GstPad *src_video_pad;
4.221 + GstPad *src_audio_pad;
4.222
4.223 - /* Flow control */
4.224 - GstFlowReturn last_video_return;
4.225 - GstFlowReturn last_audio_return;
4.226 - gboolean more_data;
4.227 - gboolean eos;
4.228 - gboolean new_file;
4.229 - guint segment;
4.230 + /* Flow control */
4.231 + GstFlowReturn last_video_return;
4.232 + GstFlowReturn last_audio_return;
4.233 + gboolean more_data;
4.234 + gboolean eos;
4.235 + gboolean new_file;
4.236 + guint segment;
4.237
4.238 - /* NUV decoding state */
4.239 - GstNuvDemuxState state;
4.240 - guint64 offset;
4.241 + /* NUV decoding state */
4.242 + GstNuvDemuxState state;
4.243 + guint64 offset;
4.244
4.245 - /* duration information */
4.246 - guint64 duration_bytes;
4.247 - guint64 duration_time;
4.248 - guint64 segment_stop;
4.249 - guint64 segment_start;
4.250 + /* duration information */
4.251 + guint64 duration_bytes;
4.252 + guint64 duration_time;
4.253 + guint64 segment_stop;
4.254 + guint64 segment_start;
4.255
4.256 - /* segment control info */
4.257 - gboolean new_audio_segment;
4.258 - gboolean new_video_segment;
4.259 + /* segment control info */
4.260 + gboolean new_audio_segment;
4.261 + gboolean new_video_segment;
4.262
4.263 - /* Mpeg ExtraData */
4.264 - guint64 mpeg_data_size;
4.265 - GstBuffer *mpeg_buffer;
4.266 + /* Mpeg ExtraData */
4.267 + guint64 mpeg_data_size;
4.268 + GstBuffer *mpeg_buffer;
4.269
4.270 - /* Headers */
4.271 + /* Headers */
4.272 nuv_header h;
4.273 nuv_extended_header eh;
4.274 nuv_frame_header fh;
4.275
4.276 - /* anothers info */
4.277 - guint64 header_lengh;
4.278 - gint64 time_start;
4.279 - gint64 time_diff;
4.280 - gint64 time_qos;
4.281 - guint64 last_frame_time;
4.282 - GSList *index;
4.283 + /* anothers info */
4.284 + guint64 header_lengh;
4.285 + gint64 time_start;
4.286 + gint64 time_diff;
4.287 + gint64 time_qos;
4.288 + guint64 last_frame_time;
4.289 + GSList *index;
4.290 };
4.291
4.292
4.293 -static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
4.294 - GST_PAD_SINK,
4.295 - GST_PAD_ALWAYS,
4.296 - GST_STATIC_CAPS ("video/x-nuv"));
4.297 +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE("sink",
4.298 + GST_PAD_SINK,
4.299 + GST_PAD_ALWAYS,
4.300 + GST_STATIC_CAPS
4.301 + ("video/x-nuv"));
4.302
4.303 static GstStaticPadTemplate audio_src_template =
4.304 -GST_STATIC_PAD_TEMPLATE ("audio_src",
4.305 - GST_PAD_SRC,
4.306 - GST_PAD_SOMETIMES,
4.307 - GST_STATIC_CAPS_ANY);
4.308 +GST_STATIC_PAD_TEMPLATE("audio_src",
4.309 + GST_PAD_SRC,
4.310 + GST_PAD_SOMETIMES,
4.311 + GST_STATIC_CAPS_ANY);
4.312
4.313 static GstStaticPadTemplate video_src_template =
4.314 -GST_STATIC_PAD_TEMPLATE ("video_src",
4.315 - GST_PAD_SRC,
4.316 - GST_PAD_SOMETIMES,
4.317 - GST_STATIC_CAPS_ANY);
4.318 +GST_STATIC_PAD_TEMPLATE("video_src",
4.319 + GST_PAD_SRC,
4.320 + GST_PAD_SOMETIMES,
4.321 + GST_STATIC_CAPS_ANY);
4.322
4.323 -static void gst_nuv_demux_dispose (GObject * object);
4.324 -static void gst_nuv_demux_finalize (GObject * object);
4.325 -static GstStateChangeReturn gst_nuv_demux_change_state (GstElement * element,
4.326 - GstStateChange transition);
4.327 -static void gst_nuv_demux_loop (GstPad * pad);
4.328 -static GstFlowReturn gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf);
4.329 -static GstFlowReturn gst_nuv_demux_play (GstPad * pad);
4.330 -static gboolean gst_nuv_demux_sink_activate_pull (GstPad * sinkpad,
4.331 - gboolean active);
4.332 -static gboolean gst_nuv_demux_sink_activate_push (GstPad * pad,
4.333 - gboolean active);
4.334 -static gboolean gst_nuv_demux_sink_activate (GstPad * sinkpad);
4.335 -static gboolean gst_nuv_demux_sink_event (GstPad *pad, GstEvent *event);
4.336 -static gboolean gst_nuv_demux_srcpad_event (GstPad * pad, GstEvent * event);
4.337 -static frame_index_data * gst_nuv_demux_do_seek_index (GstNuvDemux *nuv, gint64 seek_pos,
4.338 - gint64 segment_stop, GstFormat format);
4.339 +static void gst_nuv_demux_dispose(GObject * object);
4.340 +static void gst_nuv_demux_finalize(GObject * object);
4.341 +static GstStateChangeReturn gst_nuv_demux_change_state(GstElement * element,
4.342 + GstStateChange
4.343 + transition);
4.344 +static void gst_nuv_demux_loop(GstPad * pad);
4.345 +static GstFlowReturn gst_nuv_demux_chain(GstPad * pad, GstBuffer * buf);
4.346 +static GstFlowReturn gst_nuv_demux_play(GstPad * pad);
4.347 +static gboolean gst_nuv_demux_sink_activate_pull(GstPad * sinkpad,
4.348 + gboolean active);
4.349 +static gboolean gst_nuv_demux_sink_activate_push(GstPad * pad,
4.350 + gboolean active);
4.351 +static gboolean gst_nuv_demux_sink_activate(GstPad * sinkpad);
4.352 +static gboolean gst_nuv_demux_sink_event(GstPad * pad, GstEvent * event);
4.353 +static gboolean gst_nuv_demux_srcpad_event(GstPad * pad, GstEvent * event);
4.354 +static frame_index_data *gst_nuv_demux_do_seek_index(GstNuvDemux * nuv,
4.355 + gint64 seek_pos,
4.356 + gint64 segment_stop,
4.357 + GstFormat format);
4.358
4.359
4.360 -static GstFlowReturn gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size);
4.361 -static GstFlowReturn gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size,
4.362 - gboolean move, GstBuffer ** buffer);
4.363 -static void gst_nuv_demux_reset (GstNuvDemux * nuv);
4.364 -static void gst_nuv_demux_destoy_src_pad (GstNuvDemux * nuv);
4.365 -static void gst_nuv_demux_send_eos (GstNuvDemux * nuv);
4.366 -static void gst_nuv_demux_create_seek_index (GstNuvDemux * nuv);
4.367 +static GstFlowReturn gst_nuv_demux_move_bytes(GstNuvDemux * nuv,
4.368 + guint64 size);
4.369 +static GstFlowReturn gst_nuv_demux_read_bytes(GstNuvDemux * nuv, guint64 size,
4.370 + gboolean move,
4.371 + GstBuffer ** buffer);
4.372 +static void gst_nuv_demux_reset(GstNuvDemux * nuv);
4.373 +static void gst_nuv_demux_destoy_src_pad(GstNuvDemux * nuv);
4.374 +static void gst_nuv_demux_send_eos(GstNuvDemux * nuv);
4.375 +static void gst_nuv_demux_create_seek_index(GstNuvDemux * nuv);
4.376
4.377
4.378 -#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6)
4.379 -GstBuffer * gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes);
4.380 +#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6)
4.381 +GstBuffer *gst_adapter_take_buffer(GstAdapter * adapter, guint nbytes);
4.382 #endif
4.383
4.384
4.385 -GST_BOILERPLATE (GstNuvDemux, gst_nuv_demux, GstElement, GST_TYPE_ELEMENT);
4.386 +GST_BOILERPLATE(GstNuvDemux, gst_nuv_demux, GstElement, GST_TYPE_ELEMENT);
4.387
4.388 /******************************************************************************
4.389 * Utils function
4.390 ******************************************************************************/
4.391 #if G_BYTE_ORDER == G_BIG_ENDIAN
4.392 static inline gdouble
4.393 -_gdouble_swap_le_be (gdouble * d)
4.394 +_gdouble_swap_le_be(gdouble * d)
4.395 {
4.396 union
4.397 {
4.398 - guint64 i;
4.399 - gdouble d;
4.400 + guint64 i;
4.401 + gdouble d;
4.402 } u;
4.403
4.404 u.d = *d;
4.405 - u.i = GUINT64_SWAP_LE_BE (u.i);
4.406 + u.i = GUINT64_SWAP_LE_BE(u.i);
4.407 return u.d;
4.408 }
4.409
4.410 @@ -315,169 +323,186 @@
4.411 #endif /* G_BYTE_ORDER != G_BIG_ENDIAN */
4.412
4.413 static void
4.414 -double2fraction (double in, int *num, int *denom)
4.415 +double2fraction(double in, int *num, int *denom)
4.416 {
4.417 - if (in == 29.97) {
4.418 - *num = 30000;
4.419 - *denom = 1001;
4.420 - } else if (in == 23.976) {
4.421 - *num = 24000;
4.422 - *denom = 1001;
4.423 - } else {
4.424 - *denom = 1;
4.425 - while (in - floor(in) >= 0.1) {
4.426 - *denom *= 10;
4.427 - in *= 10.0;
4.428 - }
4.429 - *num = (int)floor(in);
4.430 - }
4.431 + if (in == 29.97)
4.432 + {
4.433 + *num = 30000;
4.434 + *denom = 1001;
4.435 + }
4.436 + else if (in == 23.976)
4.437 + {
4.438 + *num = 24000;
4.439 + *denom = 1001;
4.440 + }
4.441 + else
4.442 + {
4.443 + *denom = 1;
4.444 + while (in - floor(in) >= 0.1)
4.445 + {
4.446 + *denom *= 10;
4.447 + in *= 10.0;
4.448 + }
4.449 + *num = (int) floor(in);
4.450 + }
4.451 }
4.452
4.453 /* GObject Functions */
4.454
4.455 static void
4.456 -gst_nuv_demux_base_init (gpointer klass)
4.457 +gst_nuv_demux_base_init(gpointer klass)
4.458 {
4.459 - GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
4.460 + GstElementClass *element_class = GST_ELEMENT_CLASS(klass);
4.461
4.462 - gst_element_class_add_pad_template (element_class,
4.463 - gst_static_pad_template_get (&audio_src_template));
4.464 + gst_element_class_add_pad_template(element_class,
4.465 + gst_static_pad_template_get
4.466 + (&audio_src_template));
4.467
4.468 - gst_element_class_add_pad_template (element_class,
4.469 - gst_static_pad_template_get (&video_src_template));
4.470 + gst_element_class_add_pad_template(element_class,
4.471 + gst_static_pad_template_get
4.472 + (&video_src_template));
4.473
4.474 - gst_element_class_add_pad_template (element_class,
4.475 - gst_static_pad_template_get (&sink_template));
4.476 - gst_element_class_set_details (element_class, &gst_nuv_demux_details);
4.477 + gst_element_class_add_pad_template(element_class,
4.478 + gst_static_pad_template_get
4.479 + (&sink_template));
4.480 + gst_element_class_set_details(element_class, &gst_nuv_demux_details);
4.481 }
4.482
4.483 static void
4.484 -gst_nuv_demux_class_init (GstNuvDemuxClass * klass)
4.485 +gst_nuv_demux_class_init(GstNuvDemuxClass * klass)
4.486 {
4.487 - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
4.488 + GstElementClass *gstelement_class = GST_ELEMENT_CLASS(klass);
4.489 GObjectClass *gobject_class = (GObjectClass *) klass;
4.490
4.491 - GST_DEBUG_CATEGORY_INIT (nuvdemux_debug, "nuvdemux",
4.492 - 0, "Demuxer for NUV streams");
4.493 + GST_DEBUG_CATEGORY_INIT(nuvdemux_debug, "nuvdemux",
4.494 + 0, "Demuxer for NUV streams");
4.495
4.496 - parent_class = g_type_class_peek_parent (klass);
4.497 + parent_class = g_type_class_peek_parent(klass);
4.498
4.499 gobject_class->dispose = gst_nuv_demux_dispose;
4.500 gobject_class->finalize = gst_nuv_demux_finalize;
4.501 gstelement_class->change_state = gst_nuv_demux_change_state;
4.502
4.503 - g_type_class_add_private (gobject_class, sizeof (GstNuvDemuxPrivate));
4.504 + g_type_class_add_private(gobject_class, sizeof(GstNuvDemuxPrivate));
4.505 }
4.506
4.507 static void
4.508 -gst_nuv_demux_init (GstNuvDemux * nuv, GstNuvDemuxClass * nuv_class)
4.509 +gst_nuv_demux_init(GstNuvDemux * nuv, GstNuvDemuxClass * nuv_class)
4.510 {
4.511 - nuv->priv = GST_NUV_DEMUX_GET_PRIVATE (nuv);
4.512 - nuv->priv->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
4.513 + nuv->priv = GST_NUV_DEMUX_GET_PRIVATE(nuv);
4.514 + nuv->priv->sinkpad =
4.515 + gst_pad_new_from_static_template(&sink_template, "sink");
4.516
4.517 - /* creating adapter */
4.518 + /* creating adapter */
4.519 nuv->priv->mode = NUV_PUSH_MODE;
4.520 - nuv->priv->adapter = gst_adapter_new ();
4.521 + nuv->priv->adapter = gst_adapter_new();
4.522
4.523 nuv->priv->new_audio_segment = TRUE;
4.524 nuv->priv->new_video_segment = TRUE;
4.525
4.526 - gst_pad_set_activate_function (nuv->priv->sinkpad, gst_nuv_demux_sink_activate);
4.527 - gst_pad_set_activatepull_function (nuv->priv->sinkpad,
4.528 - gst_nuv_demux_sink_activate_pull);
4.529 - gst_pad_set_activatepush_function (nuv->priv->sinkpad,
4.530 - gst_nuv_demux_sink_activate_push);
4.531 - gst_pad_set_chain_function (nuv->priv->sinkpad,
4.532 - GST_DEBUG_FUNCPTR (gst_nuv_demux_chain));
4.533 - gst_pad_set_event_function (nuv->priv->sinkpad,
4.534 - GST_DEBUG_FUNCPTR (gst_nuv_demux_sink_event));
4.535 + gst_pad_set_activate_function(nuv->priv->sinkpad,
4.536 + gst_nuv_demux_sink_activate);
4.537 + gst_pad_set_activatepull_function(nuv->priv->sinkpad,
4.538 + gst_nuv_demux_sink_activate_pull);
4.539 + gst_pad_set_activatepush_function(nuv->priv->sinkpad,
4.540 + gst_nuv_demux_sink_activate_push);
4.541 + gst_pad_set_chain_function(nuv->priv->sinkpad,
4.542 + GST_DEBUG_FUNCPTR(gst_nuv_demux_chain));
4.543 + gst_pad_set_event_function(nuv->priv->sinkpad,
4.544 + GST_DEBUG_FUNCPTR(gst_nuv_demux_sink_event));
4.545
4.546
4.547 - gst_element_add_pad (GST_ELEMENT (nuv), nuv->priv->sinkpad);
4.548 + gst_element_add_pad(GST_ELEMENT(nuv), nuv->priv->sinkpad);
4.549
4.550 }
4.551
4.552 static void
4.553 -gst_nuv_demux_dispose (GObject * object)
4.554 +gst_nuv_demux_dispose(GObject * object)
4.555 {
4.556 - GstNuvDemux *nuv = GST_NUV_DEMUX (object);
4.557 + GstNuvDemux *nuv = GST_NUV_DEMUX(object);
4.558
4.559
4.560 - if (nuv->priv->mpeg_buffer != NULL) {
4.561 - gst_buffer_unref (nuv->priv->mpeg_buffer);
4.562 - }
4.563 + if (nuv->priv->mpeg_buffer != NULL)
4.564 + {
4.565 + gst_buffer_unref(nuv->priv->mpeg_buffer);
4.566 + }
4.567
4.568 - gst_nuv_demux_reset (GST_NUV_DEMUX (object));
4.569 - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (object));
4.570 + gst_nuv_demux_reset(GST_NUV_DEMUX(object));
4.571 + gst_nuv_demux_destoy_src_pad(GST_NUV_DEMUX(object));
4.572
4.573 - if (nuv->priv->adapter != NULL) {
4.574 - gst_object_unref (nuv->priv->adapter);
4.575 - }
4.576 + if (nuv->priv->adapter != NULL)
4.577 + {
4.578 + gst_object_unref(nuv->priv->adapter);
4.579 + }
4.580 }
4.581
4.582 static void
4.583 -gst_nuv_demux_finalize (GObject * object)
4.584 +gst_nuv_demux_finalize(GObject * object)
4.585 {
4.586 - G_OBJECT_CLASS (parent_class)->finalize (object);
4.587 + G_OBJECT_CLASS(parent_class)->finalize(object);
4.588 }
4.589
4.590
4.591 /* HeaderLoad:
4.592 */
4.593 static GstFlowReturn
4.594 -gst_nuv_demux_header_load (GstNuvDemux * nuv, nuv_header *h)
4.595 +gst_nuv_demux_header_load(GstNuvDemux * nuv, nuv_header * h)
4.596 {
4.597 GstBuffer *buffer = NULL;
4.598 - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 72, TRUE, &buffer);
4.599 + GstFlowReturn res = gst_nuv_demux_read_bytes(nuv, 72, TRUE, &buffer);
4.600
4.601 - if ((res != GST_FLOW_OK) || (buffer == NULL)) {
4.602 - goto done;
4.603 - }
4.604 + if ((res != GST_FLOW_OK) || (buffer == NULL))
4.605 + {
4.606 + goto done;
4.607 + }
4.608
4.609 - if (h != NULL) {
4.610 - memcpy (h->id, buffer->data, 12);
4.611 - memcpy (h->version, buffer->data + 12, 5);
4.612 - h->i_width = GST_READ_UINT32_LE (&buffer->data[20]);
4.613 - h->i_height = GST_READ_UINT32_LE (&buffer->data[24]);
4.614 - h->i_width_desired = GST_READ_UINT32_LE (&buffer->data[28]);
4.615 - h->i_height_desired = GST_READ_UINT32_LE (&buffer->data[32]);
4.616 - h->i_mode = GPOINTER_TO_INT (buffer->data[36]);
4.617 - h->d_aspect = READ_DOUBLE_FROM_LE (&buffer->data[40]);
4.618 - h->d_fps = READ_DOUBLE_FROM_LE (&buffer->data[48]);
4.619 - /* get the num and denom values from fps */
4.620 - double2fraction (h->d_fps, &h->i_fpsn, &h->i_fpsd);
4.621 - h->i_video_blocks = GST_READ_UINT32_LE (&buffer->data[56]);
4.622 - h->i_audio_blocks = GST_READ_UINT32_LE (&buffer->data[60]);
4.623 - h->i_text_blocks = GST_READ_UINT32_LE (&buffer->data[64]);
4.624 - h->i_keyframe_distance = GST_READ_UINT32_LE (&buffer->data[68]);
4.625 + if (h != NULL)
4.626 + {
4.627 + memcpy(h->id, buffer->data, 12);
4.628 + memcpy(h->version, buffer->data + 12, 5);
4.629 + h->i_width = GST_READ_UINT32_LE(&buffer->data[20]);
4.630 + h->i_height = GST_READ_UINT32_LE(&buffer->data[24]);
4.631 + h->i_width_desired = GST_READ_UINT32_LE(&buffer->data[28]);
4.632 + h->i_height_desired = GST_READ_UINT32_LE(&buffer->data[32]);
4.633 + h->i_mode = GPOINTER_TO_INT(buffer->data[36]);
4.634 + h->d_aspect = READ_DOUBLE_FROM_LE(&buffer->data[40]);
4.635 + h->d_fps = READ_DOUBLE_FROM_LE(&buffer->data[48]);
4.636 + /* get the num and denom values from fps */
4.637 + double2fraction(h->d_fps, &h->i_fpsn, &h->i_fpsd);
4.638 + h->i_video_blocks = GST_READ_UINT32_LE(&buffer->data[56]);
4.639 + h->i_audio_blocks = GST_READ_UINT32_LE(&buffer->data[60]);
4.640 + h->i_text_blocks = GST_READ_UINT32_LE(&buffer->data[64]);
4.641 + h->i_keyframe_distance = GST_READ_UINT32_LE(&buffer->data[68]);
4.642
4.643 - GST_DEBUG_OBJECT (nuv,
4.644 - "nuv: h=%s v=%s %dx%d a=%f fps=%f v=%d a=%d t=%d kfd=%d", h->id,
4.645 - h->version, h->i_width, h->i_height, h->d_aspect, h->d_fps,
4.646 - h->i_video_blocks, h->i_audio_blocks, h->i_text_blocks,
4.647 - h->i_keyframe_distance);
4.648 - }
4.649 + GST_DEBUG_OBJECT(nuv,
4.650 + "nuv: h=%s v=%s %dx%d a=%f fps=%f v=%d a=%d t=%d kfd=%d",
4.651 + h->id, h->version, h->i_width, h->i_height,
4.652 + h->d_aspect, h->d_fps, h->i_video_blocks,
4.653 + h->i_audio_blocks, h->i_text_blocks,
4.654 + h->i_keyframe_distance);
4.655 + }
4.656
4.657 done:
4.658 - if (buffer != NULL) {
4.659 - gst_buffer_unref (buffer);
4.660 - buffer = NULL;
4.661 - }
4.662 + if (buffer != NULL)
4.663 + {
4.664 + gst_buffer_unref(buffer);
4.665 + buffer = NULL;
4.666 + }
4.667 return res;
4.668 }
4.669
4.670 static GstFlowReturn
4.671 -gst_nuv_demux_stream_header_data (GstNuvDemux * nuv)
4.672 +gst_nuv_demux_stream_header_data(GstNuvDemux * nuv)
4.673 {
4.674 GstFlowReturn res;
4.675
4.676 - if (nuv->priv->new_file)
4.677 - res = gst_nuv_demux_header_load (nuv, NULL);
4.678 + if (nuv->priv->new_file)
4.679 + res = gst_nuv_demux_header_load(nuv, NULL);
4.680 else
4.681 - res = gst_nuv_demux_header_load (nuv, &nuv->priv->h);
4.682 + res = gst_nuv_demux_header_load(nuv, &nuv->priv->h);
4.683
4.684 if (res == GST_FLOW_OK)
4.685 - nuv->priv->state = GST_NUV_DEMUX_EXTRA_DATA;
4.686 + nuv->priv->state = GST_NUV_DEMUX_EXTRA_DATA;
4.687 return res;
4.688 }
4.689
4.690 @@ -485,258 +510,286 @@
4.691 * Read NUV file tag
4.692 */
4.693 static GstFlowReturn
4.694 -gst_nuv_demux_stream_file_header (GstNuvDemux * nuv)
4.695 +gst_nuv_demux_stream_file_header(GstNuvDemux * nuv)
4.696 {
4.697 GstFlowReturn res = GST_FLOW_OK;
4.698 GstBuffer *file_header = NULL;
4.699
4.700 - res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &file_header);
4.701 - if (res == GST_FLOW_OK) {
4.702 - if (strncmp ((gchar *) file_header->data, "MythTVVideo", 11) ||
4.703 - strncmp ((gchar *) file_header->data, "NuppelVideo", 11)) {
4.704 - nuv->priv->state = GST_NUV_DEMUX_HEADER_DATA;
4.705 - } else {
4.706 - GST_DEBUG_OBJECT (nuv, "error parsing file header");
4.707 - nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA;
4.708 - res = GST_FLOW_ERROR;
4.709 - }
4.710 - }
4.711 + res = gst_nuv_demux_read_bytes(nuv, 12, FALSE, &file_header);
4.712 + if (res == GST_FLOW_OK)
4.713 + {
4.714 + if (strncmp((gchar *) file_header->data, "MythTVVideo", 11) ||
4.715 + strncmp((gchar *) file_header->data, "NuppelVideo", 11))
4.716 + {
4.717 + nuv->priv->state = GST_NUV_DEMUX_HEADER_DATA;
4.718 + }
4.719 + else
4.720 + {
4.721 + GST_DEBUG_OBJECT(nuv, "error parsing file header");
4.722 + nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA;
4.723 + res = GST_FLOW_ERROR;
4.724 + }
4.725 + }
4.726
4.727 - if (file_header != NULL) {
4.728 - gst_buffer_unref (file_header);
4.729 - file_header = NULL;
4.730 - }
4.731 + if (file_header != NULL)
4.732 + {
4.733 + gst_buffer_unref(file_header);
4.734 + file_header = NULL;
4.735 + }
4.736 return res;
4.737 }
4.738
4.739 /* FrameHeaderLoad:
4.740 */
4.741 static GstFlowReturn
4.742 -gst_nuv_demux_frame_header_load (GstNuvDemux * nuv, nuv_frame_header *h)
4.743 +gst_nuv_demux_frame_header_load(GstNuvDemux * nuv, nuv_frame_header * h)
4.744 {
4.745 unsigned char *data;
4.746 GstBuffer *buf = NULL;
4.747
4.748 - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf);
4.749 + GstFlowReturn res = gst_nuv_demux_read_bytes(nuv, 12, TRUE, &buf);
4.750
4.751 - if ((res != GST_FLOW_OK) || (buf == NULL)) {
4.752 - goto done;
4.753 - }
4.754 + if ((res != GST_FLOW_OK) || (buf == NULL))
4.755 + {
4.756 + goto done;
4.757 + }
4.758
4.759 if (h == NULL)
4.760 goto done;
4.761 -
4.762 +
4.763 data = buf->data;
4.764
4.765 - h->i_type = GPOINTER_TO_INT (data[0]);
4.766 - h->i_compression = GPOINTER_TO_INT (data[1]);
4.767 - h->i_keyframe = GPOINTER_TO_INT (data[2]);
4.768 - h->i_filters = GPOINTER_TO_INT (data[3]);
4.769 - h->i_timecode = GST_READ_UINT32_LE (&data[4]);
4.770 - h->i_length = GST_READ_UINT32_LE (&data[8]);
4.771 + h->i_type = GPOINTER_TO_INT(data[0]);
4.772 + h->i_compression = GPOINTER_TO_INT(data[1]);
4.773 + h->i_keyframe = GPOINTER_TO_INT(data[2]);
4.774 + h->i_filters = GPOINTER_TO_INT(data[3]);
4.775 + h->i_timecode = GST_READ_UINT32_LE(&data[4]);
4.776 + h->i_length = GST_READ_UINT32_LE(&data[8]);
4.777
4.778 - GST_DEBUG_OBJECT (nuv, "frame hdr: t=%c c=%c k=%d f=0x%x timecode=%d l=%d",
4.779 - h->i_type,
4.780 - h->i_compression ? h->i_compression : ' ',
4.781 - h->i_keyframe ? h->i_keyframe : ' ',
4.782 - h->i_filters, h->i_timecode, h->i_length);
4.783 + GST_DEBUG_OBJECT(nuv, "frame hdr: t=%c c=%c k=%d f=0x%x timecode=%d l=%d",
4.784 + h->i_type,
4.785 + h->i_compression ? h->i_compression : ' ',
4.786 + h->i_keyframe ? h->i_keyframe : ' ',
4.787 + h->i_filters, h->i_timecode, h->i_length);
4.788
4.789 -done:
4.790 - if (buf != NULL) {
4.791 - gst_buffer_unref (buf);
4.792 - buf = NULL;
4.793 - }
4.794 +done:
4.795 + if (buf != NULL)
4.796 + {
4.797 + gst_buffer_unref(buf);
4.798 + buf = NULL;
4.799 + }
4.800
4.801 return res;
4.802 }
4.803
4.804 static GstFlowReturn
4.805 -gst_nuv_demux_extended_header_load (GstNuvDemux * nuv,
4.806 - nuv_extended_header * h)
4.807 +gst_nuv_demux_extended_header_load(GstNuvDemux * nuv, nuv_extended_header * h)
4.808 {
4.809 unsigned char *data;
4.810 GstBuffer *buff = NULL;
4.811
4.812 - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 512, TRUE, &buff);
4.813 + GstFlowReturn res = gst_nuv_demux_read_bytes(nuv, 512, TRUE, &buff);
4.814
4.815 - if ((res != GST_FLOW_OK) || (buff == NULL)) {
4.816 - goto done;
4.817 - }
4.818 + if ((res != GST_FLOW_OK) || (buff == NULL))
4.819 + {
4.820 + goto done;
4.821 + }
4.822
4.823 if (h == NULL)
4.824 - goto done;
4.825 + goto done;
4.826
4.827 data = buff->data;
4.828 - h->i_version = GST_READ_UINT32_LE (&data[0]);
4.829 - h->i_video_fcc = GST_MAKE_FOURCC (data[4], data[5], data[6], data[7]);
4.830 - h->i_audio_fcc = GST_MAKE_FOURCC (data[8], data[9], data[10], data[11]);
4.831 - h->i_audio_sample_rate = GST_READ_UINT32_LE (&data[12]);
4.832 - h->i_audio_bits_per_sample = GST_READ_UINT32_LE (&data[16]);
4.833 - h->i_audio_channels = GST_READ_UINT32_LE (&data[20]);
4.834 - h->i_audio_compression_ratio = GST_READ_UINT32_LE (&data[24]);
4.835 - h->i_audio_quality = GST_READ_UINT32_LE (&data[28]);
4.836 - h->i_rtjpeg_quality = GST_READ_UINT32_LE (&data[32]);
4.837 - h->i_rtjpeg_luma_filter = GST_READ_UINT32_LE (&data[36]);
4.838 - h->i_rtjpeg_chroma_filter = GST_READ_UINT32_LE (&data[40]);
4.839 - h->i_lavc_bitrate = GST_READ_UINT32_LE (&data[44]);
4.840 - h->i_lavc_qmin = GST_READ_UINT32_LE (&data[48]);
4.841 - h->i_lavc_qmin = GST_READ_UINT32_LE (&data[52]);
4.842 - h->i_lavc_maxqdiff = GST_READ_UINT32_LE (&data[56]);
4.843 - h->i_seekable_offset = GST_READ_UINT64_LE (&data[60]);
4.844 - h->i_keyframe_adjust_offset = GST_READ_UINT64_LE (&data[68]);
4.845 + h->i_version = GST_READ_UINT32_LE(&data[0]);
4.846 + h->i_video_fcc = GST_MAKE_FOURCC(data[4], data[5], data[6], data[7]);
4.847 + h->i_audio_fcc = GST_MAKE_FOURCC(data[8], data[9], data[10], data[11]);
4.848 + h->i_audio_sample_rate = GST_READ_UINT32_LE(&data[12]);
4.849 + h->i_audio_bits_per_sample = GST_READ_UINT32_LE(&data[16]);
4.850 + h->i_audio_channels = GST_READ_UINT32_LE(&data[20]);
4.851 + h->i_audio_compression_ratio = GST_READ_UINT32_LE(&data[24]);
4.852 + h->i_audio_quality = GST_READ_UINT32_LE(&data[28]);
4.853 + h->i_rtjpeg_quality = GST_READ_UINT32_LE(&data[32]);
4.854 + h->i_rtjpeg_luma_filter = GST_READ_UINT32_LE(&data[36]);
4.855 + h->i_rtjpeg_chroma_filter = GST_READ_UINT32_LE(&data[40]);
4.856 + h->i_lavc_bitrate = GST_READ_UINT32_LE(&data[44]);
4.857 + h->i_lavc_qmin = GST_READ_UINT32_LE(&data[48]);
4.858 + h->i_lavc_qmin = GST_READ_UINT32_LE(&data[52]);
4.859 + h->i_lavc_maxqdiff = GST_READ_UINT32_LE(&data[56]);
4.860 + h->i_seekable_offset = GST_READ_UINT64_LE(&data[60]);
4.861 + h->i_keyframe_adjust_offset = GST_READ_UINT64_LE(&data[68]);
4.862
4.863 - GST_DEBUG_OBJECT (nuv,
4.864 - "ex hdr: v=%d vffc=%4.4s afcc=%4.4s %dHz %dbits ach=%d acr=%d aq=%d"
4.865 - "rtjpeg q=%d lf=%d lc=%d lavc br=%d qmin=%d qmax=%d maxqdiff=%d seekableoff=%lld keyfao=%lld",
4.866 - h->i_version, (gchar *) & h->i_video_fcc, (gchar *) & h->i_audio_fcc,
4.867 - h->i_audio_sample_rate, h->i_audio_bits_per_sample, h->i_audio_channels,
4.868 - h->i_audio_compression_ratio, h->i_audio_quality, h->i_rtjpeg_quality,
4.869 - h->i_rtjpeg_luma_filter, h->i_rtjpeg_chroma_filter, h->i_lavc_bitrate,
4.870 - h->i_lavc_qmin, h->i_lavc_qmax, h->i_lavc_maxqdiff, h->i_seekable_offset,
4.871 - h->i_keyframe_adjust_offset);
4.872 + GST_DEBUG_OBJECT(nuv,
4.873 + "ex hdr: v=%d vffc=%4.4s afcc=%4.4s %dHz %dbits ach=%d acr=%d aq=%d"
4.874 + "rtjpeg q=%d lf=%d lc=%d lavc br=%d qmin=%d qmax=%d maxqdiff=%d seekableoff=%lld keyfao=%lld",
4.875 + h->i_version, (gchar *) & h->i_video_fcc,
4.876 + (gchar *) & h->i_audio_fcc, h->i_audio_sample_rate,
4.877 + h->i_audio_bits_per_sample, h->i_audio_channels,
4.878 + h->i_audio_compression_ratio, h->i_audio_quality,
4.879 + h->i_rtjpeg_quality, h->i_rtjpeg_luma_filter,
4.880 + h->i_rtjpeg_chroma_filter, h->i_lavc_bitrate,
4.881 + h->i_lavc_qmin, h->i_lavc_qmax, h->i_lavc_maxqdiff,
4.882 + h->i_seekable_offset, h->i_keyframe_adjust_offset);
4.883
4.884 done:
4.885 - if (buff != NULL) {
4.886 - gst_buffer_unref (buff);
4.887 - buff = NULL;
4.888 - }
4.889 + if (buff != NULL)
4.890 + {
4.891 + gst_buffer_unref(buff);
4.892 + buff = NULL;
4.893 + }
4.894 return res;
4.895 }
4.896
4.897
4.898 /* Query Functions */
4.899 static const GstQueryType *
4.900 -gst_nuv_demux_get_src_query_types (GstPad * pad)
4.901 +gst_nuv_demux_get_src_query_types(GstPad * pad)
4.902 {
4.903 static const GstQueryType src_types[] = {
4.904 - GST_QUERY_POSITION,
4.905 - GST_QUERY_DURATION,
4.906 - 0
4.907 + GST_QUERY_POSITION,
4.908 + GST_QUERY_DURATION,
4.909 + 0
4.910 };
4.911
4.912 return src_types;
4.913 }
4.914
4.915 static gboolean
4.916 -gst_nuv_demux_handle_src_query (GstPad * pad, GstQuery * query)
4.917 +gst_nuv_demux_handle_src_query(GstPad * pad, GstQuery * query)
4.918 {
4.919 gboolean res = FALSE;
4.920 - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
4.921 + GstNuvDemux *nuv = GST_NUV_DEMUX(gst_pad_get_parent(pad));
4.922
4.923
4.924 - switch (GST_QUERY_TYPE (query))
4.925 - {
4.926 - case GST_QUERY_POSITION:
4.927 + switch (GST_QUERY_TYPE(query))
4.928 {
4.929 + case GST_QUERY_POSITION:
4.930 + {
4.931 GstFormat format;
4.932 - gst_query_parse_position (query, &format, NULL);
4.933 - switch (format)
4.934 - {
4.935 - case GST_FORMAT_TIME:
4.936 - if (GST_CLOCK_TIME_IS_VALID (nuv->priv->last_frame_time)) {
4.937 - gst_query_set_position (query, GST_FORMAT_TIME, nuv->priv->last_frame_time);
4.938 - res = TRUE;
4.939 - }
4.940 - break;
4.941 - default:
4.942 - break;
4.943 - }
4.944 + gst_query_parse_position(query, &format, NULL);
4.945 + switch (format)
4.946 + {
4.947 + case GST_FORMAT_TIME:
4.948 + if (GST_CLOCK_TIME_IS_VALID(nuv->priv->last_frame_time))
4.949 + {
4.950 + gst_query_set_position(query, GST_FORMAT_TIME,
4.951 + nuv->priv->last_frame_time);
4.952 + res = TRUE;
4.953 + }
4.954 + break;
4.955 + default:
4.956 + break;
4.957 + }
4.958 break;
4.959 - }
4.960 - case GST_QUERY_DURATION:
4.961 - {
4.962 - GstFormat format;
4.963 - gst_query_parse_duration (query, &format, NULL);
4.964 - switch (format)
4.965 + }
4.966 + case GST_QUERY_DURATION:
4.967 {
4.968 - case GST_FORMAT_TIME:
4.969 - if (nuv->priv->duration_time != GST_CLOCK_TIME_NONE) {
4.970 - gst_query_set_duration (query, GST_FORMAT_TIME, nuv->priv->duration_time);
4.971 - res = TRUE;
4.972 - }
4.973 - break;
4.974 - default:
4.975 - break;
4.976 + GstFormat format;
4.977 + gst_query_parse_duration(query, &format, NULL);
4.978 + switch (format)
4.979 + {
4.980 + case GST_FORMAT_TIME:
4.981 + if (nuv->priv->duration_time != GST_CLOCK_TIME_NONE)
4.982 + {
4.983 + gst_query_set_duration(query, GST_FORMAT_TIME,
4.984 + nuv->priv->duration_time);
4.985 + res = TRUE;
4.986 + }
4.987 + break;
4.988 + default:
4.989 + break;
4.990 + }
4.991 + break;
4.992 }
4.993 - break;
4.994 - }
4.995 default:
4.996 break;
4.997 - }
4.998 + }
4.999
4.1000 - if (res==FALSE) {
4.1001 - res = gst_pad_query_default (pad, query);
4.1002 - }
4.1003 + if (res == FALSE)
4.1004 + {
4.1005 + res = gst_pad_query_default(pad, query);
4.1006 + }
4.1007
4.1008 - gst_object_unref (nuv);
4.1009 + gst_object_unref(nuv);
4.1010 return res;
4.1011 }
4.1012
4.1013 -static GstPad*
4.1014 -gst_nuv_demux_create_pad (GstNuvDemux *nuv, GstCaps *caps, GstStaticPadTemplate *template, const gchar* name)
4.1015 +static GstPad *
4.1016 +gst_nuv_demux_create_pad(GstNuvDemux * nuv, GstCaps * caps,
4.1017 + GstStaticPadTemplate * template, const gchar * name)
4.1018 {
4.1019 - GstPad *pad = NULL;
4.1020 - pad = gst_pad_new_from_static_template (template, name);
4.1021 - gst_pad_set_caps (pad, caps);
4.1022 - gst_pad_set_active (pad, TRUE);
4.1023 - gst_pad_use_fixed_caps (pad);
4.1024 - gst_element_add_pad (GST_ELEMENT (nuv), pad);
4.1025 + GstPad *pad = NULL;
4.1026 + pad = gst_pad_new_from_static_template(template, name);
4.1027 + gst_pad_set_caps(pad, caps);
4.1028 + gst_pad_set_active(pad, TRUE);
4.1029 + gst_pad_use_fixed_caps(pad);
4.1030 + gst_element_add_pad(GST_ELEMENT(nuv), pad);
4.1031
4.1032 - gst_pad_set_event_function (pad,
4.1033 - GST_DEBUG_FUNCPTR (gst_nuv_demux_srcpad_event));
4.1034 + gst_pad_set_event_function(pad,
4.1035 + GST_DEBUG_FUNCPTR(gst_nuv_demux_srcpad_event));
4.1036
4.1037 - gst_pad_set_query_type_function (pad,
4.1038 - GST_DEBUG_FUNCPTR (gst_nuv_demux_get_src_query_types));
4.1039 + gst_pad_set_query_type_function(pad,
4.1040 + GST_DEBUG_FUNCPTR
4.1041 + (gst_nuv_demux_get_src_query_types));
4.1042
4.1043 - gst_pad_set_query_function (pad,
4.1044 - GST_DEBUG_FUNCPTR (gst_nuv_demux_handle_src_query));
4.1045 -
4.1046 + gst_pad_set_query_function(pad,
4.1047 + GST_DEBUG_FUNCPTR
4.1048 + (gst_nuv_demux_handle_src_query));
4.1049
4.1050 - return pad;
4.1051 +
4.1052 + return pad;
4.1053 }
4.1054
4.1055 static void
4.1056 -gst_nuv_demux_create_pads (GstNuvDemux * nuv)
4.1057 +gst_nuv_demux_create_pads(GstNuvDemux * nuv)
4.1058 {
4.1059 - if (nuv->priv->h.i_video_blocks != 0) {
4.1060 - GstCaps *video_caps = NULL;
4.1061 + if (nuv->priv->h.i_video_blocks != 0)
4.1062 + {
4.1063 + GstCaps *video_caps = NULL;
4.1064
4.1065 - video_caps = gst_caps_new_simple ("video/x-divx",
4.1066 - "divxversion", G_TYPE_INT, 4,
4.1067 - "width", G_TYPE_INT, nuv->priv->h.i_width,
4.1068 - "height", G_TYPE_INT, nuv->priv->h.i_height,
4.1069 - "framerate", GST_TYPE_FRACTION, nuv->priv->h.i_fpsn, nuv->priv->h.i_fpsd,
4.1070 - "format", GST_TYPE_FOURCC, nuv->priv->eh.i_video_fcc,
4.1071 - "pixel-aspect-ratio", GST_TYPE_FRACTION,
4.1072 - (gint) (nuv->priv->h.d_aspect * 1000.0f), 1000, NULL);
4.1073 + video_caps = gst_caps_new_simple("video/x-divx",
4.1074 + "divxversion", G_TYPE_INT, 4,
4.1075 + "width", G_TYPE_INT,
4.1076 + nuv->priv->h.i_width, "height",
4.1077 + G_TYPE_INT, nuv->priv->h.i_height,
4.1078 + "framerate", GST_TYPE_FRACTION,
4.1079 + nuv->priv->h.i_fpsn,
4.1080 + nuv->priv->h.i_fpsd, "format",
4.1081 + GST_TYPE_FOURCC,
4.1082 + nuv->priv->eh.i_video_fcc,
4.1083 + "pixel-aspect-ratio",
4.1084 + GST_TYPE_FRACTION,
4.1085 + (gint) (nuv->priv->h.d_aspect *
4.1086 + 1000.0f), 1000, NULL);
4.1087
4.1088 - nuv->priv->src_video_pad = gst_nuv_demux_create_pad (nuv, video_caps, &video_src_template, "video_src");
4.1089 - gst_caps_unref (video_caps);
4.1090 - }
4.1091 + nuv->priv->src_video_pad =
4.1092 + gst_nuv_demux_create_pad(nuv, video_caps, &video_src_template,
4.1093 + "video_src");
4.1094 + gst_caps_unref(video_caps);
4.1095 + }
4.1096
4.1097 - if (nuv->priv->h.i_audio_blocks != 0) {
4.1098 - GstCaps *audio_caps = NULL;
4.1099 + if (nuv->priv->h.i_audio_blocks != 0)
4.1100 + {
4.1101 + GstCaps *audio_caps = NULL;
4.1102
4.1103 - audio_caps = gst_caps_new_simple ("audio/mpeg",
4.1104 - "rate", G_TYPE_INT, nuv->priv->eh.i_audio_sample_rate,
4.1105 - "format", GST_TYPE_FOURCC, nuv->priv->eh.i_audio_fcc,
4.1106 - "channels", G_TYPE_INT, nuv->priv->eh.i_audio_channels,
4.1107 - "layer", G_TYPE_INT, 3, // fixme: magic number
4.1108 - "mpegversion", G_TYPE_INT, nuv->priv->eh.i_version, NULL);
4.1109 -
4.1110 - nuv->priv->src_audio_pad = gst_nuv_demux_create_pad (nuv, audio_caps, &audio_src_template, "audio_src");
4.1111 - gst_caps_unref (audio_caps);
4.1112 - }
4.1113 + audio_caps = gst_caps_new_simple("audio/mpeg", "rate", G_TYPE_INT, nuv->priv->eh.i_audio_sample_rate, "format", GST_TYPE_FOURCC, nuv->priv->eh.i_audio_fcc, "channels", G_TYPE_INT, nuv->priv->eh.i_audio_channels, "layer", G_TYPE_INT, 3, // fixme: magic number
4.1114 + "mpegversion", G_TYPE_INT,
4.1115 + nuv->priv->eh.i_version, NULL);
4.1116
4.1117 - gst_element_no_more_pads (GST_ELEMENT (nuv));
4.1118 + nuv->priv->src_audio_pad =
4.1119 + gst_nuv_demux_create_pad(nuv, audio_caps, &audio_src_template,
4.1120 + "audio_src");
4.1121 + gst_caps_unref(audio_caps);
4.1122 + }
4.1123 +
4.1124 + gst_element_no_more_pads(GST_ELEMENT(nuv));
4.1125 }
4.1126
4.1127 static gboolean
4.1128 -gst_nuv_demux_validate_header (nuv_frame_header *h)
4.1129 +gst_nuv_demux_validate_header(nuv_frame_header * h)
4.1130 {
4.1131 gboolean valid = FALSE;
4.1132 - //g_usleep (1 * G_USEC_PER_SEC );
4.1133 - switch (h->i_type) {
4.1134 + //g_usleep (1 * G_USEC_PER_SEC );
4.1135 + switch (h->i_type)
4.1136 + {
4.1137 /*
4.1138 case 'V':
4.1139 if (h->i_compression == 0 ||
4.1140 @@ -768,63 +821,65 @@
4.1141 }
4.1142 break;
4.1143 */
4.1144 - case 'A':
4.1145 - case 'V':
4.1146 - case 'S':
4.1147 - case 'R':
4.1148 - case 'D':
4.1149 - case 'Q':
4.1150 - valid = TRUE;
4.1151 - break;
4.1152 - default:
4.1153 - valid = FALSE;
4.1154 - }
4.1155 + case 'A':
4.1156 + case 'V':
4.1157 + case 'S':
4.1158 + case 'R':
4.1159 + case 'D':
4.1160 + case 'Q':
4.1161 + valid = TRUE;
4.1162 + break;
4.1163 + default:
4.1164 + valid = FALSE;
4.1165 + }
4.1166
4.1167 return valid;
4.1168 }
4.1169
4.1170 static GstFlowReturn
4.1171 -gst_nuv_demux_read_head_frame (GstNuvDemux * nuv)
4.1172 +gst_nuv_demux_read_head_frame(GstNuvDemux * nuv)
4.1173 {
4.1174 GstFlowReturn ret = GST_FLOW_OK;
4.1175 gboolean valid = FALSE;
4.1176
4.1177 - do {
4.1178 - ret = gst_nuv_demux_frame_header_load (nuv, &nuv->priv->fh);
4.1179 - if (ret != GST_FLOW_OK) {
4.1180 - return ret;
4.1181 - }
4.1182 + do
4.1183 + {
4.1184 + ret = gst_nuv_demux_frame_header_load(nuv, &nuv->priv->fh);
4.1185 + if (ret != GST_FLOW_OK)
4.1186 + {
4.1187 + return ret;
4.1188 + }
4.1189
4.1190 - if (gst_nuv_demux_validate_header (&nuv->priv->fh) == TRUE)
4.1191 - valid = TRUE;
4.1192 + if (gst_nuv_demux_validate_header(&nuv->priv->fh) == TRUE)
4.1193 + valid = TRUE;
4.1194
4.1195 - } while (valid == FALSE);
4.1196 + }
4.1197 + while (valid == FALSE);
4.1198
4.1199 nuv->priv->state = GST_NUV_DEMUX_MOVI;
4.1200 return ret;
4.1201 }
4.1202
4.1203 static gboolean
4.1204 -gst_nuv_combine_flow (GstNuvDemux *nuv)
4.1205 +gst_nuv_combine_flow(GstNuvDemux * nuv)
4.1206 {
4.1207 - GstFlowReturn ret_video = nuv->priv->last_video_return;
4.1208 - GstFlowReturn ret_audio = nuv->priv->last_audio_return;
4.1209 + GstFlowReturn ret_video = nuv->priv->last_video_return;
4.1210 + GstFlowReturn ret_audio = nuv->priv->last_audio_return;
4.1211
4.1212 - if ((ret_video != GST_FLOW_OK) &&
4.1213 - (ret_audio != GST_FLOW_OK))
4.1214 - return FALSE;
4.1215 + if ((ret_video != GST_FLOW_OK) && (ret_audio != GST_FLOW_OK))
4.1216 + return FALSE;
4.1217
4.1218 - if (GST_FLOW_IS_FATAL (ret_video))
4.1219 - return FALSE;
4.1220 + if (GST_FLOW_IS_FATAL(ret_video))
4.1221 + return FALSE;
4.1222
4.1223 - if (GST_FLOW_IS_FATAL (ret_audio))
4.1224 - return FALSE;
4.1225 + if (GST_FLOW_IS_FATAL(ret_audio))
4.1226 + return FALSE;
4.1227
4.1228 - return TRUE;
4.1229 + return TRUE;
4.1230 }
4.1231
4.1232 static GstFlowReturn
4.1233 -gst_nuv_demux_stream_data (GstNuvDemux * nuv)
4.1234 +gst_nuv_demux_stream_data(GstNuvDemux * nuv)
4.1235 {
4.1236 GstFlowReturn ret = GST_FLOW_OK;
4.1237 GstPad *pad = NULL;
4.1238 @@ -834,539 +889,653 @@
4.1239
4.1240 h = nuv->priv->fh;
4.1241
4.1242 - if (h.i_type == 'R') {
4.1243 - goto done;
4.1244 - }
4.1245 -
4.1246 - if (h.i_length > 0) {
4.1247 - ret = gst_nuv_demux_read_bytes (nuv, h.i_length, TRUE, &buf);
4.1248 - if ((ret != GST_FLOW_OK) || (buf == NULL)) {
4.1249 - goto done;
4.1250 - }
4.1251 -
4.1252 - if ((h.i_timecode < 0)) {
4.1253 - h.i_timecode = 0;
4.1254 - //goto done;
4.1255 - }
4.1256 -
4.1257 - timestamp = h.i_timecode * GST_MSECOND;
4.1258 - GST_BUFFER_TIMESTAMP (buf) = timestamp;
4.1259 - }
4.1260 - else {
4.1261 - goto done;
4.1262 - }
4.1263 -
4.1264 -
4.1265 - switch (h.i_type) {
4.1266 - case 'V':
4.1267 - {
4.1268 - pad = nuv->priv->src_video_pad;
4.1269 -
4.1270 - if (nuv->priv->new_video_segment) {
4.1271 -
4.1272 - /* send new segment event*/
4.1273 - gst_pad_push_event (nuv->priv->src_video_pad,
4.1274 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
4.1275 - GST_CLOCK_TIME_NONE, 0));
4.1276 -
4.1277 - if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) {
4.1278 - nuv->priv->time_start = timestamp;
4.1279 - }
4.1280 - nuv->priv->new_video_segment = FALSE;
4.1281 - }
4.1282 -
4.1283 - break;
4.1284 - }
4.1285 - case 'A':
4.1286 - {
4.1287 - pad = nuv->priv->src_audio_pad;
4.1288 -
4.1289 - if (nuv->priv->new_audio_segment) {
4.1290 - /* send new segment event*/
4.1291 - gst_pad_push_event (nuv->priv->src_audio_pad,
4.1292 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
4.1293 - GST_CLOCK_TIME_NONE, 0));
4.1294 -
4.1295 - if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) {
4.1296 - nuv->priv->time_start = timestamp;
4.1297 - }
4.1298 - nuv->priv->new_audio_segment = FALSE;
4.1299 - }
4.1300 -
4.1301 - break;
4.1302 - }
4.1303 - case 'S':
4.1304 - {
4.1305 - switch (h.i_compression) {
4.1306 - case 'V':
4.1307 - GST_DEBUG_OBJECT (nuv, "sending new video segment: %d", h.i_timecode);
4.1308 - gst_pad_push_event (nuv->priv->src_video_pad,
4.1309 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, h.i_timecode * GST_MSECOND,
4.1310 - GST_CLOCK_TIME_NONE, 0));
4.1311 - break;
4.1312 - case 'A':
4.1313 - GST_DEBUG_OBJECT (nuv, "sending new audio segment: %d", h.i_timecode);
4.1314 - gst_pad_push_event (nuv->priv->src_audio_pad,
4.1315 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
4.1316 - GST_CLOCK_TIME_NONE, 0));
4.1317 - break;
4.1318 - default:
4.1319 - break;
4.1320 - }
4.1321 - goto done;
4.1322 - }
4.1323 - default:
4.1324 - break;
4.1325 - }
4.1326 -
4.1327 - if ((buf != NULL) && (pad != NULL)) {
4.1328 - /* pushing the buffer */
4.1329 - gst_buffer_set_caps (buf, GST_PAD_CAPS (pad));
4.1330 - ret = gst_pad_push (pad, buf);
4.1331 - buf = NULL;
4.1332 -
4.1333 - if (ret != GST_FLOW_OK) {
4.1334 - GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s", ret, gst_pad_get_name (pad));
4.1335 -
4.1336 - if (pad == nuv->priv->src_video_pad) {
4.1337 - nuv->priv->last_video_return = ret;
4.1338 - }
4.1339 - else if (pad == nuv->priv->src_audio_pad) {
4.1340 - nuv->priv->last_audio_return = ret;
4.1341 - }
4.1342 -
4.1343 - /* verify anothers flow if is necessary stop task */
4.1344 - if (gst_nuv_combine_flow (nuv) != FALSE) {
4.1345 - ret = GST_FLOW_OK;
4.1346 - } else {
4.1347 - GST_WARNING_OBJECT (nuv, "error: on push");
4.1348 + if (h.i_type == 'R')
4.1349 + {
4.1350 + goto done;
4.1351 }
4.1352
4.1353 - }
4.1354 - }
4.1355 + if (h.i_length > 0)
4.1356 + {
4.1357 + ret = gst_nuv_demux_read_bytes(nuv, h.i_length, TRUE, &buf);
4.1358 + if ((ret != GST_FLOW_OK) || (buf == NULL))
4.1359 + {
4.1360 + goto done;
4.1361 + }
4.1362 +
4.1363 + if ((h.i_timecode < 0))
4.1364 + {
4.1365 + h.i_timecode = 0;
4.1366 + //goto done;
4.1367 + }
4.1368 +
4.1369 + timestamp = h.i_timecode * GST_MSECOND;
4.1370 + GST_BUFFER_TIMESTAMP(buf) = timestamp;
4.1371 + }
4.1372 + else
4.1373 + {
4.1374 + goto done;
4.1375 + }
4.1376 +
4.1377 +
4.1378 + switch (h.i_type)
4.1379 + {
4.1380 + case 'V':
4.1381 + {
4.1382 + pad = nuv->priv->src_video_pad;
4.1383 +
4.1384 + if (nuv->priv->new_video_segment)
4.1385 + {
4.1386 +
4.1387 + /* send new segment event */
4.1388 + gst_pad_push_event(nuv->priv->src_video_pad,
4.1389 + gst_event_new_new_segment(TRUE, 1.0,
4.1390 + GST_FORMAT_TIME, 0,
4.1391 + GST_CLOCK_TIME_NONE,
4.1392 + 0));
4.1393 +
4.1394 + if (nuv->priv->time_start == GST_CLOCK_TIME_NONE)
4.1395 + {
4.1396 + nuv->priv->time_start = timestamp;
4.1397 + }
4.1398 + nuv->priv->new_video_segment = FALSE;
4.1399 + }
4.1400 +
4.1401 + break;
4.1402 + }
4.1403 + case 'A':
4.1404 + {
4.1405 + pad = nuv->priv->src_audio_pad;
4.1406 +
4.1407 + if (nuv->priv->new_audio_segment)
4.1408 + {
4.1409 + /* send new segment event */
4.1410 + gst_pad_push_event(nuv->priv->src_audio_pad,
4.1411 + gst_event_new_new_segment(TRUE, 1.0,
4.1412 + GST_FORMAT_TIME, 0,
4.1413 + GST_CLOCK_TIME_NONE,
4.1414 + 0));
4.1415 +
4.1416 + if (nuv->priv->time_start == GST_CLOCK_TIME_NONE)
4.1417 + {
4.1418 + nuv->priv->time_start = timestamp;
4.1419 + }
4.1420 + nuv->priv->new_audio_segment = FALSE;
4.1421 + }
4.1422 +
4.1423 + break;
4.1424 + }
4.1425 + case 'S':
4.1426 + {
4.1427 + switch (h.i_compression)
4.1428 + {
4.1429 + case 'V':
4.1430 + GST_DEBUG_OBJECT(nuv, "sending new video segment: %d",
4.1431 + h.i_timecode);
4.1432 + gst_pad_push_event(nuv->priv->src_video_pad,
4.1433 + gst_event_new_new_segment(TRUE, 1.0,
4.1434 + GST_FORMAT_TIME,
4.1435 + h.i_timecode *
4.1436 + GST_MSECOND,
4.1437 + GST_CLOCK_TIME_NONE,
4.1438 + 0));
4.1439 + break;
4.1440 + case 'A':
4.1441 + GST_DEBUG_OBJECT(nuv, "sending new audio segment: %d",
4.1442 + h.i_timecode);
4.1443 + gst_pad_push_event(nuv->priv->src_audio_pad,
4.1444 + gst_event_new_new_segment(TRUE, 1.0,
4.1445 + GST_FORMAT_TIME, 0,
4.1446 + GST_CLOCK_TIME_NONE,
4.1447 + 0));
4.1448 + break;
4.1449 + default:
4.1450 + break;
4.1451 + }
4.1452 + goto done;
4.1453 + }
4.1454 + default:
4.1455 + break;
4.1456 + }
4.1457 +
4.1458 + if ((buf != NULL) && (pad != NULL))
4.1459 + {
4.1460 + /* pushing the buffer */
4.1461 + gst_buffer_set_caps(buf, GST_PAD_CAPS(pad));
4.1462 + ret = gst_pad_push(pad, buf);
4.1463 + buf = NULL;
4.1464 +
4.1465 + if (ret != GST_FLOW_OK)
4.1466 + {
4.1467 + GST_WARNING_OBJECT(nuv, "error: %d pushing on srcpad %s", ret,
4.1468 + gst_pad_get_name(pad));
4.1469 +
4.1470 + if (pad == nuv->priv->src_video_pad)
4.1471 + {
4.1472 + nuv->priv->last_video_return = ret;
4.1473 + }
4.1474 + else if (pad == nuv->priv->src_audio_pad)
4.1475 + {
4.1476 + nuv->priv->last_audio_return = ret;
4.1477 + }
4.1478 +
4.1479 + /* verify anothers flow if is necessary stop task */
4.1480 + if (gst_nuv_combine_flow(nuv) != FALSE)
4.1481 + {
4.1482 + ret = GST_FLOW_OK;
4.1483 + }
4.1484 + else
4.1485 + {
4.1486 + GST_WARNING_OBJECT(nuv, "error: on push");
4.1487 + }
4.1488 +
4.1489 + }
4.1490 + }
4.1491
4.1492 done:
4.1493 - if (buf != NULL) {
4.1494 - gst_buffer_unref (buf);
4.1495 - buf = NULL;
4.1496 - }
4.1497 - if (ret == GST_FLOW_OK) {
4.1498 - nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER;
4.1499 - memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh));
4.1500 - }
4.1501 + if (buf != NULL)
4.1502 + {
4.1503 + gst_buffer_unref(buf);
4.1504 + buf = NULL;
4.1505 + }
4.1506 + if (ret == GST_FLOW_OK)
4.1507 + {
4.1508 + nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER;
4.1509 + memset(&nuv->priv->fh, 0, sizeof(nuv->priv->fh));
4.1510 + }
4.1511 return ret;
4.1512 }
4.1513
4.1514 static GstFlowReturn
4.1515 -gst_nuv_demux_stream_mpeg_data (GstNuvDemux * nuv)
4.1516 +gst_nuv_demux_stream_mpeg_data(GstNuvDemux * nuv)
4.1517 {
4.1518 GstFlowReturn ret = GST_FLOW_OK;
4.1519
4.1520 - /* ffmpeg extra data */
4.1521 - if (nuv->priv->new_file) {
4.1522 - GstBuffer *buf;
4.1523 - ret = gst_nuv_demux_read_bytes (nuv, nuv->priv->mpeg_data_size, TRUE, &buf);
4.1524 - gst_buffer_unref (buf);
4.1525 - } else {
4.1526 - ret = gst_nuv_demux_read_bytes (nuv, nuv->priv->mpeg_data_size, TRUE,
4.1527 - &nuv->priv->mpeg_buffer);
4.1528 - }
4.1529 + /* ffmpeg extra data */
4.1530 + if (nuv->priv->new_file)
4.1531 + {
4.1532 + GstBuffer *buf;
4.1533 + ret =
4.1534 + gst_nuv_demux_read_bytes(nuv, nuv->priv->mpeg_data_size, TRUE, &buf);
4.1535 + gst_buffer_unref(buf);
4.1536 + }
4.1537 + else
4.1538 + {
4.1539 + ret = gst_nuv_demux_read_bytes(nuv, nuv->priv->mpeg_data_size, TRUE,
4.1540 + &nuv->priv->mpeg_buffer);
4.1541 + }
4.1542
4.1543 - if ((ret != GST_FLOW_OK) || (nuv->priv->mpeg_buffer == NULL)) {
4.1544 - return ret;
4.1545 - }
4.1546 + if ((ret != GST_FLOW_OK) || (nuv->priv->mpeg_buffer == NULL))
4.1547 + {
4.1548 + return ret;
4.1549 + }
4.1550
4.1551 - GST_BUFFER_SIZE (nuv->priv->mpeg_buffer) = nuv->priv->mpeg_data_size;
4.1552 + GST_BUFFER_SIZE(nuv->priv->mpeg_buffer) = nuv->priv->mpeg_data_size;
4.1553 nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER;
4.1554 return ret;
4.1555 }
4.1556
4.1557 static GstFlowReturn
4.1558 -gst_nuv_demux_stream_extra_data (GstNuvDemux * nuv)
4.1559 +gst_nuv_demux_stream_extra_data(GstNuvDemux * nuv)
4.1560 {
4.1561 GstFlowReturn ret = GST_FLOW_OK;
4.1562
4.1563 - /* Load 'D' */
4.1564 + /* Load 'D' */
4.1565 nuv_frame_header h;
4.1566
4.1567 - if (nuv->priv->new_file)
4.1568 - ret = gst_nuv_demux_frame_header_load (nuv, NULL);
4.1569 - else
4.1570 - ret = gst_nuv_demux_frame_header_load (nuv, &h);
4.1571 + if (nuv->priv->new_file)
4.1572 + ret = gst_nuv_demux_frame_header_load(nuv, NULL);
4.1573 + else
4.1574 + ret = gst_nuv_demux_frame_header_load(nuv, &h);
4.1575
4.1576 if (ret != GST_FLOW_OK)
4.1577 - return ret;
4.1578 + return ret;
4.1579
4.1580 - if (h.i_type != 'D') {
4.1581 - GST_WARNING_OBJECT (nuv, "Unsuported rtjpeg");
4.1582 - return GST_FLOW_NOT_SUPPORTED;
4.1583 - }
4.1584 + if (h.i_type != 'D')
4.1585 + {
4.1586 + GST_WARNING_OBJECT(nuv, "Unsuported rtjpeg");
4.1587 + return GST_FLOW_NOT_SUPPORTED;
4.1588 + }
4.1589
4.1590 - if (h.i_length > 0) {
4.1591 - if (h.i_compression == 'F') {
4.1592 - nuv->priv->state = GST_NUV_DEMUX_MPEG_DATA;
4.1593 - } else {
4.1594 - GST_WARNING_OBJECT (nuv, "only file with extended chunk are supported");
4.1595 - return GST_FLOW_NOT_SUPPORTED;
4.1596 - }
4.1597 - } else {
4.1598 - nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER;
4.1599 - }
4.1600 + if (h.i_length > 0)
4.1601 + {
4.1602 + if (h.i_compression == 'F')
4.1603 + {
4.1604 + nuv->priv->state = GST_NUV_DEMUX_MPEG_DATA;
4.1605 + }
4.1606 + else
4.1607 + {
4.1608 + GST_WARNING_OBJECT(nuv,
4.1609 + "only file with extended chunk are supported");
4.1610 + return GST_FLOW_NOT_SUPPORTED;
4.1611 + }
4.1612 + }
4.1613 + else
4.1614 + {
4.1615 + nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER;
4.1616 + }
4.1617
4.1618 return ret;
4.1619 }
4.1620
4.1621 static GstFlowReturn
4.1622 -gst_nuv_demux_stream_extend_header_data (GstNuvDemux * nuv)
4.1623 +gst_nuv_demux_stream_extend_header_data(GstNuvDemux * nuv)
4.1624 {
4.1625 GstFlowReturn ret = GST_FLOW_OK;
4.1626
4.1627 if (nuv->priv->new_file)
4.1628 - ret = gst_nuv_demux_extended_header_load (nuv, NULL);
4.1629 - else {
4.1630 - ret = gst_nuv_demux_extended_header_load (nuv, &nuv->priv->eh);
4.1631 + ret = gst_nuv_demux_extended_header_load(nuv, NULL);
4.1632 + else
4.1633 + {
4.1634 + ret = gst_nuv_demux_extended_header_load(nuv, &nuv->priv->eh);
4.1635 if (ret != GST_FLOW_OK)
4.1636 - return ret;
4.1637 - gst_nuv_demux_create_pads (nuv);
4.1638 - }
4.1639 + return ret;
4.1640 + gst_nuv_demux_create_pads(nuv);
4.1641 + }
4.1642
4.1643 nuv->priv->state = GST_NUV_DEMUX_INDEX_CREATE;
4.1644 return ret;
4.1645 }
4.1646
4.1647 static GstFlowReturn
4.1648 -gst_nuv_demux_stream_extend_header (GstNuvDemux * nuv)
4.1649 +gst_nuv_demux_stream_extend_header(GstNuvDemux * nuv)
4.1650 {
4.1651 GstBuffer *buf = NULL;
4.1652 GstFlowReturn res = GST_FLOW_OK;
4.1653
4.1654 - res = gst_nuv_demux_read_bytes (nuv, 1, FALSE, &buf);
4.1655 - if ((res != GST_FLOW_OK) || (buf == NULL)) {
4.1656 - if (buf != NULL) {
4.1657 - gst_buffer_unref (buf);
4.1658 - }
4.1659 - return res;
4.1660 - }
4.1661 + res = gst_nuv_demux_read_bytes(nuv, 1, FALSE, &buf);
4.1662 + if ((res != GST_FLOW_OK) || (buf == NULL))
4.1663 + {
4.1664 + if (buf != NULL)
4.1665 + {
4.1666 + gst_buffer_unref(buf);
4.1667 + }
4.1668 + return res;
4.1669 + }
4.1670
4.1671 - if (buf->data[0] == 'X') {
4.1672 - gst_buffer_unref (buf);
4.1673 - buf = NULL;
4.1674 - nuv_frame_header h;
4.1675 + if (buf->data[0] == 'X')
4.1676 + {
4.1677 + gst_buffer_unref(buf);
4.1678 + buf = NULL;
4.1679 + nuv_frame_header h;
4.1680
4.1681 - res = gst_nuv_demux_frame_header_load (nuv, &h);
4.1682 - if (res != GST_FLOW_OK)
4.1683 - return res;
4.1684 + res = gst_nuv_demux_frame_header_load(nuv, &h);
4.1685 + if (res != GST_FLOW_OK)
4.1686 + return res;
4.1687
4.1688 - if (h.i_length != 512) {
4.1689 - return GST_FLOW_ERROR;
4.1690 - }
4.1691 - nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER_DATA;
4.1692 - } else {
4.1693 - nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA;
4.1694 - g_object_unref (buf);
4.1695 - GST_ELEMENT_WARNING (nuv, STREAM, FAILED,
4.1696 - (_("incomplete NUV support")), ("incomplete NUV support"));
4.1697 - return GST_FLOW_ERROR;
4.1698 - }
4.1699 + if (h.i_length != 512)
4.1700 + {
4.1701 + return GST_FLOW_ERROR;
4.1702 + }
4.1703 + nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER_DATA;
4.1704 + }
4.1705 + else
4.1706 + {
4.1707 + nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA;
4.1708 + g_object_unref(buf);
4.1709 + GST_ELEMENT_WARNING(nuv, STREAM, FAILED,
4.1710 + (_("incomplete NUV support")),
4.1711 + ("incomplete NUV support"));
4.1712 + return GST_FLOW_ERROR;
4.1713 + }
4.1714 return res;
4.1715 }
4.1716
4.1717 static void
4.1718 -gst_nuv_demux_create_seek_index (GstNuvDemux * nuv)
4.1719 +gst_nuv_demux_create_seek_index(GstNuvDemux * nuv)
4.1720 {
4.1721 GstMessage *msg;
4.1722 nuv_frame_header h;
4.1723
4.1724 - while (gst_nuv_demux_frame_header_load (nuv, &h) == GST_FLOW_OK) {
4.1725 - if ((h.i_type == 'V') && (h.i_keyframe == 0)) {
4.1726 - frame_index_data *f = g_new0 (frame_index_data, 1);
4.1727 + while (gst_nuv_demux_frame_header_load(nuv, &h) == GST_FLOW_OK)
4.1728 + {
4.1729 + if ((h.i_type == 'V') && (h.i_keyframe == 0))
4.1730 + {
4.1731 + frame_index_data *f = g_new0(frame_index_data, 1);
4.1732
4.1733 - f->offset = nuv->priv->offset - 12;
4.1734 - f->timecode = h.i_timecode * GST_MSECOND;
4.1735 + f->offset = nuv->priv->offset - 12;
4.1736 + f->timecode = h.i_timecode * GST_MSECOND;
4.1737
4.1738 - nuv->priv->index = g_slist_append (nuv->priv->index, f);
4.1739 - }
4.1740 - if (h.i_type != 'R') {
4.1741 - nuv->priv->offset += h.i_length;
4.1742 + nuv->priv->index = g_slist_append(nuv->priv->index, f);
4.1743 + }
4.1744 + if (h.i_type != 'R')
4.1745 + {
4.1746 + nuv->priv->offset += h.i_length;
4.1747 if (h.i_type == 'A' || h.i_type == 'V')
4.1748 - nuv->priv->duration_time = h.i_timecode * GST_MSECOND;
4.1749 - }
4.1750 - }
4.1751 - GST_DEBUG_OBJECT (nuv, "CREATING INDEX: DONE : DURATION Bytes/Sec: %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT,
4.1752 - nuv->priv->offset, nuv->priv->duration_time);
4.1753 -
4.1754 + nuv->priv->duration_time = h.i_timecode * GST_MSECOND;
4.1755 + }
4.1756 + }
4.1757 + GST_DEBUG_OBJECT(nuv,
4.1758 + "CREATING INDEX: DONE : DURATION Bytes/Sec: %"
4.1759 + G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, nuv->priv->offset,
4.1760 + nuv->priv->duration_time);
4.1761 +
4.1762 nuv->priv->duration_bytes = nuv->priv->offset;
4.1763 nuv->priv->offset = nuv->priv->header_lengh;
4.1764
4.1765 - msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_time);
4.1766 - gst_element_post_message (GST_ELEMENT (nuv), msg);
4.1767 + msg =
4.1768 + gst_message_new_duration(GST_OBJECT(nuv), GST_FORMAT_TIME,
4.1769 + nuv->priv->duration_time);
4.1770 + gst_element_post_message(GST_ELEMENT(nuv), msg);
4.1771 }
4.1772
4.1773 static GstFlowReturn
4.1774 -gst_nuv_demux_play (GstPad * pad)
4.1775 +gst_nuv_demux_play(GstPad * pad)
4.1776 {
4.1777 GstFlowReturn res = GST_FLOW_OK;
4.1778 - GstNuvDemux *nuv = GST_NUV_DEMUX (GST_PAD_PARENT (pad));
4.1779 + GstNuvDemux *nuv = GST_NUV_DEMUX(GST_PAD_PARENT(pad));
4.1780
4.1781 - switch (nuv->priv->state) {
4.1782 - case GST_NUV_DEMUX_START:
4.1783 - res = gst_nuv_demux_stream_file_header (nuv);
4.1784 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1785 - goto pause;
4.1786 - }
4.1787 - break;
4.1788 + switch (nuv->priv->state)
4.1789 + {
4.1790 + case GST_NUV_DEMUX_START:
4.1791 + res = gst_nuv_demux_stream_file_header(nuv);
4.1792 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1793 + {
4.1794 + goto pause;
4.1795 + }
4.1796 + break;
4.1797
4.1798 - case GST_NUV_DEMUX_HEADER_DATA:
4.1799 - res = gst_nuv_demux_stream_header_data (nuv);
4.1800 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1801 - goto pause;
4.1802 - }
4.1803 - break;
4.1804 + case GST_NUV_DEMUX_HEADER_DATA:
4.1805 + res = gst_nuv_demux_stream_header_data(nuv);
4.1806 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1807 + {
4.1808 + goto pause;
4.1809 + }
4.1810 + break;
4.1811
4.1812 - case GST_NUV_DEMUX_EXTRA_DATA:
4.1813 - res = gst_nuv_demux_stream_extra_data (nuv);
4.1814 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1815 - goto pause;
4.1816 - }
4.1817 - break;
4.1818 + case GST_NUV_DEMUX_EXTRA_DATA:
4.1819 + res = gst_nuv_demux_stream_extra_data(nuv);
4.1820 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1821 + {
4.1822 + goto pause;
4.1823 + }
4.1824 + break;
4.1825
4.1826 - case GST_NUV_DEMUX_MPEG_DATA:
4.1827 - res = gst_nuv_demux_stream_mpeg_data (nuv);
4.1828 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1829 - goto pause;
4.1830 - }
4.1831 - break;
4.1832 + case GST_NUV_DEMUX_MPEG_DATA:
4.1833 + res = gst_nuv_demux_stream_mpeg_data(nuv);
4.1834 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1835 + {
4.1836 + goto pause;
4.1837 + }
4.1838 + break;
4.1839
4.1840 - case GST_NUV_DEMUX_EXTEND_HEADER:
4.1841 - res = gst_nuv_demux_stream_extend_header (nuv);
4.1842 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1843 - goto pause;
4.1844 - }
4.1845 - break;
4.1846 + case GST_NUV_DEMUX_EXTEND_HEADER:
4.1847 + res = gst_nuv_demux_stream_extend_header(nuv);
4.1848 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1849 + {
4.1850 + goto pause;
4.1851 + }
4.1852 + break;
4.1853
4.1854 - case GST_NUV_DEMUX_EXTEND_HEADER_DATA:
4.1855 - res = gst_nuv_demux_stream_extend_header_data (nuv);
4.1856 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1857 - goto pause;
4.1858 - }
4.1859 - //store file header size
4.1860 - nuv->priv->header_lengh = nuv->priv->offset;
4.1861 - break;
4.1862 + case GST_NUV_DEMUX_EXTEND_HEADER_DATA:
4.1863 + res = gst_nuv_demux_stream_extend_header_data(nuv);
4.1864 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1865 + {
4.1866 + goto pause;
4.1867 + }
4.1868 + //store file header size
4.1869 + nuv->priv->header_lengh = nuv->priv->offset;
4.1870 + break;
4.1871
4.1872 - case GST_NUV_DEMUX_INDEX_CREATE:
4.1873 - if ((nuv->priv->mode == NUV_PULL_MODE) && (!nuv->priv->new_file)) {
4.1874 - gst_nuv_demux_create_seek_index (nuv);
4.1875 - }
4.1876 + case GST_NUV_DEMUX_INDEX_CREATE:
4.1877 + if ((nuv->priv->mode == NUV_PULL_MODE) && (!nuv->priv->new_file))
4.1878 + {
4.1879 + gst_nuv_demux_create_seek_index(nuv);
4.1880 + }
4.1881
4.1882 - case GST_NUV_DEMUX_FRAME_HEADER:
4.1883 - res = gst_nuv_demux_read_head_frame (nuv);
4.1884 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1885 - goto pause;
4.1886 - }
4.1887 - break;
4.1888 + case GST_NUV_DEMUX_FRAME_HEADER:
4.1889 + res = gst_nuv_demux_read_head_frame(nuv);
4.1890 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1891 + {
4.1892 + goto pause;
4.1893 + }
4.1894 + break;
4.1895
4.1896 - case GST_NUV_DEMUX_MOVI:
4.1897 - res = gst_nuv_demux_stream_data (nuv);
4.1898 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
4.1899 - goto pause;
4.1900 - }
4.1901 - break;
4.1902 + case GST_NUV_DEMUX_MOVI:
4.1903 + res = gst_nuv_demux_stream_data(nuv);
4.1904 + if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA))
4.1905 + {
4.1906 + goto pause;
4.1907 + }
4.1908 + break;
4.1909
4.1910 - case GST_NUV_DEMUX_INVALID_DATA:
4.1911 - goto pause;
4.1912 - break;
4.1913 - default:
4.1914 - g_assert_not_reached ();
4.1915 - }
4.1916 + case GST_NUV_DEMUX_INVALID_DATA:
4.1917 + goto pause;
4.1918 + break;
4.1919 + default:
4.1920 + g_assert_not_reached();
4.1921 + }
4.1922
4.1923 return GST_FLOW_OK;
4.1924
4.1925 pause:
4.1926 - GST_LOG_OBJECT (nuv, "pausing task, reason %s", gst_flow_get_name (res));
4.1927 - gst_pad_pause_task (nuv->priv->sinkpad);
4.1928 + GST_LOG_OBJECT(nuv, "pausing task, reason %s", gst_flow_get_name(res));
4.1929 + gst_pad_pause_task(nuv->priv->sinkpad);
4.1930
4.1931 - if (res == GST_FLOW_ERROR_EOS) {
4.1932 - gst_nuv_demux_send_eos (nuv);
4.1933 - nuv->priv->eos = TRUE;
4.1934 - res = GST_FLOW_OK;
4.1935 - }
4.1936 + if (res == GST_FLOW_ERROR_EOS)
4.1937 + {
4.1938 + gst_nuv_demux_send_eos(nuv);
4.1939 + nuv->priv->eos = TRUE;
4.1940 + res = GST_FLOW_OK;
4.1941 + }
4.1942
4.1943 - if (GST_FLOW_IS_FATAL (res)) {
4.1944 - GST_ELEMENT_ERROR (nuv, STREAM, FAILED,
4.1945 - (_("Internal data stream error.")),
4.1946 - ("streaming stopped, reason %s", gst_flow_get_name (res)));
4.1947 + if (GST_FLOW_IS_FATAL(res))
4.1948 + {
4.1949 + GST_ELEMENT_ERROR(nuv, STREAM, FAILED,
4.1950 + (_("Internal data stream error.")),
4.1951 + ("streaming stopped, reason %s",
4.1952 + gst_flow_get_name(res)));
4.1953
4.1954 - gst_nuv_demux_send_eos (nuv);
4.1955 - }
4.1956 + gst_nuv_demux_send_eos(nuv);
4.1957 + }
4.1958 return res;
4.1959 }
4.1960
4.1961 static void
4.1962 -gst_nuv_demux_send_eos (GstNuvDemux * nuv)
4.1963 +gst_nuv_demux_send_eos(GstNuvDemux * nuv)
4.1964 {
4.1965 - gst_element_post_message (GST_ELEMENT (nuv),
4.1966 - gst_message_new_segment_done (GST_OBJECT (nuv), GST_FORMAT_TIME, -1));
4.1967 + gst_element_post_message(GST_ELEMENT(nuv),
4.1968 + gst_message_new_segment_done(GST_OBJECT(nuv),
4.1969 + GST_FORMAT_TIME, -1));
4.1970
4.1971 if (nuv->priv->src_video_pad)
4.1972 - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_eos ());
4.1973 + gst_pad_push_event(nuv->priv->src_video_pad, gst_event_new_eos());
4.1974 if (nuv->priv->src_audio_pad)
4.1975 - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_eos ());
4.1976 + gst_pad_push_event(nuv->priv->src_audio_pad, gst_event_new_eos());
4.1977 }
4.1978
4.1979 static GstFlowReturn
4.1980 -gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size, gboolean move,
4.1981 - GstBuffer ** buffer)
4.1982 +gst_nuv_demux_read_bytes(GstNuvDemux * nuv, guint64 size, gboolean move,
4.1983 + GstBuffer ** buffer)
4.1984 {
4.1985 GstFlowReturn ret = GST_FLOW_OK;
4.1986
4.1987 - if (size == 0) {
4.1988 - return ret;
4.1989 - }
4.1990 + if (size == 0)
4.1991 + {
4.1992 + return ret;
4.1993 + }
4.1994
4.1995 - if (nuv->priv->mode == NUV_PULL_MODE) {
4.1996 - ret = gst_pad_pull_range (nuv->priv->sinkpad, nuv->priv->offset, size, buffer);
4.1997 - if (ret == GST_FLOW_OK) {
4.1998 - if (move) {
4.1999 - nuv->priv->offset += size;
4.2000 - }
4.2001 - /* got eos */
4.2002 - } else if (ret == GST_FLOW_UNEXPECTED) {
4.2003 - return GST_FLOW_ERROR_EOS;
4.2004 - }
4.2005 - } else {
4.2006 - if (gst_adapter_available (nuv->priv->adapter) < size) {
4.2007 - nuv->priv->more_data = TRUE;
4.2008 - return GST_FLOW_ERROR_NO_DATA;
4.2009 - }
4.2010 - if (move) {
4.2011 - *buffer = gst_adapter_take_buffer (nuv->priv->adapter, size);
4.2012 - } else {
4.2013 - guint8 *data = NULL;
4.2014 - data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size);
4.2015 - *buffer = gst_buffer_new ();
4.2016 - gst_buffer_set_data (*buffer, data, size);
4.2017 - }
4.2018 - }
4.2019 + if (nuv->priv->mode == NUV_PULL_MODE)
4.2020 + {
4.2021 + ret =
4.2022 + gst_pad_pull_range(nuv->priv->sinkpad, nuv->priv->offset, size,
4.2023 + buffer);
4.2024 + if (ret == GST_FLOW_OK)
4.2025 + {
4.2026 + if (move)
4.2027 + {
4.2028 + nuv->priv->offset += size;
4.2029 + }
4.2030 + /* got eos */
4.2031 + }
4.2032 + else if (ret == GST_FLOW_UNEXPECTED)
4.2033 + {
4.2034 + return GST_FLOW_ERROR_EOS;
4.2035 + }
4.2036 + }
4.2037 + else
4.2038 + {
4.2039 + if (gst_adapter_available(nuv->priv->adapter) < size)
4.2040 + {
4.2041 + nuv->priv->more_data = TRUE;
4.2042 + return GST_FLOW_ERROR_NO_DATA;
4.2043 + }
4.2044 + if (move)
4.2045 + {
4.2046 + *buffer = gst_adapter_take_buffer(nuv->priv->adapter, size);
4.2047 + }
4.2048 + else
4.2049 + {
4.2050 + guint8 *data = NULL;
4.2051 + data = (guint8 *) gst_adapter_peek(nuv->priv->adapter, size);
4.2052 + *buffer = gst_buffer_new();
4.2053 + gst_buffer_set_data(*buffer, data, size);
4.2054 + }
4.2055 + }
4.2056 return ret;
4.2057 }
4.2058
4.2059 static GstFlowReturn
4.2060 -gst_nuv_demux_move_bytes (GstNuvDemux * nuv, guint64 size)
4.2061 +gst_nuv_demux_move_bytes(GstNuvDemux * nuv, guint64 size)
4.2062 {
4.2063 GstFlowReturn ret = GST_FLOW_OK;
4.2064
4.2065 - if (size == 0) {
4.2066 - return ret;
4.2067 - }
4.2068 + if (size == 0)
4.2069 + {
4.2070 + return ret;
4.2071 + }
4.2072
4.2073 - if (nuv->priv->mode == NUV_PULL_MODE) {
4.2074 - nuv->priv->offset += size;
4.2075 - } else {
4.2076 - if (gst_adapter_available (nuv->priv->adapter) < size) {
4.2077 - nuv->priv->more_data = TRUE;
4.2078 - return GST_FLOW_ERROR_NO_DATA;
4.2079 - }
4.2080 - gst_adapter_flush (nuv->priv->adapter, size);
4.2081 - }
4.2082 + if (nuv->priv->mode == NUV_PULL_MODE)
4.2083 + {
4.2084 + nuv->priv->offset += size;
4.2085 + }
4.2086 + else
4.2087 + {
4.2088 + if (gst_adapter_available(nuv->priv->adapter) < size)
4.2089 + {
4.2090 + nuv->priv->more_data = TRUE;
4.2091 + return GST_FLOW_ERROR_NO_DATA;
4.2092 + }
4.2093 + gst_adapter_flush(nuv->priv->adapter, size);
4.2094 + }
4.2095 return ret;
4.2096 }
4.2097
4.2098 static gboolean
4.2099 -gst_nuv_demux_sink_activate (GstPad * sinkpad)
4.2100 +gst_nuv_demux_sink_activate(GstPad * sinkpad)
4.2101 {
4.2102 gboolean res = TRUE;
4.2103 - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad));
4.2104 -
4.2105 - if (gst_pad_check_pull_range (sinkpad)) {
4.2106 - gst_adapter_clear (nuv->priv->adapter);
4.2107 - res = gst_pad_activate_pull (sinkpad, TRUE);
4.2108 - } else {
4.2109 - gst_adapter_clear (nuv->priv->adapter);
4.2110 - res = gst_pad_activate_push (sinkpad, TRUE);
4.2111 - }
4.2112 -
4.2113 - g_object_unref (nuv);
4.2114 + GstNuvDemux *nuv = GST_NUV_DEMUX(gst_pad_get_parent(sinkpad));
4.2115 +
4.2116 + if (gst_pad_check_pull_range(sinkpad))
4.2117 + {
4.2118 + gst_adapter_clear(nuv->priv->adapter);
4.2119 + res = gst_pad_activate_pull(sinkpad, TRUE);
4.2120 + }
4.2121 + else
4.2122 + {
4.2123 + gst_adapter_clear(nuv->priv->adapter);
4.2124 + res = gst_pad_activate_push(sinkpad, TRUE);
4.2125 + }
4.2126 +
4.2127 + g_object_unref(nuv);
4.2128 return res;
4.2129 }
4.2130
4.2131 static gboolean
4.2132 -gst_nuv_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
4.2133 +gst_nuv_demux_sink_activate_pull(GstPad * sinkpad, gboolean active)
4.2134 {
4.2135 - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad));
4.2136 + GstNuvDemux *nuv = GST_NUV_DEMUX(gst_pad_get_parent(sinkpad));
4.2137
4.2138 - if (active) {
4.2139 - GST_DEBUG_OBJECT (nuv, "activating pull function");
4.2140 - nuv->priv->mode = NUV_PULL_MODE;
4.2141 - gst_adapter_clear (nuv->priv->adapter);
4.2142 + if (active)
4.2143 + {
4.2144 + GST_DEBUG_OBJECT(nuv, "activating pull function");
4.2145 + nuv->priv->mode = NUV_PULL_MODE;
4.2146 + gst_adapter_clear(nuv->priv->adapter);
4.2147
4.2148 - gst_pad_start_task (sinkpad, (GstTaskFunction) gst_nuv_demux_loop, sinkpad);
4.2149 - } else {
4.2150 - GST_DEBUG_OBJECT (nuv, "deactivating pull function");
4.2151 - gst_pad_stop_task (sinkpad);
4.2152 - }
4.2153 - gst_object_unref (nuv);
4.2154 + gst_pad_start_task(sinkpad, (GstTaskFunction) gst_nuv_demux_loop,
4.2155 + sinkpad);
4.2156 + }
4.2157 + else
4.2158 + {
4.2159 + GST_DEBUG_OBJECT(nuv, "deactivating pull function");
4.2160 + gst_pad_stop_task(sinkpad);
4.2161 + }
4.2162 + gst_object_unref(nuv);
4.2163
4.2164 return TRUE;
4.2165 }
4.2166
4.2167 static gboolean
4.2168 -gst_nuv_demux_sink_activate_push (GstPad * pad, gboolean active)
4.2169 +gst_nuv_demux_sink_activate_push(GstPad * pad, gboolean active)
4.2170 {
4.2171 - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
4.2172 + GstNuvDemux *nuv = GST_NUV_DEMUX(gst_pad_get_parent(pad));
4.2173
4.2174 - if (active) {
4.2175 - nuv->priv->mode = NUV_PUSH_MODE;
4.2176 - gst_adapter_clear (nuv->priv->adapter);
4.2177 + if (active)
4.2178 + {
4.2179 + nuv->priv->mode = NUV_PUSH_MODE;
4.2180 + gst_adapter_clear(nuv->priv->adapter);
4.2181
4.2182 - GST_DEBUG_OBJECT (nuv, "activating push/chain function");
4.2183 - } else {
4.2184 - GST_DEBUG_OBJECT (nuv, "deactivating push/chain function");
4.2185 - }
4.2186 + GST_DEBUG_OBJECT(nuv, "activating push/chain function");
4.2187 + }
4.2188 + else
4.2189 + {
4.2190 + GST_DEBUG_OBJECT(nuv, "deactivating push/chain function");
4.2191 + }
4.2192
4.2193 - gst_object_unref (nuv);
4.2194 + gst_object_unref(nuv);
4.2195
4.2196 return TRUE;
4.2197 }
4.2198
4.2199 static frame_index_data *
4.2200 -gst_nuv_demux_do_seek_index (GstNuvDemux *nuv, gint64 seek_pos,
4.2201 - gint64 segment_stop, GstFormat format)
4.2202 +gst_nuv_demux_do_seek_index(GstNuvDemux * nuv, gint64 seek_pos,
4.2203 + gint64 segment_stop, GstFormat format)
4.2204 {
4.2205 GSList *l;
4.2206 frame_index_data *ret = NULL;
4.2207
4.2208 - if (nuv->priv->index == NULL) {
4.2209 - return NULL;
4.2210 - }
4.2211 + if (nuv->priv->index == NULL)
4.2212 + {
4.2213 + return NULL;
4.2214 + }
4.2215
4.2216 - /* find keyframe closest to the requested position */
4.2217 - for (l = nuv->priv->index; l != NULL; l = l->next) {
4.2218 - frame_index_data *f = (frame_index_data *) l->data;
4.2219 - gint64 pos = 0;
4.2220 -
4.2221 - if (format == GST_FORMAT_BYTES) {
4.2222 - pos = f->offset;
4.2223 - } else if (format == GST_FORMAT_TIME) {
4.2224 - pos = f->timecode;
4.2225 - } else {
4.2226 - return NULL;
4.2227 - }
4.2228 + /* find keyframe closest to the requested position */
4.2229 + for (l = nuv->priv->index; l != NULL; l = l->next)
4.2230 + {
4.2231 + frame_index_data *f = (frame_index_data *) l->data;
4.2232 + gint64 pos = 0;
4.2233
4.2234 - if (pos >= seek_pos) {
4.2235 - ret = f;
4.2236 - break;
4.2237 - }
4.2238 + if (format == GST_FORMAT_BYTES)
4.2239 + {
4.2240 + pos = f->offset;
4.2241 + }
4.2242 + else if (format == GST_FORMAT_TIME)
4.2243 + {
4.2244 + pos = f->timecode;
4.2245 + }
4.2246 + else
4.2247 + {
4.2248 + return NULL;
4.2249 + }
4.2250
4.2251 - if ((segment_stop != -1) && (segment_stop != GST_CLOCK_TIME_NONE) && (pos > segment_stop)) {
4.2252 - break;
4.2253 - }
4.2254 - }
4.2255 + if (pos >= seek_pos)
4.2256 + {
4.2257 + ret = f;
4.2258 + break;
4.2259 + }
4.2260 +
4.2261 + if ((segment_stop != -1) && (segment_stop != GST_CLOCK_TIME_NONE)
4.2262 + && (pos > segment_stop))
4.2263 + {
4.2264 + break;
4.2265 + }
4.2266 + }
4.2267
4.2268 return ret;
4.2269 }
4.2270
4.2271 static gboolean
4.2272 -gst_nuv_demux_do_seek (GstNuvDemux *nuv, GstEvent * event)
4.2273 +gst_nuv_demux_do_seek(GstNuvDemux * nuv, GstEvent * event)
4.2274 {
4.2275 gdouble rate;
4.2276 GstFormat format;
4.2277 @@ -1381,17 +1550,19 @@
4.2278 gint64 segment_stop;
4.2279 GstEvent *newsegment_event;
4.2280
4.2281 - if (nuv->priv->eos) {
4.2282 - return FALSE;
4.2283 - }
4.2284 + if (nuv->priv->eos)
4.2285 + {
4.2286 + return FALSE;
4.2287 + }
4.2288
4.2289 - if (nuv->priv->mode == NUV_PUSH_MODE) {
4.2290 - return FALSE;
4.2291 - }
4.2292 + if (nuv->priv->mode == NUV_PUSH_MODE)
4.2293 + {
4.2294 + return FALSE;
4.2295 + }
4.2296
4.2297
4.2298 - gst_event_parse_seek (event, &rate, &format, &flags,
4.2299 - &cur_type, &cur, &stop_type, &stop);
4.2300 + gst_event_parse_seek(event, &rate, &format, &flags,
4.2301 + &cur_type, &cur, &stop_type, &stop);
4.2302
4.2303
4.2304
4.2305 @@ -1402,249 +1573,277 @@
4.2306 }
4.2307 */
4.2308
4.2309 - if (rate <= 0.0) {
4.2310 - GST_DEBUG_OBJECT (nuv, "Can only seek with positive rate");
4.2311 - return FALSE;
4.2312 - }
4.2313 -
4.2314 - if (cur_type == GST_SEEK_TYPE_SET) {
4.2315 - GST_OBJECT_LOCK (nuv);
4.2316 - if (gst_nuv_demux_do_seek_index (nuv, cur, -1, format) == NULL) {
4.2317 - GST_DEBUG_OBJECT (nuv, "No matching seek entry in index");
4.2318 - GST_OBJECT_UNLOCK (nuv);
4.2319 - return FALSE;
4.2320 - }
4.2321 - GST_OBJECT_UNLOCK (nuv);
4.2322 - }
4.2323 + if (rate <= 0.0)
4.2324 + {
4.2325 + GST_DEBUG_OBJECT(nuv, "Can only seek with positive rate");
4.2326 + return FALSE;
4.2327 + }
4.2328 +
4.2329 + if (cur_type == GST_SEEK_TYPE_SET)
4.2330 + {
4.2331 + GST_OBJECT_LOCK(nuv);
4.2332 + if (gst_nuv_demux_do_seek_index(nuv, cur, -1, format) == NULL)
4.2333 + {
4.2334 + GST_DEBUG_OBJECT(nuv, "No matching seek entry in index");
4.2335 + GST_OBJECT_UNLOCK(nuv);
4.2336 + return FALSE;
4.2337 + }
4.2338 + GST_OBJECT_UNLOCK(nuv);
4.2339 + }
4.2340
4.2341 flush = !!(flags & GST_SEEK_FLAG_FLUSH);
4.2342 -
4.2343 - if (flush) {
4.2344 - gst_pad_push_event (nuv->priv->sinkpad, gst_event_new_flush_start ());
4.2345 - if (nuv->priv->src_video_pad != NULL) {
4.2346 - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_flush_start ());
4.2347 - }
4.2348
4.2349 - if (nuv->priv->src_audio_pad != NULL) {
4.2350 - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_flush_start ());
4.2351 - }
4.2352 - }
4.2353 - else {
4.2354 - gst_pad_pause_task (nuv->priv->sinkpad);
4.2355 - }
4.2356 + if (flush)
4.2357 + {
4.2358 + gst_pad_push_event(nuv->priv->sinkpad, gst_event_new_flush_start());
4.2359 + if (nuv->priv->src_video_pad != NULL)
4.2360 + {
4.2361 + gst_pad_push_event(nuv->priv->src_video_pad,
4.2362 + gst_event_new_flush_start());
4.2363 + }
4.2364
4.2365 - GST_PAD_STREAM_LOCK (nuv->priv->sinkpad);
4.2366 - GST_OBJECT_LOCK (nuv);
4.2367 + if (nuv->priv->src_audio_pad != NULL)
4.2368 + {
4.2369 + gst_pad_push_event(nuv->priv->src_audio_pad,
4.2370 + gst_event_new_flush_start());
4.2371 + }
4.2372 + }
4.2373 + else
4.2374 + {
4.2375 + gst_pad_pause_task(nuv->priv->sinkpad);
4.2376 + }
4.2377 +
4.2378 + GST_PAD_STREAM_LOCK(nuv->priv->sinkpad);
4.2379 + GST_OBJECT_LOCK(nuv);
4.2380
4.2381
4.2382 if (cur == GST_CLOCK_TIME_NONE)
4.2383 - cur = 0;
4.2384 + cur = 0;
4.2385 if (stop == GST_CLOCK_TIME_NONE)
4.2386 - stop = nuv->priv->duration_time;
4.2387 + stop = nuv->priv->duration_time;
4.2388
4.2389 if (cur_type == GST_SEEK_TYPE_SET)
4.2390 - segment_start = cur;
4.2391 + segment_start = cur;
4.2392 else if (cur_type == GST_SEEK_TYPE_CUR)
4.2393 - segment_start = nuv->priv->segment_start + cur;
4.2394 + segment_start = nuv->priv->segment_start + cur;
4.2395 else
4.2396 - segment_start = nuv->priv->segment_start;
4.2397 + segment_start = nuv->priv->segment_start;
4.2398
4.2399 if (stop_type == GST_SEEK_TYPE_SET)
4.2400 - segment_stop = stop;
4.2401 + segment_stop = stop;
4.2402 else if (stop_type == GST_SEEK_TYPE_CUR)
4.2403 - segment_stop = nuv->priv->segment_stop + stop;
4.2404 + segment_stop = nuv->priv->segment_stop + stop;
4.2405 else
4.2406 - segment_stop = nuv->priv->segment_stop;
4.2407 + segment_stop = nuv->priv->segment_stop;
4.2408
4.2409 - segment_start = CLAMP (segment_start, 0, nuv->priv->duration_time);
4.2410 - segment_stop = CLAMP (segment_stop, 0, nuv->priv->duration_time);
4.2411 + segment_start = CLAMP(segment_start, 0, nuv->priv->duration_time);
4.2412 + segment_stop = CLAMP(segment_stop, 0, nuv->priv->duration_time);
4.2413
4.2414 - entry = gst_nuv_demux_do_seek_index (nuv, segment_start,
4.2415 - segment_stop, format);
4.2416 + entry = gst_nuv_demux_do_seek_index(nuv, segment_start,
4.2417 + segment_stop, format);
4.2418
4.2419 - if (entry == NULL) {
4.2420 - GST_DEBUG_OBJECT (nuv, "No matching seek entry in index");
4.2421 - goto seek_error;
4.2422 - }
4.2423 + if (entry == NULL)
4.2424 + {
4.2425 + GST_DEBUG_OBJECT(nuv, "No matching seek entry in index");
4.2426 + goto seek_error;
4.2427 + }
4.2428
4.2429 segment_start = entry->timecode;
4.2430
4.2431 nuv->priv->segment_start = segment_start;
4.2432 nuv->priv->segment_stop = segment_stop;
4.2433
4.2434 - GST_OBJECT_UNLOCK (nuv);
4.2435 + GST_OBJECT_UNLOCK(nuv);
4.2436
4.2437 - if (!nuv->priv->eos) {
4.2438 - GstMessage *msg;
4.2439 - msg = gst_message_new_segment_start (GST_OBJECT (nuv), GST_FORMAT_TIME,
4.2440 - nuv->priv->segment_start);
4.2441 -
4.2442 - gst_element_post_message (GST_ELEMENT (nuv), msg);
4.2443 - }
4.2444 + if (!nuv->priv->eos)
4.2445 + {
4.2446 + GstMessage *msg;
4.2447 + msg = gst_message_new_segment_start(GST_OBJECT(nuv), GST_FORMAT_TIME,
4.2448 + nuv->priv->segment_start);
4.2449
4.2450 - GST_DEBUG_OBJECT (nuv, "NEW SEGMENT START %" G_GUINT64_FORMAT ", STOP %" G_GUINT64_FORMAT,
4.2451 - segment_start, segment_stop);
4.2452 - newsegment_event = gst_event_new_new_segment (FALSE, rate,
4.2453 - GST_FORMAT_TIME, segment_start, segment_stop, segment_start);
4.2454 + gst_element_post_message(GST_ELEMENT(nuv), msg);
4.2455 + }
4.2456
4.2457 + GST_DEBUG_OBJECT(nuv,
4.2458 + "NEW SEGMENT START %" G_GUINT64_FORMAT ", STOP %"
4.2459 + G_GUINT64_FORMAT, segment_start, segment_stop);
4.2460 + newsegment_event =
4.2461 + gst_event_new_new_segment(FALSE, rate, GST_FORMAT_TIME, segment_start,
4.2462 + segment_stop, segment_start);
4.2463
4.2464 - if (flush) {
4.2465 - if (nuv->priv->src_video_pad != NULL) {
4.2466 - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_flush_stop ());
4.2467 - }
4.2468
4.2469 - if (nuv->priv->src_audio_pad != NULL) {
4.2470 - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_flush_stop ());
4.2471 - }
4.2472 + if (flush)
4.2473 + {
4.2474 + if (nuv->priv->src_video_pad != NULL)
4.2475 + {
4.2476 + gst_pad_push_event(nuv->priv->src_video_pad,
4.2477 + gst_event_new_flush_stop());
4.2478 + }
4.2479
4.2480 - gst_pad_push_event (nuv->priv->sinkpad, gst_event_new_flush_stop ());
4.2481 - }
4.2482 + if (nuv->priv->src_audio_pad != NULL)
4.2483 + {
4.2484 + gst_pad_push_event(nuv->priv->src_audio_pad,
4.2485 + gst_event_new_flush_stop());
4.2486 + }
4.2487
4.2488 -
4.2489 - if (nuv->priv->src_video_pad != NULL) {
4.2490 - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_ref (newsegment_event));
4.2491 - }
4.2492 - if (nuv->priv->src_audio_pad != NULL) {
4.2493 - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_ref (newsegment_event));
4.2494 - }
4.2495 + gst_pad_push_event(nuv->priv->sinkpad, gst_event_new_flush_stop());
4.2496 + }
4.2497
4.2498 - gst_event_unref (newsegment_event);
4.2499 +
4.2500 + if (nuv->priv->src_video_pad != NULL)
4.2501 + {
4.2502 + gst_pad_push_event(nuv->priv->src_video_pad,
4.2503 + gst_event_ref(newsegment_event));
4.2504 + }
4.2505 + if (nuv->priv->src_audio_pad != NULL)
4.2506 + {
4.2507 + gst_pad_push_event(nuv->priv->src_audio_pad,
4.2508 + gst_event_ref(newsegment_event));
4.2509 + }
4.2510 +
4.2511 + gst_event_unref(newsegment_event);
4.2512
4.2513 nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER;
4.2514 nuv->priv->offset = entry->offset;
4.2515
4.2516 - gst_pad_start_task (nuv->priv->sinkpad, (GstTaskFunction) gst_nuv_demux_loop,
4.2517 - nuv->priv->sinkpad);
4.2518 + gst_pad_start_task(nuv->priv->sinkpad, (GstTaskFunction) gst_nuv_demux_loop,
4.2519 + nuv->priv->sinkpad);
4.2520
4.2521 - GST_PAD_STREAM_UNLOCK (nuv->priv->sinkpad);
4.2522 + GST_PAD_STREAM_UNLOCK(nuv->priv->sinkpad);
4.2523 return TRUE;
4.2524
4.2525 seek_error:
4.2526 - GST_DEBUG_OBJECT (nuv, "Got a seek error");
4.2527 - GST_OBJECT_UNLOCK (nuv);
4.2528 - GST_PAD_STREAM_UNLOCK (nuv->priv->sinkpad);
4.2529 + GST_DEBUG_OBJECT(nuv, "Got a seek error");
4.2530 + GST_OBJECT_UNLOCK(nuv);
4.2531 + GST_PAD_STREAM_UNLOCK(nuv->priv->sinkpad);
4.2532 return FALSE;
4.2533
4.2534 }
4.2535
4.2536 static gboolean
4.2537 -gst_nuv_demux_srcpad_event (GstPad * pad, GstEvent * event)
4.2538 +gst_nuv_demux_srcpad_event(GstPad * pad, GstEvent * event)
4.2539 {
4.2540 gboolean res = FALSE;
4.2541 GstNuvDemux *nuv;
4.2542
4.2543 - nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
4.2544 -
4.2545 - switch (GST_EVENT_TYPE (event)) {
4.2546 - case GST_EVENT_SEEK:
4.2547 - res = gst_nuv_demux_do_seek (nuv, event);
4.2548 - break;
4.2549 - default:
4.2550 - res = FALSE;
4.2551 - break;
4.2552 - }
4.2553 -
4.2554 - gst_object_unref (nuv);
4.2555 + nuv = GST_NUV_DEMUX(gst_pad_get_parent(pad));
4.2556 +
4.2557 + switch (GST_EVENT_TYPE(event))
4.2558 + {
4.2559 + case GST_EVENT_SEEK:
4.2560 + res = gst_nuv_demux_do_seek(nuv, event);
4.2561 + break;
4.2562 + default:
4.2563 + res = FALSE;
4.2564 + break;
4.2565 + }
4.2566 +
4.2567 + gst_object_unref(nuv);
4.2568 return res;
4.2569 }
4.2570
4.2571 static gboolean
4.2572 -gst_nuv_demux_sink_event (GstPad * pad, GstEvent * event)
4.2573 +gst_nuv_demux_sink_event(GstPad * pad, GstEvent * event)
4.2574 {
4.2575 - gboolean res = FALSE;
4.2576 - GstNuvDemux *nuv;
4.2577 + gboolean res = FALSE;
4.2578 + GstNuvDemux *nuv;
4.2579
4.2580 - nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
4.2581 -
4.2582 - switch (GST_EVENT_TYPE (event)) {
4.2583 - case GST_EVENT_NEWSEGMENT:
4.2584 - {
4.2585 - gboolean update;
4.2586 - gdouble rate;
4.2587 - GstFormat format;
4.2588 - gint64 start;
4.2589 - gint64 stop;
4.2590 - gint64 position;
4.2591 + nuv = GST_NUV_DEMUX(gst_pad_get_parent(pad));
4.2592
4.2593 - gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &position);
4.2594 - if ((format == GST_FORMAT_BYTES) && (start == 0)) {
4.2595 - g_debug ("NEW SEGMENT 0");
4.2596 - if (nuv->priv->segment > 0) {
4.2597 - nuv->priv->new_file = TRUE;
4.2598 - nuv->priv->state = GST_NUV_DEMUX_START;
4.2599 - nuv->priv->offset = 0;
4.2600 - }
4.2601 - nuv->priv->segment++;
4.2602 + switch (GST_EVENT_TYPE(event))
4.2603 + {
4.2604 + case GST_EVENT_NEWSEGMENT:
4.2605 + {
4.2606 + gboolean update;
4.2607 + gdouble rate;
4.2608 + GstFormat format;
4.2609 + gint64 start;
4.2610 + gint64 stop;
4.2611 + gint64 position;
4.2612
4.2613 - /*
4.2614 - newsegment_event = gst_event_new_new_segment (FALSE, rate,
4.2615 - GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE);
4.2616 + gst_event_parse_new_segment(event, &update, &rate, &format, &start,
4.2617 + &stop, &position);
4.2618 + if ((format == GST_FORMAT_BYTES) && (start == 0))
4.2619 + {
4.2620 + g_debug("NEW SEGMENT 0");
4.2621 + if (nuv->priv->segment > 0)
4.2622 + {
4.2623 + nuv->priv->new_file = TRUE;
4.2624 + nuv->priv->state = GST_NUV_DEMUX_START;
4.2625 + nuv->priv->offset = 0;
4.2626 + }
4.2627 + nuv->priv->segment++;
4.2628
4.2629 - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_ref (newsegment_event));
4.2630 - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_ref (newsegment_event));
4.2631 - gst_event_unref (newsegment_event);
4.2632 - */
4.2633 - res = gst_pad_event_default(pad, event);
4.2634 - }
4.2635 - break;
4.2636 - }
4.2637 - case GST_EVENT_CUSTOM_DOWNSTREAM:
4.2638 - {
4.2639 - /*
4.2640 - nuv->priv->new_file = TRUE;
4.2641 - nuv->priv->state = GST_NUV_DEMUX_START;
4.2642 - nuv->priv->offset = 0;
4.2643 - */
4.2644 - GST_PAD_STREAM_LOCK (pad);
4.2645 - gst_nuv_demux_reset( nuv );
4.2646 - GST_PAD_STREAM_UNLOCK (pad);
4.2647 + /*
4.2648 + newsegment_event = gst_event_new_new_segment (FALSE, rate,
4.2649 + GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE);
4.2650
4.2651 - res = gst_pad_event_default (pad, event);
4.2652 - break;
4.2653 - }
4.2654 - default:
4.2655 - res = gst_pad_event_default (pad, event);
4.2656 - break;
4.2657 - }
4.2658 + gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_ref (newsegment_event));
4.2659 + gst_pad_push_event (nuv->priv->src_video_pad, gst_event_ref (newsegment_event));
4.2660 + gst_event_unref (newsegment_event);
4.2661 + */
4.2662 + res = gst_pad_event_default(pad, event);
4.2663 + }
4.2664 + break;
4.2665 + }
4.2666 + case GST_EVENT_CUSTOM_DOWNSTREAM:
4.2667 + {
4.2668 + /*
4.2669 + nuv->priv->new_file = TRUE;
4.2670 + nuv->priv->state = GST_NUV_DEMUX_START;
4.2671 + nuv->priv->offset = 0;
4.2672 + */
4.2673 + GST_PAD_STREAM_LOCK(pad);
4.2674 + gst_nuv_demux_reset(nuv);
4.2675 + GST_PAD_STREAM_UNLOCK(pad);
4.2676
4.2677 - return res;
4.2678 + res = gst_pad_event_default(pad, event);
4.2679 + break;
4.2680 + }
4.2681 + default:
4.2682 + res = gst_pad_event_default(pad, event);
4.2683 + break;
4.2684 + }
4.2685 +
4.2686 + return res;
4.2687 }
4.2688
4.2689 static GstFlowReturn
4.2690 -gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf)
4.2691 +gst_nuv_demux_chain(GstPad * pad, GstBuffer * buf)
4.2692 {
4.2693 GstFlowReturn ret = GST_FLOW_OK;
4.2694 - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
4.2695 -
4.2696 + GstNuvDemux *nuv = GST_NUV_DEMUX(gst_pad_get_parent(pad));
4.2697 +
4.2698 if (nuv->priv->mode != NUV_PUSH_MODE)
4.2699 - return ret;
4.2700 + return ret;
4.2701
4.2702 - gst_adapter_push (nuv->priv->adapter, buf);
4.2703 -
4.2704 - while ((ret == GST_FLOW_OK) && (nuv->priv->more_data == FALSE)) {
4.2705 - ret = gst_nuv_demux_play (pad);
4.2706 - }
4.2707 + gst_adapter_push(nuv->priv->adapter, buf);
4.2708 +
4.2709 + while ((ret == GST_FLOW_OK) && (nuv->priv->more_data == FALSE))
4.2710 + {
4.2711 + ret = gst_nuv_demux_play(pad);
4.2712 + }
4.2713
4.2714 nuv->priv->more_data = FALSE;
4.2715 - gst_object_unref (nuv);
4.2716 + gst_object_unref(nuv);
4.2717
4.2718 return ret;
4.2719 }
4.2720
4.2721 static void
4.2722 -gst_nuv_demux_loop (GstPad * pad)
4.2723 +gst_nuv_demux_loop(GstPad * pad)
4.2724 {
4.2725 - gst_nuv_demux_play (pad);
4.2726 + gst_nuv_demux_play(pad);
4.2727 }
4.2728
4.2729 static void
4.2730 -gst_nuv_demux_index_free (gpointer data, gpointer user_data)
4.2731 +gst_nuv_demux_index_free(gpointer data, gpointer user_data)
4.2732 {
4.2733 - g_free (data);
4.2734 + g_free(data);
4.2735 }
4.2736
4.2737 static void
4.2738 -gst_nuv_demux_reset (GstNuvDemux * nuv)
4.2739 +gst_nuv_demux_reset(GstNuvDemux * nuv)
4.2740 {
4.2741 nuv->priv->eos = FALSE;
4.2742 nuv->priv->more_data = FALSE;
4.2743 @@ -1662,160 +1861,172 @@
4.2744 nuv->priv->segment_start = GST_CLOCK_TIME_NONE;
4.2745 nuv->priv->new_file = FALSE;
4.2746
4.2747 - //clear index list
4.2748 - g_slist_foreach (nuv->priv->index, gst_nuv_demux_index_free, NULL);
4.2749 - g_slist_free (nuv->priv->index);
4.2750 + //clear index list
4.2751 + g_slist_foreach(nuv->priv->index, gst_nuv_demux_index_free, NULL);
4.2752 + g_slist_free(nuv->priv->index);
4.2753 nuv->priv->index = NULL;
4.2754
4.2755 - gst_adapter_clear (nuv->priv->adapter);
4.2756 + gst_adapter_clear(nuv->priv->adapter);
4.2757
4.2758 - if (nuv->priv->mpeg_buffer != NULL) {
4.2759 - gst_buffer_unref (nuv->priv->mpeg_buffer);
4.2760 - nuv->priv->mpeg_buffer = NULL;
4.2761 - }
4.2762 + if (nuv->priv->mpeg_buffer != NULL)
4.2763 + {
4.2764 + gst_buffer_unref(nuv->priv->mpeg_buffer);
4.2765 + nuv->priv->mpeg_buffer = NULL;
4.2766 + }
4.2767 }
4.2768
4.2769 static void
4.2770 -gst_nuv_demux_destoy_src_pad (GstNuvDemux * nuv)
4.2771 +gst_nuv_demux_destoy_src_pad(GstNuvDemux * nuv)
4.2772 {
4.2773 - if (nuv->priv->src_video_pad) {
4.2774 - gst_element_remove_pad (GST_ELEMENT (nuv), nuv->priv->src_video_pad);
4.2775 - nuv->priv->src_video_pad = NULL;
4.2776 - }
4.2777 + if (nuv->priv->src_video_pad)
4.2778 + {
4.2779 + gst_element_remove_pad(GST_ELEMENT(nuv), nuv->priv->src_video_pad);
4.2780 + nuv->priv->src_video_pad = NULL;
4.2781 + }
4.2782
4.2783 - if (nuv->priv->src_audio_pad) {
4.2784 - gst_element_remove_pad (GST_ELEMENT (nuv), nuv->priv->src_audio_pad);
4.2785 - nuv->priv->src_audio_pad = NULL;
4.2786 - }
4.2787 + if (nuv->priv->src_audio_pad)
4.2788 + {
4.2789 + gst_element_remove_pad(GST_ELEMENT(nuv), nuv->priv->src_audio_pad);
4.2790 + nuv->priv->src_audio_pad = NULL;
4.2791 + }
4.2792 }
4.2793
4.2794 static GstStateChangeReturn
4.2795 -gst_nuv_demux_change_state (GstElement * element, GstStateChange transition)
4.2796 +gst_nuv_demux_change_state(GstElement * element, GstStateChange transition)
4.2797 {
4.2798 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
4.2799
4.2800 - g_debug ("Nuvdemux state_change");
4.2801 - switch (transition) {
4.2802 - case GST_STATE_CHANGE_NULL_TO_READY:
4.2803 - gst_nuv_demux_reset (GST_NUV_DEMUX (element));
4.2804 - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element));
4.2805 - break;
4.2806 - default:
4.2807 - break;
4.2808 - }
4.2809 + g_debug("Nuvdemux state_change");
4.2810 + switch (transition)
4.2811 + {
4.2812 + case GST_STATE_CHANGE_NULL_TO_READY:
4.2813 + gst_nuv_demux_reset(GST_NUV_DEMUX(element));
4.2814 + gst_nuv_demux_destoy_src_pad(GST_NUV_DEMUX(element));
4.2815 + break;
4.2816 + default:
4.2817 + break;
4.2818 + }
4.2819
4.2820 - g_debug ("Nuvdemux state_change: 1");
4.2821 + g_debug("Nuvdemux state_change: 1");
4.2822
4.2823 - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
4.2824 - if (ret == GST_STATE_CHANGE_FAILURE) {
4.2825 - goto done;
4.2826 - }
4.2827 + ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
4.2828 + if (ret == GST_STATE_CHANGE_FAILURE)
4.2829 + {
4.2830 + goto done;
4.2831 + }
4.2832
4.2833
4.2834 - g_debug ("Nuvdemux state_change: 2");
4.2835 + g_debug("Nuvdemux state_change: 2");
4.2836
4.2837 - switch (transition) {
4.2838 - case GST_STATE_CHANGE_READY_TO_NULL:
4.2839 - gst_nuv_demux_reset (GST_NUV_DEMUX (element));
4.2840 - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element));
4.2841 - break;
4.2842 - default:
4.2843 - break;
4.2844 - }
4.2845 + switch (transition)
4.2846 + {
4.2847 + case GST_STATE_CHANGE_READY_TO_NULL:
4.2848 + gst_nuv_demux_reset(GST_NUV_DEMUX(element));
4.2849 + gst_nuv_demux_destoy_src_pad(GST_NUV_DEMUX(element));
4.2850 + break;
4.2851 + default:
4.2852 + break;
4.2853 + }
4.2854
4.2855
4.2856 - g_debug ("Nuvdemux state_change: DONE");
4.2857 + g_debug("Nuvdemux state_change: DONE");
4.2858
4.2859 done:
4.2860 return ret;
4.2861 }
4.2862
4.2863 -#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6)
4.2864 +#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6)
4.2865 GstBuffer *
4.2866 -gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes)
4.2867 +gst_adapter_take_buffer(GstAdapter * adapter, guint nbytes)
4.2868 {
4.2869 GstBuffer *buffer;
4.2870 GstBuffer *cur;
4.2871 guint8 *data;
4.2872
4.2873 - g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
4.2874 - g_return_val_if_fail (nbytes > 0, NULL);
4.2875 + g_return_val_if_fail(GST_IS_ADAPTER(adapter), NULL);
4.2876 + g_return_val_if_fail(nbytes > 0, NULL);
4.2877
4.2878 - GST_LOG_OBJECT (adapter, "taking buffer of %u bytes", nbytes);
4.2879 + GST_LOG_OBJECT(adapter, "taking buffer of %u bytes", nbytes);
4.2880
4.2881 - /* we don't have enough data, return NULL. This is unlikely
4.2882 - * as one usually does an _available() first instead of peeking a
4.2883 - * random size. */
4.2884 - if (G_UNLIKELY (nbytes > adapter->size))
4.2885 - return NULL;
4.2886 + /* we don't have enough data, return NULL. This is unlikely
4.2887 + * as one usually does an _available() first instead of peeking a
4.2888 + * random size. */
4.2889 + if (G_UNLIKELY(nbytes > adapter->size))
4.2890 + return NULL;
4.2891
4.2892 - /* our head buffer has enough data left, return it */
4.2893 + /* our head buffer has enough data left, return it */
4.2894 cur = adapter->buflist->data;
4.2895 - if (GST_BUFFER_SIZE (cur) >= nbytes + adapter->skip) {
4.2896 - GST_LOG_OBJECT (adapter, "providing buffer of %d bytes via sub-buffer",
4.2897 - nbytes);
4.2898 - buffer = gst_buffer_create_sub (cur, adapter->skip, nbytes);
4.2899 + if (GST_BUFFER_SIZE(cur) >= nbytes + adapter->skip)
4.2900 + {
4.2901 + GST_LOG_OBJECT(adapter, "providing buffer of %d bytes via sub-buffer",
4.2902 + nbytes);
4.2903 + buffer = gst_buffer_create_sub(cur, adapter->skip, nbytes);
4.2904
4.2905 - gst_adapter_flush (adapter, nbytes);
4.2906 + gst_adapter_flush(adapter, nbytes);
4.2907
4.2908 - return buffer;
4.2909 - }
4.2910 + return buffer;
4.2911 + }
4.2912
4.2913 - data = gst_adapter_take (adapter, nbytes);
4.2914 + data = gst_adapter_take(adapter, nbytes);
4.2915 if (data == NULL)
4.2916 - return NULL;
4.2917 + return NULL;
4.2918
4.2919 - buffer = gst_buffer_new ();
4.2920 - GST_BUFFER_DATA (buffer) = data;
4.2921 - GST_BUFFER_MALLOCDATA (buffer) = data;
4.2922 - GST_BUFFER_SIZE (buffer) = nbytes;
4.2923 + buffer = gst_buffer_new();
4.2924 + GST_BUFFER_DATA(buffer) = data;
4.2925 + GST_BUFFER_MALLOCDATA(buffer) = data;
4.2926 + GST_BUFFER_SIZE(buffer) = nbytes;
4.2927
4.2928 return buffer;
4.2929 }
4.2930 #endif
4.2931
4.2932 static void
4.2933 -gst_nuv_typefind (GstTypeFind * tf, gpointer unused)
4.2934 +gst_nuv_typefind(GstTypeFind * tf, gpointer unused)
4.2935 {
4.2936 - guint8 *data = gst_type_find_peek (tf, 0, 11);
4.2937 + guint8 *data = gst_type_find_peek(tf, 0, 11);
4.2938
4.2939 - if (data) {
4.2940 - if (memcmp (data, "MythTVVideo", 11) == 0
4.2941 - || memcmp (data, "NuppelVideo", 11) == 0) {
4.2942 - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM,
4.2943 - gst_caps_new_simple ("video/x-nuv", NULL));
4.2944 - }
4.2945 - }
4.2946 + if (data)
4.2947 + {
4.2948 + if (memcmp(data, "MythTVVideo", 11) == 0
4.2949 + || memcmp(data, "NuppelVideo", 11) == 0)
4.2950 + {
4.2951 + gst_type_find_suggest(tf, GST_TYPE_FIND_MAXIMUM,
4.2952 + gst_caps_new_simple("video/x-nuv", NULL));
4.2953 + }
4.2954 + }
4.2955 }
4.2956
4.2957 static gboolean
4.2958 -plugin_init (GstPlugin * plugin)
4.2959 +plugin_init(GstPlugin * plugin)
4.2960 {
4.2961 - static gchar *exts[] = { "nuv", NULL };
4.2962 + static gchar *exts[] = { "nuv", NULL };
4.2963 #ifdef ENABLE_NLS
4.2964 - setlocale (LC_ALL, "");
4.2965 - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
4.2966 + setlocale(LC_ALL, "");
4.2967 + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
4.2968 #endif /* ENABLE_NLS */
4.2969
4.2970 - if (!gst_element_register (plugin, "nuvdemux", GST_RANK_SECONDARY,
4.2971 - GST_TYPE_NUV_DEMUX)) {
4.2972 - return FALSE;
4.2973 - }
4.2974 + if (!gst_element_register(plugin, "nuvdemux", GST_RANK_SECONDARY,
4.2975 + GST_TYPE_NUV_DEMUX))
4.2976 + {
4.2977 + return FALSE;
4.2978 + }
4.2979
4.2980 - if (!gst_type_find_register (plugin, "video/x-nuv", GST_RANK_SECONDARY,
4.2981 - gst_nuv_typefind,
4.2982 - exts,
4.2983 - gst_caps_new_simple ("video/x-nuv", NULL), NULL, NULL)) {
4.2984 - GST_WARNING ("can't register typefind");
4.2985 - return FALSE;
4.2986 - }
4.2987 + if (!gst_type_find_register(plugin, "video/x-nuv", GST_RANK_SECONDARY,
4.2988 + gst_nuv_typefind,
4.2989 + exts,
4.2990 + gst_caps_new_simple("video/x-nuv", NULL), NULL,
4.2991 + NULL))
4.2992 + {
4.2993 + GST_WARNING("can't register typefind");
4.2994 + return FALSE;
4.2995 + }
4.2996
4.2997 return TRUE;
4.2998 }
4.2999
4.3000 -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
4.3001 - GST_VERSION_MINOR,
4.3002 - "nuvdemux",
4.3003 - "Demuxes and muxes audio and video",
4.3004 - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
4.3005 -
4.3006 +GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
4.3007 + GST_VERSION_MINOR,
4.3008 + "nuvdemux",
4.3009 + "Demuxes and muxes audio and video",
4.3010 + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
4.3011 + GST_PACKAGE_ORIGIN)
5.1 --- a/gst-gmyth/nuvdemux/gstnuvdemux.h Thu Jun 14 18:19:52 2007 +0100
5.2 +++ b/gst-gmyth/nuvdemux/gstnuvdemux.h Thu Jun 14 18:21:08 2007 +0100
5.3 @@ -26,7 +26,6 @@
5.4 #include <gst/base/gstadapter.h>
5.5
5.6 G_BEGIN_DECLS
5.7 -
5.8 #define GST_TYPE_NUV_DEMUX \
5.9 (gst_nuv_demux_get_type ())
5.10 #define GST_NUV_DEMUX(obj) \
5.11 @@ -37,19 +36,19 @@
5.12 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NUV_DEMUX))
5.13 #define GST_IS_NUV_DEMUX_CLASS(klass) \
5.14 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NUV_DEMUX))
5.15 -
5.16 typedef struct _GstNuvDemuxPrivate GstNuvDemuxPrivate;
5.17 -typedef struct _GstNuvDemux {
5.18 - GstElement parent;
5.19 +typedef struct _GstNuvDemux
5.20 +{
5.21 + GstElement parent;
5.22 GstNuvDemuxPrivate *priv;
5.23 } GstNuvDemux;
5.24
5.25 -typedef struct _GstNuvDemuxClass {
5.26 +typedef struct _GstNuvDemuxClass
5.27 +{
5.28 GstElementClass parent_class;
5.29 } GstNuvDemuxClass;
5.30
5.31 -GType gst_nuv_demux_get_type (void);
5.32 +GType gst_nuv_demux_get_type(void);
5.33
5.34 G_END_DECLS
5.35 -
5.36 #endif /* __GST_NUV_DEMUX_H__ */