source: verona/swig/verona.i @ 461:c6f6d5644b50

Last change on this file since 461:c6f6d5644b50 was 461:c6f6d5644b50, checked in by Vadim Lebedev <vadim@…>, 13 months ago

fix item ph_hdr_list.item method

File size: 12.9 KB
Line 
1
2
3#ifdef SWIGCSHARP
4%module (directors=1) csharp_verona
5#endif
6#ifdef SWIGPYTHON
7%module (directors=1) py_verona
8#endif
9#ifdef SWIGJAVA
10%module (directors=1) jni_verona
11#endif
12#ifdef SWIGRUBY
13%module (directors=1) rb_verona
14#endif
15#ifdef SWIGPERL
16%module (directors=1) perl_verona
17#endif
18
19%{
20#include "phapipp.h"
21%}
22
23
24#if defined(_WIN32_WCE)
25#define SWIG_CSHARP_NO_STRING_HELPER
26#define COMPACT_FRAMEWORK_COMPATIBLE
27#endif
28
29#ifdef SWIGCSHARP
30%{
31#if defined(_WIN32_WCE)
32#define SWIG_CSHARP_NO_STRING_HELPER
33#define COMPACT_FRAMEWORK_COMPATIBLE
34#endif
35#include <stdint.h>
36%}
37#endif
38
39#ifdef SWIGJAVA
40%insert("runtime") %{
41#define SWIG_JAVA_NO_DETACH_CURRENT_THREAD
42#define SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON
43%}
44%include "enumtypeunsafe.swg"
45%javaconst(1);
46
47
48%module(directors="1") jni_verona
49%{
50#include <jni.h>
51#ifdef ANDROID
52#include <android/log.h>
53#endif
54struct TmpJOBJ {
55        JNIEnv* env;
56        jobject jo;
57        TmpJOBJ(JNIEnv* e, jobject o) : env(e), jo(o) { }
58        ~TmpJOBJ() { env->DeleteLocalRef(jo); }
59 };
60
61
62
63
64
65extern "C" void osip_set_jvm(JavaVM *ajvm);
66extern "C" void ms_set_jvm(JavaVM *vm);
67
68JNIEXPORT jint JNICALL  JNI_OnLoad(JavaVM *ajvm, void *reserved)                                                     
69{
70        ms_set_jvm(ajvm);
71        osip_set_jvm(ajvm);
72        return JNI_VERSION_1_6;
73}
74
75
76%}
77
78%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * {
79 $input = 0;
80  if ($1) {
81    $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
82    if (!$input) return $null;
83  }
84
85  TmpJOBJ $1_tmpobj(jenv, (jobject) $input);
86
87
88
89#endif
90
91#ifdef SWIGRUBY
92%include "std/std_map.i"
93%include "std/std_string.i"
94#else
95%include "std_map.i"
96%include "std_string.i"
97%include "std_vector.i"
98%include "std_pair.i"
99#endif
100//%traits_ptypen(char)
101
102#ifdef SWIGPYTHON
103%{
104PyObject*
105make_hdrlist(const ph_hdr_list *hl) {
106  PyObject* result;
107
108  result = PyList_New(hl->count);
109  for(int i = 0; i < hl->count; i++)
110     PyList_SET_ITEM(result, i, Py_BuildValue("ss", hl->elems[i].hdr, hl->elems[i].val));
111     
112  return result;   
113}
114
115PyObject*
116make_hdrlist2(const std::vector<std::pair<const char*, const char*> >& hl ) {
117  PyObject* result;
118
119  result = PyList_New(hl.size());
120  for(int i = 0; i < hl.size(); i++)
121     PyList_SET_ITEM(result, i, Py_BuildValue("ss", hl[i].first, hl[i].second));
122     
123  return result;     
124}
125%}
126
127%typemap(out) std::map<char*, char*> {
128  typedef std::map<char*, char*> ccmap;
129  ccmap& m = $1;
130  PyObject *list = PyList_New(m.size());
131  int i = 0;
132  for(ccmap::const_iterator it = m.begin(); it != m.end(); it++) {
133    PyList_SET_ITEM(list, i++, Py_BuildValue("(ss)", it->first, it->second));
134  }
135  $result = list;
136}
137
138
139%typemap(argout) struct ph_hdr_list *{
140  $result = make_hdrlist($1);
141}
142
143
144%typemap(directorin) const phSubscriptionStateInfo_t * {
145
146        $input = Py_BuildValue("iisso", $1_name->event, $1_name->status, $1_name->from, $1_name->to, make_hdrlist(&$1_name->hlist));
147
148}
149
150%typemap(in) const std::vector<std::pair<const char*, const char*> >& {
151
152  // we transform any Python sequence of items which are sequences where first 2 elements are string to a vector<pair<const char*, const char *>>
153  if (PySequence_Check($input)) {
154    std::vector<std::pair<const char*, const char*> > tmpvec;
155    $1 = &tmpvec;
156   
157        int size = PySequence_Size($input);
158        for(int i = 0; i < size; i++) {
159                PyObject *o = PySequence_GetItem($input, i);
160                if (PySequence_Check(o)) {
161                   if (PyString_Check(PySequence_GetItem(o, 0)) && PyString_Check(PySequence_GetItem(o, 1))) {
162                         $1->push_back(std::make_pair<const char*, const char*>(PyString_AsString(PySequence_GetItem(o, 0)),
163                                PyString_AsString(PySequence_GetItem(o, 1))));
164                         } else {
165                            PyErr_SetString(PyExc_TypeError,"not a string sequence");                       
166                            return NULL;
167                         }
168                         
169                   } else {
170                            PyErr_SetString(PyExc_TypeError,"item is not a sequence");
171                            return NULL;
172                   }
173                 
174                   
175        }
176  } else {
177     PyErr_SetString(PyExc_TypeError,"not a sequence");
178     return NULL;
179   
180  }
181}
182
183
184%typemap(directorin) const phMsgStateInfo_t * {
185
186        $input = Py_BuildValue("iissssssio", $1_name->event, $1_name->status, $1_name->from, $1_name->to,
187                        $1_name->ctype, $1_name->subtype, $1_name->content, $1_name->rawctt, $1_name->cid,
188                 make_hdrlist(&$1_name->hlist));
189
190}
191
192%typemap(directorin) const phMsgStateInfo2 * {
193
194        $input = Py_BuildValue("iissssssio", $1_name->event, $1_name->status, $1_name->from, $1_name->to,
195                        $1_name->ctype, $1_name->subtype, $1_name->content, $1_name->rawctt, $1_name->cid,
196                 make_hdrlist2($1_name->hlist));
197
198}
199
200
201%typemap(directorin) const pCallStateInfo_t * {
202
203        $input = Py_BuildValue("isiiiissiiso", $1_name->event, $1_name->localUri, $1_name->newcid,  $1_name->oldcid,
204                        $1_name->vlid, $1_name->streams, $1_name->callinfo, $1_name->remoteUri, $1_name->errorCode,
205                        $1_name->dtmfDigit, $1_name->remoteSdp,
206                 make_hdrlist(&$1_name->hlist));
207
208}
209
210#endif
211
212
213#ifndef SWIGPYTHON
214namespace std {
215       %template(pStrMap) map<char*, char *>;
216       %template(pcStrPair) pair<const char*, const char*>;
217       %template(pcStrVec) vector<pair<const char*, const char *> >;
218}
219#endif
220
221%extend ph_hdr_list {
222
223     ph_hdr_val *item(int i) { return i < self->count ? elems+i : 0; }
224};
225#if 0
226enum ph_subs_type
227{
228  PH_SUBS_PRESENCE,    /*  regular presence events */
229  PH_SUBS_WINFO,        /* presence+watcher info */ 
230  PH_SUBS_PRESENCE_LIST, /* batched presence notifications */ 
231  PH_SUBS_CONFLIST,    /*  server based conference list */
232  PH_SUBS_SIPPROFILE,   /* server based contact list */
233  PH_SUBS_ADDRBOOK_QRY   /* query the addressbook for a contact list */
234};
235
236
237/**
238 * @enum phCallStateEvent
239 * @brief call progress events.
240 *
241 */
242enum  phCallStateEvent {
243        phDIALING, phRINGING, phNOANSWER, phCALLBUSY,
244        phCALLREDIRECTED, phCALLOK,     phCALLHELD, phINCALLREADY,
245        phCALLRESUMED, phHOLDOK, phRESUMEOK, phINCALL,
246        phCALLCLOSED, phCALLERROR, phDTMF, phXFERPROGRESS,
247        phXFEROK, phXFERFAIL, phXFERREQ, phCALLREPLACED,
248        phRINGandSTART, phRINGandSTOP, phCALLCLOSEDandSTOPRING
249};
250/**
251 * @struct phCallStateInfo
252 */
253struct phCallStateInfo_t {
254        enum phCallStateEvent event;
255        void *userData;              /*!< used to match placeCall with callbacks */
256        const char *localUri;        /*!< valid for all events execpt CALLCLOSED and DTMF */
257        int   newcid;                /*!< valid for CALLREPLACED and XFERREQ */
258        int   oldcid;                /*!< in case of CALL OK specifies the old CALL which was target of XFRERREQ */
259        int   vlid;                  /*!< virtual line id */
260        int   streams;               /*!< proposed (for phINCALL) and active (for other events) streams for the call */
261        char  *callinfo;             /*! pointer to Call-Info header value if available */
262        const char  *remoteUri;    /*!< valid for all events execpt CALLCLOSED, DTMF and CALLERROR */
263        int   errorCode;           /*!< valid for CALLERROR */
264        int   dtmfDigit;           /*!< valid for DTMF */ 
265        const char *remoteSdp;
266};
267
268
269/**
270 * @enum phMsgEvent
271 */
272enum phMsgEvent {
273    phMsgNew, phMsgOk, phMsgError
274};
275/**
276 * @struct phMsgStateInfo
277 */
278struct phMsgStateInfo_t {
279        enum phMsgEvent event;
280        int   status;
281        const char *from;
282        const char *to;
283        const char *ctype;
284        const char *subtype;
285        const char *content;
286        const char *rawctt;
287        int   cid;     /*!<  when non-zero this is message inside a dialog corresponding to call 'cid' */
288};
289
290
291/**
292 * @enum phSubscriptionEvent
293 */
294enum phSubscriptionEvent {
295        phSubscriptionOk, phSubscriptionErrNotFound, phSubscriptionError
296};
297/**
298 * @struct phSubscriptionStateInfo
299 */
300struct phSubscriptionStateInfo_t  {
301        enum phSubscriptionEvent event;
302        int status;
303        char *from;
304        char *to;
305};
306
307struct phPicture
308{
309        int width,height;
310        void *planes[4];
311        int strides[4];
312};
313
314
315/**
316 * @struct phVideoFrameReceivedEvent
317 */
318struct phVideoFrameReceivedEvent_t {
319        struct phPicture *frame_remote;
320        struct phPicture *frame_local;
321};
322
323
324/**
325 * @enum phConfEvent
326 */
327enum phConfEvent {
328        phCONFCREATED,   /* conference is created */
329        phCONFJOINED,    /* memeber joined a the conferences */
330        phCONFLEFT,      /* member left a conference */
331        phCONFCLOSED,     /* coneference closed       */
332        phCONFJOINERROR,   /* error joining a member to a conference */
333        phCONFERROR       /* generic error */
334};
335/**
336 * @enum phConfStateInfo
337 */
338struct phConfStateInfo_t {
339        int  confEvent;
340        int  memberCid;  /* call id's for the calls participating in the conference */
341        /* valid for CONFJOINED,CONFLEFT,CONFJOINERROR events      */
342        int  errorCode;
343};
344
345/**
346 * @struct phVideoConfig
347 */
348
349
350/**
351 * @struct ph_videoconfig_s
352 * @brief temporary structure that holds codec config, to be set from GUI
353 */
354struct ph_videoconfig_s {
355#define PHAPI_VIDEO_LINE_50KBPS         0
356#define PHAPI_VIDEO_LINE_64KBPS         1
357#define PHAPI_VIDEO_LINE_128KBPS        2
358#define PHAPI_VIDEO_LINE_256KBPS        3
359#define PHAPI_VIDEO_LINE_512KBPS        4
360#define PHAPI_VIDEO_LINE_1024KBPS       5
361#define PHAPI_VIDEO_LINE_2048KBPS       6
362#define PHAPI_VIDEO_LINE_AUTOMATIC      5
363        int video_fps;
364        int video_camera_flip_frame;
365        int video_max_frame_size;
366        int video_webcam_capture_width; /** width x height for capture must be given. 320x240 is a good guess */
367        int video_webcam_capture_height;
368        int video_line_configuration;
369        int video_codec_max_bitrate;
370        int video_codec_min_bitrate;
371        char video_device[256];
372};
373
374struct ph_config_s {
375  char local_ip_addr[16];  /*!< ip address to use in case of muti-homed setup */
376  char local_audio_rtp_port[16]; /*!< port number used for RTP data */
377  char local_audio_rtcp_port[16]; /*!< port number used for RTCP data */
378  char local_audio_rtp_port_max[16]; /*!< maximal port number used for RTP data */
379  char local_audio_rtcp_port_max[16]; /*!< maximal port number used for RTCP data */
380  char local_video_rtp_port[16]; /*!< port number used for video RTP data */
381  char local_video_rtcp_port[16]; /*!< port number used for video RTCP data */
382
383  char sipport[16];              /*!< sip port number */
384  int transport;                        /*!< sip transport */
385  char nattype[16];         /*!< nat type (auto,none,fcone,rcone,prcone,sym)  */
386  char audio_codecs[128];         /*!< comma separate list of codecs in order of priority */
387  char video_codecs[128];         /*!< comma separate list of codecs in order of priority */
388                            /* example: PCMU,PCMA,GSM,ILBC,SPEEX   */
389
390  int  asyncmode;           /*!< when true phApi creates a separate eXosip polling thread... in client/server mode MUST be TRUE */
391  char audio_dev[64];       /*!< audio device identifier */
392                            /* example: IN=2 OUT=1 ; 2 is input device and 1 is ouput device */
393  int softboost;            /* to be removed */
394  int nomedia;
395  int noaec;                /* when non-zero - disable aec */
396  unsigned int vad;         /* if bit31=1  DTX/VAD features activated and bits0-30 contains the power threshold */
397  int cng;                  /* if 1,  CNG feature will be negotiated */
398 
399  // SPIKE_HDX: setting of hdxmode in phconfig
400  int hdxmode;              /* if 0, half duplex mode is desactivated. otherwise check enum PH_HDX_MODES */
401 
402  int nat_refresh_udp_time;       /* timeout for udp sip address/port refresh (when 0 no-refresh) */
403  int nat_refresh_tcp_time;       /* timeout for tcp sip address/port refresh (when 0 no-refresh) */
404  int nat_refresh_time_adjust;/*  timeout adjustment (must be at most nat_refresh_time/2) nat_refresh_time */
405  int ptime;                              /* default global ptime */
406  int jitterdepth;           /* jitter buffer depth in miliseconds (if 0 default of 60 msecs is used) */
407  int stream_timeout;            /* max allowed latency before timeout in second, 0 or -1 to disable */
408  int nodefaultline;         /* temporary hack for implementing backward compatibility... Don't touch it */
409  int autoredir;            /*!< when NONZERO the redirect requests will be automatically executed by phApi
410                              the new CID will be deliverd in newcid field  in the CALLREDIRECTED event */
411  char stunserver[128]; /*!< stun server address:port or name:port */
412
413#define PH_TUNNEL_SSL 4
414#define PH_TUNNEL_AUTOCONF 2
415#define PH_TUNNEL_USE  1
416  int  use_tunnel;
417
418  char httpt_server[128];
419  int  httpt_server_port;
420  char http_proxy[128];
421  int  http_proxy_port;
422  char http_proxy_user[128];
423  char http_proxy_passwd[128];
424#ifdef WIN32
425  void* videoHandle;
426#endif
427
428  struct ph_videoconfig_s video_config;
429  char  plugin_path[256];  /*!< where to look for plugin modules */
430  int qos;                  /* QoS bits to add to TOS to : 0x2 min cost, 0x4 max reliability, 0x8 max throughput, 0x10 min delay */
431  unsigned int hdxlevel;    /* if bit31=1  HDX level is valid and bits0-30 contains the power threshold */
432
433};
434#endif
435
436%feature("director") phapi;
437
438%include "phapi.h"
439%include "phapipp.h"
Note: See TracBrowser for help on using the repository browser.