

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
29 messages in net.java.dev.jna.users[jna-users] Struct with Union with St...| From | Sent On | Attachments |
|---|---|---|
| Wolfgang Pichler | Mar 25, 2009 5:58 am | |
| Timothy Wall | Mar 25, 2009 7:02 am | |
| Timothy Wall | Mar 25, 2009 7:06 am | |
| Wolfgang Pichler | Mar 25, 2009 7:21 am | |
| Timothy Wall | Mar 25, 2009 7:24 am | |
| Wolfgang Pichler | Mar 25, 2009 8:11 am | |
| Wolfgang Pichler | Mar 25, 2009 8:20 am | |
| Novatchkov Hristo | Mar 25, 2009 8:41 am | |
| Timothy Wall | Mar 25, 2009 9:59 am | |
| Timothy Wall | Mar 25, 2009 10:28 am | |
| Timothy Wall | Mar 25, 2009 10:38 am | |
| Hristo Novatchkov | Mar 25, 2009 11:40 am | |
| Wolfgang Pichler | Mar 25, 2009 12:02 pm | |
| LYou...@gkservices.com | Mar 25, 2009 12:11 pm | |
| Timothy Wall | Mar 25, 2009 12:52 pm | |
| Wolfgang Pichler | Mar 26, 2009 12:22 am | |
| Timothy Wall | Mar 26, 2009 4:46 am | |
| Wolfgang Pichler | Mar 26, 2009 5:23 am | |
| Timothy Wall | Mar 26, 2009 6:09 am | |
| Wolfgang Pichler | Mar 26, 2009 6:13 am | |
| Wolfgang Pichler | Mar 26, 2009 6:26 am | |
| Timothy Wall | Mar 26, 2009 6:40 am | |
| Wolfgang Pichler | Mar 26, 2009 12:22 pm | |
| Timothy Wall | Mar 26, 2009 1:00 pm | |
| Wolfgang Pichler | Mar 26, 2009 3:15 pm | |
| Timothy Wall | Mar 30, 2009 6:06 am | |
| Wolfgang Pichler | Mar 30, 2009 11:55 am | |
| Timothy Wall | Mar 30, 2009 12:14 pm | |
| Wolfgang Pichler | Mar 31, 2009 12:35 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] Struct with Union with Structs... | Actions... |
|---|---|---|
| From: | Wolfgang Pichler (wpic...@callino.at) | |
| Date: | Mar 25, 2009 5:58:53 am | |
| List: | net.java.dev.jna.users | |
Hi all,
i am new here - so please be nice if I am asking a dumb question.
I am trying to wrap the iaxclient library to be useable with java. There is already an implementation - but quit old - and with the iaxclient v1 - not v2.
You can find the iaxclient.h here: <http://iaxclient.sourceforge.net/doc/html/iaxclient_8h.html> http://iaxclient.sourceforge.net/doc/html/iaxclient_8h.html
I have it already working to get loaded - and it does already registers with my server - but I am not able at time to handle all events correctly. I do have already done the function to install a callback for the events - the callback does also gets called - and does already get the event as it should - but the event structure is the following c code
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html> 00538 typedef struct iaxc_event_struct {
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#54a75fb153 ef93ce76665db988f80582> 00543 struct iaxc_event_struct *next; 00544
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#4c3030b8ec c6f056b541bcbbfc5d0c9b> 00549 int type; 00550 00554 union {
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#ec445e84a3 03bcc8e984930888e24233> 00556 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html> iaxc_ev_levels levels;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#ce59f28817 bb808d9b962b8fd99c12c1> 00558 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__text.html> iaxc_ev_text text;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#05c2b5a052 dac915184b9830ea54e6b3> 00560 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__call__state.html> iaxc_ev_call_state call;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#68a6aa497a 583a7e57fd11b2641cf1f9> 00562 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__netstats.html> iaxc_ev_netstats netstats;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#f330175448 1ff9d8008cc83ef39e3d25> 00564 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__video__stats.html
iaxc_ev_video_stats videostats;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#81635df20f 08035a344a4ec7f2a8f6e9> 00566 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__url.html> iaxc_ev_url <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__url.html#329ea845 d3504bd8c7daafc724f8d980> url;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#f436003528 4c6b34633c04c7a0fc0616> 00568 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__video.html> iaxc_ev_video video;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#f98a67cc72 848193002a8f6fe15a4f09> 00570 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__audio.html> iaxc_ev_audio audio;
<http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html#db909b87e8 5776e97e339280ef2e986f> 00572 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html
iaxc_ev_registration reg;
00573 } ev; 00574 } iaxc_event <http://iaxclient.sourceforge.net/doc/html/structiaxc__event.html> ;
With iaxc_ev_registriation
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html
00513 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html iaxc_ev_registration {
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #cb9d89fc8e8574ac5e4f2383ec18aa61> 00519 int <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #cb9d89fc8e8574ac5e4f2383ec18aa61> id; 00520
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #c80181b9281394344f215db8318740b5> 00527 int <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #c80181b9281394344f215db8318740b5> reply; 00528
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #ccfd5115e74e18036835cdf55adb903b> 00532 int <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__registration.html #ccfd5115e74e18036835cdf55adb903b> msgcount; 00533 };
And iaxc_ev_levels
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html> 00183 struct <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html> iaxc_ev_levels {
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html#a02aa 4fc1dd80f5b285dad0bc8833773> 00187 float <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html#a02aa 4fc1dd80f5b285dad0bc8833773> input; 00188
<http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html#7573f 04f3b2b5737259e92c799803bae> 00192 float <http://iaxclient.sourceforge.net/doc/html/structiaxc__ev__levels.html#7573f 04f3b2b5737259e92c799803bae> output; 00193 };
I have mapped it to
public static class iaxc_ev_registration extends Structure {
public int id;
public int reply;
public int msgcount;
}
public static class iaxc_ev_levels extends Structure {
public float input;
public float output;
}
public static class iaxc_event_struct extends Structure {
public static class ByValue extends iaxc_event_struct implements
Structure.ByValue {
}
public Pointer next;
public int type;
public static class iaxc_event_union extends Union {
public iaxc_ev_registration registration;
public iaxc_ev_levels levels;
}
public iaxc_event_union ev;
}
In the callback i will get the iaxc_event_struct passed correctly - I can distinguish between the event types - but then when I try to access a specific event type structure - the structure is not initialized (nulled). When i for example directly add iaxc_ev_registration instead of the union - then I will have an initialized structure in the event handler for the registration event - but can't analyze all other events. I have read about using setType and read function to initialize the union - but it does not work.
Here is the callback function
IAXClient.INSTANCE.iaxc_set_event_callback(new IAXClient.FUNCTION() {
@Override
public int invoke(iaxc_event_struct.ByValue event) {
if (event==null) {
return 0;
}
switch(event.type) {
case IAXClient.IAXC_EVENT_REGISTRATION:
System.out.println("Event Raw: " + event.ev.toString());
event.ev.setType(IAXClient.iaxc_ev_registration.class);
event.ev.read();
IAXClient.iaxc_ev_registration reg = (iaxc_ev_registration) event.ev.getTypedValue(IAXClient.iaxc_ev_registration.class);
System.out.println("Event Reg: " + reg.reply);
break;
case IAXClient.IAXC_EVENT_LEVELS:
IAXClient.iaxc_ev_levels levels = (iaxc_ev_levels) event.ev.getTypedValue(IAXClient.iaxc_ev_levels.class);
System.out.println("Event LEvel: " + levels.input);
break;
default:
break;
}
return 0;
}
});
I think it will be something trivial - but I don't get it working by myself.
Can someone here enlighten me ?
Best regards,
Wolfgang







