Changeset 507:02df594a66c2 in verona


Ignore:
Timestamp:
Jul 31, 2012 2:57:52 PM (11 months ago)
Author:
Nikita Kozlov <nikita@…>
Branch:
default
Message:

siwg scripts update

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • phapi/phapi.c

    r503 r507  
    58955895                        ph_update_nego_mflags(ca,ph_get_media_direction(new_sdp,"audio"),ph_get_media_direction(new_sdp,"video")); 
    58965896         
     5897#ifndef ANDROID /* XXX: we will start the stream after we are sure that the ringback tone si finished */ 
    58975898                        if (ph_call_media_start(ca, je, mflags, ca->localresume)) 
    58985899                        { 
    58995900                                DBG_SIP_NEGO("SIP NEGO: ph_call_answered but without stream\n"); 
    59005901                        } 
     5902#endif 
    59015903                } 
    59025904        } 
     
    75357537void phSetDebugLevel(int level) { 
    75367538        phDebugLevel = level; 
     7539        osip_trace_enable_until_level(level); 
    75377540} 
    75387541 
  • phcpp/phapipp.cpp

    r499 r507  
    187187} 
    188188 
     189int phapi::callStartMedia(int cid, int streamFlags) 
     190{ 
     191        return phCallStartMedia(cid, streamFlags); 
     192} 
    189193 
    190194int phapi::subscribe(int vlid, const char* to, int winfo, int use_proxy, int expire, 
     
    500504void phapi::onSubscriptionProgress(int sid,  const phSubscriptionStateInfo_t *info)  { } 
    501505void phapi::onFrameReady(int cid, phVideoFrameReceivedEvent_t *ev) { } 
    502 void phapi::onPhLogCsl(const char *msg){ } 
     506void phapi::onPhLogCsl(int level, const char *msg){ } 
    503507 
    504508void phapi::onSoundFileStopped(void *userdata , unsigned int _id, void *arg){} 
     
    580584} 
    581585 
    582 void phapi::phLogCsl(const char *msg) 
    583 { 
    584         if (uniqueobj) 
    585                 uniqueobj->onPhLogCsl(msg); 
     586void phapi::phLogCsl(int level, const char *msg) 
     587{ 
     588        if (uniqueobj) 
     589                uniqueobj->onPhLogCsl(level, msg); 
    586590} 
    587591 
  • phcpp/phapipp.h

    r499 r507  
    6464 
    6565 
     66#ifndef SWIGJAVA 
     67typedef std::pair<int, std::string> strresult; 
     68#else 
     69struct  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 
     78typedef std::vector<std::string> strvector; 
     79typedef std::vector<std::pair<const char*, const char*> > cstrpairvec; 
     80 
     81struct  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 
     90struct  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 
    6699namespace verona { 
    67100 
     
    194227        virtual int mutePlayback(int cid, int val); 
    195228        virtual int muteCapture(int cid, int val); 
     229        virtual int callStartMedia(int cid, int streamFlags); 
    196230         
    197231        virtual int setSoundFileGain(phStream* phstream,float gain); 
     
    238272#endif 
    239273        virtual void onDtmfProgress(int cid, int dtmf); 
    240         virtual void onPhLogCsl(const char *msg); 
     274        virtual void onPhLogCsl(int level, const char *msg); 
    241275        virtual void onSoundFileStopped(void *userdata , unsigned int _id, void *arg); 
    242276        virtual void onQosEvent(int cid, const phQosInfo_t * info); 
     
    257291        static void  subscriptionProgress(int sid,  const phSubscriptionStateInfo_t *info); 
    258292        static void  frameReady(int cid, phVideoFrameReceivedEvent_t *ev); 
    259         static void  phLogCsl(const char *msg); 
     293        static void  phLogCsl(int level, const char *msg); 
    260294        static void  soundFileStopped(void *userdata , unsigned int _id, void *arg); 
    261295        static void  qosEvent(int cid, const phQosInfo_t * info); 
  • swig/verona.i

    r498 r507  
    1616%module (directors=1) perl_verona 
    1717#endif 
     18 
     19%include "typemaps.i" 
    1820 
    1921%{ 
     
    6062 
    6163 
     64inline const char* as_cstr(const std::string& s) { 
     65        return s.c_str(); 
     66} 
     67 
     68inline const char* as_cstr(const char* s) { 
     69        return s; 
     70} 
    6271 
    6372 
     
    8998  
    9099} 
     100struct barr { 
     101   const char *data; 
     102   int size; 
     103}; 
     104 
     105jbyteArray 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 
    91112%} 
    92113 
     
    94115%include <std_string.i> 
    95116using namespace std; 
     117%apply (char *STRING, int LENGTH) { (const char *bdata, int bsize) }; 
    96118 
    97119%typemap(out) std::string* { 
     
    100122 
    101123} 
     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  } 
    102135 
    103136%typemap(in) std::string  
     
    177210%typemap(newfree) std::string * "delete $1;"; 
    178211 
     212 
     213 
    179214#endif 
    180215 
     
    187222%include "std_string.i" 
    188223#endif 
     224 
    189225%include "std_vector.i" 
    190226%include "std_pair.i" 
     
    193229 
    194230#ifdef SWIGPYTHON 
     231//%template(cstrpairvec) std::vector<std::pair<const char*, const char*> >; 
     232 
    195233%{ 
    196234PyObject* 
     
    215253  return result;       
    216254} 
    217 %} 
     255 
     256 
     257template<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 
     279template<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 
    218326 
    219327%typemap(out) std::map<char*, char*> { 
     
    240348} 
    241349 
    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; 
    273359} 
    274360 
     
    300386} 
    301387 
    302 #endif 
     388%{ 
     389typedef PyObject SWIG_Object; 
     390  
     391template<class T> struct SwigObj { 
     392   SWIG_Object* obj(int v) { return PyLong_FromLong(v); }           
     393 }; 
     394 
     395template<> struct SwigObj<std::string> { 
     396  static SWIG_Object* obj(const std::string& s) { return PyString_FromStringAndSize(s.c_str(), s.length()); }    
     397 }; 
     398 
     399template<> 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  
     408template<> 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 
     419template<> 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%{ 
     449template<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 
    303469 
    304470 
     
    307473       %template(pStrMap) map<char*, char *>;  
    308474       %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 
    310479} 
    311480#endif 
     
    315484     ph_hdr_val *item(int i) { return i < self->count ? self->elems+i : 0; } 
    316485};  
     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  
    317547#if 0 
    318548enum ph_subs_type  
     
    527757 
    528758%feature("director") phapi; 
    529  
     759%apply int *OUTPUT {int *isreceipt}; 
    530760%include "phapi.h" 
    531761%include "phapipp.h" 
     762 
     763#ifdef SWIGJAVA 
     764struct 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.