Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get() on WebRTCBin causes java.lang.InstantiationException #240

Open
suCRR opened this issue May 20, 2021 · 6 comments
Open

get() on WebRTCBin causes java.lang.InstantiationException #240

suCRR opened this issue May 20, 2021 · 6 comments
Labels

Comments

@suCRR
Copy link

suCRR commented May 20, 2021

Hi,

I'm trying to get the ice-agent of on webRTCBin. This property is quite new (I don't know the exact gst version) and most probably isn't known within the java bindings. The property is type of GstWebRTCICE class and I couldn't find a GstWebRTCICE class within the java binding code.

webRTCBin = new WebRTCBin("sendonly"); Object agent = webRTCBin.get("ice-agent");

causes:

java.lang.RuntimeException: java.lang.InstantiationException at org.freedesktop.gstreamer.glib.NativeObject.objectFor(NativeObject.java:195) at org.freedesktop.gstreamer.glib.Natives.objectFor(Natives.java:166) at org.freedesktop.gstreamer.glib.Natives.callerOwnsReturn(Natives.java:140) at org.freedesktop.gstreamer.lowlevel.GTypeMapper$2.fromNative(GTypeMapper.java:113) at com.sun.jna.Function.invoke(Function.java:369) at com.sun.jna.Library$Handler.invoke(Library.java:244) at com.sun.proxy.$Proxy18.g_value_dup_object(Unknown Source) at org.freedesktop.gstreamer.glib.GObject.get(GObject.java:194)

Is there any workaround for this? How could a implement a binding for GstWebRTCICE?

BR Clemens

@suCRR suCRR changed the title get() on WebRTCBin causes get() on WebRTCBin causes java.lang.InstantiationException May 20, 2021
@neilcsmith-net
Copy link
Member

You can register your own mappings by implementing `NativeObject.TypeProvider (eg. like https://github.com/gstreamer-java/gst1-java-core/blob/master/src/org/freedesktop/gstreamer/webrtc/WebRTC.java#L33 ) and registering it to be picked up by ServiceLoader

However, this should be giving you a GstObject already in the mapping, so might be a bug that needs looking at. Or the hierarchy of the GType has changed? There is a problem with GObject being abstract, but the docs at https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=c#GstWebRTCICE suggest GstObject. If you add a mapping, make sure it extends GstObject.

This might be better discussed on the mailing list - might get more people to see / comment there. Then we can follow up if there's an issue to fix, or features to add.

@gpr-indevelopment
Copy link

I have been having the same problem while calling get() on a property of a GObject that cannot be mapped to a GType. The underlying code tries to instantiate the property with the constructor from GObject, which will always fail because it is abstract.

@neilcsmith-net mentioned that GstObject should be picked up automatically, but it is not happening. I am trying to retrieve a sender object: https://gstreamer.freedesktop.org/documentation/webrtclib/gst-libs/gst/webrtc/webrtc-priv.html?gi-language=c#GstWebRTCRTPSender

Tested with version 0.94 and 1.4 of the Java bindings.

Will try registering a mapping like suggested to see if it works

@neilcsmith-net
Copy link
Member

@gpr-indevelopment can you share a simple example that shows the problem you're facing exactly? That type should be a GstObject so shouldn't be affected by GObject being abstract. Need to look more in depth at what is happening.

@gpr-indevelopment
Copy link

gpr-indevelopment commented May 22, 2022

@neilcsmith-net Sure! Sorry for taking this long.

I have an active unidirectional video stream going from my server to a browser client. In this example the pipeline is playing. I tried calling get on "sender" since it is listed under listPropertyNames method of the transceiver. The error happens when:

GstObject transceiver = webRtcBin.emit(GstObject.class, "get-transceiver", 0); // This returns a valid object
transceiver.get("sender"); // Throws InstantiationException

@gpr-indevelopment
Copy link

gpr-indevelopment commented Jun 5, 2022

@neilcsmith-net actually registering a new mapping for GstWebRTCICE like you suggested did the trick, and the java.lang.InstantiationException doesnt happen anymore.

You can register your own mappings by implementing `NativeObject.TypeProvider (eg. like https://github.com/gstreamer-java/gst1-java-core/blob/master/src/org/freedesktop/gstreamer/webrtc/WebRTC.java#L33 ) and registering it to be picked up by ServiceLoader

However, this should be giving you a GstObject already in the mapping, so might be a bug that needs looking at. Or the hierarchy of the GType has changed? There is a problem with GObject being abstract, but the docs at https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=c#GstWebRTCICE suggest GstObject. If you add a mapping, make sure it extends GstObject.

This might be better discussed on the mailing list - might get more people to see / comment there. Then we can follow up if there's an issue to fix, or features to add.

@lionelmazeyrat
Copy link

@gpr-indevelopment could you please post the example code to register the mapping for GstWebRTCICE.
I try to emit "add-local-ip-address" and to set add min-rtp-port/max-rtp-port

GstWebRTCICE
GObject.Object ╰──GObject.InitiallyUnowned ╰──Gst.Object ╰──GstWebRTCICE
Action Signals
add-local-ip-address let ret = object.emit ("add-local-ip-address", address);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants