Re: [PATCH 0/9] Multi-valued proposal (WIP)
- From: "Juan A." Suárez Romero <jasuarez igalia com>
- To: grilo-list gnome org
- Subject: Re: [PATCH 0/9] Multi-valued proposal (WIP)
- Date: Wed, 23 Feb 2011 17:13:59 +0100
On Wed, 2011-02-23 at 15:54 +0000, Iago Toral wrote:
> >> I guess the question here is if the extra flexibility we get from
> >> this
> >> approach and the code reuse is worth the additional slight
> >> obscurity.
> >>
> >> The alternative to this, as I explained in an e-mail before would
> >> be to
> >> have explicit, fixed relations defined at compile time. Things
> >> like:
> >>
> >> GrlDataVideoURI, GrlDataThumbnail, etc
> >>
> >> These would be structs:
> >>
> >> typedef struct {
> >> gchar *uri;
> >> gchar *mime;
> >> guint width;
> >> guint height;
> >> ...
> >> } GrlVideoURI;
> >>
> >> And then we would have API to set and get these structs from a
> >> GrlData
> >> object:
> >>
> >> GrlMediaVideo *video;
> >> GrlVideoUri *uri_data = grl_video_uri_new (uri, mime, width,
> >> height);
> >> grl_media_video_set_uri (video, uri_data);
> >> ...
> >> GrlVideoUri *uri_data = grl_media_video_get_uri (video);
> >> gchar *uri = grl_video_uri_get_uri (uri_data);
> >> gchar *mime = grl_video_uri_get_mime (uri_data);
> >> ...
> >>
> >> As you can see, the correlations here are fixed, they are defined
> >> by
> >> structures, so they are explicit and we provide the users with
> >> specific
> >> APIs to handle each correlation,, which I think is less obscure
> >> than
> >> using a generic API. The drawback is of course that they are
> fixed,
> >> and
> >> that you have to create structures and specific API for each
> >> correlation
> >> (more code) and you cannot define new relations at run-time.
> >
> > Exactly. If Grilo wouldn't allow to create new keys by plugins,
> then
> > of
> > course I go with this approach.
> >
> > But here there is an important point I would like to say: what I
> sent
> > is
> > a preliminary work that focus on the core part for adding
> > multi-valued
> > properties. Based on this work, we can add new api to ease some
> > things,
> > as we added api in GrlMediaAudio to ease its handle using GrlData
> > api.
> >
> > Thus, maybe we can add your api proposal to GrlMediaVideo using
> > GrlDataMulti api to implement it.
>
> And how would you do that exactly?
>
Basically, grl_media_video_set_uri(video, uri_data) can build a
GrlProperty with the content of uri_data and add it to
GRL_DATA_MULTI(video)
In the same way, grl_media_video_get_uri (video, 0) internally would get
the GrlProperty for position 0, and dump the values to the GrlVideoUri
structure.
If a plugin defines a new key that are correlated with the uri key,
basically means that using the GrlVideoUri you will lost the value,
because it won't be dumped to/from the structure. But still you have a
chance to get it.
J.A.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]