1 Star 0 Fork 0

via/python3-pjsip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
_pjsua.c 113.68 KB
一键复制 编辑 原始数据 按行查看 历史
Matthew Williams 提交于 2016-01-06 01:09 . update copyright
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642
/* $Id: _pjsua.c 4724 2014-01-31 08:52:09Z nanang $ */
/*
* Copyright (C) 2016 Matthew Williams <[email protected]>
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "_pjsua.h"
struct module_state {
PyObject *error;
};
#define THIS_FILE "main.c"
#define POOL_SIZE 512
#define SND_DEV_NUM 64
#define SND_NAME_LEN 64
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
/* LIB BASE */
static PyObject* g_obj_log_cb;
static long g_thread_id;
static struct py_thread_desc
{
struct py_thread_desc *next;
pj_thread_desc desc;
} *py_thread_desc;
/*
* The global callback object.
*/
static PyObj_pjsua_callback * g_obj_callback;
/* Set this to 1 if all threads are created by Python */
#define NO_PJSIP_THREAD 1
#if NO_PJSIP_THREAD
# define ENTER_PYTHON()
# define LEAVE_PYTHON()
#else
# define ENTER_PYTHON() PyGILState_STATE state = PyGILState_Ensure()
# define LEAVE_PYTHON() PyGILState_Release(state)
#endif
static void clear_py_thread_desc(void)
{
while (py_thread_desc) {
struct py_thread_desc *next = py_thread_desc->next;
free(py_thread_desc);
py_thread_desc = next;
}
}
/*
* cb_log_cb
* declares method for reconfiguring logging process for callback struct
*/
static void cb_log_cb(int level, const char *data, int len)
{
/* Ignore if this callback is called from alien thread context,
* or otherwise it will crash Python.
*/
if (pj_thread_local_get(g_thread_id) == 0)
return;
if (PyCallable_Check(g_obj_log_cb)) {
PyObject *param_data;
ENTER_PYTHON();
param_data = PyBytes_FromStringAndSize(data, len);
PyObject_CallFunction(
g_obj_log_cb,
"iOi",
level,
param_data,
len,
NULL
);
Py_DECREF(param_data);
LEAVE_PYTHON();
}
}
/*
* cb_on_call_state
* declares method on_call_state for callback struct
*/
static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e)
{
PJ_UNUSED_ARG(e);
if (PyCallable_Check(g_obj_callback->on_call_state)) {
PyObject * obj;
ENTER_PYTHON();
obj = Py_BuildValue("");
PyObject_CallFunction(
g_obj_callback->on_call_state,
"iO",
call_id,
obj,
NULL
);
Py_DECREF(obj);
LEAVE_PYTHON();
}
}
/*
* cb_on_incoming_call
* declares method on_incoming_call for callback struct
*/
static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
pjsip_rx_data *rdata)
{
if (PyCallable_Check(g_obj_callback->on_incoming_call)) {
PyObj_pjsip_rx_data *obj;
ENTER_PYTHON();
obj = (PyObj_pjsip_rx_data*)
PyObj_pjsip_rx_data_new(&PyTyp_pjsip_rx_data,
NULL, NULL);
PyObj_pjsip_rx_data_import(obj, rdata);
PyObject_CallFunction(
g_obj_callback->on_incoming_call,
"iiO",
acc_id,
call_id,
obj,
NULL
);
Py_DECREF(obj);
LEAVE_PYTHON();
}
}
/*
* cb_on_call_media_state
* declares method on_call_media_state for callback struct
*/
static void cb_on_call_media_state(pjsua_call_id call_id)
{
if (PyCallable_Check(g_obj_callback->on_call_media_state)) {
ENTER_PYTHON();
PyObject_CallFunction(
g_obj_callback->on_call_media_state,
"i",
call_id,
NULL
);
LEAVE_PYTHON();
}
}
/*
* cb_on_dtmf_digit()
* Callback from PJSUA-LIB on receiving DTMF digit
*/
static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit)
{
if (PyCallable_Check(g_obj_callback->on_dtmf_digit)) {
char digit_str[10];
PyGILState_STATE state = PyGILState_Ensure();
pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit);
PyObject_CallFunction(
g_obj_callback->on_dtmf_digit,
"is",
call_id,
digit_str,
NULL
);
PyGILState_Release(state);
}
}
/*
* Notify application on call being transferred.
* !modified @061206
*/
static void cb_on_call_transfer_request(pjsua_call_id call_id,
const pj_str_t *dst,
pjsip_status_code *code)
{
if (PyCallable_Check(g_obj_callback->on_call_transfer_request)) {
PyObject *ret, *param_dst;
int cd;
ENTER_PYTHON();
param_dst = PyUnicode_FromPJ(dst);
ret = PyObject_CallFunction(
g_obj_callback->on_call_transfer_request,
"iOi",
call_id,
param_dst,
*code,
NULL
);
Py_DECREF(param_dst);
if (ret != NULL) {
if (ret != Py_None) {
if (PyArg_Parse(ret,"i",&cd)) {
*code = cd;
}
}
Py_DECREF(ret);
}
LEAVE_PYTHON();
}
}
/*
* Notify application of the status of previously sent call
* transfer request. Application can monitor the status of the
* call transfer request, for example to decide whether to
* terminate existing call.
* !modified @061206
*/
static void cb_on_call_transfer_status( pjsua_call_id call_id,
int status_code,
const pj_str_t *status_text,
pj_bool_t final,
pj_bool_t *p_cont)
{
if (PyCallable_Check(g_obj_callback->on_call_transfer_status)) {
PyObject *ret, *param_reason;
ENTER_PYTHON();
param_reason = PyUnicode_FromPJ(status_text);
ret = PyObject_CallFunction(
g_obj_callback->on_call_transfer_status,
"iiOii",
call_id,
status_code,
param_reason,
final,
*p_cont,
NULL
);
Py_DECREF(param_reason);
if (ret != NULL) {
if (ret != Py_None) {
int cnt;
if (PyArg_Parse(ret,"i",&cnt)) {
*p_cont = cnt;
}
}
Py_DECREF(ret);
}
LEAVE_PYTHON();
}
}
/*
* Notify application about incoming INVITE with Replaces header.
* Application may reject the request by setting non-2xx code.
* !modified @061206
*/
static void cb_on_call_replace_request( pjsua_call_id call_id,
pjsip_rx_data *rdata,
int *st_code,
pj_str_t *st_text)
{
PJ_UNUSED_ARG(rdata);
if (PyCallable_Check(g_obj_callback->on_call_replace_request)) {
PyObject *ret, *param_reason, *param_rdata;
int cd;
ENTER_PYTHON();
param_reason = PyUnicode_FromPJ(st_text);
param_rdata = Py_BuildValue("");
ret = PyObject_CallFunction(
g_obj_callback->on_call_replace_request,
"iOiO",
call_id,
param_rdata,
*st_code,
param_reason,
NULL
);
Py_DECREF(param_rdata);
Py_DECREF(param_reason);
if (ret != NULL) {
if (ret != Py_None) {
PyObject * txt;
if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) {
*st_code = cd;
*st_text = PyUnicode_ToPJ(txt);
}
}
Py_DECREF(ret);
}
LEAVE_PYTHON();
}
}
/*
* Notify application that an existing call has been replaced with
* a new call. This happens when PJSUA-API receives incoming INVITE
* request with Replaces header.
*/
static void cb_on_call_replaced(pjsua_call_id old_call_id,
pjsua_call_id new_call_id)
{
if (PyCallable_Check(g_obj_callback->on_call_replaced)) {
ENTER_PYTHON();
PyObject_CallFunction(
g_obj_callback->on_call_replaced,
"ii",
old_call_id,
new_call_id,
NULL
);
LEAVE_PYTHON();
}
}
/*
* cb_on_reg_state
* declares method on_reg_state for callback struct
*/
static void cb_on_reg_state(pjsua_acc_id acc_id)
{
if (PyCallable_Check(g_obj_callback->on_reg_state)) {
ENTER_PYTHON();
PyObject_CallFunction(
g_obj_callback->on_reg_state,
"i",
acc_id,
NULL
);
LEAVE_PYTHON();
}
}
/*
* cb_on_incoming_subscribe
*/
static void cb_on_incoming_subscribe( pjsua_acc_id acc_id,
pjsua_srv_pres *srv_pres,
pjsua_buddy_id buddy_id,
const pj_str_t *from,
pjsip_rx_data *rdata,
pjsip_status_code *code,
pj_str_t *reason,
pjsua_msg_data *msg_data)
{
static char reason_buf[64];
PJ_UNUSED_ARG(rdata);
PJ_UNUSED_ARG(msg_data);
if (PyCallable_Check(g_obj_callback->on_incoming_subscribe)) {
PyObject *ret, *param_from, *param_contact, *param_srv_pres;
pjsip_contact_hdr *contact_hdr;
pj_pool_t *pool = NULL;
ENTER_PYTHON();
param_from = PyUnicode_FromPJ(from);
param_srv_pres = PyLong_FromLong((long)srv_pres);
contact_hdr = (pjsip_contact_hdr*)
pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
if (contact_hdr) {
char *contact;
int len;
pool = pjsua_pool_create("pytmp", 512, 512);
contact = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE+1);
len = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri,
contact, PJSIP_MAX_URL_SIZE);
if (len < 1)
len = 0;
contact[len] = '\0';
param_contact = PyBytes_FromStringAndSize(contact, len);
} else {
param_contact = Py_BuildValue("");
}
ret = PyObject_CallFunction(
g_obj_callback->on_incoming_subscribe,
"iiOOO",
acc_id,
buddy_id,
param_from,
param_contact,
param_srv_pres,
NULL
);
if (pool)
pj_pool_release(pool);
Py_DECREF(param_from);
Py_DECREF(param_contact);
Py_DECREF(param_srv_pres);
if (ret && PyTuple_Check(ret)) {
if (PyTuple_Size(ret) >= 1)
*code = (int)PyLong_AsLong(PyTuple_GetItem(ret, 0));
if (PyTuple_Size(ret) >= 2) {
if (PyTuple_GetItem(ret, 1) != Py_None) {
pj_str_t tmp;
tmp = PyUnicode_ToPJ(PyTuple_GetItem(ret, 1));
reason->ptr = reason_buf;
pj_strncpy(reason, &tmp, sizeof(reason_buf));
} else {
reason->slen = 0;
}
}
Py_XDECREF(ret);
} else if (ret) {
Py_XDECREF(ret);
}
LEAVE_PYTHON();
}
}
/*
* cb_on_buddy_state
* declares method on_buddy state for callback struct
*/
static void cb_on_buddy_state(pjsua_buddy_id buddy_id)
{
if (PyCallable_Check(g_obj_callback->on_buddy_state)) {
ENTER_PYTHON();
PyObject_CallFunction(
g_obj_callback->on_buddy_state,
"i",
buddy_id,
NULL
);
LEAVE_PYTHON();
}
}
/*
* cb_on_pager
* declares method on_pager for callback struct
*/
static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from,
const pj_str_t *to, const pj_str_t *contact,
const pj_str_t *mime_type, const pj_str_t *body,
pjsip_rx_data *rdata, pjsua_acc_id acc_id)
{
PJ_UNUSED_ARG(rdata);
if (PyCallable_Check(g_obj_callback->on_pager)) {
PyObject *param_from, *param_to, *param_contact, *param_mime_type,
*param_body;
ENTER_PYTHON();
param_from = PyUnicode_FromPJ(from);
param_to = PyUnicode_FromPJ(to);
param_contact = PyUnicode_FromPJ(contact);
param_mime_type = PyUnicode_FromPJ(mime_type);
param_body = PyUnicode_FromPJ(body);
PyObject_CallFunction(
g_obj_callback->on_pager,
"iOOOOOi",
call_id,
param_from,
param_to,
param_contact,
param_mime_type,
param_body,
acc_id,
NULL
);
Py_DECREF(param_body);
Py_DECREF(param_mime_type);
Py_DECREF(param_contact);
Py_DECREF(param_to);
Py_DECREF(param_from);
LEAVE_PYTHON();
}
}
/*
* cb_on_pager_status
* declares method on_pager_status for callback struct
*/
static void cb_on_pager_status(pjsua_call_id call_id, const pj_str_t *to,
const pj_str_t *body, void *user_data,
pjsip_status_code status,
const pj_str_t *reason,
pjsip_tx_data *tdata,
pjsip_rx_data *rdata,
pjsua_acc_id acc_id)
{
if (PyCallable_Check(g_obj_callback->on_pager)) {
PyObject *param_call_id, *param_to, *param_body,
*param_user_data, *param_status, *param_reason,
*param_acc_id;
ENTER_PYTHON();
PJ_UNUSED_ARG(tdata);
PJ_UNUSED_ARG(rdata);
PyObject_CallFunctionObjArgs(
g_obj_callback->on_pager_status,
param_call_id = Py_BuildValue("i",call_id),
param_to = PyUnicode_FromPJ(to),
param_body = PyUnicode_FromPJ(body),
param_user_data = Py_BuildValue("i", user_data),
param_status = Py_BuildValue("i",status),
param_reason = PyUnicode_FromPJ(reason),
param_acc_id = Py_BuildValue("i",acc_id),
NULL
);
Py_DECREF(param_call_id);
Py_DECREF(param_to);
Py_DECREF(param_body);
Py_DECREF(param_user_data);
Py_DECREF(param_status);
Py_DECREF(param_reason);
Py_DECREF(param_acc_id);
LEAVE_PYTHON();
}
}
/*
* cb_on_typing
* declares method on_typing for callback struct
*/
static void cb_on_typing(pjsua_call_id call_id, const pj_str_t *from,
const pj_str_t *to, const pj_str_t *contact,
pj_bool_t is_typing, pjsip_rx_data *rdata,
pjsua_acc_id acc_id)
{
if (PyCallable_Check(g_obj_callback->on_typing)) {
PyObject *param_call_id, *param_from, *param_to, *param_contact,
*param_is_typing, *param_acc_id;
ENTER_PYTHON();
PJ_UNUSED_ARG(rdata);
PyObject_CallFunctionObjArgs(
g_obj_callback->on_typing,
param_call_id = Py_BuildValue("i",call_id),
param_from = PyUnicode_FromPJ(from),
param_to = PyUnicode_FromPJ(to),
param_contact = PyUnicode_FromPJ(contact),
param_is_typing = Py_BuildValue("i",is_typing),
param_acc_id = Py_BuildValue("i",acc_id),
NULL
);
Py_DECREF(param_call_id);
Py_DECREF(param_from);
Py_DECREF(param_to);
Py_DECREF(param_contact);
Py_DECREF(param_is_typing);
Py_DECREF(param_acc_id);
LEAVE_PYTHON();
}
}
/*
* on_mwi_info
*/
static void cb_on_mwi_info(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info)
{
if (PyCallable_Check(g_obj_callback->on_mwi_info)) {
PyObject *param_acc_id, *param_body;
pj_str_t body;
ENTER_PYTHON();
body.ptr = mwi_info->rdata->msg_info.msg->body->data;
body.slen = mwi_info->rdata->msg_info.msg->body->len;
PyObject_CallFunctionObjArgs(
g_obj_callback->on_mwi_info,
param_acc_id = Py_BuildValue("i",acc_id),
param_body = PyUnicode_FromPJ(&body),
NULL
);
Py_DECREF(param_acc_id);
Py_DECREF(param_body);
LEAVE_PYTHON();
}
}
/*
* translate_hdr
* internal function
* translate from hdr_list to pjsip_generic_string_hdr
*/
void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list)
{
pj_list_init(hdr);
if (PyList_Check(py_hdr_list)) {
int i;
for (i=0; i<PyList_Size(py_hdr_list); ++i) {
pj_str_t hname, hvalue;
pjsip_generic_string_hdr * new_hdr;
PyObject * tuple = PyList_GetItem(py_hdr_list, i);
if (PyTuple_Check(tuple)) {
if (PyTuple_Size(tuple) >= 1)
hname = PyUnicode_ToPJ(PyTuple_GetItem(tuple,0));
else
hname.slen = 0;
if (PyTuple_Size(tuple) >= 2)
hvalue = PyUnicode_ToPJ(PyTuple_GetItem(tuple,1));
else
hvalue.slen = 0;
} else {
hname.ptr = "";
hname.slen = 0;
hvalue.ptr = "";
hvalue.slen = 0;
}
new_hdr = pjsip_generic_string_hdr_create(pool, &hname, &hvalue);
pj_list_push_back((pj_list_type *)hdr, (pj_list_type *)new_hdr);
}
}
}
/*
* py_pjsua_thread_register
*/
static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
const char *name;
PyObject *py_desc;
pj_thread_t *thread;
struct py_thread_desc *thread_desc;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) {
return NULL;
}
thread_desc = (struct py_thread_desc*)
malloc(sizeof(struct py_thread_desc));
thread_desc->next = py_thread_desc;
py_thread_desc = thread_desc;
status = pj_thread_register(name, thread_desc->desc, &thread);
if (status == PJ_SUCCESS)
status = pj_thread_local_set(g_thread_id, (void*)1);
return Py_BuildValue("i",status);
}
/*
* py_pjsua_logging_config_default
*/
static PyObject *py_pjsua_logging_config_default(PyObject *pSelf,
PyObject *pArgs)
{
PyObj_pjsua_logging_config *obj;
pjsua_logging_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_logging_config_default(&cfg);
obj = (PyObj_pjsua_logging_config*)
PyObj_pjsua_logging_config_new(&PyTyp_pjsua_logging_config,
NULL, NULL);
PyObj_pjsua_logging_config_import(obj, &cfg);
return (PyObject*)obj;
}
/*
* py_pjsua_config_default
*/
static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs)
{
PyObj_pjsua_config *obj;
pjsua_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_config_default(&cfg);
obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config,
NULL, NULL);
PyObj_pjsua_config_import(obj, &cfg);
return (PyObject*)obj;
}
/*
* py_pjsua_media_config_default
*/
static PyObject * py_pjsua_media_config_default(PyObject *pSelf,
PyObject *pArgs)
{
PyObj_pjsua_media_config *obj;
pjsua_media_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_media_config_default(&cfg);
obj = (PyObj_pjsua_media_config *)
PyType_GenericNew(&PyTyp_pjsua_media_config, NULL, NULL);
PyObj_pjsua_media_config_import(obj, &cfg);
return (PyObject *)obj;
}
/*
* py_pjsua_msg_data_init
*/
static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs)
{
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
return (PyObject *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data,
NULL, NULL);
}
/*
* py_pjsua_reconfigure_logging
*/
static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf,
PyObject *pArgs)
{
PyObject *logObj;
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "O", &logObj)) {
return NULL;
}
if (logObj != Py_None) {
PyObj_pjsua_logging_config *log;
pjsua_logging_config cfg;
log = (PyObj_pjsua_logging_config*)logObj;
cfg.msg_logging = log->msg_logging;
cfg.level = log->level;
cfg.console_level = log->console_level;
cfg.decor = log->decor;
cfg.log_filename = PyUnicode_ToPJ(log->log_filename);
Py_XDECREF(g_obj_log_cb);
g_obj_log_cb = log->cb;
Py_INCREF(g_obj_log_cb);
cfg.cb = &cb_log_cb;
status = pjsua_reconfigure_logging(&cfg);
} else {
status = pjsua_reconfigure_logging(NULL);
}
return Py_BuildValue("i",status);
}
/*
* py_pjsua_perror
*/
static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs)
{
const char *sender;
const char *title;
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) {
return NULL;
}
pjsua_perror(sender, title, status);
return Py_BuildValue("");
}
/*
* py_pjsua_create
*/
static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_create();
if (status == PJ_SUCCESS) {
status = pj_thread_local_alloc(&g_thread_id);
if (status == PJ_SUCCESS)
status = pj_thread_local_set(g_thread_id, (void*)1);
pj_atexit(&clear_py_thread_desc);
}
return Py_BuildValue("i",status);
}
/*
* py_pjsua_init
*/
static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *o_ua_cfg, *o_log_cfg, *o_media_cfg;
pjsua_config cfg_ua, *p_cfg_ua;
pjsua_logging_config cfg_log, *p_cfg_log;
pjsua_media_config cfg_media, *p_cfg_media;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg)) {
return NULL;
}
pjsua_config_default(&cfg_ua);
pjsua_logging_config_default(&cfg_log);
pjsua_media_config_default(&cfg_media);
if (o_ua_cfg != Py_None) {
PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg;
PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg);
Py_XDECREF(g_obj_callback);
g_obj_callback = obj_ua_cfg->cb;
Py_INCREF(g_obj_callback);
cfg_ua.cb.on_call_state = &cb_on_call_state;
cfg_ua.cb.on_incoming_call = &cb_on_incoming_call;
cfg_ua.cb.on_call_media_state = &cb_on_call_media_state;
cfg_ua.cb.on_dtmf_digit = &cb_on_dtmf_digit;
cfg_ua.cb.on_call_transfer_request = &cb_on_call_transfer_request;
cfg_ua.cb.on_call_transfer_status = &cb_on_call_transfer_status;
cfg_ua.cb.on_call_replace_request = &cb_on_call_replace_request;
cfg_ua.cb.on_call_replaced = &cb_on_call_replaced;
cfg_ua.cb.on_reg_state = &cb_on_reg_state;
cfg_ua.cb.on_incoming_subscribe = &cb_on_incoming_subscribe;
cfg_ua.cb.on_buddy_state = &cb_on_buddy_state;
cfg_ua.cb.on_pager2 = &cb_on_pager;
cfg_ua.cb.on_pager_status2 = &cb_on_pager_status;
cfg_ua.cb.on_typing2 = &cb_on_typing;
cfg_ua.cb.on_mwi_info = &cb_on_mwi_info;
p_cfg_ua = &cfg_ua;
} else {
p_cfg_ua = NULL;
}
if (o_log_cfg != Py_None) {
PyObj_pjsua_logging_config * obj_log;
obj_log = (PyObj_pjsua_logging_config *)o_log_cfg;
PyObj_pjsua_logging_config_export(&cfg_log, obj_log);
Py_XDECREF(g_obj_log_cb);
g_obj_log_cb = obj_log->cb;
Py_INCREF(g_obj_log_cb);
cfg_log.cb = &cb_log_cb;
p_cfg_log = &cfg_log;
} else {
p_cfg_log = NULL;
}
if (o_media_cfg != Py_None) {
PyObj_pjsua_media_config_export(&cfg_media,
(PyObj_pjsua_media_config*)o_media_cfg);
p_cfg_media = &cfg_media;
} else {
p_cfg_media = NULL;
}
status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_start
*/
static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_start();
return Py_BuildValue("i", status);
}
/*
* py_pjsua_destroy
*/
static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_destroy();
return Py_BuildValue("i", status);
}
/*
* py_pjsua_handle_events
*/
static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs)
{
int ret;
int msec;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &msec)) {
return NULL;
}
if (msec < 0)
msec = 0;
#if !NO_PJSIP_THREAD
/* Since handle_events() will block, we must wrap it with ALLOW_THREADS
* construct, or otherwise many Python blocking functions (such as
* time.sleep(), readline(), etc.) may hang/block indefinitely.
* See http://www.python.org/doc/current/api/threads.html for more info.
*/
Py_BEGIN_ALLOW_THREADS
#endif
ret = pjsua_handle_events(msec);
#if !NO_PJSIP_THREAD
Py_END_ALLOW_THREADS
#endif
return Py_BuildValue("i", ret);
}
/*
* py_pjsua_verify_sip_url
*/
static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
const char *url;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "s", &url)) {
return NULL;
}
status = pjsua_verify_sip_url(url);
return Py_BuildValue("i", status);
}
/*
* function doc
*/
static char pjsua_thread_register_doc[] =
"int _pjsua.thread_register(string name, int[] desc)";
static char pjsua_perror_doc[] =
"void _pjsua.perror (string sender, string title, int status) "
"Display error message for the specified error code. Parameters: "
"sender: The log sender field; "
"title: Message title for the error; "
"status: Status code.";
static char pjsua_create_doc[] =
"int _pjsua.create (void) "
"Instantiate pjsua application. Application "
"must call this function before calling any other functions, to make sure "
"that the underlying libraries are properly initialized. Once this "
"function has returned success, application must call pjsua_destroy() "
"before quitting.";
static char pjsua_init_doc[] =
"int _pjsua.init (_pjsua.Config obj_ua_cfg, "
"_pjsua.Logging_Config log_cfg, _pjsua.Media_Config media_cfg) "
"Initialize pjsua with the specified settings. All the settings are "
"optional, and the default values will be used when the config is not "
"specified. Parameters: "
"obj_ua_cfg : User agent configuration; "
"log_cfg : Optional logging configuration; "
"media_cfg : Optional media configuration.";
static char pjsua_start_doc[] =
"int _pjsua.start (void) "
"Application is recommended to call this function after all "
"initialization is done, so that the library can do additional checking "
"set up additional";
static char pjsua_destroy_doc[] =
"int _pjsua.destroy (void) "
"Destroy pjsua This function must be called once PJSUA is created. To "
"make it easier for application, application may call this function "
"several times with no danger.";
static char pjsua_handle_events_doc[] =
"int _pjsua.handle_events (int msec_timeout) "
"Poll pjsua for events, and if necessary block the caller thread for the "
"specified maximum interval (in miliseconds) Parameters: "
"msec_timeout: Maximum time to wait, in miliseconds. "
"Returns: The number of events that have been handled during the poll. "
"Negative value indicates error, and application can retrieve the error "
"as (err = -return_value).";
static char pjsua_verify_sip_url_doc[] =
"int _pjsua.verify_sip_url (string c_url) "
"Verify that valid SIP url is given Parameters: "
"c_url: The URL, as NULL terminated string.";
static char pjsua_reconfigure_logging_doc[] =
"int _pjsua.reconfigure_logging (_pjsua.Logging_Config c) "
"Application can call this function at any time (after pjsua_create(), of "
"course) to change logging settings. Parameters: "
"c: Logging configuration.";
static char pjsua_logging_config_default_doc[] =
"_pjsua.Logging_Config _pjsua.logging_config_default () "
"Use this function to initialize logging config.";
static char pjsua_config_default_doc[] =
"_pjsua.Config _pjsua.config_default (). Use this function to "
"initialize pjsua config. ";
static char pjsua_media_config_default_doc[] =
"_pjsua.Media_Config _pjsua.media_config_default (). "
"Use this function to initialize media config.";
static char pjsua_msg_data_init_doc[] =
"_pjsua.Msg_Data void _pjsua.msg_data_init () "
"Initialize message data ";
/* END OF LIB BASE */
/* LIB TRANSPORT */
/*
* py_pjsua_transport_config_default
*/
static PyObject *py_pjsua_transport_config_default(PyObject *pSelf,
PyObject *pArgs)
{
PyObj_pjsua_transport_config *obj;
pjsua_transport_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_transport_config_default(&cfg);
obj = (PyObj_pjsua_transport_config*)
PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config,
NULL, NULL);
PyObj_pjsua_transport_config_import(obj, &cfg);
return (PyObject *)obj;
}
/*
* py_pjsua_transport_create
*/
static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
int type;
PyObject *pCfg;
pjsua_transport_config cfg;
pjsua_transport_id id;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &type, &pCfg)) {
return NULL;
}
if (pCfg != Py_None) {
PyObj_pjsua_transport_config *obj;
obj = (PyObj_pjsua_transport_config*)pCfg;
PyObj_pjsua_transport_config_export(&cfg, obj);
status = pjsua_transport_create(type, &cfg, &id);
} else {
status = pjsua_transport_create(type, NULL, &id);
}
return Py_BuildValue("ii", status, id);
}
/*
* py_pjsua_enum_transports
*/
static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *list;
pjsua_transport_id id[PJSIP_MAX_TRANSPORTS];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(id);
status = pjsua_enum_transports(id, &c);
list = PyList_New(c);
for (i = 0; i < c; i++) {
PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
}
return (PyObject*)list;
}
/*
* py_pjsua_transport_get_info
* !modified @ 051206
*/
static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
int id;
pjsua_transport_info info;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_transport_get_info(id, &info);
if (status == PJ_SUCCESS) {
PyObj_pjsua_transport_info *obj;
obj = (PyObj_pjsua_transport_info *)
PyObj_pjsua_transport_info_new(&PyTyp_pjsua_transport_info,
NULL, NULL);
PyObj_pjsua_transport_info_import(obj, &info);
return (PyObject*)obj;
} else {
return Py_BuildValue("");
}
}
/*
* py_pjsua_transport_set_enable
*/
static PyObject *py_pjsua_transport_set_enable(PyObject *pSelf,
PyObject *pArgs)
{
pj_status_t status;
int id;
int enabled;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled)) {
return NULL;
}
status = pjsua_transport_set_enable(id, enabled);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_transport_close
*/
static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
int id;
int force;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) {
return NULL;
}
status = pjsua_transport_close(id, force);
return Py_BuildValue("i", status);
}
static char pjsua_transport_config_default_doc[] =
"_pjsua.Transport_Config _pjsua.transport_config_default () "
"Call this function to initialize UDP config with default values.";
static char pjsua_transport_create_doc[] =
"int, int _pjsua.transport_create (int type, "
"_pjsua.Transport_Config cfg) "
"Create SIP transport.";
static char pjsua_enum_transports_doc[] =
"int[] _pjsua.enum_transports () "
"Enumerate all transports currently created in the system.";
static char pjsua_transport_get_info_doc[] =
"void _pjsua.transport_get_info "
"(_pjsua.Transport_ID id, _pjsua.Transport_Info info) "
"Get information about transports.";
static char pjsua_transport_set_enable_doc[] =
"void _pjsua.transport_set_enable "
"(_pjsua.Transport_ID id, int enabled) "
"Disable a transport or re-enable it. "
"By default transport is always enabled after it is created. "
"Disabling a transport does not necessarily close the socket, "
"it will only discard incoming messages and prevent the transport "
"from being used to send outgoing messages.";
static char pjsua_transport_close_doc[] =
"void _pjsua.transport_close (_pjsua.Transport_ID id, int force) "
"Close the transport. If transport is forcefully closed, "
"it will be immediately closed, and any pending transactions "
"that are using the transport may not terminate properly. "
"Otherwise, the system will wait until all transactions are closed "
"while preventing new users from using the transport, and will close "
"the transport when it is safe to do so.";
/* END OF LIB TRANSPORT */
/* LIB ACCOUNT */
/*
* py_pjsua_acc_config_default
*/
static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs)
{
PyObj_pjsua_acc_config *obj;
pjsua_acc_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
if (!PyArg_ParseTuple(pArgs, "")) {
return NULL;
}
pjsua_acc_config_default(&cfg);
obj = (PyObj_pjsua_acc_config *)
PyObj_pjsua_acc_config_new(&PyTyp_pjsua_acc_config,
NULL, NULL);
PyObj_pjsua_acc_config_import(obj, &cfg);
return (PyObject *)obj;
}
/*
* py_pjsua_acc_get_count
*/
static PyObject *py_pjsua_acc_get_count(PyObject *pSelf, PyObject *pArgs)
{
int count;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
count = pjsua_acc_get_count();
return Py_BuildValue("i", count);
}
/*
* py_pjsua_acc_is_valid
*/
static PyObject *py_pjsua_acc_is_valid(PyObject *pSelf, PyObject *pArgs)
{
int id;
int is_valid;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
is_valid = pjsua_acc_is_valid(id);
return Py_BuildValue("i", is_valid);
}
/*
* py_pjsua_acc_set_default
*/
static PyObject *py_pjsua_acc_set_default(PyObject *pSelf, PyObject *pArgs)
{
int id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_acc_set_default(id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_get_default
*/
static PyObject *py_pjsua_acc_get_default(PyObject *pSelf, PyObject *pArgs)
{
int id;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
id = pjsua_acc_get_default();
return Py_BuildValue("i", id);
}
/*
* py_pjsua_acc_add
*/
static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs)
{
int is_default;
PyObject *pCfg;
int acc_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "Oi", &pCfg, &is_default)) {
return NULL;
}
if (pCfg != Py_None) {
pjsua_acc_config cfg;
PyObj_pjsua_acc_config *ac;
pjsua_acc_config_default(&cfg);
ac = (PyObj_pjsua_acc_config *)pCfg;
PyObj_pjsua_acc_config_export(&cfg, ac);
status = pjsua_acc_add(&cfg, is_default, &acc_id);
} else {
status = PJ_EINVAL;
acc_id = PJSUA_INVALID_ID;
}
return Py_BuildValue("ii", status, acc_id);
}
/*
* py_pjsua_acc_add_local
*/
static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs)
{
int is_default;
int tid;
int acc_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) {
return NULL;
}
status = pjsua_acc_add_local(tid, is_default, &acc_id);
return Py_BuildValue("ii", status, acc_id);
}
/*
* py_pjsua_acc_set_user_data
*/
static PyObject *py_pjsua_acc_set_user_data(PyObject *pSelf, PyObject *pArgs)
{
int acc_id;
PyObject *pUserData, *old_user_data;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pUserData)) {
return NULL;
}
old_user_data = (PyObject*) pjsua_acc_get_user_data(acc_id);
status = pjsua_acc_set_user_data(acc_id, (void*)pUserData);
if (status == PJ_SUCCESS) {
Py_XINCREF(pUserData);
Py_XDECREF(old_user_data);
}
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_get_user_data
*/
static PyObject *py_pjsua_acc_get_user_data(PyObject *pSelf, PyObject *pArgs)
{
int acc_id;
PyObject *user_data;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) {
return NULL;
}
user_data = (PyObject*) pjsua_acc_get_user_data(acc_id);
return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue("");
}
/*
* py_pjsua_acc_del
*/
static PyObject *py_pjsua_acc_del(PyObject *pSelf, PyObject *pArgs)
{
int acc_id;
PyObject *user_data;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) {
return NULL;
}
user_data = (PyObject*) pjsua_acc_get_user_data(acc_id);
Py_XDECREF(user_data);
status = pjsua_acc_del(acc_id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_modify
*/
static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs)
{
PyObject *pCfg;
PyObj_pjsua_acc_config * ac;
int acc_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pCfg)) {
return NULL;
}
if (pCfg != Py_None) {
pjsua_acc_config cfg;
pjsua_acc_config_default(&cfg);
ac = (PyObj_pjsua_acc_config*)pCfg;
PyObj_pjsua_acc_config_export(&cfg, ac);
status = pjsua_acc_modify(acc_id, &cfg);
} else {
status = PJ_EINVAL;
}
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_set_online_status
*/
static PyObject *py_pjsua_acc_set_online_status(PyObject *pSelf,
PyObject *pArgs)
{
int is_online;
int acc_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) {
return NULL;
}
status = pjsua_acc_set_online_status(acc_id, is_online);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_set_online_status2
*/
static PyObject *py_pjsua_acc_set_online_status2(PyObject *pSelf,
PyObject *pArgs)
{
int is_online;
int acc_id;
int activity_id;
const char *activity_text = NULL;
const char *rpid_id = NULL;
pjrpid_element rpid;
pj_status_t status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiiss", &acc_id, &is_online,
&activity_id, &activity_text, &rpid_id))
{
return NULL;
}
pj_bzero(&rpid, sizeof(rpid));
rpid.type = PJRPID_ELEMENT_TYPE_PERSON;
rpid.activity = activity_id;
if (activity_text)
rpid.note = pj_str((char*)activity_text);
if (rpid_id)
rpid.id = pj_str((char*)rpid_id);
status = pjsua_acc_set_online_status2(acc_id, is_online, &rpid);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_set_registration
*/
static PyObject *py_pjsua_acc_set_registration(PyObject *pSelf,
PyObject *pArgs)
{
int renew;
int acc_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) {
return NULL;
}
status = pjsua_acc_set_registration(acc_id, renew);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_get_info
*/
static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs)
{
int acc_id;
PyObj_pjsua_acc_info * obj;
pjsua_acc_info info;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) {
return NULL;
}
status = pjsua_acc_get_info(acc_id, &info);
if (status == PJ_SUCCESS) {
obj = (PyObj_pjsua_acc_info*)
PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL);
PyObj_pjsua_acc_info_import(obj, &info);
return (PyObject*)obj;
} else {
return Py_BuildValue("");
}
}
/*
* py_pjsua_enum_accs
*/
static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *list;
pjsua_acc_id id[PJSUA_MAX_ACC];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(id);
status = pjsua_enum_accs(id, &c);
if (status != PJ_SUCCESS)
c = 0;
list = PyList_New(c);
for (i = 0; i < c; i++) {
PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
}
return (PyObject*)list;
}
/*
* py_pjsua_acc_enum_info
*/
static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *list;
pjsua_acc_info info[PJSUA_MAX_ACC];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
if (!PyArg_ParseTuple(pArgs, "")) {
return NULL;
}
c = PJ_ARRAY_SIZE(info);
status = pjsua_acc_enum_info(info, &c);
if (status != PJ_SUCCESS)
c = 0;
list = PyList_New(c);
for (i = 0; i < c; i++) {
PyObj_pjsua_acc_info *obj;
obj = (PyObj_pjsua_acc_info *)
PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL);
PyObj_pjsua_acc_info_import(obj, &info[i]);
PyList_SetItem(list, i, (PyObject*)obj);
}
return (PyObject*)list;
}
/*
* py_pjsua_acc_set_transport
*/
static PyObject *py_pjsua_acc_set_transport(PyObject *pSelf, PyObject *pArgs)
{
int acc_id, transport_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &transport_id)) {
return NULL;
}
status = pjsua_acc_set_transport(acc_id, transport_id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_acc_pres_notify
*/
static PyObject *py_pjsua_acc_pres_notify(PyObject *pSelf,
PyObject *pArgs)
{
int acc_id, state;
PyObject *arg_pres, *arg_msg_data, *arg_reason;
void *srv_pres;
pjsua_msg_data msg_data;
pj_str_t reason;
pj_bool_t with_body;
pj_pool_t *pool = NULL;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOiOO", &acc_id, &arg_pres,
&state, &arg_reason, &arg_msg_data))
{
return NULL;
}
srv_pres = (void*) PyLong_AsLong(arg_pres);
with_body = (state != PJSIP_EVSUB_STATE_TERMINATED);
if (arg_reason && PyBytes_Check(arg_reason)) {
reason = PyUnicode_ToPJ(arg_reason);
} else {
reason = pj_str("");
}
pjsua_msg_data_init(&msg_data);
if (arg_msg_data && arg_msg_data != Py_None) {
PyObj_pjsua_msg_data *omd = (PyObj_pjsua_msg_data *)arg_msg_data;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_pres_notify(acc_id, (pjsua_srv_pres*)srv_pres,
(pjsip_evsub_state)state, NULL,
&reason, with_body, &msg_data);
if (pool) {
pj_pool_release(pool);
}
return Py_BuildValue("i", status);
}
static char pjsua_acc_config_default_doc[] =
"_pjsua.Acc_Config _pjsua.acc_config_default () "
"Call this function to initialize account config with default values.";
static char pjsua_acc_get_count_doc[] =
"int _pjsua.acc_get_count () "
"Get number of current accounts.";
static char pjsua_acc_is_valid_doc[] =
"int _pjsua.acc_is_valid (int acc_id) "
"Check if the specified account ID is valid.";
static char pjsua_acc_set_default_doc[] =
"int _pjsua.acc_set_default (int acc_id) "
"Set default account to be used when incoming "
"and outgoing requests doesn't match any accounts.";
static char pjsua_acc_get_default_doc[] =
"int _pjsua.acc_get_default () "
"Get default account.";
static char pjsua_acc_add_doc[] =
"int, int _pjsua.acc_add (_pjsua.Acc_Config cfg, "
"int is_default) "
"Add a new account to pjsua. PJSUA must have been initialized "
"(with pjsua_init()) before calling this function.";
static char pjsua_acc_add_local_doc[] =
"int,int _pjsua.acc_add_local (int tid, "
"int is_default) "
"Add a local account. A local account is used to identify "
"local endpoint instead of a specific user, and for this reason, "
"a transport ID is needed to obtain the local address information.";
static char pjsua_acc_del_doc[] =
"int _pjsua.acc_del (int acc_id) "
"Delete account.";
static char pjsua_acc_modify_doc[] =
"int _pjsua.acc_modify (int acc_id, _pjsua.Acc_Config cfg) "
"Modify account information.";
static char pjsua_acc_set_online_status_doc[] =
"int _pjsua.acc_set_online_status2(int acc_id, int is_online) "
"Modify account's presence status to be advertised "
"to remote/presence subscribers.";
static char pjsua_acc_set_online_status2_doc[] =
"int _pjsua.acc_set_online_status (int acc_id, int is_online, "
"int activity_id, string activity_text) "
"Modify account's presence status to be advertised "
"to remote/presence subscribers.";
static char pjsua_acc_set_registration_doc[] =
"int _pjsua.acc_set_registration (int acc_id, int renew) "
"Update registration or perform unregistration.";
static char pjsua_acc_get_info_doc[] =
"_pjsua.Acc_Info _pjsua.acc_get_info (int acc_id) "
"Get account information.";
static char pjsua_enum_accs_doc[] =
"int[] _pjsua.enum_accs () "
"Enum accounts all account ids.";
static char pjsua_acc_enum_info_doc[] =
"_pjsua.Acc_Info[] _pjsua.acc_enum_info () "
"Enum accounts info.";
/* END OF LIB ACCOUNT */
/* LIB BUDDY */
/*
* py_pjsua_buddy_config_default
*/
static PyObject *py_pjsua_buddy_config_default(PyObject *pSelf,
PyObject *pArgs)
{
PyObj_pjsua_buddy_config *obj;
pjsua_buddy_config cfg;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_buddy_config_default(&cfg);
obj = (PyObj_pjsua_buddy_config *)
PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_config, NULL, NULL);
PyObj_pjsua_buddy_config_import(obj, &cfg);
return (PyObject *)obj;
}
/*
* py_pjsua_get_buddy_count
*/
static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs)
{
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
return Py_BuildValue("i", pjsua_get_buddy_count());
}
/*
* py_pjsua_buddy_is_valid
*/
static PyObject *py_pjsua_buddy_is_valid(PyObject *pSelf, PyObject *pArgs)
{
int id;
int is_valid;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
is_valid = pjsua_buddy_is_valid(id);
return Py_BuildValue("i", is_valid);
}
/*
* py_pjsua_enum_buddies
*/
static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *list;
pjsua_buddy_id id[PJSUA_MAX_BUDDIES];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(id);
status = pjsua_enum_buddies(id, &c);
if (status != PJ_SUCCESS)
c = 0;
list = PyList_New(c);
for (i = 0; i < c; i++) {
PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
}
return (PyObject*)list;
}
/*
* py_pjsua_buddy_find
*/
static PyObject *py_pjsua_buddy_find(PyObject *pSelf, PyObject *pArgs)
{
PyObject *pURI;
pj_str_t uri;
pjsua_buddy_id buddy_id;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "O", &pURI)) {
return NULL;
}
if (!PyBytes_Check(pURI))
return Py_BuildValue("i", PJSUA_INVALID_ID);
uri = PyUnicode_ToPJ(pURI);
buddy_id = pjsua_buddy_find(&uri);
return Py_BuildValue("i", buddy_id);
}
/*
* py_pjsua_buddy_get_info
*/
static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs)
{
int buddy_id;
pjsua_buddy_info info;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
return NULL;
}
status = pjsua_buddy_get_info(buddy_id, &info);
if (status == PJ_SUCCESS) {
PyObj_pjsua_buddy_info *obj;
obj = (PyObj_pjsua_buddy_info *)
PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info,
NULL, NULL);
PyObj_pjsua_buddy_info_import(obj, &info);
return (PyObject*)obj;
} else {
return Py_BuildValue("");
}
}
/*
* py_pjsua_buddy_add
*/
static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs)
{
PyObject *pCfg;
int buddy_id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "O", &pCfg)) {
return NULL;
}
if (pCfg != Py_None) {
pjsua_buddy_config cfg;
PyObj_pjsua_buddy_config *bc;
bc = (PyObj_pjsua_buddy_config *)pCfg;
pjsua_buddy_config_default(&cfg);
PyObj_pjsua_buddy_config_export(&cfg, bc);
status = pjsua_buddy_add(&cfg, &buddy_id);
} else {
status = PJ_EINVAL;
buddy_id = PJSUA_INVALID_ID;
}
return Py_BuildValue("ii", status, buddy_id);
}
/*
* py_pjsua_buddy_del
*/
static PyObject *py_pjsua_buddy_del(PyObject *pSelf, PyObject *pArgs)
{
int buddy_id;
int status;
PyObject *user_data;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
return NULL;
}
user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id);
Py_XDECREF(user_data);
status = pjsua_buddy_del(buddy_id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_buddy_set_user_data
*/
static PyObject *py_pjsua_buddy_set_user_data(PyObject *pSelf, PyObject *pArgs)
{
int buddy_id;
int status;
PyObject *user_data, *old_user_data;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &buddy_id, &user_data)) {
return NULL;
}
if (!pjsua_buddy_is_valid(buddy_id)) {
return Py_BuildValue("i", 0);
}
old_user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id);
status = pjsua_buddy_set_user_data(buddy_id, (void*)user_data);
if (status == PJ_SUCCESS) {
Py_XINCREF(user_data);
Py_XDECREF(old_user_data);
}
return Py_BuildValue("i", status);
}
/*
* py_pjsua_buddy_get_user_data
*/
static PyObject *py_pjsua_buddy_get_user_data(PyObject *pSelf, PyObject *pArgs)
{
int buddy_id;
PyObject *user_data;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
return NULL;
}
user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id);
return user_data? Py_BuildValue("O", user_data) : Py_BuildValue("");
}
/*
* py_pjsua_buddy_subscribe_pres
*/
static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf,
PyObject *pArgs)
{
int buddy_id;
int status;
int subscribe;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) {
return NULL;
}
status = pjsua_buddy_subscribe_pres(buddy_id, subscribe);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_pres_dump
*/
static PyObject *py_pjsua_pres_dump(PyObject *pSelf, PyObject *pArgs)
{
int verbose;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &verbose)) {
return NULL;
}
pjsua_pres_dump(verbose);
return Py_BuildValue("");
}
/*
* py_pjsua_im_send
*/
static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs)
{
int status;
int acc_id;
pj_str_t *mime_type, tmp_mime_type;
pj_str_t to, content;
PyObject *pTo;
PyObject *pMimeType;
PyObject *pContent;
pjsua_msg_data msg_data;
PyObject *pMsgData;
int user_data;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id,
&pTo, &pMimeType, &pContent, &pMsgData, &user_data))
{
return NULL;
}
if (pMimeType != Py_None) {
mime_type = &tmp_mime_type;
tmp_mime_type = PyUnicode_ToPJ(pMimeType);
} else {
mime_type = NULL;
}
to = PyUnicode_ToPJ(pTo);
content = PyUnicode_ToPJ(pContent);
pjsua_msg_data_init(&msg_data);
if (pMsgData != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)pMsgData;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_im_send(acc_id, &to, mime_type, &content,
&msg_data, (void*)(long)user_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i",status);
}
/*
* py_pjsua_im_typing
*/
static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs)
{
int status;
int acc_id;
pj_str_t to;
PyObject *pTo;
int is_typing;
pjsua_msg_data msg_data;
PyObject *pMsgData;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &pTo, &is_typing,
&pMsgData))
{
return NULL;
}
to = PyUnicode_ToPJ(pTo);
pjsua_msg_data_init(&msg_data);
if (pMsgData != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)pMsgData;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
static char pjsua_buddy_config_default_doc[] =
"_pjsua.Buddy_Config _pjsua.buddy_config_default () "
"Set default values to the buddy config.";
static char pjsua_get_buddy_count_doc[] =
"int _pjsua.get_buddy_count () "
"Get total number of buddies.";
static char pjsua_buddy_is_valid_doc[] =
"int _pjsua.buddy_is_valid (int buddy_id) "
"Check if buddy ID is valid.";
static char pjsua_enum_buddies_doc[] =
"int[] _pjsua.enum_buddies () "
"Enum buddy IDs.";
static char pjsua_buddy_get_info_doc[] =
"_pjsua.Buddy_Info _pjsua.buddy_get_info (int buddy_id) "
"Get detailed buddy info.";
static char pjsua_buddy_add_doc[] =
"int,int _pjsua.buddy_add (_pjsua.Buddy_Config cfg) "
"Add new buddy.";
static char pjsua_buddy_del_doc[] =
"int _pjsua.buddy_del (int buddy_id) "
"Delete buddy.";
static char pjsua_buddy_subscribe_pres_doc[] =
"int _pjsua.buddy_subscribe_pres (int buddy_id, int subscribe) "
"Enable/disable buddy's presence monitoring.";
static char pjsua_pres_dump_doc[] =
"void _pjsua.pres_dump (int verbose) "
"Dump presence subscriptions to log file.";
static char pjsua_im_send_doc[] =
"int _pjsua.im_send (int acc_id, string to, string mime_type, "
"string content, _pjsua.Msg_Data msg_data, int user_data) "
"Send instant messaging outside dialog, using the specified account "
"for route set and authentication.";
static char pjsua_im_typing_doc[] =
"int _pjsua.im_typing (int acc_id, string to, int is_typing, "
"_pjsua.Msg_Data msg_data) "
"Send typing indication outside dialog.";
/* END OF LIB BUDDY */
/* LIB MEDIA */
/*
* py_pjsua_conf_get_max_ports
*/
static PyObject *py_pjsua_conf_get_max_ports(PyObject *pSelf, PyObject *pArgs)
{
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
return Py_BuildValue("i", pjsua_conf_get_max_ports());
}
/*
* py_pjsua_conf_get_active_ports
*/
static PyObject *py_pjsua_conf_get_active_ports(PyObject *pSelf,
PyObject *pArgs)
{
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
return Py_BuildValue("i", pjsua_conf_get_active_ports());
}
/*
* py_pjsua_enum_conf_ports
*/
static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *list;
pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(id);
status = pjsua_enum_conf_ports(id, &c);
if (status != PJ_SUCCESS)
c = 0;
list = PyList_New(c);
for (i = 0; i < c; i++) {
PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
}
return (PyObject*)list;
}
/*
* py_pjsua_conf_get_port_info
*/
static PyObject *py_pjsua_conf_get_port_info(PyObject *pSelf, PyObject *pArgs)
{
int id;
PyObj_pjsua_conf_port_info *ret;
pjsua_conf_port_info info;
int status;
unsigned i;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_conf_get_port_info(id, &info);
ret = (PyObj_pjsua_conf_port_info *)
conf_port_info_new(&PyTyp_pjsua_conf_port_info, NULL, NULL);
ret->bits_per_sample = info.bits_per_sample;
ret->channel_count = info.channel_count;
ret->clock_rate = info.clock_rate;
ret->name = PyUnicode_FromPJ(&info.name);
ret->samples_per_frame = info.samples_per_frame;
ret->slot_id = info.slot_id;
Py_XDECREF(ret->listeners);
ret->listeners = PyList_New(info.listener_cnt);
for (i = 0; i < info.listener_cnt; i++) {
PyObject *item = Py_BuildValue("i",info.listeners[i]);
PyList_SetItem(ret->listeners, i, item);
}
return (PyObject*)ret;
}
/*
* py_pjsua_conf_remove_port
*/
static PyObject *py_pjsua_conf_remove_port(PyObject *pSelf, PyObject *pArgs)
{
int id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_conf_remove_port(id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_conf_connect
*/
static PyObject *py_pjsua_conf_connect(PyObject *pSelf, PyObject *pArgs)
{
int source, sink;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) {
return NULL;
}
status = pjsua_conf_connect(source, sink);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_conf_disconnect
*/
static PyObject *py_pjsua_conf_disconnect(PyObject *pSelf, PyObject *pArgs)
{
int source, sink;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) {
return NULL;
}
status = pjsua_conf_disconnect(source, sink);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_conf_set_tx_level
*/
static PyObject *py_pjsua_conf_set_tx_level(PyObject *pSelf, PyObject *pArgs)
{
int slot;
float level;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) {
return NULL;
}
status = pjsua_conf_adjust_tx_level(slot, level);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_conf_set_rx_level
*/
static PyObject *py_pjsua_conf_set_rx_level(PyObject *pSelf, PyObject *pArgs)
{
int slot;
float level;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) {
return NULL;
}
status = pjsua_conf_adjust_rx_level(slot, level);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_conf_get_signal_level
*/
static PyObject *py_pjsua_conf_get_signal_level(PyObject *pSelf,
PyObject *pArgs)
{
int slot;
unsigned tx_level, rx_level;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &slot)) {
return NULL;
}
status = pjsua_conf_get_signal_level(slot, &tx_level, &rx_level);
return Py_BuildValue("iff", status, (float)(tx_level/255.0),
(float)(rx_level/255.0));
}
/*
* py_pjsua_player_create
*/
static PyObject *py_pjsua_player_create(PyObject *pSelf, PyObject *pArgs)
{
int id;
int options;
PyObject *pFilename;
pj_str_t filename;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "Oi", &pFilename, &options)) {
return NULL;
}
filename = PyUnicode_ToPJ(pFilename);
status = pjsua_player_create(&filename, options, &id);
return Py_BuildValue("ii", status, id);
}
/*
* py_pjsua_playlist_create
*/
static PyObject *py_pjsua_playlist_create(PyObject *pSelf, PyObject *pArgs)
{
int id;
int options;
PyObject *pLabel, *pFileList;
pj_str_t label;
int count;
pj_str_t files[64];
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "OOi", &pLabel, &pFileList, &options)) {
return NULL;
}
label = PyUnicode_ToPJ(pLabel);
if (!PyList_Check(pFileList))
return Py_BuildValue("ii", PJ_EINVAL, PJSUA_INVALID_ID);
count = 0;
for (count=0; count<PyList_Size(pFileList) &&
count<PJ_ARRAY_SIZE(files); ++count)
{
files[count] = PyUnicode_ToPJ(PyList_GetItem(pFileList, count));
}
status = pjsua_playlist_create(files, count, &label, options, &id);
return Py_BuildValue("ii", status, id);
}
/*
* py_pjsua_player_get_conf_port
*/
static PyObject *py_pjsua_player_get_conf_port(PyObject *pSelf,
PyObject *pArgs)
{
int id, port_id;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
port_id = pjsua_player_get_conf_port(id);
return Py_BuildValue("i", port_id);
}
/*
* py_pjsua_player_set_pos
*/
static PyObject *py_pjsua_player_set_pos(PyObject *pSelf, PyObject *pArgs)
{
int id;
int samples;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &id, &samples)) {
return NULL;
}
if (samples < 0)
samples = 0;
status = pjsua_player_set_pos(id, samples);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_player_destroy
*/
static PyObject *py_pjsua_player_destroy(PyObject *pSelf, PyObject *pArgs)
{
int id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_player_destroy(id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_recorder_create
*/
static PyObject *py_pjsua_recorder_create(PyObject *pSelf, PyObject *pArgs)
{
int id, options;
int max_size;
PyObject *pFilename, *pEncParam;
pj_str_t filename;
int enc_type;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "OiOii", &pFilename, &enc_type, &pEncParam,
&max_size, &options))
{
return NULL;
}
filename = PyUnicode_ToPJ(pFilename);
status = pjsua_recorder_create(&filename, enc_type, NULL, max_size,
options, &id);
return Py_BuildValue("ii", status, id);
}
/*
* py_pjsua_recorder_get_conf_port
*/
static PyObject *py_pjsua_recorder_get_conf_port(PyObject *pSelf,
PyObject *pArgs)
{
int id, port_id;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
port_id = pjsua_recorder_get_conf_port(id);
return Py_BuildValue("i", port_id);
}
/*
* py_pjsua_recorder_destroy
*/
static PyObject *py_pjsua_recorder_destroy(PyObject *pSelf, PyObject *pArgs)
{
int id;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
return NULL;
}
status = pjsua_recorder_destroy(id);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_enum_snd_devs
*/
static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *ret;
pjmedia_snd_dev_info info[SND_DEV_NUM];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(info);
status = pjsua_enum_snd_devs(info, &c);
if (status != PJ_SUCCESS)
c = 0;
ret = PyList_New(c);
for (i = 0; i < c; i++) {
PyObj_pjmedia_snd_dev_info * obj;
obj = (PyObj_pjmedia_snd_dev_info *)
pjmedia_snd_dev_info_new(&PyTyp_pjmedia_snd_dev_info,
NULL, NULL);
obj->default_samples_per_sec = info[i].default_samples_per_sec;
obj->input_count = info[i].input_count;
obj->output_count = info[i].output_count;
obj->name = PyBytes_FromString(info[i].name);
PyList_SetItem(ret, i, (PyObject *)obj);
}
return (PyObject*)ret;
}
/*
* py_pjsua_get_snd_dev
*/
static PyObject *py_pjsua_get_snd_dev(PyObject *pSelf, PyObject *pArgs)
{
int capture_dev, playback_dev;
int status;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_get_snd_dev(&capture_dev, &playback_dev);
return Py_BuildValue("ii", capture_dev, playback_dev);
}
/*
* py_pjsua_set_snd_dev
*/
static PyObject *py_pjsua_set_snd_dev(PyObject *pSelf, PyObject *pArgs)
{
int capture_dev, playback_dev;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) {
return NULL;
}
status = pjsua_set_snd_dev(capture_dev, playback_dev);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_set_null_snd_dev
*/
static PyObject *py_pjsua_set_null_snd_dev(PyObject *pSelf, PyObject *pArgs)
{
int status;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_set_null_snd_dev();
return Py_BuildValue("i", status);
}
/*
* py_pjsua_set_ec
*/
static PyObject *py_pjsua_set_ec(PyObject *pSelf, PyObject *pArgs)
{
int options;
int tail_ms;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) {
return NULL;
}
status = pjsua_set_ec(tail_ms, options);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_get_ec_tail
*/
static PyObject *py_pjsua_get_ec_tail(PyObject *pSelf, PyObject *pArgs)
{
int status;
unsigned tail_ms;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
status = pjsua_get_ec_tail(&tail_ms);
if (status != PJ_SUCCESS)
tail_ms = 0;
return Py_BuildValue("i", tail_ms);
}
/*
* py_pjsua_enum_codecs
*/
static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *ret;
pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(info);
status = pjsua_enum_codecs(info, &c);
if (status != PJ_SUCCESS)
c = 0;
ret = PyList_New(c);
for (i = 0; i < c; i++) {
PyObj_pjsua_codec_info * obj;
obj = (PyObj_pjsua_codec_info *)
codec_info_new(&PyTyp_pjsua_codec_info, NULL, NULL);
obj->codec_id = PyUnicode_FromPJ(&info[i].codec_id);
obj->priority = info[i].priority;
PyList_SetItem(ret, i, (PyObject *)obj);
}
return (PyObject*)ret;
}
/*
* py_pjsua_codec_set_priority
*/
static PyObject *py_pjsua_codec_set_priority(PyObject *pSelf, PyObject *pArgs)
{
int status;
PyObject *pCodecId;
pj_str_t codec_id;
int priority;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "Oi", &pCodecId, &priority)) {
return NULL;
}
codec_id = PyUnicode_ToPJ(pCodecId);
if (priority < 0)
priority = 0;
if (priority > 255)
priority = 255;
status = pjsua_codec_set_priority(&codec_id, (pj_uint8_t)priority);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_codec_get_param
*/
static PyObject *py_pjsua_codec_get_param(PyObject *pSelf, PyObject *pArgs)
{
int status;
PyObject *pCodecId;
pj_str_t codec_id;
pjmedia_codec_param param;
PyObj_pjmedia_codec_param *ret;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "O", &pCodecId)) {
return NULL;
}
codec_id = PyUnicode_ToPJ(pCodecId);
status = pjsua_codec_get_param(&codec_id, &param);
if (status != PJ_SUCCESS)
return Py_BuildValue("");
ret = (PyObj_pjmedia_codec_param *)
pjmedia_codec_param_new(&PyTyp_pjmedia_codec_param, NULL, NULL);
ret->info->avg_bps = param.info.avg_bps;
ret->info->channel_cnt = param.info.channel_cnt;
ret->info->clock_rate = param.info.clock_rate;
ret->info->frm_ptime = param.info.frm_ptime;
ret->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample;
ret->info->pt = param.info.pt;
ret->setting->cng = param.setting.cng;
//ret->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode;
//ret->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode;
ret->setting->frm_per_pkt = param.setting.frm_per_pkt;
ret->setting->penh = param.setting.penh;
ret->setting->plc = param.setting.plc;
ret->setting->vad = param.setting.vad;
return (PyObject*)ret;
}
/*
* py_pjsua_codec_set_param
*/
static PyObject *py_pjsua_codec_set_param(PyObject *pSelf, PyObject *pArgs)
{
int status;
PyObject *pCodecId, *pCodecParam;
pj_str_t codec_id;
pjmedia_codec_param param;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "OO", &pCodecId, &pCodecParam)) {
return NULL;
}
codec_id = PyUnicode_ToPJ(pCodecId);
if (pCodecParam != Py_None) {
PyObj_pjmedia_codec_param *obj;
obj = (PyObj_pjmedia_codec_param *)pCodecParam;
param.info.avg_bps = obj->info->avg_bps;
param.info.channel_cnt = obj->info->channel_cnt;
param.info.clock_rate = obj->info->clock_rate;
param.info.frm_ptime = obj->info->frm_ptime;
param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample;
param.info.pt = obj->info->pt;
param.setting.cng = obj->setting->cng;
//param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode;
//param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode;
param.setting.frm_per_pkt = obj->setting->frm_per_pkt;
param.setting.penh = obj->setting->penh;
param.setting.plc = obj->setting->plc;
param.setting.vad = obj->setting->vad;
status = pjsua_codec_set_param(&codec_id, &param);
} else {
status = pjsua_codec_set_param(&codec_id, NULL);
}
return Py_BuildValue("i", status);
}
static char pjsua_conf_get_max_ports_doc[] =
"int _pjsua.conf_get_max_ports () "
"Get maxinum number of conference ports.";
static char pjsua_conf_get_active_ports_doc[] =
"int _pjsua.conf_get_active_ports () "
"Get current number of active ports in the bridge.";
static char pjsua_enum_conf_ports_doc[] =
"int[] _pjsua.enum_conf_ports () "
"Enumerate all conference ports.";
static char pjsua_conf_get_port_info_doc[] =
"_pjsua.Conf_Port_Info _pjsua.conf_get_port_info (int id) "
"Get information about the specified conference port";
static char pjsua_conf_remove_port_doc[] =
"int _pjsua.conf_remove_port (int id) "
"Remove arbitrary slot from the conference bridge. "
"Application should only call this function "
"if it registered the port manually.";
static char pjsua_conf_connect_doc[] =
"int _pjsua.conf_connect (int source, int sink) "
"Establish unidirectional media flow from souce to sink. "
"One source may transmit to multiple destinations/sink. "
"And if multiple sources are transmitting to the same sink, "
"the media will be mixed together. Source and sink may refer "
"to the same ID, effectively looping the media. "
"If bidirectional media flow is desired, application "
"needs to call this function twice, with the second "
"one having the arguments reversed.";
static char pjsua_conf_disconnect_doc[] =
"int _pjsua.conf_disconnect (int source, int sink) "
"Disconnect media flow from the source to destination port.";
static char pjsua_player_create_doc[] =
"int, int _pjsua.player_create (string filename, int options) "
"Create a file player, and automatically connect "
"this player to the conference bridge.";
static char pjsua_player_get_conf_port_doc[] =
"int _pjsua.player_get_conf_port (int) "
"Get conference port ID associated with player.";
static char pjsua_player_set_pos_doc[] =
"int _pjsua.player_set_pos (int id, int samples) "
"Set playback position.";
static char pjsua_player_destroy_doc[] =
"int _pjsua.player_destroy (int id) "
"Close the file, remove the player from the bridge, "
"and free resources associated with the file player.";
static char pjsua_recorder_create_doc[] =
"int, int _pjsua.recorder_create (string filename, "
"int enc_type, int enc_param, int max_size, int options) "
"Create a file recorder, and automatically connect this recorder "
"to the conference bridge. The recorder currently supports recording "
"WAV file, and on Windows, MP3 file. The type of the recorder to use "
"is determined by the extension of the file (e.g. '.wav' or '.mp3').";
static char pjsua_recorder_get_conf_port_doc[] =
"int _pjsua.recorder_get_conf_port (int id) "
"Get conference port associated with recorder.";
static char pjsua_recorder_destroy_doc[] =
"int _pjsua.recorder_destroy (int id) "
"Destroy recorder (this will complete recording).";
static char pjsua_enum_snd_devs_doc[] =
"_pjsua.PJMedia_Snd_Dev_Info[] _pjsua.enum_snd_devs (int count) "
"Enum sound devices.";
static char pjsua_get_snd_dev_doc[] =
"int, int _pjsua.get_snd_dev () "
"Get currently active sound devices. "
"If sound devices has not been created "
"(for example when pjsua_start() is not called), "
"it is possible that the function returns "
"PJ_SUCCESS with -1 as device IDs.";
static char pjsua_set_snd_dev_doc[] =
"int _pjsua.set_snd_dev (int capture_dev, int playback_dev) "
"Select or change sound device. Application may call this function "
"at any time to replace current sound device.";
static char pjsua_set_null_snd_dev_doc[] =
"int _pjsua.set_null_snd_dev () "
"Set pjsua to use null sound device. The null sound device only "
"provides the timing needed by the conference bridge, and will not "
"interract with any hardware.";
static char pjsua_set_ec_doc[] =
"int _pjsua.set_ec (int tail_ms, int options) "
"Configure the echo canceller tail length of the sound port.";
static char pjsua_get_ec_tail_doc[] =
"int _pjsua.get_ec_tail () "
"Get current echo canceller tail length.";
static char pjsua_enum_codecs_doc[] =
"_pjsua.Codec_Info[] _pjsua.enum_codecs () "
"Enum all supported codecs in the system.";
static char pjsua_codec_set_priority_doc[] =
"int _pjsua.codec_set_priority (string id, int priority) "
"Change codec priority.";
static char pjsua_codec_get_param_doc[] =
"_pjsua.PJMedia_Codec_Param _pjsua.codec_get_param (string id) "
"Get codec parameters";
static char pjsua_codec_set_param_doc[] =
"int _pjsua.codec_set_param (string id, "
"_pjsua.PJMedia_Codec_Param param) "
"Set codec parameters.";
/* END OF LIB MEDIA */
/* LIB CALL */
/*
* py_pjsua_call_get_max_count
*/
static PyObject *py_pjsua_call_get_max_count(PyObject *pSelf, PyObject *pArgs)
{
int count;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
count = pjsua_call_get_max_count();
return Py_BuildValue("i", count);
}
/*
* py_pjsua_call_get_count
*/
static PyObject *py_pjsua_call_get_count(PyObject *pSelf, PyObject *pArgs)
{
int count;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
count = pjsua_call_get_count();
return Py_BuildValue("i", count);
}
/*
* py_pjsua_enum_calls
*/
static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs)
{
pj_status_t status;
PyObject *ret;
pjsua_transport_id id[PJSUA_MAX_CALLS];
unsigned c, i;
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
c = PJ_ARRAY_SIZE(id);
status = pjsua_enum_calls(id, &c);
if (status != PJ_SUCCESS)
c = 0;
ret = PyList_New(c);
for (i = 0; i < c; i++) {
PyList_SetItem(ret, i, Py_BuildValue("i", id[i]));
}
return (PyObject*)ret;
}
/*
* py_pjsua_call_make_call
*/
static PyObject *py_pjsua_call_make_call(PyObject *pSelf, PyObject *pArgs)
{
int status;
int acc_id;
pj_str_t dst_uri;
PyObject *pDstUri, *pMsgData, *pUserData;
pjsua_call_setting option;
pjsua_msg_data msg_data;
int call_id;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
pjsua_call_setting_default(&option);
if (!PyArg_ParseTuple(pArgs, "iOIOO", &acc_id, &pDstUri, &option.flag,
&pUserData, &pMsgData))
{
return NULL;
}
dst_uri = PyUnicode_ToPJ(pDstUri);
pjsua_msg_data_init(&msg_data);
if (pMsgData != Py_None) {
PyObj_pjsua_msg_data * omd;
omd = (PyObj_pjsua_msg_data *)pMsgData;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
Py_XINCREF(pUserData);
status = pjsua_call_make_call(acc_id, &dst_uri,
&option, (void*)pUserData,
&msg_data, &call_id);
if (pool != NULL)
pj_pool_release(pool);
if (status != PJ_SUCCESS) {
Py_XDECREF(pUserData);
}
return Py_BuildValue("ii", status, call_id);
}
/*
* py_pjsua_call_is_active
*/
static PyObject *py_pjsua_call_is_active(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
int is_active;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) {
return NULL;
}
is_active = pjsua_call_is_active(call_id);
return Py_BuildValue("i", is_active);
}
/*
* py_pjsua_call_has_media
*/
static PyObject *py_pjsua_call_has_media(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
int has_media;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) {
return NULL;
}
has_media = pjsua_call_has_media(call_id);
return Py_BuildValue("i", has_media);
}
/*
* py_pjsua_call_get_conf_port
*/
static PyObject* py_pjsua_call_get_conf_port(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
int port_id;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) {
return NULL;
}
port_id = pjsua_call_get_conf_port(call_id);
return Py_BuildValue("i", port_id);
}
/*
* py_pjsua_call_get_info
*/
static PyObject* py_pjsua_call_get_info(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
int status;
PyObj_pjsua_call_info *ret;
pjsua_call_info info;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) {
return NULL;
}
status = pjsua_call_get_info(call_id, &info);
if (status != PJ_SUCCESS)
return Py_BuildValue("");
ret = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info,
NULL, NULL);
ret->acc_id = info.acc_id;
Py_XDECREF(ret->call_id);
ret->call_id = PyUnicode_FromPJ(&info.call_id);
ret->conf_slot = info.conf_slot;
ret->connect_duration = info.connect_duration.sec * 1000 +
info.connect_duration.msec;
ret->total_duration = info.total_duration.sec * 1000 +
info.total_duration.msec;
ret->id = info.id;
ret->last_status = info.last_status;
Py_XDECREF(ret->last_status_text);
ret->last_status_text = PyUnicode_FromPJ(&info.last_status_text);
Py_XDECREF(ret->local_contact);
ret->local_contact = PyUnicode_FromPJ(&info.local_contact);
Py_XDECREF(ret->local_info);
ret->local_info = PyUnicode_FromPJ(&info.local_info);
Py_XDECREF(ret->remote_contact);
ret->remote_contact = PyUnicode_FromPJ(&info.remote_contact);
Py_XDECREF(ret->remote_info);
ret->remote_info = PyUnicode_FromPJ(&info.remote_info);
ret->media_dir = info.media_dir;
ret->media_status = info.media_status;
ret->role = info.role;
ret->state = info.state;
Py_XDECREF(ret->state_text);
ret->state_text = PyUnicode_FromPJ(&info.state_text);
return (PyObject*)ret;
}
/*
* py_pjsua_call_set_user_data
*/
static PyObject *py_pjsua_call_set_user_data(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
PyObject *pUserData, *old_user_data;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pUserData)) {
return NULL;
}
old_user_data = (PyObject*) pjsua_call_get_user_data(call_id);
if (old_user_data == pUserData) {
return Py_BuildValue("i", PJ_SUCCESS);
}
Py_XINCREF(pUserData);
Py_XDECREF(old_user_data);
status = pjsua_call_set_user_data(call_id, (void*)pUserData);
if (status != PJ_SUCCESS) {
Py_XDECREF(pUserData);
}
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_get_user_data
*/
static PyObject *py_pjsua_call_get_user_data(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
PyObject *user_data;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) {
return NULL;
}
user_data = (PyObject*)pjsua_call_get_user_data(call_id);
return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue("");
}
/*
* py_pjsua_call_answer
*/
static PyObject *py_pjsua_call_answer(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
pj_str_t * reason, tmp_reason;
PyObject *pReason;
unsigned code;
pjsua_msg_data msg_data;
PyObject * omdObj;
pj_pool_t * pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason, &omdObj)) {
return NULL;
}
if (pReason == Py_None) {
reason = NULL;
} else {
reason = &tmp_reason;
tmp_reason = PyUnicode_ToPJ(pReason);
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_answer(call_id, code, reason, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_hangup
*/
static PyObject *py_pjsua_call_hangup(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
pj_str_t *reason, tmp_reason;
PyObject *pReason;
unsigned code;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason,
&omdObj))
{
return NULL;
}
if (pReason == Py_None) {
reason = NULL;
} else {
reason = &tmp_reason;
tmp_reason = PyUnicode_ToPJ(pReason);
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_hangup(call_id, code, reason, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_set_hold
*/
static PyObject *py_pjsua_call_set_hold(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj)) {
return NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_set_hold(call_id, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i",status);
}
/*
* py_pjsua_call_reinvite
*/
static PyObject *py_pjsua_call_reinvite(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
int unhold;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj)) {
return NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_reinvite(call_id, unhold, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_update
*/
static PyObject *py_pjsua_call_update(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
int option;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &option, &omdObj)) {
return NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_update(call_id, option, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_send_request
*/
static PyObject *py_pjsua_call_send_request(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
PyObject *pMethod;
pj_str_t method;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pMethod, &omdObj)) {
return NULL;
}
if (!PyUnicode_Check(pMethod)) {
return NULL;
}
method = PyUnicode_ToPJ(pMethod);
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_send_request(call_id, &method, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_xfer
*/
static PyObject *py_pjsua_call_xfer(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
pj_str_t dest;
PyObject *pDstUri;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pDstUri, &omdObj)) {
return NULL;
}
if (!PyBytes_Check(pDstUri))
return NULL;
dest = PyUnicode_ToPJ(pDstUri);
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_xfer(call_id, &dest, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_xfer_replaces
*/
static PyObject *py_pjsua_call_xfer_replaces(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
int dest_call_id;
unsigned options;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &dest_call_id,
&options, &omdObj))
{
return NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_xfer_replaces(call_id, dest_call_id, options,
&msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_dial_dtmf
*/
static PyObject *py_pjsua_call_dial_dtmf(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
PyObject *pDigits;
pj_str_t digits;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pDigits)) {
return NULL;
}
if (!PyBytes_Check(pDigits))
return Py_BuildValue("i", PJ_EINVAL);
digits = PyUnicode_ToPJ(pDigits);
status = pjsua_call_dial_dtmf(call_id, &digits);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_send_im
*/
static PyObject *py_pjsua_call_send_im(PyObject *pSelf, PyObject *pArgs)
{
int status;
int call_id;
pj_str_t content;
pj_str_t * mime_type, tmp_mime_type;
PyObject *pMimeType, *pContent, *omdObj;
pjsua_msg_data msg_data;
int user_data;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iOOOi", &call_id, &pMimeType, &pContent,
&omdObj, &user_data))
{
return NULL;
}
if (!PyBytes_Check(pContent))
return Py_BuildValue("i", PJ_EINVAL);
content = PyUnicode_ToPJ(pContent);
if (PyBytes_Check(pMimeType)) {
mime_type = &tmp_mime_type;
tmp_mime_type = PyUnicode_ToPJ(pMimeType);
} else {
mime_type = NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data * omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_send_im(call_id, mime_type, &content,
&msg_data, (void*)(long)user_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_send_typing_ind
*/
static PyObject *py_pjsua_call_send_typing_ind(PyObject *pSelf,
PyObject *pArgs)
{
int status;
int call_id;
int is_typing;
pjsua_msg_data msg_data;
PyObject *omdObj;
pj_pool_t *pool = NULL;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) {
return NULL;
}
pjsua_msg_data_init(&msg_data);
if (omdObj != Py_None) {
PyObj_pjsua_msg_data *omd;
omd = (PyObj_pjsua_msg_data *)omdObj;
msg_data.content_type = PyUnicode_ToPJ(omd->content_type);
msg_data.msg_body = PyUnicode_ToPJ(omd->msg_body);
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE);
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
}
status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data);
if (pool)
pj_pool_release(pool);
return Py_BuildValue("i", status);
}
/*
* py_pjsua_call_hangup_all
*/
static PyObject *py_pjsua_call_hangup_all(PyObject *pSelf, PyObject *pArgs)
{
PJ_UNUSED_ARG(pSelf);
PJ_UNUSED_ARG(pArgs);
pjsua_call_hangup_all();
return Py_BuildValue("");
}
/*
* py_pjsua_call_dump
*/
static PyObject *py_pjsua_call_dump(PyObject *pSelf, PyObject *pArgs)
{
int call_id;
int with_media;
PyObject *ret;
PyObject *pIndent;
char *buffer;
char *indent;
unsigned maxlen;
int status;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media,
&maxlen, &pIndent))
{
return NULL;
}
buffer = (char*) malloc(maxlen * sizeof(char));
indent = PyBytes_AsString(pIndent);
status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent);
if (status != PJ_SUCCESS) {
free(buffer);
return PyBytes_FromString("");
}
ret = PyBytes_FromString(buffer);
free(buffer);
return (PyObject*)ret;
}
/*
* py_pjsua_dump
* Dump application states.
*/
static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs)
{
int detail;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &detail)) {
return NULL;
}
pjsua_dump(detail);
return Py_BuildValue("");
}
/*
* py_pj_strerror
*/
static PyObject *py_pj_strerror(PyObject *pSelf, PyObject *pArgs)
{
int err;
char err_msg[PJ_ERR_MSG_SIZE];
pj_str_t ret;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "i", &err)) {
return NULL;
}
ret = pj_strerror(err, err_msg, sizeof(err_msg));
return PyBytes_FromStringAndSize(err_msg, ret.slen);
}
/*
* py_pj_parse_simple_sip
*/
static PyObject *py_pj_parse_simple_sip(PyObject *pSelf, PyObject *pArgs)
{
const char *arg_uri;
pj_pool_t *pool;
char tmp[PJSIP_MAX_URL_SIZE];
pjsip_uri *uri;
pjsip_sip_uri *sip_uri;
PyObject *ret, *item;
PJ_UNUSED_ARG(pSelf);
if (!PyArg_ParseTuple(pArgs, "s", &arg_uri)) {
return NULL;
}
strncpy(tmp, arg_uri, sizeof(tmp));
tmp[sizeof(tmp)-1] = '\0';
pool = pjsua_pool_create("py_pj_parse_simple_sip", 512, 512);
uri = pjsip_parse_uri(pool, tmp, strlen(tmp), 0);
if (uri == NULL || (!PJSIP_URI_SCHEME_IS_SIP(uri) &&
!PJSIP_URI_SCHEME_IS_SIPS(uri))) {
pj_pool_release(pool);
return Py_BuildValue("");
}
ret = PyTuple_New(5);
sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(uri);
/* Scheme */
item = PyUnicode_FromPJ(pjsip_uri_get_scheme(uri));
PyTuple_SetItem(ret, 0, item);
/* Username */
item = PyUnicode_FromPJ(&sip_uri->user);
PyTuple_SetItem(ret, 1, item);
/* Host */
item = PyUnicode_FromPJ(&sip_uri->host);
PyTuple_SetItem(ret, 2, item);
/* Port */
if (sip_uri->port == 5060) {
sip_uri->port = 0;
}
item = Py_BuildValue("i", sip_uri->port);
PyTuple_SetItem(ret, 3, item);
/* Transport */
if (pj_stricmp2(&sip_uri->transport_param, "udp")) {
sip_uri->transport_param.ptr = "";
sip_uri->transport_param.slen = 0;
}
item = PyUnicode_FromPJ(&sip_uri->transport_param);
PyTuple_SetItem(ret, 4, item);
pj_pool_release(pool);
return ret;
}
static char pjsua_call_get_max_count_doc[] =
"int _pjsua.call_get_max_count () "
"Get maximum number of calls configured in pjsua.";
static char pjsua_call_get_count_doc[] =
"int _pjsua.call_get_count () "
"Get number of currently active calls.";
static char pjsua_enum_calls_doc[] =
"int[] _pjsua.enum_calls () "
"Get maximum number of calls configured in pjsua.";
static char pjsua_call_make_call_doc[] =
"int,int _pjsua.call_make_call (int acc_id, string dst_uri, int options,"
"int user_data, _pjsua.Msg_Data msg_data) "
"Make outgoing call to the specified URI using the specified account.";
static char pjsua_call_is_active_doc[] =
"int _pjsua.call_is_active (int call_id) "
"Check if the specified call has active INVITE session and the INVITE "
"session has not been disconnected.";
static char pjsua_call_has_media_doc[] =
"int _pjsua.call_has_media (int call_id) "
"Check if call has an active media session.";
static char pjsua_call_get_conf_port_doc[] =
"int _pjsua.call_get_conf_port (int call_id) "
"Get the conference port identification associated with the call.";
static char pjsua_call_get_info_doc[] =
"_pjsua.Call_Info _pjsua.call_get_info (int call_id) "
"Obtain detail information about the specified call.";
static char pjsua_call_set_user_data_doc[] =
"int _pjsua.call_set_user_data (int call_id, int user_data) "
"Attach application specific data to the call.";
static char pjsua_call_get_user_data_doc[] =
"int _pjsua.call_get_user_data (int call_id) "
"Get user data attached to the call.";
static char pjsua_call_answer_doc[] =
"int _pjsua.call_answer (int call_id, int code, string reason, "
"_pjsua.Msg_Data msg_data) "
"Send response to incoming INVITE request.";
static char pjsua_call_hangup_doc[] =
"int _pjsua.call_hangup (int call_id, int code, string reason, "
"_pjsua.Msg_Data msg_data) "
"Hangup call by using method that is appropriate according "
"to the call state.";
static char pjsua_call_set_hold_doc[] =
"int _pjsua.call_set_hold (int call_id, _pjsua.Msg_Data msg_data) "
"Put the specified call on hold.";
static char pjsua_call_reinvite_doc[] =
"int _pjsua.call_reinvite (int call_id, int unhold, "
"_pjsua.Msg_Data msg_data) "
"Send re-INVITE (to release hold).";
static char pjsua_call_xfer_doc[] =
"int _pjsua.call_xfer (int call_id, string dest, "
"_pjsua.Msg_Data msg_data) "
"Initiate call transfer to the specified address. "
"This function will send REFER request to instruct remote call party "
"to initiate a new INVITE session to the specified destination/target.";
static char pjsua_call_xfer_replaces_doc[] =
"int _pjsua.call_xfer_replaces (int call_id, int dest_call_id, "
"int options, _pjsua.Msg_Data msg_data) "
"Initiate attended call transfer. This function will send REFER request "
"to instruct remote call party to initiate new INVITE session to the URL "
"of dest_call_id. The party at dest_call_id then should 'replace' the call"
"with us with the new call from the REFER recipient.";
static char pjsua_call_dial_dtmf_doc[] =
"int _pjsua.call_dial_dtmf (int call_id, string digits) "
"Send DTMF digits to remote using RFC 2833 payload formats.";
static char pjsua_call_send_im_doc[] =
"int _pjsua.call_send_im (int call_id, string mime_type, string content,"
"_pjsua.Msg_Data msg_data, int user_data) "
"Send instant messaging inside INVITE session.";
static char pjsua_call_send_typing_ind_doc[] =
"int _pjsua.call_send_typing_ind (int call_id, int is_typing, "
"_pjsua.Msg_Data msg_data) "
"Send IM typing indication inside INVITE session.";
static char pjsua_call_hangup_all_doc[] =
"void _pjsua.call_hangup_all () "
"Terminate all calls.";
static char pjsua_call_dump_doc[] =
"int _pjsua.call_dump (int call_id, int with_media, int maxlen, "
"string indent) "
"Dump call and media statistics to string.";
/* END OF LIB CALL */
/*
* Map of function names to functions
*/
static PyMethodDef py_pjsua_methods[] =
{
{
"thread_register", py_pjsua_thread_register, METH_VARARGS,
pjsua_thread_register_doc
},
{
"perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc
},
{
"create", py_pjsua_create, METH_VARARGS, pjsua_create_doc
},
{
"init", py_pjsua_init, METH_VARARGS, pjsua_init_doc
},
{
"start", py_pjsua_start, METH_VARARGS, pjsua_start_doc
},
{
"destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc
},
{
"handle_events", py_pjsua_handle_events, METH_VARARGS,
pjsua_handle_events_doc
},
{
"verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS,
pjsua_verify_sip_url_doc
},
{
"reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS,
pjsua_reconfigure_logging_doc
},
{
"logging_config_default", py_pjsua_logging_config_default,
METH_VARARGS, pjsua_logging_config_default_doc
},
{
"config_default", py_pjsua_config_default, METH_VARARGS,
pjsua_config_default_doc
},
{
"media_config_default", py_pjsua_media_config_default, METH_VARARGS,
pjsua_media_config_default_doc
},
{
"msg_data_init", py_pjsua_msg_data_init, METH_VARARGS,
pjsua_msg_data_init_doc
},
{
"transport_config_default", py_pjsua_transport_config_default,
METH_VARARGS,pjsua_transport_config_default_doc
},
{
"transport_create", py_pjsua_transport_create, METH_VARARGS,
pjsua_transport_create_doc
},
{
"transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS,
pjsua_enum_transports_doc
},
{
"transport_get_info", py_pjsua_transport_get_info, METH_VARARGS,
pjsua_transport_get_info_doc
},
{
"transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS,
pjsua_transport_set_enable_doc
},
{
"transport_close", py_pjsua_transport_close, METH_VARARGS,
pjsua_transport_close_doc
},
{
"acc_config_default", py_pjsua_acc_config_default, METH_VARARGS,
pjsua_acc_config_default_doc
},
{
"acc_get_count", py_pjsua_acc_get_count, METH_VARARGS,
pjsua_acc_get_count_doc
},
{
"acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS,
pjsua_acc_is_valid_doc
},
{
"acc_set_default", py_pjsua_acc_set_default, METH_VARARGS,
pjsua_acc_set_default_doc
},
{
"acc_get_default", py_pjsua_acc_get_default, METH_VARARGS,
pjsua_acc_get_default_doc
},
{
"acc_add", py_pjsua_acc_add, METH_VARARGS,
pjsua_acc_add_doc
},
{
"acc_add_local", py_pjsua_acc_add_local, METH_VARARGS,
pjsua_acc_add_local_doc
},
{
"acc_del", py_pjsua_acc_del, METH_VARARGS,
pjsua_acc_del_doc
},
{
"acc_set_user_data", py_pjsua_acc_set_user_data, METH_VARARGS,
"Accociate user data with the account"
},
{
"acc_get_user_data", py_pjsua_acc_get_user_data, METH_VARARGS,
"Get account's user data"
},
{
"acc_modify", py_pjsua_acc_modify, METH_VARARGS,
pjsua_acc_modify_doc
},
{
"acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS,
pjsua_acc_set_online_status_doc
},
{
"acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS,
pjsua_acc_set_online_status2_doc
},
{
"acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS,
pjsua_acc_set_registration_doc
},
{
"acc_get_info", py_pjsua_acc_get_info, METH_VARARGS,
pjsua_acc_get_info_doc
},
{
"acc_pres_notify", py_pjsua_acc_pres_notify, METH_VARARGS,
"Accept or reject subscription request"
},
{
"enum_accs", py_pjsua_enum_accs, METH_VARARGS,
pjsua_enum_accs_doc
},
{
"acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS,
pjsua_acc_enum_info_doc
},
{
"acc_set_transport", py_pjsua_acc_set_transport, METH_VARARGS,
"Lock transport to use the specified transport"
},
{
"buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS,
pjsua_buddy_config_default_doc
},
{
"get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS,
pjsua_get_buddy_count_doc
},
{
"buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS,
pjsua_buddy_is_valid_doc
},
{
"enum_buddies", py_pjsua_enum_buddies, METH_VARARGS,
pjsua_enum_buddies_doc
},
{
"buddy_find", py_pjsua_buddy_find, METH_VARARGS,
"Find buddy with the specified URI"
},
{
"buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS,
pjsua_buddy_get_info_doc
},
{
"buddy_add", py_pjsua_buddy_add, METH_VARARGS,
pjsua_buddy_add_doc
},
{
"buddy_del", py_pjsua_buddy_del, METH_VARARGS,
pjsua_buddy_del_doc
},
{
"buddy_set_user_data", py_pjsua_buddy_set_user_data, METH_VARARGS,
"Associate user data to the buddy object"
},
{
"buddy_get_user_data", py_pjsua_buddy_get_user_data, METH_VARARGS,
"Get buddy user data"
},
{
"buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS,
pjsua_buddy_subscribe_pres_doc
},
{
"pres_dump", py_pjsua_pres_dump, METH_VARARGS,
pjsua_pres_dump_doc
},
{
"im_send", py_pjsua_im_send, METH_VARARGS,
pjsua_im_send_doc
},
{
"im_typing", py_pjsua_im_typing, METH_VARARGS,
pjsua_im_typing_doc
},
{
"conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS,
pjsua_conf_get_max_ports_doc
},
{
"conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS,
pjsua_conf_get_active_ports_doc
},
{
"enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS,
pjsua_enum_conf_ports_doc
},
{
"conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS,
pjsua_conf_get_port_info_doc
},
{
"conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS,
pjsua_conf_remove_port_doc
},
{
"conf_connect", py_pjsua_conf_connect, METH_VARARGS,
pjsua_conf_connect_doc
},
{
"conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS,
pjsua_conf_disconnect_doc
},
{
"conf_set_tx_level", py_pjsua_conf_set_tx_level, METH_VARARGS,
"Adjust the signal level to be transmitted from the bridge to the"
" specified port by making it louder or quieter"
},
{
"conf_set_rx_level", py_pjsua_conf_set_rx_level, METH_VARARGS,
"Adjust the signal level to be received from the specified port (to"
" the bridge) by making it louder or quieter"
},
{
"conf_get_signal_level", py_pjsua_conf_get_signal_level, METH_VARARGS,
"Get last signal level transmitted to or received from the specified port"
},
{
"player_create", py_pjsua_player_create, METH_VARARGS,
pjsua_player_create_doc
},
{
"playlist_create", py_pjsua_playlist_create, METH_VARARGS,
"Create WAV playlist"
},
{
"player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS,
pjsua_player_get_conf_port_doc
},
{
"player_set_pos", py_pjsua_player_set_pos, METH_VARARGS,
pjsua_player_set_pos_doc
},
{
"player_destroy", py_pjsua_player_destroy, METH_VARARGS,
pjsua_player_destroy_doc
},
{
"recorder_create", py_pjsua_recorder_create, METH_VARARGS,
pjsua_recorder_create_doc
},
{
"recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS,
pjsua_recorder_get_conf_port_doc
},
{
"recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS,
pjsua_recorder_destroy_doc
},
{
"enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS,
pjsua_enum_snd_devs_doc
},
{
"get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS,
pjsua_get_snd_dev_doc
},
{
"set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS,
pjsua_set_snd_dev_doc
},
{
"set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS,
pjsua_set_null_snd_dev_doc
},
{
"set_ec", py_pjsua_set_ec, METH_VARARGS,
pjsua_set_ec_doc
},
{
"get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS,
pjsua_get_ec_tail_doc
},
{
"enum_codecs", py_pjsua_enum_codecs, METH_VARARGS,
pjsua_enum_codecs_doc
},
{
"codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS,
pjsua_codec_set_priority_doc
},
{
"codec_get_param", py_pjsua_codec_get_param, METH_VARARGS,
pjsua_codec_get_param_doc
},
{
"codec_set_param", py_pjsua_codec_set_param, METH_VARARGS,
pjsua_codec_set_param_doc
},
{
"call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS,
pjsua_call_get_max_count_doc
},
{
"call_get_count", py_pjsua_call_get_count, METH_VARARGS,
pjsua_call_get_count_doc
},
{
"enum_calls", py_pjsua_enum_calls, METH_VARARGS,
pjsua_enum_calls_doc
},
{
"call_make_call", py_pjsua_call_make_call, METH_VARARGS,
pjsua_call_make_call_doc
},
{
"call_is_active", py_pjsua_call_is_active, METH_VARARGS,
pjsua_call_is_active_doc
},
{
"call_has_media", py_pjsua_call_has_media, METH_VARARGS,
pjsua_call_has_media_doc
},
{
"call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS,
pjsua_call_get_conf_port_doc
},
{
"call_get_info", py_pjsua_call_get_info, METH_VARARGS,
pjsua_call_get_info_doc
},
{
"call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS,
pjsua_call_set_user_data_doc
},
{
"call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS,
pjsua_call_get_user_data_doc
},
{
"call_answer", py_pjsua_call_answer, METH_VARARGS,
pjsua_call_answer_doc
},
{
"call_hangup", py_pjsua_call_hangup, METH_VARARGS,
pjsua_call_hangup_doc
},
{
"call_set_hold", py_pjsua_call_set_hold, METH_VARARGS,
pjsua_call_set_hold_doc
},
{
"call_reinvite", py_pjsua_call_reinvite, METH_VARARGS,
pjsua_call_reinvite_doc
},
{
"call_update", py_pjsua_call_update, METH_VARARGS,
"Send UPDATE"
},
{
"call_xfer", py_pjsua_call_xfer, METH_VARARGS,
pjsua_call_xfer_doc
},
{
"call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS,
pjsua_call_xfer_replaces_doc
},
{
"call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS,
pjsua_call_dial_dtmf_doc
},
{
"call_send_im", py_pjsua_call_send_im, METH_VARARGS,
pjsua_call_send_im_doc
},
{
"call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS,
pjsua_call_send_typing_ind_doc
},
{
"call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS,
pjsua_call_hangup_all_doc
},
{
"call_dump", py_pjsua_call_dump, METH_VARARGS,
pjsua_call_dump_doc
},
{
"call_send_request", py_pjsua_call_send_request, METH_VARARGS,
"Send arbitrary request"
},
{
"dump", py_pjsua_dump, METH_VARARGS, "Dump application state"
},
{
"strerror", py_pj_strerror, METH_VARARGS, "Get error message"
},
{
"parse_simple_uri", py_pj_parse_simple_sip, METH_VARARGS, "Parse URI"
},
{NULL, NULL} /* end of function list */
};
static int py_pjsua_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(GETSTATE(m)->error);
return 0;
}
static int py_pjsua_clear(PyObject *m) {
Py_CLEAR(GETSTATE(m)->error);
return 0;
}
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"pjsua",
NULL,
sizeof(struct module_state),
py_pjsua_methods,
NULL,
py_pjsua_traverse,
py_pjsua_clear,
NULL
};
#define INITERROR return NULL
PyObject *
PyInit__pjsua(void)
{
PyObject* m = NULL;
#define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name)
PyEval_InitThreads();
if (PyType_Ready(&PyTyp_pjsua_callback) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_config) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_msg_data) < 0)
INITERROR;
PyTyp_pjsua_media_config.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyTyp_pjsua_media_config) < 0)
INITERROR;
PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0)
INITERROR;
PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0)
INITERROR;
/* LIB TRANSPORT */
if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0)
INITERROR;
/* END OF LIB TRANSPORT */
/* LIB ACCOUNT */
if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0)
INITERROR;
/* END OF LIB ACCOUNT */
/* LIB BUDDY */
if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0)
INITERROR;
/* END OF LIB BUDDY */
/* LIB MEDIA */
if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0)
INITERROR;
PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0)
INITERROR;
PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0)
INITERROR;
if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0)
INITERROR;
/* END OF LIB MEDIA */
/* LIB CALL */
if (PyType_Ready(&PyTyp_pjsua_call_info) < 0)
INITERROR;
/* END OF LIB CALL */
m = PyModule_Create(&moduledef);
Py_INCREF(&PyTyp_pjsua_callback);
PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback);
Py_INCREF(&PyTyp_pjsua_config);
PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config);
Py_INCREF(&PyTyp_pjsua_media_config);
PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config);
Py_INCREF(&PyTyp_pjsua_logging_config);
PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_config);
Py_INCREF(&PyTyp_pjsua_msg_data);
PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data);
Py_INCREF(&PyTyp_pjsip_cred_info);
PyModule_AddObject(m, "Pjsip_Cred_Info",
(PyObject *)&PyTyp_pjsip_cred_info
);
Py_INCREF(&PyTyp_pjsip_rx_data);
PyModule_AddObject(m, "Pjsip_Rx_Data",
(PyObject *)&PyTyp_pjsip_rx_data
);
/* LIB TRANSPORT */
Py_INCREF(&PyTyp_pjsua_transport_config);
PyModule_AddObject
(m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config);
Py_INCREF(&PyTyp_pjsua_transport_info);
PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info);
/* END OF LIB TRANSPORT */
/* LIB ACCOUNT */
Py_INCREF(&PyTyp_pjsua_acc_config);
PyModule_AddObject(m, "Acc_Config", (PyObject *)&PyTyp_pjsua_acc_config);
Py_INCREF(&PyTyp_pjsua_acc_info);
PyModule_AddObject(m, "Acc_Info", (PyObject *)&PyTyp_pjsua_acc_info);
/* END OF LIB ACCOUNT */
/* LIB BUDDY */
Py_INCREF(&PyTyp_pjsua_buddy_config);
PyModule_AddObject(m, "Buddy_Config", (PyObject *)&PyTyp_pjsua_buddy_config);
Py_INCREF(&PyTyp_pjsua_buddy_info);
PyModule_AddObject(m, "Buddy_Info", (PyObject *)&PyTyp_pjsua_buddy_info);
/* END OF LIB BUDDY */
/* LIB MEDIA */
Py_INCREF(&PyTyp_pjsua_codec_info);
PyModule_AddObject(m, "Codec_Info", (PyObject *)&PyTyp_pjsua_codec_info);
Py_INCREF(&PyTyp_pjsua_conf_port_info);
PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info);
Py_INCREF(&PyTyp_pjmedia_snd_dev_info);
PyModule_AddObject(m, "PJMedia_Snd_Dev_Info",
(PyObject *)&PyTyp_pjmedia_snd_dev_info);
Py_INCREF(&PyTyp_pjmedia_codec_param_info);
PyModule_AddObject(m, "PJMedia_Codec_Param_Info",
(PyObject *)&PyTyp_pjmedia_codec_param_info);
Py_INCREF(&PyTyp_pjmedia_codec_param_setting);
PyModule_AddObject(m, "PJMedia_Codec_Param_Setting",
(PyObject *)&PyTyp_pjmedia_codec_param_setting);
Py_INCREF(&PyTyp_pjmedia_codec_param);
PyModule_AddObject(m, "PJMedia_Codec_Param",
(PyObject *)&PyTyp_pjmedia_codec_param);
/* END OF LIB MEDIA */
/* LIB CALL */
Py_INCREF(&PyTyp_pjsua_call_info);
PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info);
/* END OF LIB CALL */
return m;
/*
* Add various constants.
*/
/* Skip it.. */
#undef ADD_CONSTANT
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/chooosky/python3-pjsip.git
[email protected]:chooosky/python3-pjsip.git
chooosky
python3-pjsip
python3-pjsip
master

搜索帮助