Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-18 Thread Lei Miao

That worked! Thank you so much for the help!

I still have a related question though:

In the following function in the generated c code,

static gchar**my_streaming_source_real_get_protocols (GstURIHandler* 
base, GType type, int* result_length1) {

MyStreamingSource * self;
gchar** result = NULL;
gchar** _tmp0_ = NULL;
gint _tmp0__length1 = 0;
self = (MyStreamingSource*) base;
_tmp0_ = MY_STREAMING_SOURCE_protocols;
_tmp0__length1 = G_N_ELEMENTS (MY_STREAMING_SOURCE_protocols);
if (result_length1) {
*result_length1 = _tmp0__length1;
}
result = _tmp0_;
return result;
}

the last argument int* result_length1 somehow is causing seg faults. 
If I remove this argument manually, then the problem goes away.


I was wondering why this argument is added, since in the vapi, I only have:

[CCode (array_length = false, array_null_terminated = true)]
public abstract unowned string[] get_protocols (GLib.Type type);

and in the vala code, I have

public unowned string[] get_protocols(Type type) { return protocols; } 
where protocols is a string array.


Is there a way to remove this argument in the generated c code?

Regards,

LM

On 3/18/2014 4:35 AM, Luca Bruno wrote:

On 17/03/2014 20:29, Lei Miao wrote:

Thanks for pointing out the typo.

Unfortunately, it doesn't resolve the problem.

Below is what I have right now in gstreamer-1.0.vapi:

[CCode (cheader_filename = gst/gst.h, type_cname = 
GstURIHandlerInterface, type_id = gst_uri_handler_get_type ())]

public interface URIHandler : GLib.Object {
[CCode (array_length = false, array_null_terminated = true)]
public abstract unowned string[] get_protocols (GLib.Type type);
public abstract string get_uri ();
[CCode (vfunc_name = get_type)]
public abstract Gst.URIType get_uri_type (GLib.Type type);
public abstract bool set_uri (string uri) throws GLib.Error;
}

In the generated c file, I have:

iface-get_protocols = (gchar** (*)(GstURIHandler*, GType)) ...
iface-get_uri_type = (GstURIType (*)(GstURIHandler*, GType)) ...
iface-get_uri = (gchar* (*)(GstURIHandler*)) ...
iface-set_uri = (gboolean (*)(GstURIHandler*, const gchar*, 
GError**)) ...


It won't compile due to the following error:
error: 'GstURIHandlerInterface' has no member named 'get_uri_type'

If I manually change iface-get_uri_type to iface-get_type, then 
it compiles.

Mh ok. Try putting vfunc_name also when implementing the method.


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-17 Thread Lei Miao
Thanks for pointing out the typo.

Unfortunately, it doesn't resolve the problem.

Below is what I have right now in gstreamer-1.0.vapi:

[CCode (cheader_filename = gst/gst.h, type_cname =
GstURIHandlerInterface, type_id = gst_uri_handler_get_type ())]
public interface URIHandler : GLib.Object {
[CCode (array_length = false, array_null_terminated = true)]
public abstract unowned string[] get_protocols (GLib.Type type);
public abstract string get_uri ();
[CCode (vfunc_name = get_type)]
public abstract Gst.URIType get_uri_type (GLib.Type type);
public abstract bool set_uri (string uri) throws GLib.Error;
}

In the generated c file, I have:

iface-get_protocols = (gchar** (*)(GstURIHandler*, GType)) ...
iface-get_uri_type = (GstURIType (*)(GstURIHandler*, GType)) ...
iface-get_uri = (gchar* (*)(GstURIHandler*)) ...
iface-set_uri = (gboolean (*)(GstURIHandler*, const gchar*, GError**)) ...

It won't compile due to the following error:
error: 'GstURIHandlerInterface' has no member named 'get_uri_type'

If I manually change iface-get_uri_type to iface-get_type, then it
compiles.

Regards,

LM



On Mon, Mar 17, 2014 at 4:33 AM, Luca Bruno lethalma...@gmail.com wrote:

 On 16/03/2014 22:33, Lei Miao wrote:

 Yes, I tried it, but it has no effect.

 I have the following in my vala code:
 ...
 [CCode (vfunc = get_type)]
 public URIType get_uri_type (Type type) { return URIType.SRC; }
 ...

 Is it what you recommended?

 Basically, the problem is that iface-get_type =... is missing in
 ...gst_uri_handler_interface_init() function in the generated c file.

 Regards,

 Sorry, vfunc_name: https://git.gnome.org/browse/
 vala/tree/vapi/gio-2.0.vapi#n1365


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-16 Thread Lei Miao

Thank you for the information, but it doesn't seem to be related to my case.

To be clear, I was referring to the following interface:


 struct GstURIHandlerInterface

struct GstURIHandlerInterface {
  GTypeInterface parent;

  /* vtable */
  /* querying capabilities */
  GstURIType (* get_type)   (GType type);
  const gchar * const *  (* get_protocols)  (GType type);

  /* using the interface */
  gchar *(* get_uri)(GstURIHandler * handler);
  gboolean   (* set_uri)(GstURIHandler * handler,
 const gchar   * uri,
 GError   ** error);
};


It has the get_type method that needs to be implemented in my vala 
code. In gst_element_register() in gstelementfactory.c, it checks the 
type by calling get_type():


...
if (!iface || !iface-get_type || !iface-get_protocols)
  goto urierror;
...

Regards,

LM

On 3/16/2014 6:08 AM, Luca Bruno wrote:
Try [CCode (vfunc = get_type)] or such, see gio vapi for some 
examples about read_fn.



On Sun, Mar 16, 2014 at 10:05 AM, Abderrahim Kitouni 
a.kito...@gmail.com mailto:a.kito...@gmail.com wrote:


Hi,

I've looked at thé gst docs and the vfunc for get_uri_type is
called get_type.

HTH,

On March 16, 2014 9:19:34 AM CET, Luca Bruno
lethalma...@gmail.com mailto:lethalma...@gmail.com wrote:

I don't understand what you mean by gstreamer uses get_type, can you 
point
to the specific C method?


On Sat, Mar 15, 2014 at 4:05 PM, Lei Miao leimia...@gmail.com  
mailto:leimia...@gmail.com wrote:


Thank you for the response. I could implement
get_uri_type, but the problem is that gstreamer uses
get_type. If I can implement get_type in vala, then I
don't have to modify gstreamer code. Regards, LM On Mar
14, 2014 5:30 PM, Luca Bruno lethalma...@gmail.com
mailto:lethalma...@gmail.com wrote:

I don't understand why you are using get_type.
Implement get_uri_type. On Fri, Mar 14, 2014 at 10:21
PM, Lei Miao leimia...@gmail.com
mailto:leimia...@gmail.com wrote:

Hi, I am trying to write a gstreamer 1.0 plugin
using vala. However, I am having trouble to
implement the get_type() method of the
Gst.URIHandler interface defined here:

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstUriHandler.html#GstURIHandlerInterface
. In particular, my class inherits Gst.bin and
implements Gst.URIHandler interface: public class
StreamingSource: Gst.Bin, Gst.URIHandler { ...
public URIType get_type (Type type) { return
URIType.SRC; } ... } When I compile the vala code
to c code, I get the following error:
StreamingSource.get_type hides inherited method
`GLib.Object.get_type'. Use the `new' keyword if
hiding was intentional public URIType get_type
(Type type) { return URIType.SRC; } The problem
seems to be that GLib.Object also has a method
called get_type. So in this case, does anybody
know how I can implement the get_type method of
Gst.URIHandler? It's worth noting that according
to this link:

http://references.valadoc.org/#!api=gstreamer-1.0/Gst.URIHandler

http://references.valadoc.org/#%21api=gstreamer-1.0/Gst.URIHandler
, the method is called get_uri_type() instead.
This is inconsistent with the gstreamer 1.0
reference manual. In fact, Gstreamer code has both
methods defined, but it uses get_type() for
element registration. Regards, LM


vala-list mailing list vala-list@gnome.org
mailto:vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

-- www.debian.org http://www.debian.org - The
Universal Operating System



-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.





--
www.debian.org http://www.debian.org - The Universal Operating System


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-16 Thread Lei Miao

Yes, I tried it, but it has no effect.

I have the following in my vala code:
...
[CCode (vfunc = get_type)]
public URIType get_uri_type (Type type) { return URIType.SRC; }
...

Is it what you recommended?

Basically, the problem is that iface-get_type =... is missing in 
...gst_uri_handler_interface_init() function in the generated c file.


Regards,

LM

On 3/16/2014 10:37 AM, Luca Bruno wrote:

Why isn't [CCode (vfunc = get_type)] related to it? Did you try already?


On Sun, Mar 16, 2014 at 3:07 PM, Lei Miao leimia...@gmail.com 
mailto:leimia...@gmail.com wrote:


Thank you for the information, but it doesn't seem to be related
to my case.

To be clear, I was referring to the following interface:


  struct GstURIHandlerInterface

struct GstURIHandlerInterface {
   GTypeInterface parent;

   /* vtable */
   /* querying capabilities */
   GstURIType (* get_type)   (GType type);
   const gchar * const *  (* get_protocols)  (GType type);

   /* using the interface */
   gchar *(* get_uri)(GstURIHandler * handler);
   gboolean   (* set_uri)(GstURIHandler * handler,
  const gchar   * uri,
  GError   ** error);
};


It has the get_type method that needs to be implemented in my
vala code. In gst_element_register() in gstelementfactory.c, it
checks the type by calling get_type():

...
if (!iface || !iface-get_type || !iface-get_protocols)
  goto urierror;
...

Regards,

LM

On 3/16/2014 6:08 AM, Luca Bruno wrote:

Try [CCode (vfunc = get_type)] or such, see gio vapi for some
examples about read_fn.


On Sun, Mar 16, 2014 at 10:05 AM, Abderrahim Kitouni
a.kito...@gmail.com mailto:a.kito...@gmail.com wrote:

Hi,

I've looked at thé gst docs and the vfunc for get_uri_type is
called get_type.

HTH,

On March 16, 2014 9:19:34 AM CET, Luca Bruno
lethalma...@gmail.com mailto:lethalma...@gmail.com wrote:

I don't understand what you mean by gstreamer uses get_type, can 
you point
to the specific C method?


On Sat, Mar 15, 2014 at 4:05 PM, Lei Miao leimia...@gmail.com  
mailto:leimia...@gmail.com wrote:


Thank you for the response. I could implement
get_uri_type, but the problem is that gstreamer uses
get_type. If I can implement get_type in vala, then I
don't have to modify gstreamer code. Regards, LM On
Mar 14, 2014 5:30 PM, Luca Bruno
lethalma...@gmail.com
mailto:lethalma...@gmail.com wrote:

I don't understand why you are using get_type.
Implement get_uri_type. On Fri, Mar 14, 2014 at
10:21 PM, Lei Miao leimia...@gmail.com
mailto:leimia...@gmail.com wrote:

Hi, I am trying to write a gstreamer 1.0
plugin using vala. However, I am having
trouble to implement the get_type() method of
the Gst.URIHandler interface defined here:

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstUriHandler.html#GstURIHandlerInterface
. In particular, my class inherits Gst.bin
and implements Gst.URIHandler interface:
public class StreamingSource: Gst.Bin,
Gst.URIHandler { ... public URIType get_type
(Type type) { return URIType.SRC; } ... }
When I compile the vala code to c code, I get
the following error: StreamingSource.get_type
hides inherited method
`GLib.Object.get_type'. Use the `new' keyword
if hiding was intentional public URIType
get_type (Type type) { return URIType.SRC; }
The problem seems to be that GLib.Object also
has a method called get_type. So in this
case, does anybody know how I can implement
the get_type method of Gst.URIHandler? It's
worth noting that according to this link:

http://references.valadoc.org/#!api=gstreamer-1.0/Gst.URIHandler

http://references.valadoc.org/#%21api=gstreamer-1.0/Gst.URIHandler
, the method is called get_uri_type()
instead. This is inconsistent with the
gstreamer 1.0 reference manual. In fact,
Gstreamer code has both methods defined

Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-15 Thread Lei Miao
Thank you for the response.

I could implement get_uri_type, but the problem is that gstreamer uses
get_type.

If I can implement get_type in vala, then I don't have to modify gstreamer
code.

Regards,

LM
On Mar 14, 2014 5:30 PM, Luca Bruno lethalma...@gmail.com wrote:

 I don't understand why you are using get_type. Implement get_uri_type.


 On Fri, Mar 14, 2014 at 10:21 PM, Lei Miao leimia...@gmail.com wrote:

 Hi,

 I am trying to write a gstreamer 1.0 plugin using vala. However, I am
 having trouble to implement the get_type() method of the Gst.URIHandler
 interface defined here:

 http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstUriHandler.html#GstURIHandlerInterface
 .

 In particular, my class inherits Gst.bin and implements Gst.URIHandler
 interface:

  public class StreamingSource: Gst.Bin, Gst.URIHandler {

 ...

 public URIType get_type (Type type) { return URIType.SRC; }

 ...
 }

 When I compile the vala code to c code, I get the following error:

 StreamingSource.get_type hides inherited method `GLib.Object.get_type'.
 Use
 the `new' keyword if hiding was intentional
 public URIType get_type (Type type) { return URIType.SRC;
 }

 The problem seems to be that GLib.Object also has a method called
 get_type. So in this case, does anybody know how I can implement the
 get_type method of Gst.URIHandler?

 It's worth noting that according to this link:
 http://references.valadoc.org/#!api=gstreamer-1.0/Gst.URIHandler , the
 method is called get_uri_type() instead. This is inconsistent with the
 gstreamer 1.0 reference manual. In fact, Gstreamer code has both methods
 defined, but it uses get_type() for element registration.

 Regards,

 LM
 ___
 vala-list mailing list
 vala-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/vala-list




 --
 www.debian.org - The Universal Operating System

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] How to implement the get_type method of Gst.URIHandler interface in vala?

2014-03-14 Thread Lei Miao
Hi,

I am trying to write a gstreamer 1.0 plugin using vala. However, I am
having trouble to implement the get_type() method of the Gst.URIHandler
interface defined here:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstUriHandler.html#GstURIHandlerInterface.

In particular, my class inherits Gst.bin and implements Gst.URIHandler
interface:

 public class StreamingSource: Gst.Bin, Gst.URIHandler {

...

public URIType get_type (Type type) { return URIType.SRC; }

...
}

When I compile the vala code to c code, I get the following error:

StreamingSource.get_type hides inherited method `GLib.Object.get_type'. Use
the `new' keyword if hiding was intentional
public URIType get_type (Type type) { return URIType.SRC; }

The problem seems to be that GLib.Object also has a method called
get_type. So in this case, does anybody know how I can implement the
get_type method of Gst.URIHandler?

It's worth noting that according to this link:
http://references.valadoc.org/#!api=gstreamer-1.0/Gst.URIHandler , the
method is called get_uri_type() instead. This is inconsistent with the
gstreamer 1.0 reference manual. In fact, Gstreamer code has both methods
defined, but it uses get_type() for element registration.

Regards,

LM
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list