Could tell me how string type can be casting automatically object type?

Brendan Long self at brendanlong.com
Thu Sep 26 13:27:29 PDT 2013


g_value_register_transform_func is probably what you want. There's lots
of examples in the "gstreamer" repo. gst/gstvalue.c seems like a good
place to look.
> $ git grep g_value_register_transform
> gst/gstcaps.c:  g_value_register_transform_func (_gst_caps_type,
> gst/gstcapsfeatures.c:  g_value_register_transform_func
> (_gst_caps_features_type, G_TYPE_STRING,
> gst/gststructure.c:  g_value_register_transform_func
> (_gst_structure_type, G_TYPE_STRING,
> gst/gsttaglist.c: *    g_value_register_transform_func
> (_gst_tag_list_type, G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_INT_RANGE,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func
> (GST_TYPE_INT64_RANGE, G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func
> (GST_TYPE_DOUBLE_RANGE, G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func
> (GST_TYPE_FRACTION_RANGE, G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_LIST,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_ARRAY,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_FRACTION,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_STRING,
> GST_TYPE_FRACTION,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_FRACTION,
> G_TYPE_DOUBLE,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_FRACTION,
> G_TYPE_FLOAT,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_DOUBLE,
> GST_TYPE_FRACTION,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_FLOAT,
> GST_TYPE_FRACTION,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_DATE,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_STRING,
> G_TYPE_DATE,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_OBJECT,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_BITMASK,
> G_TYPE_UINT64,
> gst/gstvalue.c:  g_value_register_transform_func (GST_TYPE_BITMASK,
> G_TYPE_STRING,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_UINT64,
> GST_TYPE_BITMASK,
> gst/gstvalue.c:  g_value_register_transform_func (G_TYPE_STRING,
> GST_TYPE_BITMASK,

Also, for converting things like fakesink to GstElement, GStreamer
already does that. See gst_parse_bin_from_description in gst/gstutils.c
and gst/parse/grammar.y to see how.


On 09/25/2013 07:20 AM, HoonHee Lee wrote:
> I mean, gstplaybin2.c has a PROP_AUDIO_SINK property such as PROP_VIDEO_SINK
> and PROP_TEXT_SINK.
>
> source code is like this.
>
> static void
> gst_play_bin_class_init (GstPlayBinClass * klass)
> {
>   ...
>   g_object_class_install_property (gobject_klass, PROP_AUDIO_SINK,
>       *g_param_spec_object* ("audio-sink", "Audio Sink",
>           "the audio output element to use (NULL = default sink)",
>           *GST_TYPE_ELEMENT*, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
>   ...
> }
>
> static void
> gst_play_bin_set_property (GObject * object, guint prop_id,
>     const GValue * value, GParamSpec * pspec)
> {
>   ...
>   case PROP_AUDIO_SINK:
>       gst_play_bin_set_sink (playbin, &playbin->audio_sink, "audio",
>           *g_value_get_object* (value));
>   ...
> }
>
> static void
> gst_play_bin_set_sink (GstPlayBin * playbin, GstElement ** elem,
>     const gchar * dbg, *GstElement* * sink)
> {
>   ...
> }
>
>
> When I use gst-launch playbin uri="xxx" audio-sink="fakesink",
> I am just wondering that how "fakesink" string can be casting automatically
> GstElement Type by g_value_get_object().
> And I think PROP_ACTIVE_PAD property of gstinputselector.c is same
> mechanism.
>
> I just want to know which function is making to be possible this mechanism.
> Because I want that string type can be casting automatically my customized
> object such as GstElement or GstPad Type.
>
> I am not sure, but g_value_transform () or g_value_register_transform_func
> () is right?
>
> Please tell me how string type can be casting automatically object type.
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Could-tell-me-how-string-type-can-be-casting-automatically-object-type-tp4662191.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130926/c237387b/attachment.pgp>


More information about the gstreamer-devel mailing list