source: verona/swig/verona.i @ 490:d4157b0b2ab6

Last change on this file since 490:d4157b0b2ab6 was 490:d4157b0b2ab6, checked in by Vadim Lebedev <vadim@…>, 12 months ago

fix syntax error

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