| 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 | %include "typemaps.i" |
|---|
| 20 | |
|---|
| 21 | %{ |
|---|
| 22 | #include "phapipp.h" |
|---|
| 23 | %} |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #if defined(_WIN32_WCE) |
|---|
| 27 | #define SWIG_CSHARP_NO_STRING_HELPER |
|---|
| 28 | #define COMPACT_FRAMEWORK_COMPATIBLE |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | #ifdef SWIGCSHARP |
|---|
| 32 | %{ |
|---|
| 33 | #if defined(_WIN32_WCE) |
|---|
| 34 | #define SWIG_CSHARP_NO_STRING_HELPER |
|---|
| 35 | #define COMPACT_FRAMEWORK_COMPATIBLE |
|---|
| 36 | #endif |
|---|
| 37 | #include <stdint.h> |
|---|
| 38 | %} |
|---|
| 39 | #endif |
|---|
| 40 | |
|---|
| 41 | #ifdef SWIGJAVA |
|---|
| 42 | %insert("runtime") %{ |
|---|
| 43 | #define SWIG_JAVA_NO_DETACH_CURRENT_THREAD |
|---|
| 44 | #define SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON |
|---|
| 45 | %} |
|---|
| 46 | %include "enumtypeunsafe.swg" |
|---|
| 47 | %javaconst(1); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | %module(directors="1") jni_verona |
|---|
| 51 | %{ |
|---|
| 52 | #include <jni.h> |
|---|
| 53 | #ifdef ANDROID |
|---|
| 54 | #include <android/log.h> |
|---|
| 55 | #endif |
|---|
| 56 | struct TmpJOBJ { |
|---|
| 57 | JNIEnv* env; |
|---|
| 58 | jobject jo; |
|---|
| 59 | TmpJOBJ(JNIEnv* e, jobject o) : env(e), jo(o) { } |
|---|
| 60 | ~TmpJOBJ() { env->DeleteLocalRef(jo); } |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | inline const char* as_cstr(const std::string& s) { |
|---|
| 65 | return s.c_str(); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | inline const char* as_cstr(const char* s) { |
|---|
| 69 | return s; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | extern "C" void osip_set_jvm(JavaVM *ajvm); |
|---|
| 75 | extern "C" void ms_set_jvm(JavaVM *vm); |
|---|
| 76 | |
|---|
| 77 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) |
|---|
| 78 | { |
|---|
| 79 | ms_set_jvm(ajvm); |
|---|
| 80 | osip_set_jvm(ajvm); |
|---|
| 81 | return JNI_VERSION_1_6; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | typedef std::basic_string<jchar> JavaStr; |
|---|
| 85 | jstring make_jstr(JNIEnv *jenv, const std::string *s) |
|---|
| 86 | { |
|---|
| 87 | JavaStr tmp(s->begin(), s->end()); |
|---|
| 88 | return jenv->NewString(tmp.data(), tmp.size()); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | void make_cxxstr(JNIEnv* jenv, std::string& st, jstring jst) |
|---|
| 92 | { |
|---|
| 93 | int len = (int) jenv->GetStringUTFLength(jst); |
|---|
| 94 | jint jlen = jenv->GetStringLength(jst); |
|---|
| 95 | st.reserve(len+1); |
|---|
| 96 | st.resize(len); |
|---|
| 97 | jenv->GetStringUTFRegion(jst, 0, jlen, (char*) st.data()); |
|---|
| 98 | |
|---|
| 99 | } |
|---|
| 100 | struct barr { |
|---|
| 101 | const char *data; |
|---|
| 102 | int size; |
|---|
| 103 | }; |
|---|
| 104 | |
|---|
| 105 | jbyteArray make_bytearray(JNIEnv* env, const barr& d) |
|---|
| 106 | { |
|---|
| 107 | jbyteArray jb = env->NewByteArray(d.size); |
|---|
| 108 | env->SetByteArrayRegion(jb, 0, d.size, (const jbyte*)d.data); |
|---|
| 109 | return jb; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | %} |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | %include <std_string.i> |
|---|
| 116 | using namespace std; |
|---|
| 117 | %apply (char *STRING, int LENGTH) { (const char *bdata, int bsize) }; |
|---|
| 118 | |
|---|
| 119 | %typemap(out) std::string* { |
|---|
| 120 | |
|---|
| 121 | $result = make_jstr(jenv, $1); // out std::string * |
|---|
| 122 | |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | %typemap(out) barr { |
|---|
| 126 | $result = make_bytearray(jenv, $1); // out barr |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | %typemap(jni) barr "jbyteArray" |
|---|
| 130 | %typemap(jtype) barr "byte[]" |
|---|
| 131 | %typemap(jstype) barr "byte[]" |
|---|
| 132 | %typemap(javaout) barr { |
|---|
| 133 | return $jnicall; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | %typemap(in) std::string |
|---|
| 137 | %{ if(!$input) { |
|---|
| 138 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); |
|---|
| 139 | return $null; |
|---|
| 140 | } |
|---|
| 141 | make_cxxstr(jenv, $1, $input); // in std::string |
|---|
| 142 | |
|---|
| 143 | %} |
|---|
| 144 | |
|---|
| 145 | %typemap(in) const std::string& |
|---|
| 146 | %{ if(!$input) { |
|---|
| 147 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); |
|---|
| 148 | return $null; |
|---|
| 149 | } |
|---|
| 150 | std::string $1_cxxstr; |
|---|
| 151 | make_cxxstr(jenv, $1_cxxstr, $input); |
|---|
| 152 | $1 = &$1_cxxstr; // in const std::string& |
|---|
| 153 | %} |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | %typemap(directorout) std::string |
|---|
| 157 | %{ if(!$input) { |
|---|
| 158 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); |
|---|
| 159 | return $null; |
|---|
| 160 | } |
|---|
| 161 | make_cxxstr(jenv, $result, $input); // dirout std::string |
|---|
| 162 | %} |
|---|
| 163 | |
|---|
| 164 | %typemap(directorout) const std::string & |
|---|
| 165 | %{ if(!$input) { |
|---|
| 166 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); |
|---|
| 167 | return $null; |
|---|
| 168 | } |
|---|
| 169 | std::string $1_cxxstr; |
|---|
| 170 | make_cxxstr(jenv, $1_cxxstr, $input); |
|---|
| 171 | $result = &$1_cxxstr; // dirout const std::string& |
|---|
| 172 | %} |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | %typemap(directorin,descriptor="Ljava/lang/String;") std::string |
|---|
| 177 | %{ |
|---|
| 178 | // dirin std::string |
|---|
| 179 | $input = make_jstr(jenv, &$1); |
|---|
| 180 | TmpJOBJ tmp$1_name(jenv, (jobject) $input); |
|---|
| 181 | %} |
|---|
| 182 | |
|---|
| 183 | %typemap(out) std::string |
|---|
| 184 | %{ $result = make_jstr(jenv, &$1); // out std::string %} |
|---|
| 185 | |
|---|
| 186 | %typemap(directorin,descriptor="Ljava/lang/String;") const std::string & |
|---|
| 187 | %{ |
|---|
| 188 | // dirin cost std::string& |
|---|
| 189 | $input = make_jstr(jenv, &$1); |
|---|
| 190 | TmpJOBJ tmp$1_name(jenv, (jobject) $input); |
|---|
| 191 | %} |
|---|
| 192 | |
|---|
| 193 | %typemap(directorin,descriptor="Ljava/lang/String;") const char*, char* |
|---|
| 194 | %{ |
|---|
| 195 | // dirin char* |
|---|
| 196 | $input = 0; |
|---|
| 197 | if ($1) { |
|---|
| 198 | $input = jenv->NewStringUTF((const char *)$1); |
|---|
| 199 | if (!$input) return $null; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | TmpJOBJ tmp$1_name(jenv, (jobject) $input); |
|---|
| 203 | %} |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | %typemap(out) const std::string & |
|---|
| 207 | %{ $result = make_jstr(jenv, $1); // out const std::string & %} |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | %typemap(newfree) std::string * "delete $1;"; |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | #endif |
|---|
| 215 | |
|---|
| 216 | #ifdef SWIGRUBY |
|---|
| 217 | %include "std/std_map.i" |
|---|
| 218 | %include "std/std_string.i" |
|---|
| 219 | #else |
|---|
| 220 | %include "std_map.i" |
|---|
| 221 | #ifndef SWIGJAVA |
|---|
| 222 | %include "std_string.i" |
|---|
| 223 | #endif |
|---|
| 224 | |
|---|
| 225 | %include "std_vector.i" |
|---|
| 226 | %include "std_pair.i" |
|---|
| 227 | #endif |
|---|
| 228 | //%traits_ptypen(char) |
|---|
| 229 | |
|---|
| 230 | #ifdef SWIGPYTHON |
|---|
| 231 | //%template(cstrpairvec) std::vector<std::pair<const char*, const char*> >; |
|---|
| 232 | |
|---|
| 233 | %{ |
|---|
| 234 | PyObject* |
|---|
| 235 | make_hdrlist(const ph_hdr_list *hl) { |
|---|
| 236 | PyObject* result; |
|---|
| 237 | |
|---|
| 238 | result = PyList_New(hl->count); |
|---|
| 239 | for(int i = 0; i < hl->count; i++) |
|---|
| 240 | PyList_SET_ITEM(result, i, Py_BuildValue("ss", hl->elems[i].hdr, hl->elems[i].val)); |
|---|
| 241 | |
|---|
| 242 | return result; |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | PyObject* |
|---|
| 246 | make_hdrlist2(const std::vector<std::pair<const char*, const char*> >& hl ) { |
|---|
| 247 | PyObject* result; |
|---|
| 248 | |
|---|
| 249 | result = PyList_New(hl.size()); |
|---|
| 250 | for(int i = 0; i < hl.size(); i++) |
|---|
| 251 | PyList_SET_ITEM(result, i, Py_BuildValue("ss", hl[i].first, hl[i].second)); |
|---|
| 252 | |
|---|
| 253 | return result; |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | template<class SEQ> bool make_str_seq(PyObject *input, SEQ& seq) |
|---|
| 258 | { |
|---|
| 259 | typedef typename SEQ::value_type value_type; |
|---|
| 260 | |
|---|
| 261 | if (PySequence_Check(input)) { |
|---|
| 262 | int size = PySequence_Size(input); |
|---|
| 263 | for(int i = 0; i < size; i++) { |
|---|
| 264 | if (PyString_Check(PySequence_Fast_GET_ITEM(input, i))) { |
|---|
| 265 | seq.push_back(value_type(PyString_AsString(PySequence_Fast_GET_ITEM(input, i)))); |
|---|
| 266 | } else { |
|---|
| 267 | PyErr_SetString(PyExc_TypeError,"not a string sequence"); |
|---|
| 268 | return false; |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | } else { |
|---|
| 272 | PyErr_SetString(PyExc_TypeError,"not a sequence"); |
|---|
| 273 | return false; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | return true; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | template<class SEQ> bool make_strpair_seq(PyObject *input, SEQ& seq) |
|---|
| 280 | { |
|---|
| 281 | if (PySequence_Check(input)) { |
|---|
| 282 | int size = PySequence_Size(input); |
|---|
| 283 | for(int i = 0; i < size; i++) { |
|---|
| 284 | PyObject *o = PySequence_Fast_GET_ITEM(input, i); |
|---|
| 285 | if (PySequence_Check(o) && 2 == PySequence_Size(o)) { |
|---|
| 286 | if (PyString_Check(PySequence_Fast_GET_ITEM(o, 0)) && PyString_Check(PySequence_Fast_GET_ITEM(o, 1))) { |
|---|
| 287 | seq.push_back(std::make_pair<const char*, const char*>(PyString_AsString(PySequence_Fast_GET_ITEM(o, 0)), |
|---|
| 288 | PyString_AsString(PySequence_Fast_GET_ITEM(o, 1)))); |
|---|
| 289 | } else { |
|---|
| 290 | PyErr_SetString(PyExc_TypeError,"not a string sequence"); |
|---|
| 291 | return false; |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | } else { |
|---|
| 295 | PyErr_SetString(PyExc_TypeError,"item is not a 2 element sequence"); |
|---|
| 296 | return false; |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | } |
|---|
| 301 | } else { |
|---|
| 302 | PyErr_SetString(PyExc_TypeError,"not a sequence"); |
|---|
| 303 | return false; |
|---|
| 304 | |
|---|
| 305 | } |
|---|
| 306 | return true; |
|---|
| 307 | } |
|---|
| 308 | %} |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | %typemap(in) strvector& ($*1_ltype tmpvec), vector<char*>& ($*1_ltype tmpvec), vector<const char*>& ($*1_ltype tmpvec) { |
|---|
| 312 | // in strvector& |
|---|
| 313 | if (!make_str_seq($input, tmpvec)) |
|---|
| 314 | return NULL; |
|---|
| 315 | $1 = &tmpvec; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | %typemap(in) strvector, vector<char*>, vector<const char*> { |
|---|
| 319 | // in strvector |
|---|
| 320 | if (!make_str_seq($input, $1)) |
|---|
| 321 | return NULL; |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | %typemap(out) std::map<char*, char*> { |
|---|
| 328 | typedef std::map<char*, char*> ccmap; |
|---|
| 329 | ccmap& m = $1; |
|---|
| 330 | PyObject *list = PyList_New(m.size()); |
|---|
| 331 | int i = 0; |
|---|
| 332 | for(ccmap::const_iterator it = m.begin(); it != m.end(); it++) { |
|---|
| 333 | PyList_SET_ITEM(list, i++, Py_BuildValue("(ss)", it->first, it->second)); |
|---|
| 334 | } |
|---|
| 335 | $result = list; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | %typemap(argout) struct ph_hdr_list *{ |
|---|
| 340 | $result = make_hdrlist($1); |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | %typemap(directorin) const phSubscriptionStateInfo * { |
|---|
| 345 | |
|---|
| 346 | $input = Py_BuildValue("iissN", $1_name->event, $1_name->status, $1_name->from, $1_name->to, make_hdrlist(&$1_name->hlist)); |
|---|
| 347 | |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | %typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) cstrpairvec, cstrpairvec&, const cstrpairvec&, cstrpairvec*, const cstrpairvec* %{ |
|---|
| 351 | $1 = PySequence_Check($input); |
|---|
| 352 | %} |
|---|
| 353 | |
|---|
| 354 | %typemap(in) cstrpairvec& ($*1_ltype tmpvec) { |
|---|
| 355 | // in strpair vector& |
|---|
| 356 | if (!make_strpair_seq($input, tmpvec)) |
|---|
| 357 | return NULL; |
|---|
| 358 | $1 = &tmpvec; |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | %typemap(directorin) const phMsgStateInfo * { |
|---|
| 363 | |
|---|
| 364 | $input = Py_BuildValue("iissssssiiN", $1_name->event, $1_name->status, $1_name->from, $1_name->to, |
|---|
| 365 | $1_name->ctype, $1_name->subtype, $1_name->content, $1_name->rawctt, $1_name->tid, $1_name->cid, |
|---|
| 366 | make_hdrlist(&$1_name->hlist)); |
|---|
| 367 | |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | %typemap(directorin) const phMsgStateInfo2 * { |
|---|
| 371 | |
|---|
| 372 | $input = Py_BuildValue("iissssssio", $1_name->event, $1_name->status, $1_name->from, $1_name->to, |
|---|
| 373 | $1_name->ctype, $1_name->subtype, $1_name->content, $1_name->rawctt, $1_name->cid, |
|---|
| 374 | make_hdrlist2($1_name->hlist)); |
|---|
| 375 | |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | %typemap(directorin) const phCallStateInfo * { |
|---|
| 380 | |
|---|
| 381 | $input = Py_BuildValue("isiiiissiisN", $1_name->event, $1_name->localUri, $1_name->newcid, $1_name->oldcid, |
|---|
| 382 | $1_name->vlid, $1_name->streams, $1_name->callinfo, $1_name->remoteUri, $1_name->errorCode, |
|---|
| 383 | $1_name->dtmfDigit, $1_name->remoteSdp, |
|---|
| 384 | make_hdrlist(&$1_name->hlist)); |
|---|
| 385 | |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | %{ |
|---|
| 389 | typedef PyObject SWIG_Object; |
|---|
| 390 | |
|---|
| 391 | template<class T> struct SwigObj { |
|---|
| 392 | SWIG_Object* obj(int v) { return PyLong_FromLong(v); } |
|---|
| 393 | }; |
|---|
| 394 | |
|---|
| 395 | template<> struct SwigObj<std::string> { |
|---|
| 396 | static SWIG_Object* obj(const std::string& s) { return PyString_FromStringAndSize(s.c_str(), s.length()); } |
|---|
| 397 | }; |
|---|
| 398 | |
|---|
| 399 | template<> struct SwigObj< std::pair<int, std::string> > { |
|---|
| 400 | static SWIG_Object* obj(const std::pair<int, std::string>& p) { |
|---|
| 401 | SWIG_Object *tuple; |
|---|
| 402 | |
|---|
| 403 | tuple = Py_BuildValue("(is#)", p.first, p.second.c_str(), p.second.size() ); |
|---|
| 404 | return tuple; |
|---|
| 405 | } |
|---|
| 406 | }; |
|---|
| 407 | |
|---|
| 408 | template<> struct SwigObj< strresult2 > { |
|---|
| 409 | static SWIG_Object* obj(const strresult2& p) { |
|---|
| 410 | SWIG_Object *tuple; |
|---|
| 411 | |
|---|
| 412 | tuple = Py_BuildValue("(is#s#)", p.first, p.second.c_str(), p.second.size(), p.third.c_str(), p.third.size() ); |
|---|
| 413 | return tuple; |
|---|
| 414 | } |
|---|
| 415 | }; |
|---|
| 416 | |
|---|
| 417 | |
|---|
| 418 | |
|---|
| 419 | template<> struct SwigObj< strresult3 > { |
|---|
| 420 | static SWIG_Object* obj(const strresult3& p) { |
|---|
| 421 | SWIG_Object *tuple; |
|---|
| 422 | |
|---|
| 423 | tuple = Py_BuildValue("(is#s#s#)", p.first, p.second.c_str(), p.second.size(), p.third.c_str(), p.third.size(), |
|---|
| 424 | p.fourth.c_str(), p.fourth.size() ); |
|---|
| 425 | return tuple; |
|---|
| 426 | } |
|---|
| 427 | }; |
|---|
| 428 | %} |
|---|
| 429 | |
|---|
| 430 | %typemap(out) strresult* { |
|---|
| 431 | $result = SwigObj<strresult>::obj(*$1); |
|---|
| 432 | delete $1; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | %typemap(out) strresult2* { |
|---|
| 436 | $result = SwigObj<strresult2>::obj(*$1); |
|---|
| 437 | delete $1; |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | %typemap(out) strresult3* { |
|---|
| 441 | $result = SwigObj<strresult3>::obj(*$1); |
|---|
| 442 | delete $1; |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | #endif |
|---|
| 446 | |
|---|
| 447 | #ifdef SWIGJAVA |
|---|
| 448 | %{ |
|---|
| 449 | template<class SEQ> bool make_str_seq(_jobjectArray* input, SEQ& seq, JNIEnv *jenv) |
|---|
| 450 | { |
|---|
| 451 | typedef typename SEQ::value_type value_type; |
|---|
| 452 | |
|---|
| 453 | int i = 0; |
|---|
| 454 | jint size = jenv->GetArrayLength((_jarray*)input); |
|---|
| 455 | /* make a copy of each string */ |
|---|
| 456 | for (i = 0; i<size; i++) { |
|---|
| 457 | jstring j_string = (jstring)jenv->GetObjectArrayElement( input, i); |
|---|
| 458 | const char * c_string = jenv->GetStringUTFChars(j_string, 0); |
|---|
| 459 | seq.push_back(value_type(c_string)); |
|---|
| 460 | jenv->ReleaseStringUTFChars(j_string, c_string); |
|---|
| 461 | jenv->DeleteLocalRef(j_string); |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | return true; |
|---|
| 465 | } |
|---|
| 466 | %} |
|---|
| 467 | #endif |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | #ifndef SWIGPYTHON |
|---|
| 472 | namespace std { |
|---|
| 473 | %template(pStrMap) map<char*, char *>; |
|---|
| 474 | %template(pcStrPair) pair<const char*, const char*>; |
|---|
| 475 | %template(pcStrPairVec) std::vector<std::pair<const char*, const char*> >; |
|---|
| 476 | #ifndef SWIGJAVA |
|---|
| 477 | %template(strresult) pair<int, std::string>; |
|---|
| 478 | #endif |
|---|
| 479 | } |
|---|
| 480 | #endif |
|---|
| 481 | |
|---|
| 482 | %extend ph_hdr_list { |
|---|
| 483 | |
|---|
| 484 | ph_hdr_val *item(int i) { return i < self->count ? self->elems+i : 0; } |
|---|
| 485 | }; |
|---|
| 486 | |
|---|
| 487 | #ifdef SWIGJAVA |
|---|
| 488 | |
|---|
| 489 | %template(strvector) std::vector<std::string>; |
|---|
| 490 | |
|---|
| 491 | %typemap(jni) strvector& "jobjectArray" |
|---|
| 492 | %typemap(jtype) strvector& "String[]" |
|---|
| 493 | %typemap(jstype) strvector& "String[]" |
|---|
| 494 | %typemap(javain) strvector& "$javainput" |
|---|
| 495 | %typemap(directorin, descriptor="[Ljava/lang/String;", noblock=1) strvector&, vector<char*>, vector<const char*> %{ |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | { |
|---|
| 499 | jobject nullstr = jenv->NewStringUTF(""); |
|---|
| 500 | $input = (jobjectArray)jenv->NewObjectArray($1.size(), |
|---|
| 501 | jenv->FindClass("java/lang/String"), |
|---|
| 502 | nullstr); |
|---|
| 503 | jenv->DeleteLocalRef(nullstr); |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | TmpJOBJ tvec_$1name(jenv, (jobject) $input); |
|---|
| 507 | |
|---|
| 508 | for(int i = 0; i < $1.size(); i++) { |
|---|
| 509 | jobject je = jenv->NewStringUTF(::as_cstr($1[i])); |
|---|
| 510 | jenv->SetObjectArrayElement($input, i, je); |
|---|
| 511 | jenv->DeleteLocalRef(je); |
|---|
| 512 | } |
|---|
| 513 | |
|---|
| 514 | |
|---|
| 515 | %} |
|---|
| 516 | |
|---|
| 517 | %typemap(javadirectorin) strvector& "$jniinput" |
|---|
| 518 | %typemap(javadirectorin) int* "$jniinput" |
|---|
| 519 | %typemap(javadirectorout) int* "$jniinput" |
|---|
| 520 | %typemap(directorin, descriptor="[I", noblock = 1) int* %{ |
|---|
| 521 | { |
|---|
| 522 | jintArray result; |
|---|
| 523 | result = jenv->NewIntArray(1); |
|---|
| 524 | // move from the temp structure to the java structure |
|---|
| 525 | jenv->SetIntArrayRegion(result, 0, 1, $1); |
|---|
| 526 | $input = result; |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | TmpJOBJ tvec_$1name(jenv, (jobject) $input); |
|---|
| 530 | |
|---|
| 531 | %} |
|---|
| 532 | |
|---|
| 533 | |
|---|
| 534 | |
|---|
| 535 | %typemap(in) strvector& ($*1_ltype tmpvec), vector<char*>& ($*1_ltype tmpvec), vector<const char*>& ($*1_ltype tmpvec) { |
|---|
| 536 | make_str_seq($input, tmpvec, jenv); |
|---|
| 537 | $1 = &tmpvec; |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | %typemap(in) strvector, vector<char*>, vector<const char*> %{ |
|---|
| 541 | make_str_seq($input, $1, jenv); |
|---|
| 542 | %} |
|---|
| 543 | #endif |
|---|
| 544 | |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | #if 0 |
|---|
| 548 | enum ph_subs_type |
|---|
| 549 | { |
|---|
| 550 | PH_SUBS_PRESENCE, /* regular presence events */ |
|---|
| 551 | PH_SUBS_WINFO, /* presence+watcher info */ |
|---|
| 552 | PH_SUBS_PRESENCE_LIST, /* batched presence notifications */ |
|---|
| 553 | PH_SUBS_CONFLIST, /* server based conference list */ |
|---|
| 554 | PH_SUBS_SIPPROFILE, /* server based contact list */ |
|---|
| 555 | PH_SUBS_ADDRBOOK_QRY /* query the addressbook for a contact list */ |
|---|
| 556 | }; |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | /** |
|---|
| 560 | * @enum phCallStateEvent |
|---|
| 561 | * @brief call progress events. |
|---|
| 562 | * |
|---|
| 563 | */ |
|---|
| 564 | enum phCallStateEvent { |
|---|
| 565 | phDIALING, phRINGING, phNOANSWER, phCALLBUSY, |
|---|
| 566 | phCALLREDIRECTED, phCALLOK, phCALLHELD, phINCALLREADY, |
|---|
| 567 | phCALLRESUMED, phHOLDOK, phRESUMEOK, phINCALL, |
|---|
| 568 | phCALLCLOSED, phCALLERROR, phDTMF, phXFERPROGRESS, |
|---|
| 569 | phXFEROK, phXFERFAIL, phXFERREQ, phCALLREPLACED, |
|---|
| 570 | phRINGandSTART, phRINGandSTOP, phCALLCLOSEDandSTOPRING |
|---|
| 571 | }; |
|---|
| 572 | /** |
|---|
| 573 | * @struct phCallStateInfo |
|---|
| 574 | */ |
|---|
| 575 | struct phCallStateInfo_t { |
|---|
| 576 | enum phCallStateEvent event; |
|---|
| 577 | void *userData; /*!< used to match placeCall with callbacks */ |
|---|
| 578 | const char *localUri; /*!< valid for all events execpt CALLCLOSED and DTMF */ |
|---|
| 579 | int newcid; /*!< valid for CALLREPLACED and XFERREQ */ |
|---|
| 580 | int oldcid; /*!< in case of CALL OK specifies the old CALL which was target of XFRERREQ */ |
|---|
| 581 | int vlid; /*!< virtual line id */ |
|---|
| 582 | int streams; /*!< proposed (for phINCALL) and active (for other events) streams for the call */ |
|---|
| 583 | char *callinfo; /*! pointer to Call-Info header value if available */ |
|---|
| 584 | const char *remoteUri; /*!< valid for all events execpt CALLCLOSED, DTMF and CALLERROR */ |
|---|
| 585 | int errorCode; /*!< valid for CALLERROR */ |
|---|
| 586 | int dtmfDigit; /*!< valid for DTMF */ |
|---|
| 587 | const char *remoteSdp; |
|---|
| 588 | }; |
|---|
| 589 | |
|---|
| 590 | |
|---|
| 591 | /** |
|---|
| 592 | * @enum phMsgEvent |
|---|
| 593 | */ |
|---|
| 594 | enum phMsgEvent { |
|---|
| 595 | phMsgNew, phMsgOk, phMsgError |
|---|
| 596 | }; |
|---|
| 597 | /** |
|---|
| 598 | * @struct phMsgStateInfo |
|---|
| 599 | */ |
|---|
| 600 | struct phMsgStateInfo_t { |
|---|
| 601 | enum phMsgEvent event; |
|---|
| 602 | int status; |
|---|
| 603 | const char *from; |
|---|
| 604 | const char *to; |
|---|
| 605 | const char *ctype; |
|---|
| 606 | const char *subtype; |
|---|
| 607 | const char *content; |
|---|
| 608 | const char *rawctt; |
|---|
| 609 | int cid; /*!< when non-zero this is message inside a dialog corresponding to call 'cid' */ |
|---|
| 610 | }; |
|---|
| 611 | |
|---|
| 612 | |
|---|
| 613 | /** |
|---|
| 614 | * @enum phSubscriptionEvent |
|---|
| 615 | */ |
|---|
| 616 | enum phSubscriptionEvent { |
|---|
| 617 | phSubscriptionOk, phSubscriptionErrNotFound, phSubscriptionError |
|---|
| 618 | }; |
|---|
| 619 | /** |
|---|
| 620 | * @struct phSubscriptionStateInfo |
|---|
| 621 | */ |
|---|
| 622 | struct phSubscriptionStateInfo_t { |
|---|
| 623 | enum phSubscriptionEvent event; |
|---|
| 624 | int status; |
|---|
| 625 | char *from; |
|---|
| 626 | char *to; |
|---|
| 627 | }; |
|---|
| 628 | |
|---|
| 629 | struct phPicture |
|---|
| 630 | { |
|---|
| 631 | int width,height; |
|---|
| 632 | void *planes[4]; |
|---|
| 633 | int strides[4]; |
|---|
| 634 | }; |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | /** |
|---|
| 638 | * @struct phVideoFrameReceivedEvent |
|---|
| 639 | */ |
|---|
| 640 | struct phVideoFrameReceivedEvent_t { |
|---|
| 641 | struct phPicture *frame_remote; |
|---|
| 642 | struct phPicture *frame_local; |
|---|
| 643 | }; |
|---|
| 644 | |
|---|
| 645 | |
|---|
| 646 | /** |
|---|
| 647 | * @enum phConfEvent |
|---|
| 648 | */ |
|---|
| 649 | enum phConfEvent { |
|---|
| 650 | phCONFCREATED, /* conference is created */ |
|---|
| 651 | phCONFJOINED, /* memeber joined a the conferences */ |
|---|
| 652 | phCONFLEFT, /* member left a conference */ |
|---|
| 653 | phCONFCLOSED, /* coneference closed */ |
|---|
| 654 | phCONFJOINERROR, /* error joining a member to a conference */ |
|---|
| 655 | phCONFERROR /* generic error */ |
|---|
| 656 | }; |
|---|
| 657 | /** |
|---|
| 658 | * @enum phConfStateInfo |
|---|
| 659 | */ |
|---|
| 660 | struct phConfStateInfo_t { |
|---|
| 661 | int confEvent; |
|---|
| 662 | int memberCid; /* call id's for the calls participating in the conference */ |
|---|
| 663 | /* valid for CONFJOINED,CONFLEFT,CONFJOINERROR events */ |
|---|
| 664 | int errorCode; |
|---|
| 665 | }; |
|---|
| 666 | |
|---|
| 667 | /** |
|---|
| 668 | * @struct phVideoConfig |
|---|
| 669 | */ |
|---|
| 670 | |
|---|
| 671 | |
|---|
| 672 | /** |
|---|
| 673 | * @struct ph_videoconfig_s |
|---|
| 674 | * @brief temporary structure that holds codec config, to be set from GUI |
|---|
| 675 | */ |
|---|
| 676 | struct ph_videoconfig_s { |
|---|
| 677 | #define PHAPI_VIDEO_LINE_50KBPS 0 |
|---|
| 678 | #define PHAPI_VIDEO_LINE_64KBPS 1 |
|---|
| 679 | #define PHAPI_VIDEO_LINE_128KBPS 2 |
|---|
| 680 | #define PHAPI_VIDEO_LINE_256KBPS 3 |
|---|
| 681 | #define PHAPI_VIDEO_LINE_512KBPS 4 |
|---|
| 682 | #define PHAPI_VIDEO_LINE_1024KBPS 5 |
|---|
| 683 | #define PHAPI_VIDEO_LINE_2048KBPS 6 |
|---|
| 684 | #define PHAPI_VIDEO_LINE_AUTOMATIC 5 |
|---|
| 685 | int video_fps; |
|---|
| 686 | int video_camera_flip_frame; |
|---|
| 687 | int video_max_frame_size; |
|---|
| 688 | int video_webcam_capture_width; /** width x height for capture must be given. 320x240 is a good guess */ |
|---|
| 689 | int video_webcam_capture_height; |
|---|
| 690 | int video_line_configuration; |
|---|
| 691 | int video_codec_max_bitrate; |
|---|
| 692 | int video_codec_min_bitrate; |
|---|
| 693 | char video_device[256]; |
|---|
| 694 | }; |
|---|
| 695 | |
|---|
| 696 | struct ph_config_s { |
|---|
| 697 | char local_ip_addr[16]; /*!< ip address to use in case of muti-homed setup */ |
|---|
| 698 | char local_audio_rtp_port[16]; /*!< port number used for RTP data */ |
|---|
| 699 | char local_audio_rtcp_port[16]; /*!< port number used for RTCP data */ |
|---|
| 700 | char local_audio_rtp_port_max[16]; /*!< maximal port number used for RTP data */ |
|---|
| 701 | char local_audio_rtcp_port_max[16]; /*!< maximal port number used for RTCP data */ |
|---|
| 702 | char local_video_rtp_port[16]; /*!< port number used for video RTP data */ |
|---|
| 703 | char local_video_rtcp_port[16]; /*!< port number used for video RTCP data */ |
|---|
| 704 | |
|---|
| 705 | char sipport[16]; /*!< sip port number */ |
|---|
| 706 | int transport; /*!< sip transport */ |
|---|
| 707 | char nattype[16]; /*!< nat type (auto,none,fcone,rcone,prcone,sym) */ |
|---|
| 708 | char audio_codecs[128]; /*!< comma separate list of codecs in order of priority */ |
|---|
| 709 | char video_codecs[128]; /*!< comma separate list of codecs in order of priority */ |
|---|
| 710 | /* example: PCMU,PCMA,GSM,ILBC,SPEEX */ |
|---|
| 711 | |
|---|
| 712 | int asyncmode; /*!< when true phApi creates a separate eXosip polling thread... in client/server mode MUST be TRUE */ |
|---|
| 713 | char audio_dev[64]; /*!< audio device identifier */ |
|---|
| 714 | /* example: IN=2 OUT=1 ; 2 is input device and 1 is ouput device */ |
|---|
| 715 | int softboost; /* to be removed */ |
|---|
| 716 | int nomedia; |
|---|
| 717 | int noaec; /* when non-zero - disable aec */ |
|---|
| 718 | unsigned int vad; /* if bit31=1 DTX/VAD features activated and bits0-30 contains the power threshold */ |
|---|
| 719 | int cng; /* if 1, CNG feature will be negotiated */ |
|---|
| 720 | |
|---|
| 721 | // SPIKE_HDX: setting of hdxmode in phconfig |
|---|
| 722 | int hdxmode; /* if 0, half duplex mode is desactivated. otherwise check enum PH_HDX_MODES */ |
|---|
| 723 | |
|---|
| 724 | int nat_refresh_udp_time; /* timeout for udp sip address/port refresh (when 0 no-refresh) */ |
|---|
| 725 | int nat_refresh_tcp_time; /* timeout for tcp sip address/port refresh (when 0 no-refresh) */ |
|---|
| 726 | int nat_refresh_time_adjust;/* timeout adjustment (must be at most nat_refresh_time/2) nat_refresh_time */ |
|---|
| 727 | int ptime; /* default global ptime */ |
|---|
| 728 | int jitterdepth; /* jitter buffer depth in miliseconds (if 0 default of 60 msecs is used) */ |
|---|
| 729 | int stream_timeout; /* max allowed latency before timeout in second, 0 or -1 to disable */ |
|---|
| 730 | int nodefaultline; /* temporary hack for implementing backward compatibility... Don't touch it */ |
|---|
| 731 | int autoredir; /*!< when NONZERO the redirect requests will be automatically executed by phApi |
|---|
| 732 | the new CID will be deliverd in newcid field in the CALLREDIRECTED event */ |
|---|
| 733 | char stunserver[128]; /*!< stun server address:port or name:port */ |
|---|
| 734 | |
|---|
| 735 | #define PH_TUNNEL_SSL 4 |
|---|
| 736 | #define PH_TUNNEL_AUTOCONF 2 |
|---|
| 737 | #define PH_TUNNEL_USE 1 |
|---|
| 738 | int use_tunnel; |
|---|
| 739 | |
|---|
| 740 | char httpt_server[128]; |
|---|
| 741 | int httpt_server_port; |
|---|
| 742 | char http_proxy[128]; |
|---|
| 743 | int http_proxy_port; |
|---|
| 744 | char http_proxy_user[128]; |
|---|
| 745 | char http_proxy_passwd[128]; |
|---|
| 746 | #ifdef WIN32 |
|---|
| 747 | void* videoHandle; |
|---|
| 748 | #endif |
|---|
| 749 | |
|---|
| 750 | struct ph_videoconfig_s video_config; |
|---|
| 751 | char plugin_path[256]; /*!< where to look for plugin modules */ |
|---|
| 752 | int qos; /* QoS bits to add to TOS to : 0x2 min cost, 0x4 max reliability, 0x8 max throughput, 0x10 min delay */ |
|---|
| 753 | unsigned int hdxlevel; /* if bit31=1 HDX level is valid and bits0-30 contains the power threshold */ |
|---|
| 754 | |
|---|
| 755 | }; |
|---|
| 756 | #endif |
|---|
| 757 | |
|---|
| 758 | %feature("director") phapi; |
|---|
| 759 | %apply int *OUTPUT {int *isreceipt}; |
|---|
| 760 | %include "phapi.h" |
|---|
| 761 | %include "phapipp.h" |
|---|
| 762 | |
|---|
| 763 | #ifdef SWIGJAVA |
|---|
| 764 | struct barr; |
|---|
| 765 | |
|---|
| 766 | %extend strresult { |
|---|
| 767 | |
|---|
| 768 | barr jsecond() { |
|---|
| 769 | barr ba = { self->second.c_str(), self->second.size() }; |
|---|
| 770 | return ba; |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | #endif |
|---|
| 774 | |
|---|