From patchwork Tue Jan 3 22:02:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 6034 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id AEE3023F7F for ; Tue, 3 Jan 2012 22:02:59 +0000 (UTC) Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id 93B72A18058 for ; Tue, 3 Jan 2012 22:02:59 +0000 (UTC) Received: by eeke52 with SMTP id e52so17198096eek.11 for ; Tue, 03 Jan 2012 14:02:59 -0800 (PST) Received: by 10.205.120.14 with SMTP id fw14mr12074591bkc.53.1325628179277; Tue, 03 Jan 2012 14:02:59 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs352478bkc; Tue, 3 Jan 2012 14:02:59 -0800 (PST) Received: by 10.100.237.16 with SMTP id k16mr21209854anh.85.1325628176827; Tue, 03 Jan 2012 14:02:56 -0800 (PST) Received: from mail-gx0-f178.google.com (mail-gx0-f178.google.com [209.85.161.178]) by mx.google.com with ESMTPS id c14si22546441anh.105.2012.01.03.14.02.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jan 2012 14:02:56 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.161.178 as permitted sender) client-ip=209.85.161.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.161.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by ggnq4 with SMTP id q4so11570394ggn.37 for ; Tue, 03 Jan 2012 14:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=pHp9/NZuJJgUwe7LCptKNbjtTn1krW4Z3BzL+1l3wkg=; b=DY7zMq6fnqUqBWq9dv98uFu60Yum+gyH8+q+XmHkYoBvz3Z/jg3X847gdII/FeRJjI Dq+UTPUaC5ZjKYVd0z03GhwCQ2clwDkJfWNSm26Uo2H4np0fQvtnXQZ14B+TN6rQYYCF 4uRO0zQBIDJImGtiFyUwXKRfN0VsnhP7baCn4= Received: by 10.101.138.22 with SMTP id q22mr11248957ann.60.1325628176207; Tue, 03 Jan 2012 14:02:56 -0800 (PST) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id q40sm107943755anh.18.2012.01.03.14.02.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jan 2012 14:02:55 -0800 (PST) Sender: Rob Clark From: Rob Clark To: patches@linaro.org Cc: Rob Clark Subject: [PATCH 01/19] resindvd: use decodebin2 so needed parsers are plugged Date: Tue, 3 Jan 2012 16:02:44 -0600 Message-Id: <1325628171-4803-1-git-send-email-rob@ti.com> X-Mailer: git-send-email 1.7.5.4 --- See: https://bugzilla.gnome.org/show_bug.cgi?id=667217 ext/resindvd/rsndec.c | 159 +++++-------------------------------------------- ext/resindvd/rsndec.h | 2 - 2 files changed, 16 insertions(+), 145 deletions(-) diff --git a/ext/resindvd/rsndec.c b/ext/resindvd/rsndec.c index 7db1e46..2f42e28 100644 --- a/ext/resindvd/rsndec.c +++ b/ext/resindvd/rsndec.c @@ -103,6 +103,15 @@ rsn_dec_dispose (GObject * object) G_OBJECT_CLASS (rsn_dec_parent_class)->dispose (object); } +static void +child_pad_added (GstElement * element, GstPad * pad, RsnDec * self) +{ + GST_DEBUG_OBJECT (self, "New pad: %" GST_PTR_FORMAT, pad); + gst_ghost_pad_set_target (self->srcpad, pad); + + gst_element_sync_state_with_parent (element); +} + static gboolean rsn_dec_set_child (RsnDec * self, GstElement * new_child) { @@ -127,16 +136,16 @@ rsn_dec_set_child (RsnDec * self, GstElement * new_child) gst_ghost_pad_set_target (self->sinkpad, child_pad); gst_object_unref (child_pad); - child_pad = gst_element_get_static_pad (new_child, "src"); - if (child_pad == NULL) { - return FALSE; - } - gst_ghost_pad_set_target (self->srcpad, child_pad); - gst_object_unref (child_pad); + /* Listen for new pads from the decoder */ + g_signal_connect (G_OBJECT (new_child), "pad-added", + G_CALLBACK (child_pad_added), self); GST_DEBUG_OBJECT (self, "Add child %" GST_PTR_FORMAT, new_child); self->current_decoder = new_child; + /* not sure if we need this here, or if the one in child_pad_added + * is sufficient.. + */ gst_element_sync_state_with_parent (new_child); return TRUE; @@ -155,114 +164,6 @@ typedef struct GstCaps *decoder_caps; } RsnDecFactoryFilterCtx; -static gboolean -rsndec_factory_filter (GstPluginFeature * feature, RsnDecFactoryFilterCtx * ctx) -{ - GstElementFactory *factory; - guint rank; - const gchar *klass; - const GList *templates; - GList *walk; - gboolean can_sink = FALSE; - - /* we only care about element factories */ - if (!GST_IS_ELEMENT_FACTORY (feature)) - return FALSE; - - factory = GST_ELEMENT_FACTORY (feature); - - klass = gst_element_factory_get_klass (factory); - /* only decoders can play */ - if (strstr (klass, "Decoder") == NULL) - return FALSE; - - /* only select elements with autoplugging rank */ - rank = gst_plugin_feature_get_rank (feature); - if (rank < GST_RANK_MARGINAL) - return FALSE; - - /* See if the element has a sink pad that can possibly sink this caps */ - - /* get the templates from the element factory */ - templates = gst_element_factory_get_static_pad_templates (factory); - for (walk = (GList *) templates; walk && !can_sink; walk = g_list_next (walk)) { - GstStaticPadTemplate *templ = walk->data; - - /* we only care about the sink templates */ - if (templ->direction == GST_PAD_SINK) { - GstCaps *intersect; - GstCaps *tmpl_caps; - - /* try to intersect the caps with the caps of the template */ - tmpl_caps = gst_static_caps_get (&templ->static_caps); - - intersect = gst_caps_intersect (ctx->desired_caps, tmpl_caps); - gst_caps_unref (tmpl_caps); - - /* check if the intersection is empty */ - if (!gst_caps_is_empty (intersect)) { - GstCaps *new_dec_caps; - /* non empty intersection, we can use this element */ - can_sink = TRUE; - new_dec_caps = gst_caps_union (ctx->decoder_caps, intersect); - gst_caps_unref (ctx->decoder_caps); - ctx->decoder_caps = new_dec_caps; - } - gst_caps_unref (intersect); - } - } - - if (can_sink) { - GST_DEBUG ("Found decoder element %s (%s)", - gst_element_factory_get_longname (factory), - gst_plugin_feature_get_name (feature)); - } - - return can_sink; -} - -static gint -sort_by_ranks (GstPluginFeature * f1, GstPluginFeature * f2) -{ - gint diff; - const gchar *rname1, *rname2; - - diff = gst_plugin_feature_get_rank (f2) - gst_plugin_feature_get_rank (f1); - if (diff != 0) - return diff; - - rname1 = gst_plugin_feature_get_name (f1); - rname2 = gst_plugin_feature_get_name (f2); - - diff = strcmp (rname2, rname1); - - return diff; -} - -static gpointer -_get_decoder_factories (gpointer arg) -{ - GstElementClass *klass = arg; - GList *factories; - GstPadTemplate *templ = gst_element_class_get_pad_template (klass, - "sink"); - RsnDecFactoryFilterCtx ctx = { NULL, }; - - ctx.desired_caps = gst_pad_template_get_caps (templ); - /* Set decoder caps to empty. Will be filled by the factory_filter */ - ctx.decoder_caps = gst_caps_new_empty (); - - factories = gst_default_registry_feature_filter ( - (GstPluginFeatureFilter) rsndec_factory_filter, FALSE, &ctx); - - factories = g_list_sort (factories, (GCompareFunc) sort_by_ranks); - - GST_DEBUG ("Available decoder caps %" GST_PTR_FORMAT, ctx.decoder_caps); - gst_caps_unref (ctx.decoder_caps); - - return factories; -} - static GstStateChangeReturn rsn_dec_change_state (GstElement * element, GstStateChange transition) { @@ -273,12 +174,8 @@ rsn_dec_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY:{ GstElement *new_child; - const GList *decoder_factories; - new_child = gst_element_factory_make ("autoconvert", NULL); - decoder_factories = klass->get_decoder_factories (klass); - g_object_set (G_OBJECT (new_child), "initial-identity", TRUE, - "factories", decoder_factories, NULL); + new_child = gst_element_factory_make ("decodebin2", NULL); if (new_child == NULL || !rsn_dec_set_child (self, new_child)) ret = GST_STATE_CHANGE_FAILURE; break; @@ -365,16 +262,6 @@ static GstStaticPadTemplate audio_src_template = GST_STATIC_PAD_TEMPLATE ("src", G_DEFINE_TYPE (RsnAudioDec, rsn_audiodec, RSN_TYPE_DEC); -static const GList * -rsn_audiodec_get_decoder_factories (RsnDecClass * klass) -{ - static GOnce gonce = G_ONCE_INIT; - - g_once (&gonce, _get_decoder_factories, klass); - - return (const GList *) gonce.retval; -} - static void rsn_audiodec_class_init (RsnAudioDecClass * klass) { @@ -389,8 +276,6 @@ rsn_audiodec_class_init (RsnAudioDecClass * klass) gst_element_class_set_details_simple (element_class, "RsnAudioDec", "Audio/Decoder", "Resin DVD audio stream decoder", "Jan Schmidt "); - - dec_class->get_decoder_factories = rsn_audiodec_get_decoder_factories; } static void @@ -415,16 +300,6 @@ static GstStaticPadTemplate video_src_template = GST_STATIC_PAD_TEMPLATE ("src", G_DEFINE_TYPE (RsnVideoDec, rsn_videodec, RSN_TYPE_DEC); -static const GList * -rsn_videodec_get_decoder_factories (RsnDecClass * klass) -{ - static GOnce gonce = G_ONCE_INIT; - - g_once (&gonce, _get_decoder_factories, klass); - - return (const GList *) gonce.retval; -} - static void rsn_videodec_class_init (RsnAudioDecClass * klass) { @@ -439,8 +314,6 @@ rsn_videodec_class_init (RsnAudioDecClass * klass) gst_element_class_set_details_simple (element_class, "RsnVideoDec", "Video/Decoder", "Resin DVD video stream decoder", "Jan Schmidt "); - - dec_class->get_decoder_factories = rsn_videodec_get_decoder_factories; } static void diff --git a/ext/resindvd/rsndec.h b/ext/resindvd/rsndec.h index 93c79a6..3778787 100644 --- a/ext/resindvd/rsndec.h +++ b/ext/resindvd/rsndec.h @@ -70,8 +70,6 @@ struct _RsnDec { struct _RsnDecClass { GstBinClass parent_class; - - const GList * (*get_decoder_factories) (RsnDecClass *klass); }; G_END_DECLS