Changeset 507:02df594a66c2 in verona
- Timestamp:
- Jul 31, 2012 2:57:52 PM (11 months ago)
- Branch:
- default
- Files:
-
- 4 edited
-
phapi/phapi.c (modified) (2 diffs)
-
phcpp/phapipp.cpp (modified) (3 diffs)
-
phcpp/phapipp.h (modified) (4 diffs)
-
swig/verona.i (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
phapi/phapi.c
r503 r507 5895 5895 ph_update_nego_mflags(ca,ph_get_media_direction(new_sdp,"audio"),ph_get_media_direction(new_sdp,"video")); 5896 5896 5897 #ifndef ANDROID /* XXX: we will start the stream after we are sure that the ringback tone si finished */ 5897 5898 if (ph_call_media_start(ca, je, mflags, ca->localresume)) 5898 5899 { 5899 5900 DBG_SIP_NEGO("SIP NEGO: ph_call_answered but without stream\n"); 5900 5901 } 5902 #endif 5901 5903 } 5902 5904 } … … 7535 7537 void phSetDebugLevel(int level) { 7536 7538 phDebugLevel = level; 7539 osip_trace_enable_until_level(level); 7537 7540 } 7538 7541 -
phcpp/phapipp.cpp
r499 r507 187 187 } 188 188 189 int phapi::callStartMedia(int cid, int streamFlags) 190 { 191 return phCallStartMedia(cid, streamFlags); 192 } 189 193 190 194 int phapi::subscribe(int vlid, const char* to, int winfo, int use_proxy, int expire, … … 500 504 void phapi::onSubscriptionProgress(int sid, const phSubscriptionStateInfo_t *info) { } 501 505 void phapi::onFrameReady(int cid, phVideoFrameReceivedEvent_t *ev) { } 502 void phapi::onPhLogCsl( const char *msg){ }506 void phapi::onPhLogCsl(int level, const char *msg){ } 503 507 504 508 void phapi::onSoundFileStopped(void *userdata , unsigned int _id, void *arg){} … … 580 584 } 581 585 582 void phapi::phLogCsl( const char *msg)583 { 584 if (uniqueobj) 585 uniqueobj->onPhLogCsl( msg);586 void phapi::phLogCsl(int level, const char *msg) 587 { 588 if (uniqueobj) 589 uniqueobj->onPhLogCsl(level, msg); 586 590 } 587 591 -
phcpp/phapipp.h
r499 r507 64 64 65 65 66 #ifndef SWIGJAVA 67 typedef std::pair<int, std::string> strresult; 68 #else 69 struct strresult { 70 int first; 71 std::string second; 72 73 strresult(int i, const std::string& s2) : first(i), second(s2) { } 74 strresult(int i) : first(i) { } 75 }; 76 #endif 77 78 typedef std::vector<std::string> strvector; 79 typedef std::vector<std::pair<const char*, const char*> > cstrpairvec; 80 81 struct strresult2 { 82 int first; 83 std::string second,third; 84 85 strresult2(int i, const std::string& s2, const std::string& s3) : first(i), second(s2), third(s3) { } 86 strresult2(int i) : first(i) { } 87 }; 88 89 90 struct strresult3 { 91 int first; 92 std::string second,third,fourth; 93 94 strresult3(int i, const std::string& s2, const std::string& s3, const std::string& s4) : 95 first(i), second(s2), third(s3), fourth(s4) { } 96 strresult3(int i) : first(i) { } 97 }; 98 66 99 namespace verona { 67 100 … … 194 227 virtual int mutePlayback(int cid, int val); 195 228 virtual int muteCapture(int cid, int val); 229 virtual int callStartMedia(int cid, int streamFlags); 196 230 197 231 virtual int setSoundFileGain(phStream* phstream,float gain); … … 238 272 #endif 239 273 virtual void onDtmfProgress(int cid, int dtmf); 240 virtual void onPhLogCsl( const char *msg);274 virtual void onPhLogCsl(int level, const char *msg); 241 275 virtual void onSoundFileStopped(void *userdata , unsigned int _id, void *arg); 242 276 virtual void onQosEvent(int cid, const phQosInfo_t * info); … … 257 291 static void subscriptionProgress(int sid, const phSubscriptionStateInfo_t *info); 258 292 static void frameReady(int cid, phVideoFrameReceivedEvent_t *ev); 259 static void phLogCsl( const char *msg);293 static void phLogCsl(int level, const char *msg); 260 294 static void soundFileStopped(void *userdata , unsigned int _id, void *arg); 261 295 static void qosEvent(int cid, const phQosInfo_t * info); -
swig/verona.i
r498 r507 16 16 %module (directors=1) perl_verona 17 17 #endif 18 19 %include "typemaps.i" 18 20 19 21 %{ … … 60 62 61 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 } 62 71 63 72 … … 89 98 90 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 91 112 %} 92 113 … … 94 115 %include <std_string.i> 95 116 using namespace std; 117 %apply (char *STRING, int LENGTH) { (const char *bdata, int bsize) }; 96 118 97 119 %typemap(out) std::string* { … … 100 122 101 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 } 102 135 103 136 %typemap(in) std::string … … 177 210 %typemap(newfree) std::string * "delete $1;"; 178 211 212 213 179 214 #endif 180 215 … … 187 222 %include "std_string.i" 188 223 #endif 224 189 225 %include "std_vector.i" 190 226 %include "std_pair.i" … … 193 229 194 230 #ifdef SWIGPYTHON 231 //%template(cstrpairvec) std::vector<std::pair<const char*, const char*> >; 232 195 233 %{ 196 234 PyObject* … … 215 253 return result; 216 254 } 217 %} 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 218 326 219 327 %typemap(out) std::map<char*, char*> { … … 240 348 } 241 349 242 %typemap(in) const std::vector<std::pair<const char*, const char*> >& { 243 244 // we transform any Python sequence of items which are sequences where first 2 elements are string to a vector<pair<const char*, const char *>> 245 if (PySequence_Check($input)) { 246 std::vector<std::pair<const char*, const char*> > tmpvec; 247 $1 = &tmpvec; 248 249 int size = PySequence_Size($input); 250 for(int i = 0; i < size; i++) { 251 PyObject *o = PySequence_GetItem($input, i); 252 if (PySequence_Check(o)) { 253 if (PyString_Check(PySequence_GetItem(o, 0)) && PyString_Check(PySequence_GetItem(o, 1))) { 254 $1->push_back(std::make_pair<const char*, const char*>(PyString_AsString(PySequence_GetItem(o, 0)), 255 PyString_AsString(PySequence_GetItem(o, 1)))); 256 } else { 257 PyErr_SetString(PyExc_TypeError,"not a string sequence"); 258 return NULL; 259 } 260 261 } else { 262 PyErr_SetString(PyExc_TypeError,"item is not a sequence"); 263 return NULL; 264 } 265 266 267 } 268 } else { 269 PyErr_SetString(PyExc_TypeError,"not a sequence"); 270 return NULL; 271 272 } 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; 273 359 } 274 360 … … 300 386 } 301 387 302 #endif 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 303 469 304 470 … … 307 473 %template(pStrMap) map<char*, char *>; 308 474 %template(pcStrPair) pair<const char*, const char*>; 309 %template(pcStrVec) vector<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 310 479 } 311 480 #endif … … 315 484 ph_hdr_val *item(int i) { return i < self->count ? self->elems+i : 0; } 316 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 317 547 #if 0 318 548 enum ph_subs_type … … 527 757 528 758 %feature("director") phapi; 529 759 %apply int *OUTPUT {int *isreceipt}; 530 760 %include "phapi.h" 531 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
Note: See TracChangeset
for help on using the changeset viewer.
