Changeset 869 for pjproject/trunk
- Timestamp:
- Dec 28, 2006 3:13:48 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/py_pjsua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua.py
- Property svn:eol-style deleted
r851 r869 118 118 bcfg = py_pjsua.Buddy_Config() 119 119 status, id = py_pjsua.buddy_add(bcfg) 120 acc_id = id 120 121 print "py buddy add status " + `status` + " id " + `id` 121 122 bool = py_pjsua.buddy_is_valid(id) … … 124 125 print "buddy count " + `count` 125 126 binfo = py_pjsua.buddy_get_info(id) 126 ids = py_pjsua.enum_buddies( 3)127 ids = py_pjsua.enum_buddies() 127 128 status = py_pjsua.buddy_del(id) 128 129 print "py buddy del status " + `status` … … 138 139 #end of lib buddy 139 140 141 #lib media 142 count = py_pjsua.conf_get_max_ports() 143 print "py media conf get max ports " + `count` 144 count = py_pjsua.conf_get_active_ports() 145 print "py media conf get active ports " + `count` 146 ids = py_pjsua.enum_conf_ports() 147 for id in ids: 148 print "py media conf ports " + `id` 149 cp_info = py_pjsua.conf_get_port_info(id) 150 print "port info name " + cp_info.name 151 pool = py_pjsua.PJ_Pool() 152 port = py_pjsua.PJMedia_Port() 153 status, id = py_pjsua.conf_add_port(pool,port) 154 print "py media conf add port status " + `status` + " id " + `id` 155 if status != 0 : 156 py_pjsua.perror("py_pjsua","add port",status) 157 status = py_pjsua.conf_remove_port(id) 158 print "py media conf remove port status " + `status` 159 if status != 0 : 160 py_pjsua.perror("py_pjsua","remove port",status) 161 status = py_pjsua.conf_connect(id, id) 162 print "py media conf connect status " + `status` 163 if status != 0 : 164 py_pjsua.perror("py_pjsua","connect",status) 165 status = py_pjsua.conf_disconnect(id, id) 166 print "py media conf disconnect status " + `status` 167 if status != 0 : 168 py_pjsua.perror("py_pjsua","disconnect",status) 169 status, id = py_pjsua.player_create("test.wav", 0) 170 print "py media player create status " + `status` + " id " + `id` 171 if status != 0 : 172 py_pjsua.perror("py_pjsua","player create",status) 173 c_id = py_pjsua.player_get_conf_port(id) 174 print "py media player get conf port id " + `c_id` 175 status = py_pjsua.player_set_pos(id, 10) 176 if status != 0 : 177 py_pjsua.perror("py_pjsua","player set pos",status) 178 status = py_pjsua.player_destroy(id) 179 if status != 0 : 180 py_pjsua.perror("py_pjsua","player destroy",status) 181 status, id = py_pjsua.recorder_create("rec.wav", 0, "None", 1000, 0) 182 print "py media recorder create status " + `status` + " id " + `id` 183 if status != 0 : 184 py_pjsua.perror("py_pjsua","recorder create",status) 185 status = py_pjsua.recorder_get_conf_port(id) 186 print "py media recorder get conf port status " + `status` 187 if status != 0 : 188 py_pjsua.perror("py_pjsua","recorder get conf port",status) 189 status = py_pjsua.recorder_destroy(id) 190 print "py media recorder destroy status " + `status` 191 if status != 0 : 192 py_pjsua.perror("py_pjsua","recorder destroy",status) 193 #cdev, pdev = py_pjsua.get_snd_dev() 194 #print "py media get snd dev capture dev " + `cdev` + " playback dev " + `pdev` 195 status = py_pjsua.set_snd_dev(0,1) 196 print "py media set snd dev status " + `status` 197 if status != 0 : 198 py_pjsua.perror("py_pjsua","set snd dev",status) 199 status = py_pjsua.set_null_snd_dev() 200 print "py media set null snd dev status " + `status` 201 if status != 0 : 202 py_pjsua.perror("py_pjsua","set null snd dev",status) 203 port = py_pjsua.set_no_snd_dev() 204 status = py_pjsua.set_ec(0,0) 205 print "py media set ec status " + `status` 206 if status != 0 : 207 py_pjsua.perror("py_pjsua","set ec",status) 208 tail = py_pjsua.get_ec_tail() 209 print "py media get ec tail " + `tail` 210 infos = py_pjsua.enum_codecs() 211 for info in infos: 212 print "py media enum codecs " + `info` 213 status = py_pjsua.codec_set_priority("coba", 0) 214 print "py media codec set priority " + `status` 215 if status != 0 : 216 py_pjsua.perror("py_pjsua","codec set priority",status) 217 c_param = py_pjsua.codec_get_param("coba") 218 status = py_pjsua.codec_set_param("coba", c_param) 219 print "py media codec set param " + `status` 220 if status != 0 : 221 py_pjsua.perror("py_pjsua","codec set param",status) 222 223 #end of lib media 224 225 #lib call 226 227 count = py_pjsua.call_get_max_count() 228 print "py call get max count " + `count` 229 count = py_pjsua.call_get_count() 230 print "py call get count " + `count` 231 ids = py_pjsua.enum_calls() 232 for id in ids: 233 print "py enum calls id " + `id` 234 msg_data = py_pjsua.Msg_Data() 235 status, id = py_pjsua.call_make_call(-1, "sip:bulukucing1@iptel.org", 0, 0, msg_data) 236 print "py call make call " + `status` + " id " + `id` 237 if status != 0 : 238 py_pjsua.perror("py_pjsua","call make call",status) 239 bool = py_pjsua.call_is_active(id) 240 print "py call is active " + `bool` 241 bool = py_pjsua.call_has_media(id) 242 print "py call has media " + `bool` 243 cp_id = py_pjsua.call_get_conf_port(id) 244 print "py call get conf port " + `cp_id` 245 info = py_pjsua.call_get_info(id) 246 if info != None : 247 print "py info id " + `info.id` 248 status = py_pjsua.call_set_user_data(id, 0) 249 print "py call set user data status " + `status` 250 if status != 0 : 251 py_pjsua.perror("py_pjsua","set user data",status) 252 user_data = py_pjsua.call_get_user_data(id) 253 print "py call get user data " + `user_data` 254 255 256 257 #end of lib call 258 140 259 py_pjsua.perror("saya","hallo",70006) 141 260 -
pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c
- Property svn:eol-style deleted
r851 r869 1681 1681 pj_thread_t *thread; 1682 1682 void *thread_desc; 1683 #if 0 1683 1684 int size; 1684 1685 int i; 1685 1686 int *td; 1687 #endif 1686 1688 1687 1689 if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) … … 3144 3146 /* 3145 3147 * py_pjsua_enum_transports 3148 * !modified @ 261206 3146 3149 */ 3147 3150 static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs) … … 3150 3153 PyObject *list; 3151 3154 3152 pjsua_transport_id *id;3155 pjsua_transport_id id[PJSIP_MAX_TRANSPORTS]; 3153 3156 int c, i; 3154 if (!PyArg_ParseTuple(pArgs, " i", &c))3157 if (!PyArg_ParseTuple(pArgs, "")) 3155 3158 { 3156 3159 return NULL; 3157 3160 } 3158 3161 3159 id = (pjsua_transport_id *)malloc(c * sizeof(pjsua_transport_id));3162 c = PJ_ARRAY_SIZE(id); 3160 3163 status = pjsua_enum_transports(id, &c); 3161 3164 … … 3267 3270 "Register transport that has been created by application."; 3268 3271 static char pjsua_enum_transports_doc[] = 3269 "int[] py_pjsua.enum_transports ( int count) "3272 "int[] py_pjsua.enum_transports () " 3270 3273 "Enumerate all transports currently created in the system."; 3271 3274 static char pjsua_transport_get_info_doc[] = … … 4100 4103 /* 4101 4104 * py_pjsua_enum_accs 4102 * !modified @ 0512064105 * !modified @ 241206 4103 4106 */ 4104 4107 static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs) … … 4107 4110 PyObject *list; 4108 4111 4109 pjsua_acc_id *id;4112 pjsua_acc_id id[PJSUA_MAX_ACC]; 4110 4113 int c, i; 4111 if (!PyArg_ParseTuple(pArgs, " i", &c))4114 if (!PyArg_ParseTuple(pArgs, "")) 4112 4115 { 4113 4116 return NULL; 4114 4117 } 4115 4116 id = (pjsua_acc_id *)malloc(c * sizeof(pjsua_acc_id));4118 c = PJ_ARRAY_SIZE(id); 4119 4117 4120 status = pjsua_enum_accs(id, &c); 4118 4121 … … 4122 4125 if (ret == -1) { 4123 4126 return NULL; 4124 4127 } 4125 4128 } 4126 4129 … … 4131 4134 /* 4132 4135 * py_pjsua_acc_enum_info 4133 * !modified @ 0512064136 * !modified @ 241206 4134 4137 */ 4135 4138 static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs) … … 4138 4141 PyObject *list; 4139 4142 4140 pjsua_acc_info *info;4143 pjsua_acc_info info[PJSUA_MAX_ACC]; 4141 4144 int c, i; 4142 if (!PyArg_ParseTuple(pArgs, " i", &c))4145 if (!PyArg_ParseTuple(pArgs, "")) 4143 4146 { 4144 4147 return NULL; 4145 4148 } 4146 4149 4147 info = (pjsua_acc_info *)malloc(c * sizeof(pjsua_acc_info));4150 c = PJ_ARRAY_SIZE(info); 4148 4151 status = pjsua_acc_enum_info(info, &c); 4149 4152 … … 4325 4328 "Get account information."; 4326 4329 static char pjsua_enum_accs_doc[] = 4327 "int[] py_pjsua.enum_accs ( int count) "4330 "int[] py_pjsua.enum_accs () " 4328 4331 "Enum accounts all account ids."; 4329 4332 static char pjsua_acc_enum_info_doc[] = 4330 "py_pjsua.Acc_Info[] py_pjsua.acc_enum_info ( int count) "4333 "py_pjsua.Acc_Info[] py_pjsua.acc_enum_info () " 4331 4334 "Enum accounts info."; 4332 4335 static char pjsua_acc_find_for_outgoing_doc[] = … … 4673 4676 /* 4674 4677 * py_pjsua_enum_buddies 4675 * !modified @ 0612064678 * !modified @ 241206 4676 4679 */ 4677 4680 static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs) … … 4680 4683 PyObject *list; 4681 4684 4682 pjsua_buddy_id *id;4685 pjsua_buddy_id id[PJSUA_MAX_BUDDIES]; 4683 4686 int c, i; 4684 if (!PyArg_ParseTuple(pArgs, " i", &c))4687 if (!PyArg_ParseTuple(pArgs, "")) 4685 4688 { 4686 4689 return NULL; 4687 4690 } 4688 4691 4689 id = (pjsua_buddy_id *)malloc(c * sizeof(pjsua_buddy_id));4692 c = PJ_ARRAY_SIZE(id); 4690 4693 status = pjsua_enum_buddies(id, &c); 4691 4694 … … 4917 4920 "Check if buddy ID is valid."; 4918 4921 static char pjsua_enum_buddies_doc[] = 4919 "int[] py_pjsua.enum_buddies ( int count) "4922 "int[] py_pjsua.enum_buddies () " 4920 4923 "Enum buddy IDs."; 4921 4924 static char pjsua_buddy_get_info_doc[] = … … 4946 4949 /* END OF LIB BUDDY */ 4947 4950 4948 4951 /* LIB MEDIA */ 4952 4953 4954 4955 /* 4956 * codec_info_Object 4957 * Codec Info 4958 * !modified @ 071206 4959 */ 4960 typedef struct 4961 { 4962 PyObject_HEAD 4963 /* Type-specific fields go here. */ 4964 4965 PyObject * codec_id; 4966 pj_uint8_t priority; 4967 char buf_[32]; 4968 } codec_info_Object; 4969 4970 4971 /* 4972 * codec_info_dealloc 4973 * deletes a codec_info from memory 4974 * !modified @ 071206 4975 */ 4976 static void codec_info_dealloc(codec_info_Object* self) 4977 { 4978 Py_XDECREF(self->codec_id); 4979 4980 self->ob_type->tp_free((PyObject*)self); 4981 } 4982 4983 4984 /* 4985 * codec_info_new 4986 * constructor for codec_info object 4987 * !modified @ 071206 4988 */ 4989 static PyObject * codec_info_new(PyTypeObject *type, PyObject *args, 4990 PyObject *kwds) 4991 { 4992 codec_info_Object *self; 4993 4994 self = (codec_info_Object *)type->tp_alloc(type, 0); 4995 if (self != NULL) 4996 { 4997 self->codec_id = PyString_FromString(""); 4998 if (self->codec_id == NULL) 4999 { 5000 Py_DECREF(self); 5001 return NULL; 5002 } 5003 5004 5005 } 5006 return (PyObject *)self; 5007 } 5008 5009 /* 5010 * codec_info_members 5011 * !modified @ 071206 5012 */ 5013 static PyMemberDef codec_info_members[] = 5014 { 5015 { 5016 "codec_id", T_OBJECT_EX, 5017 offsetof(codec_info_Object, codec_id), 0, 5018 "Codec unique identification." 5019 }, 5020 5021 { 5022 "priority", T_INT, 5023 offsetof(codec_info_Object, priority), 0, 5024 "Codec priority (integer 0-255)." 5025 }, 5026 5027 5028 5029 {NULL} /* Sentinel */ 5030 }; 5031 5032 5033 5034 5035 /* 5036 * codec_info_Type 5037 */ 5038 static PyTypeObject codec_info_Type = 5039 { 5040 PyObject_HEAD_INIT(NULL) 5041 0, /*ob_size*/ 5042 "py_pjsua.Codec_Info", /*tp_name*/ 5043 sizeof(codec_info_Object), /*tp_basicsize*/ 5044 0, /*tp_itemsize*/ 5045 (destructor)codec_info_dealloc,/*tp_dealloc*/ 5046 0, /*tp_print*/ 5047 0, /*tp_getattr*/ 5048 0, /*tp_setattr*/ 5049 0, /*tp_compare*/ 5050 0, /*tp_repr*/ 5051 0, /*tp_as_number*/ 5052 0, /*tp_as_sequence*/ 5053 0, /*tp_as_mapping*/ 5054 0, /*tp_hash */ 5055 0, /*tp_call*/ 5056 0, /*tp_str*/ 5057 0, /*tp_getattro*/ 5058 0, /*tp_setattro*/ 5059 0, /*tp_as_buffer*/ 5060 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5061 "Codec Info objects", /* tp_doc */ 5062 0, /* tp_traverse */ 5063 0, /* tp_clear */ 5064 0, /* tp_richcompare */ 5065 0, /* tp_weaklistoffset */ 5066 0, /* tp_iter */ 5067 0, /* tp_iternext */ 5068 0, /* tp_methods */ 5069 codec_info_members, /* tp_members */ 5070 0, /* tp_getset */ 5071 0, /* tp_base */ 5072 0, /* tp_dict */ 5073 0, /* tp_descr_get */ 5074 0, /* tp_descr_set */ 5075 0, /* tp_dictoffset */ 5076 0, /* tp_init */ 5077 0, /* tp_alloc */ 5078 codec_info_new, /* tp_new */ 5079 5080 }; 5081 5082 /* 5083 * conf_port_info_Object 5084 * Conf Port Info 5085 */ 5086 typedef struct 5087 { 5088 PyObject_HEAD 5089 /* Type-specific fields go here. */ 5090 5091 int slot_id; 5092 PyObject * name; 5093 unsigned clock_rate; 5094 unsigned channel_count; 5095 unsigned samples_per_frame; 5096 unsigned bits_per_sample; 5097 unsigned listener_cnt; 5098 PyListObject * listeners; 5099 5100 } conf_port_info_Object; 5101 5102 5103 /* 5104 * conf_port_info_dealloc 5105 * deletes a conf_port_info from memory 5106 */ 5107 static void conf_port_info_dealloc(conf_port_info_Object* self) 5108 { 5109 Py_XDECREF(self->name); 5110 Py_XDECREF(self->listeners); 5111 self->ob_type->tp_free((PyObject*)self); 5112 } 5113 5114 5115 /* 5116 * conf_port_info_new 5117 * constructor for conf_port_info object 5118 */ 5119 static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, 5120 PyObject *kwds) 5121 { 5122 conf_port_info_Object *self; 5123 5124 self = (conf_port_info_Object *)type->tp_alloc(type, 0); 5125 if (self != NULL) 5126 { 5127 self->name = PyString_FromString(""); 5128 if (self->name == NULL) 5129 { 5130 Py_DECREF(self); 5131 return NULL; 5132 } 5133 5134 self->listeners = (PyListObject *)PyList_New(254); 5135 if (self->listeners == NULL) 5136 { 5137 Py_DECREF(self); 5138 return NULL; 5139 } 5140 } 5141 return (PyObject *)self; 5142 } 5143 5144 /* 5145 * conf_port_info_members 5146 */ 5147 static PyMemberDef conf_port_info_members[] = 5148 { 5149 { 5150 "slot_id", T_INT, 5151 offsetof(conf_port_info_Object, slot_id), 0, 5152 "Conference port number." 5153 }, 5154 { 5155 "name", T_OBJECT_EX, 5156 offsetof(conf_port_info_Object, name), 0, 5157 "Port name" 5158 }, 5159 { 5160 "clock_rate", T_INT, 5161 offsetof(conf_port_info_Object, clock_rate), 0, 5162 "Clock rate" 5163 }, 5164 { 5165 "channel_count", T_INT, 5166 offsetof(conf_port_info_Object, channel_count), 0, 5167 "Number of channels." 5168 }, 5169 { 5170 "samples_per_frame", T_INT, 5171 offsetof(conf_port_info_Object, samples_per_frame), 0, 5172 "Samples per frame " 5173 }, 5174 { 5175 "bits_per_sample", T_INT, 5176 offsetof(conf_port_info_Object, bits_per_sample), 0, 5177 "Bits per sample" 5178 }, 5179 /*{ 5180 "listener_cnt", T_INT, 5181 offsetof(conf_port_info_Object, listener_cnt), 0, 5182 "Number of listeners in the array." 5183 },*/ 5184 { 5185 "listeners", T_OBJECT_EX, 5186 offsetof(conf_port_info_Object, listeners), 0, 5187 "Array of listeners (in other words, ports where this port " 5188 "is transmitting to" 5189 }, 5190 5191 {NULL} /* Sentinel */ 5192 }; 5193 5194 5195 5196 5197 /* 5198 * conf_port_info_Type 5199 */ 5200 static PyTypeObject conf_port_info_Type = 5201 { 5202 PyObject_HEAD_INIT(NULL) 5203 0, /*ob_size*/ 5204 "py_pjsua.Conf_Port_Info", /*tp_name*/ 5205 sizeof(conf_port_info_Object), /*tp_basicsize*/ 5206 0, /*tp_itemsize*/ 5207 (destructor)conf_port_info_dealloc,/*tp_dealloc*/ 5208 0, /*tp_print*/ 5209 0, /*tp_getattr*/ 5210 0, /*tp_setattr*/ 5211 0, /*tp_compare*/ 5212 0, /*tp_repr*/ 5213 0, /*tp_as_number*/ 5214 0, /*tp_as_sequence*/ 5215 0, /*tp_as_mapping*/ 5216 0, /*tp_hash */ 5217 0, /*tp_call*/ 5218 0, /*tp_str*/ 5219 0, /*tp_getattro*/ 5220 0, /*tp_setattro*/ 5221 0, /*tp_as_buffer*/ 5222 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5223 "Conf Port Info objects", /* tp_doc */ 5224 0, /* tp_traverse */ 5225 0, /* tp_clear */ 5226 0, /* tp_richcompare */ 5227 0, /* tp_weaklistoffset */ 5228 0, /* tp_iter */ 5229 0, /* tp_iternext */ 5230 0, /* tp_methods */ 5231 conf_port_info_members, /* tp_members */ 5232 0, /* tp_getset */ 5233 0, /* tp_base */ 5234 0, /* tp_dict */ 5235 0, /* tp_descr_get */ 5236 0, /* tp_descr_set */ 5237 0, /* tp_dictoffset */ 5238 0, /* tp_init */ 5239 0, /* tp_alloc */ 5240 conf_port_info_new, /* tp_new */ 5241 5242 }; 5243 5244 /* 5245 * pjmedia_port_Object 5246 */ 5247 typedef struct 5248 { 5249 PyObject_HEAD 5250 /* Type-specific fields go here. */ 5251 pjmedia_port * port; 5252 } pjmedia_port_Object; 5253 5254 5255 /* 5256 * pjmedia_port_Type 5257 */ 5258 static PyTypeObject pjmedia_port_Type = 5259 { 5260 PyObject_HEAD_INIT(NULL) 5261 0, /*ob_size*/ 5262 "py_pjsua.PJMedia_Port", /*tp_name*/ 5263 sizeof(pjmedia_port_Object), /*tp_basicsize*/ 5264 0, /*tp_itemsize*/ 5265 0, /*tp_dealloc*/ 5266 0, /*tp_print*/ 5267 0, /*tp_getattr*/ 5268 0, /*tp_setattr*/ 5269 0, /*tp_compare*/ 5270 0, /*tp_repr*/ 5271 0, /*tp_as_number*/ 5272 0, /*tp_as_sequence*/ 5273 0, /*tp_as_mapping*/ 5274 0, /*tp_hash */ 5275 0, /*tp_call*/ 5276 0, /*tp_str*/ 5277 0, /*tp_getattro*/ 5278 0, /*tp_setattro*/ 5279 0, /*tp_as_buffer*/ 5280 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5281 "pjmedia_port objects", /* tp_doc */ 5282 5283 }; 5284 5285 /* 5286 * pjmedia_snd_dev_info_Object 5287 * PJMedia Snd Dev Info 5288 */ 5289 typedef struct 5290 { 5291 PyObject_HEAD 5292 /* Type-specific fields go here. */ 5293 5294 5295 unsigned input_count; 5296 unsigned output_count; 5297 unsigned default_samples_per_sec; 5298 PyListObject * name; 5299 5300 } pjmedia_snd_dev_info_Object; 5301 5302 5303 /* 5304 * pjmedia_snd_dev_info_dealloc 5305 * deletes a pjmedia_snd_dev_info from memory 5306 */ 5307 static void pjmedia_snd_dev_info_dealloc(pjmedia_snd_dev_info_Object* self) 5308 { 5309 Py_XDECREF(self->name); 5310 self->ob_type->tp_free((PyObject*)self); 5311 } 5312 5313 5314 /* 5315 * pjmedia_snd_dev_info_new 5316 * constructor for pjmedia_snd_dev_info object 5317 */ 5318 static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args, 5319 PyObject *kwds) 5320 { 5321 pjmedia_snd_dev_info_Object *self; 5322 5323 self = (pjmedia_snd_dev_info_Object *)type->tp_alloc(type, 0); 5324 if (self != NULL) 5325 { 5326 self->name = (PyListObject *)PyList_New(64); 5327 if (self->name == NULL) 5328 { 5329 Py_DECREF(self); 5330 return NULL; 5331 } 5332 5333 } 5334 return (PyObject *)self; 5335 } 5336 5337 /* 5338 * pjmedia_snd_dev_info_members 5339 */ 5340 static PyMemberDef pjmedia_snd_dev_info_members[] = 5341 { 5342 5343 { 5344 "name", T_OBJECT_EX, 5345 offsetof(pjmedia_snd_dev_info_Object, name), 0, 5346 "Device name" 5347 }, 5348 { 5349 "input_count", T_INT, 5350 offsetof(pjmedia_snd_dev_info_Object, input_count), 0, 5351 "Max number of input channels" 5352 }, 5353 { 5354 "output_count", T_INT, 5355 offsetof(pjmedia_snd_dev_info_Object, output_count), 0, 5356 "Max number of output channels" 5357 }, 5358 { 5359 "default_samples_per_sec", T_INT, 5360 offsetof(pjmedia_snd_dev_info_Object, default_samples_per_sec), 0, 5361 "Default sampling rate." 5362 }, 5363 5364 5365 {NULL} /* Sentinel */ 5366 }; 5367 5368 5369 5370 5371 /* 5372 * pjmedia_snd_dev_info_Type 5373 */ 5374 static PyTypeObject pjmedia_snd_dev_info_Type = 5375 { 5376 PyObject_HEAD_INIT(NULL) 5377 0, /*ob_size*/ 5378 "py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ 5379 sizeof(pjmedia_snd_dev_info_Object), /*tp_basicsize*/ 5380 0, /*tp_itemsize*/ 5381 (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ 5382 0, /*tp_print*/ 5383 0, /*tp_getattr*/ 5384 0, /*tp_setattr*/ 5385 0, /*tp_compare*/ 5386 0, /*tp_repr*/ 5387 0, /*tp_as_number*/ 5388 0, /*tp_as_sequence*/ 5389 0, /*tp_as_mapping*/ 5390 0, /*tp_hash */ 5391 0, /*tp_call*/ 5392 0, /*tp_str*/ 5393 0, /*tp_getattro*/ 5394 0, /*tp_setattro*/ 5395 0, /*tp_as_buffer*/ 5396 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5397 "PJMedia Snd Dev Info objects", /* tp_doc */ 5398 0, /* tp_traverse */ 5399 0, /* tp_clear */ 5400 0, /* tp_richcompare */ 5401 0, /* tp_weaklistoffset */ 5402 0, /* tp_iter */ 5403 0, /* tp_iternext */ 5404 0, /* tp_methods */ 5405 pjmedia_snd_dev_info_members, /* tp_members */ 5406 0, /* tp_getset */ 5407 0, /* tp_base */ 5408 0, /* tp_dict */ 5409 0, /* tp_descr_get */ 5410 0, /* tp_descr_set */ 5411 0, /* tp_dictoffset */ 5412 0, /* tp_init */ 5413 0, /* tp_alloc */ 5414 pjmedia_snd_dev_info_new, /* tp_new */ 5415 5416 }; 5417 5418 /* 5419 * pjmedia_codec_param_info_Object 5420 * PJMedia Codec Param Info 5421 */ 5422 typedef struct 5423 { 5424 PyObject_HEAD 5425 /* Type-specific fields go here. */ 5426 5427 unsigned clock_rate; 5428 unsigned channel_cnt; 5429 pj_uint32_t avg_bps; 5430 pj_uint16_t frm_ptime; 5431 pj_uint8_t pcm_bits_per_sample; 5432 pj_uint8_t pt; 5433 5434 } pjmedia_codec_param_info_Object; 5435 5436 5437 5438 /* 5439 * pjmedia_codec_param_info_members 5440 */ 5441 static PyMemberDef pjmedia_codec_param_info_members[] = 5442 { 5443 5444 { 5445 "clock_rate", T_INT, 5446 offsetof(pjmedia_codec_param_info_Object, clock_rate), 0, 5447 "Sampling rate in Hz" 5448 }, 5449 { 5450 "channel_cnt", T_INT, 5451 offsetof(pjmedia_codec_param_info_Object, channel_cnt), 0, 5452 "Channel count" 5453 }, 5454 { 5455 "avg_bps", T_INT, 5456 offsetof(pjmedia_codec_param_info_Object, avg_bps), 0, 5457 "Average bandwidth in bits/sec" 5458 }, 5459 { 5460 "frm_ptime", T_INT, 5461 offsetof(pjmedia_codec_param_info_Object, frm_ptime), 0, 5462 "Base frame ptime in msec." 5463 }, 5464 { 5465 "pcm_bits_per_sample", T_INT, 5466 offsetof(pjmedia_codec_param_info_Object, pcm_bits_per_sample), 0, 5467 "Bits/sample in the PCM side" 5468 }, 5469 { 5470 "pt", T_INT, 5471 offsetof(pjmedia_codec_param_info_Object, pt), 0, 5472 "Payload type" 5473 }, 5474 5475 {NULL} /* Sentinel */ 5476 }; 5477 5478 5479 5480 5481 /* 5482 * pjmedia_codec_param_info_Type 5483 */ 5484 static PyTypeObject pjmedia_codec_param_info_Type = 5485 { 5486 PyObject_HEAD_INIT(NULL) 5487 0, /*ob_size*/ 5488 "py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ 5489 sizeof(pjmedia_codec_param_info_Object), /*tp_basicsize*/ 5490 0, /*tp_itemsize*/ 5491 0,/*tp_dealloc*/ 5492 0, /*tp_print*/ 5493 0, /*tp_getattr*/ 5494 0, /*tp_setattr*/ 5495 0, /*tp_compare*/ 5496 0, /*tp_repr*/ 5497 0, /*tp_as_number*/ 5498 0, /*tp_as_sequence*/ 5499 0, /*tp_as_mapping*/ 5500 0, /*tp_hash */ 5501 0, /*tp_call*/ 5502 0, /*tp_str*/ 5503 0, /*tp_getattro*/ 5504 0, /*tp_setattro*/ 5505 0, /*tp_as_buffer*/ 5506 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5507 "PJMedia Codec Param Info objects", /* tp_doc */ 5508 0, /* tp_traverse */ 5509 0, /* tp_clear */ 5510 0, /* tp_richcompare */ 5511 0, /* tp_weaklistoffset */ 5512 0, /* tp_iter */ 5513 0, /* tp_iternext */ 5514 0, /* tp_methods */ 5515 pjmedia_codec_param_info_members, /* tp_members */ 5516 5517 5518 }; 5519 5520 /* 5521 * pjmedia_codec_param_setting_Object 5522 * PJMedia Codec Param Setting 5523 */ 5524 typedef struct 5525 { 5526 PyObject_HEAD 5527 /* Type-specific fields go here. */ 5528 pj_uint8_t frm_per_pkt; 5529 unsigned vad; 5530 unsigned cng; 5531 unsigned penh; 5532 unsigned plc; 5533 unsigned reserved; 5534 pj_uint8_t enc_fmtp_mode; 5535 pj_uint8_t dec_fmtp_mode; 5536 5537 } pjmedia_codec_param_setting_Object; 5538 5539 5540 5541 /* 5542 * pjmedia_codec_param_setting_members 5543 */ 5544 static PyMemberDef pjmedia_codec_param_setting_members[] = 5545 { 5546 5547 { 5548 "frm_per_pkt", T_INT, 5549 offsetof(pjmedia_codec_param_setting_Object, frm_per_pkt), 0, 5550 "Number of frames per packet" 5551 }, 5552 { 5553 "vad", T_INT, 5554 offsetof(pjmedia_codec_param_setting_Object, vad), 0, 5555 "Voice Activity Detector" 5556 }, 5557 { 5558 "penh", T_INT, 5559 offsetof(pjmedia_codec_param_setting_Object, penh), 0, 5560 "Perceptual Enhancement" 5561 }, 5562 { 5563 "plc", T_INT, 5564 offsetof(pjmedia_codec_param_setting_Object, plc), 0, 5565 "Packet loss concealment" 5566 }, 5567 { 5568 "reserved", T_INT, 5569 offsetof(pjmedia_codec_param_setting_Object, reserved), 0, 5570 "Reserved, must be zero" 5571 }, 5572 { 5573 "cng", T_INT, 5574 offsetof(pjmedia_codec_param_setting_Object, cng), 0, 5575 "Comfort Noise Generator" 5576 }, 5577 { 5578 "enc_fmtp_mode", T_INT, 5579 offsetof(pjmedia_codec_param_setting_Object, enc_fmtp_mode), 0, 5580 "Mode param in fmtp (def:0)" 5581 }, 5582 { 5583 "dec_fmtp_mode", T_INT, 5584 offsetof(pjmedia_codec_param_setting_Object, dec_fmtp_mode), 0, 5585 "Mode param in fmtp (def:0)" 5586 }, 5587 5588 {NULL} /* Sentinel */ 5589 }; 5590 5591 5592 5593 5594 /* 5595 * pjmedia_codec_param_setting_Type 5596 */ 5597 static PyTypeObject pjmedia_codec_param_setting_Type = 5598 { 5599 PyObject_HEAD_INIT(NULL) 5600 0, /*ob_size*/ 5601 "py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/ 5602 sizeof(pjmedia_codec_param_setting_Object), /*tp_basicsize*/ 5603 0, /*tp_itemsize*/ 5604 0,/*tp_dealloc*/ 5605 0, /*tp_print*/ 5606 0, /*tp_getattr*/ 5607 0, /*tp_setattr*/ 5608 0, /*tp_compare*/ 5609 0, /*tp_repr*/ 5610 0, /*tp_as_number*/ 5611 0, /*tp_as_sequence*/ 5612 0, /*tp_as_mapping*/ 5613 0, /*tp_hash */ 5614 0, /*tp_call*/ 5615 0, /*tp_str*/ 5616 0, /*tp_getattro*/ 5617 0, /*tp_setattro*/ 5618 0, /*tp_as_buffer*/ 5619 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5620 "PJMedia Codec Param Setting objects", /* tp_doc */ 5621 0, /* tp_traverse */ 5622 0, /* tp_clear */ 5623 0, /* tp_richcompare */ 5624 0, /* tp_weaklistoffset */ 5625 0, /* tp_iter */ 5626 0, /* tp_iternext */ 5627 0, /* tp_methods */ 5628 pjmedia_codec_param_setting_members, /* tp_members */ 5629 5630 5631 }; 5632 5633 /* 5634 * pjmedia_codec_param_Object 5635 * PJMedia Codec Param 5636 */ 5637 typedef struct 5638 { 5639 PyObject_HEAD 5640 /* Type-specific fields go here. */ 5641 5642 pjmedia_codec_param_info_Object * info; 5643 pjmedia_codec_param_setting_Object * setting; 5644 5645 } pjmedia_codec_param_Object; 5646 5647 5648 /* 5649 * pjmedia_codec_param_dealloc 5650 * deletes a pjmedia_codec_param from memory 5651 */ 5652 static void pjmedia_codec_param_dealloc(pjmedia_codec_param_Object* self) 5653 { 5654 Py_XDECREF(self->info); 5655 Py_XDECREF(self->setting); 5656 self->ob_type->tp_free((PyObject*)self); 5657 } 5658 5659 5660 /* 5661 * pjmedia_codec_param_new 5662 * constructor for pjmedia_codec_param object 5663 */ 5664 static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args, 5665 PyObject *kwds) 5666 { 5667 pjmedia_codec_param_Object *self; 5668 5669 self = (pjmedia_codec_param_Object *)type->tp_alloc(type, 0); 5670 if (self != NULL) 5671 { 5672 self->info = (pjmedia_codec_param_info_Object *) 5673 PyType_GenericNew(&pjmedia_codec_param_info_Type, NULL, NULL); 5674 if (self->info == NULL) 5675 { 5676 Py_DECREF(self); 5677 return NULL; 5678 } 5679 self->setting = (pjmedia_codec_param_setting_Object *) 5680 PyType_GenericNew(&pjmedia_codec_param_setting_Type, NULL, NULL); 5681 if (self->setting == NULL) 5682 { 5683 Py_DECREF(self); 5684 return NULL; 5685 } 5686 } 5687 return (PyObject *)self; 5688 } 5689 5690 /* 5691 * pjmedia_codec_param_members 5692 */ 5693 static PyMemberDef pjmedia_codec_param_members[] = 5694 { 5695 5696 { 5697 "info", T_OBJECT_EX, 5698 offsetof(pjmedia_codec_param_Object, info), 0, 5699 "The 'info' part of codec param describes the capability of the codec," 5700 " and the value should NOT be changed by application." 5701 }, 5702 { 5703 "setting", T_OBJECT_EX, 5704 offsetof(pjmedia_codec_param_Object, setting), 0, 5705 "The 'setting' part of codec param describes various settings to be " 5706 "applied to the codec. When the codec param is retrieved from the " 5707 "codec or codec factory, the values of these will be filled by " 5708 "the capability of the codec. Any features that are supported by " 5709 "the codec (e.g. vad or plc) will be turned on, so that application " 5710 "can query which capabilities are supported by the codec. " 5711 "Application may change the settings here before instantiating " 5712 "the codec/stream." 5713 }, 5714 5715 {NULL} /* Sentinel */ 5716 }; 5717 5718 5719 5720 5721 /* 5722 * pjmedia_codec_param_Type 5723 */ 5724 static PyTypeObject pjmedia_codec_param_Type = 5725 { 5726 PyObject_HEAD_INIT(NULL) 5727 0, /*ob_size*/ 5728 "py_pjsua.PJMedia_Codec_Param", /*tp_name*/ 5729 sizeof(pjmedia_codec_param_Object), /*tp_basicsize*/ 5730 0, /*tp_itemsize*/ 5731 (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ 5732 0, /*tp_print*/ 5733 0, /*tp_getattr*/ 5734 0, /*tp_setattr*/ 5735 0, /*tp_compare*/ 5736 0, /*tp_repr*/ 5737 0, /*tp_as_number*/ 5738 0, /*tp_as_sequence*/ 5739 0, /*tp_as_mapping*/ 5740 0, /*tp_hash */ 5741 0, /*tp_call*/ 5742 0, /*tp_str*/ 5743 0, /*tp_getattro*/ 5744 0, /*tp_setattro*/ 5745 0, /*tp_as_buffer*/ 5746 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 5747 "PJMedia Codec Param objects", /* tp_doc */ 5748 0, /* tp_traverse */ 5749 0, /* tp_clear */ 5750 0, /* tp_richcompare */ 5751 0, /* tp_weaklistoffset */ 5752 0, /* tp_iter */ 5753 0, /* tp_iternext */ 5754 0, /* tp_methods */ 5755 pjmedia_codec_param_members, /* tp_members */ 5756 0, /* tp_getset */ 5757 0, /* tp_base */ 5758 0, /* tp_dict */ 5759 0, /* tp_descr_get */ 5760 0, /* tp_descr_set */ 5761 0, /* tp_dictoffset */ 5762 0, /* tp_init */ 5763 0, /* tp_alloc */ 5764 pjmedia_codec_param_new, /* tp_new */ 5765 5766 }; 5767 5768 /* 5769 * py_pjsua_conf_get_max_ports 5770 */ 5771 static PyObject *py_pjsua_conf_get_max_ports 5772 (PyObject *pSelf, PyObject *pArgs) 5773 { 5774 int ret; 5775 5776 if (!PyArg_ParseTuple(pArgs, "")) 5777 { 5778 return NULL; 5779 } 5780 ret = pjsua_conf_get_max_ports(); 5781 5782 return Py_BuildValue("i", ret); 5783 } 5784 5785 /* 5786 * py_pjsua_conf_get_active_ports 5787 */ 5788 static PyObject *py_pjsua_conf_get_active_ports 5789 (PyObject *pSelf, PyObject *pArgs) 5790 { 5791 int ret; 5792 if (!PyArg_ParseTuple(pArgs, "")) 5793 { 5794 return NULL; 5795 } 5796 ret = pjsua_conf_get_active_ports(); 5797 5798 return Py_BuildValue("i", ret); 5799 } 5800 5801 /* 5802 * py_pjsua_enum_conf_ports 5803 * !modified @ 241206 5804 */ 5805 static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) 5806 { 5807 pj_status_t status; 5808 PyObject *list; 5809 5810 pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; 5811 int c, i; 5812 if (!PyArg_ParseTuple(pArgs, "")) 5813 { 5814 return NULL; 5815 } 5816 5817 c = PJ_ARRAY_SIZE(id); 5818 status = pjsua_enum_conf_ports(id, &c); 5819 5820 list = PyList_New(c); 5821 for (i = 0; i < c; i++) { 5822 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 5823 if (ret == -1) { 5824 return NULL; 5825 } 5826 } 5827 5828 free(id); 5829 return Py_BuildValue("O",list); 5830 } 5831 5832 /* 5833 * py_pjsua_conf_get_port_info 5834 */ 5835 static PyObject *py_pjsua_conf_get_port_info 5836 (PyObject *pSelf, PyObject *pArgs) 5837 { 5838 int id; 5839 conf_port_info_Object * obj; 5840 pjsua_conf_port_info info; 5841 int status; 5842 int i; 5843 5844 if (!PyArg_ParseTuple(pArgs, "i", &id)) 5845 { 5846 return NULL; 5847 } 5848 5849 5850 status = pjsua_conf_get_port_info(id, &info); 5851 obj = (conf_port_info_Object *)conf_port_info_new 5852 (&conf_port_info_Type,NULL,NULL); 5853 obj->bits_per_sample = info.bits_per_sample; 5854 obj->channel_count = info.bits_per_sample; 5855 obj->clock_rate = info.clock_rate; 5856 obj->listener_cnt = info.listener_cnt; 5857 obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen); 5858 obj->samples_per_frame = info.samples_per_frame; 5859 obj->slot_id = info.slot_id; 5860 5861 for (i = 0; i < 254; i++) { 5862 PyObject * item = Py_BuildValue("i",info.listeners[i]); 5863 PyList_SetItem((PyObject *)obj->listeners, i, item); 5864 } 5865 return Py_BuildValue("O", obj); 5866 } 5867 5868 /* 5869 * py_pjsua_conf_add_port 5870 */ 5871 static PyObject *py_pjsua_conf_add_port 5872 (PyObject *pSelf, PyObject *pArgs) 5873 { 5874 int p_id; 5875 pjmedia_port_Object * oport; 5876 pj_pool_Object * opool; 5877 5878 int status; 5879 5880 5881 if (!PyArg_ParseTuple(pArgs, "OO", &opool, &oport)) 5882 { 5883 return NULL; 5884 } 5885 5886 5887 5888 status = pjsua_conf_add_port(opool->pool, oport->port, &p_id); 5889 5890 5891 return Py_BuildValue("ii", status, p_id); 5892 } 5893 5894 /* 5895 * py_pjsua_conf_remove_port 5896 */ 5897 static PyObject *py_pjsua_conf_remove_port 5898 (PyObject *pSelf, PyObject *pArgs) 5899 { 5900 int id; 5901 int status; 5902 5903 5904 if (!PyArg_ParseTuple(pArgs, "i", &id)) 5905 { 5906 return NULL; 5907 } 5908 5909 status = pjsua_conf_remove_port(id); 5910 5911 5912 return Py_BuildValue("i", status); 5913 } 5914 5915 /* 5916 * py_pjsua_conf_connect 5917 */ 5918 static PyObject *py_pjsua_conf_connect 5919 (PyObject *pSelf, PyObject *pArgs) 5920 { 5921 int source, sink; 5922 int status; 5923 5924 5925 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) 5926 { 5927 return NULL; 5928 } 5929 5930 status = pjsua_conf_connect(source, sink); 5931 5932 5933 return Py_BuildValue("i", status); 5934 } 5935 5936 /* 5937 * py_pjsua_conf_disconnect 5938 */ 5939 static PyObject *py_pjsua_conf_disconnect 5940 (PyObject *pSelf, PyObject *pArgs) 5941 { 5942 int source, sink; 5943 int status; 5944 5945 5946 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) 5947 { 5948 return NULL; 5949 } 5950 5951 status = pjsua_conf_disconnect(source, sink); 5952 5953 5954 return Py_BuildValue("i", status); 5955 } 5956 5957 /* 5958 * py_pjsua_player_create 5959 */ 5960 static PyObject *py_pjsua_player_create 5961 (PyObject *pSelf, PyObject *pArgs) 5962 { 5963 int id; 5964 int options; 5965 PyObject * filename; 5966 pj_str_t str; 5967 int status; 5968 5969 5970 if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options)) 5971 { 5972 return NULL; 5973 } 5974 str.ptr = PyString_AsString(filename); 5975 str.slen = strlen(PyString_AsString(filename)); 5976 status = pjsua_player_create(&str, options, &id); 5977 5978 return Py_BuildValue("ii", status, id); 5979 } 5980 5981 /* 5982 * py_pjsua_player_get_conf_port 5983 */ 5984 static PyObject *py_pjsua_player_get_conf_port 5985 (PyObject *pSelf, PyObject *pArgs) 5986 { 5987 5988 int id, port_id; 5989 5990 5991 if (!PyArg_ParseTuple(pArgs, "i", &id)) 5992 { 5993 return NULL; 5994 } 5995 5996 port_id = pjsua_player_get_conf_port(id); 5997 5998 5999 return Py_BuildValue("i", port_id); 6000 } 6001 6002 /* 6003 * py_pjsua_player_set_pos 6004 */ 6005 static PyObject *py_pjsua_player_set_pos 6006 (PyObject *pSelf, PyObject *pArgs) 6007 { 6008 int id; 6009 pj_uint32_t samples; 6010 int status; 6011 6012 6013 if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples)) 6014 { 6015 return NULL; 6016 } 6017 6018 status = pjsua_player_set_pos(id, samples); 6019 6020 6021 return Py_BuildValue("i", status); 6022 } 6023 6024 /* 6025 * py_pjsua_player_destroy 6026 */ 6027 static PyObject *py_pjsua_player_destroy 6028 (PyObject *pSelf, PyObject *pArgs) 6029 { 6030 int id; 6031 int status; 6032 6033 6034 if (!PyArg_ParseTuple(pArgs, "i", &id)) 6035 { 6036 return NULL; 6037 } 6038 6039 status = pjsua_player_destroy(id); 6040 6041 6042 return Py_BuildValue("i", status); 6043 } 6044 6045 /* 6046 * py_pjsua_recorder_create 6047 * !modified @ 261206 6048 */ 6049 static PyObject *py_pjsua_recorder_create 6050 (PyObject *pSelf, PyObject *pArgs) 6051 { 6052 int p_id; 6053 int options; 6054 int max_size; 6055 PyObject * filename; 6056 pj_str_t str; 6057 PyObject * enc_param; 6058 pj_str_t strparam; 6059 int enc_type; 6060 6061 int status; 6062 6063 6064 if (!PyArg_ParseTuple(pArgs, "OiOii", &filename, &enc_type, &enc_param, &max_size, &options)) 6065 { 6066 return NULL; 6067 } 6068 str.ptr = PyString_AsString(filename); 6069 str.slen = strlen(PyString_AsString(filename)); 6070 strparam.ptr = PyString_AsString(enc_param); 6071 strparam.slen = strlen(PyString_AsString(enc_param)); 6072 status = pjsua_recorder_create(&str, enc_type, NULL, max_size, options, &p_id); 6073 6074 return Py_BuildValue("ii", status, p_id); 6075 } 6076 6077 /* 6078 * py_pjsua_recorder_get_conf_port 6079 */ 6080 static PyObject *py_pjsua_recorder_get_conf_port 6081 (PyObject *pSelf, PyObject *pArgs) 6082 { 6083 6084 int id, port_id; 6085 6086 6087 if (!PyArg_ParseTuple(pArgs, "i", &id)) 6088 { 6089 return NULL; 6090 } 6091 6092 port_id = pjsua_recorder_get_conf_port(id); 6093 6094 6095 return Py_BuildValue("i", port_id); 6096 } 6097 6098 /* 6099 * py_pjsua_recorder_destroy 6100 */ 6101 static PyObject *py_pjsua_recorder_destroy 6102 (PyObject *pSelf, PyObject *pArgs) 6103 { 6104 int id; 6105 int status; 6106 6107 6108 if (!PyArg_ParseTuple(pArgs, "i", &id)) 6109 { 6110 return NULL; 6111 } 6112 6113 status = pjsua_recorder_destroy(id); 6114 6115 6116 return Py_BuildValue("i", status); 6117 } 6118 6119 /* 6120 * py_pjsua_enum_snd_devs 6121 */ 6122 static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs) 6123 { 6124 pj_status_t status; 6125 PyObject *list; 6126 6127 pjmedia_snd_dev_info *info; 6128 int c, i; 6129 if (!PyArg_ParseTuple(pArgs, "i", &c)) 6130 { 6131 return NULL; 6132 } 6133 6134 info = (pjmedia_snd_dev_info *)malloc(c * sizeof(pjmedia_snd_dev_info)); 6135 status = pjsua_enum_snd_devs(info, &c); 6136 6137 list = PyList_New(c); 6138 for (i = 0; i < c; i++) { 6139 int ret; 6140 int j; 6141 pjmedia_snd_dev_info_Object * obj; 6142 obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new 6143 (&pjmedia_snd_dev_info_Type, NULL, NULL); 6144 obj->default_samples_per_sec = info[i].default_samples_per_sec; 6145 obj->input_count = info[i].input_count; 6146 obj->output_count = info[i].output_count; 6147 for (j = 0; j < 64; j++) 6148 { 6149 PyObject * ostr; 6150 char * str; 6151 str = (char *)malloc(sizeof(char)); 6152 str[0] = info[i].name[j]; 6153 ostr = PyString_FromStringAndSize(str,1); 6154 PyList_SetItem((PyObject *)obj->name, j, ostr); 6155 free(str); 6156 } 6157 ret = PyList_SetItem(list, i, (PyObject *)obj); 6158 if (ret == -1) { 6159 return NULL; 6160 } 6161 } 6162 6163 free(info); 6164 return Py_BuildValue("O",list); 6165 } 6166 6167 /* 6168 * py_pjsua_get_snd_dev 6169 */ 6170 static PyObject *py_pjsua_get_snd_dev 6171 (PyObject *pSelf, PyObject *pArgs) 6172 { 6173 int capture_dev, playback_dev; 6174 int status; 6175 6176 6177 if (!PyArg_ParseTuple(pArgs, "")) 6178 { 6179 return NULL; 6180 } 6181 6182 status = pjsua_get_snd_dev(&capture_dev, &playback_dev); 6183 6184 6185 return Py_BuildValue("ii", capture_dev, playback_dev); 6186 } 6187 6188 /* 6189 * py_pjsua_set_snd_dev 6190 */ 6191 static PyObject *py_pjsua_set_snd_dev 6192 (PyObject *pSelf, PyObject *pArgs) 6193 { 6194 int capture_dev, playback_dev; 6195 int status; 6196 6197 6198 if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) 6199 { 6200 return NULL; 6201 } 6202 6203 status = pjsua_set_snd_dev(capture_dev, playback_dev); 6204 6205 6206 return Py_BuildValue("i", status); 6207 } 6208 6209 /* 6210 * py_pjsua_set_null_snd_dev 6211 */ 6212 static PyObject *py_pjsua_set_null_snd_dev 6213 (PyObject *pSelf, PyObject *pArgs) 6214 { 6215 6216 int status; 6217 6218 6219 if (!PyArg_ParseTuple(pArgs, "")) 6220 { 6221 return NULL; 6222 } 6223 6224 status = pjsua_set_null_snd_dev(); 6225 6226 6227 return Py_BuildValue("i", status); 6228 } 6229 6230 /* 6231 * py_pjsua_set_no_snd_dev 6232 */ 6233 static PyObject *py_pjsua_set_no_snd_dev 6234 (PyObject *pSelf, PyObject *pArgs) 6235 { 6236 6237 pjmedia_port_Object * obj; 6238 6239 if (!PyArg_ParseTuple(pArgs, "")) 6240 { 6241 return NULL; 6242 } 6243 6244 obj = (pjmedia_port_Object *)PyType_GenericNew 6245 (&pjmedia_port_Type, NULL, NULL); 6246 obj->port = pjsua_set_no_snd_dev(); 6247 return Py_BuildValue("O", obj); 6248 } 6249 6250 /* 6251 * py_pjsua_set_ec 6252 */ 6253 static PyObject *py_pjsua_set_ec 6254 (PyObject *pSelf, PyObject *pArgs) 6255 { 6256 int options; 6257 int tail_ms; 6258 int status; 6259 6260 6261 if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) 6262 { 6263 return NULL; 6264 } 6265 6266 status = pjsua_set_ec(tail_ms, options); 6267 6268 6269 return Py_BuildValue("i", status); 6270 } 6271 6272 /* 6273 * py_pjsua_get_ec_tail 6274 */ 6275 static PyObject *py_pjsua_get_ec_tail 6276 (PyObject *pSelf, PyObject *pArgs) 6277 { 6278 6279 int status; 6280 int p_tail_ms; 6281 6282 if (!PyArg_ParseTuple(pArgs, "")) 6283 { 6284 return NULL; 6285 } 6286 6287 status = pjsua_get_ec_tail(&p_tail_ms); 6288 6289 6290 return Py_BuildValue("i", p_tail_ms); 6291 } 6292 6293 /* 6294 * py_pjsua_enum_codecs 6295 * !modified @ 261206 6296 */ 6297 static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) 6298 { 6299 pj_status_t status; 6300 PyObject *list; 6301 6302 pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; 6303 int c, i; 6304 if (!PyArg_ParseTuple(pArgs, "")) 6305 { 6306 return NULL; 6307 } 6308 6309 c = PJ_ARRAY_SIZE(info); 6310 status = pjsua_enum_codecs(info, &c); 6311 6312 list = PyList_New(c); 6313 for (i = 0; i < c; i++) { 6314 int ret; 6315 int j; 6316 codec_info_Object * obj; 6317 obj = (codec_info_Object *)codec_info_new 6318 (&codec_info_Type, NULL, NULL); 6319 obj->codec_id = PyString_FromStringAndSize 6320 (info[i].codec_id.ptr, info[i].codec_id.slen); 6321 obj->priority = info[i].priority; 6322 for (j = 0; j < 32; j++) 6323 { 6324 obj->buf_[j] = info[i].buf_[j]; 6325 } 6326 ret = PyList_SetItem(list, i, (PyObject *)obj); 6327 if (ret == -1) { 6328 return NULL; 6329 } 6330 } 6331 6332 free(info); 6333 return Py_BuildValue("O",list); 6334 } 6335 6336 /* 6337 * py_pjsua_codec_set_priority 6338 */ 6339 static PyObject *py_pjsua_codec_set_priority 6340 (PyObject *pSelf, PyObject *pArgs) 6341 { 6342 6343 int status; 6344 PyObject * id; 6345 pj_str_t str; 6346 pj_uint8_t priority; 6347 6348 if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority)) 6349 { 6350 return NULL; 6351 } 6352 str.ptr = PyString_AsString(id); 6353 str.slen = strlen(PyString_AsString(id)); 6354 status = pjsua_codec_set_priority(&str, priority); 6355 6356 6357 return Py_BuildValue("i", status); 6358 } 6359 6360 /* 6361 * py_pjsua_codec_get_param 6362 */ 6363 static PyObject *py_pjsua_codec_get_param 6364 (PyObject *pSelf, PyObject *pArgs) 6365 { 6366 6367 int status; 6368 PyObject * id; 6369 pj_str_t str; 6370 pjmedia_codec_param param; 6371 pjmedia_codec_param_Object *obj; 6372 6373 6374 if (!PyArg_ParseTuple(pArgs, "O", &id)) 6375 { 6376 return NULL; 6377 } 6378 str.ptr = PyString_AsString(id); 6379 str.slen = strlen(PyString_AsString(id)); 6380 status = pjsua_codec_get_param(&str, ¶m); 6381 obj = (pjmedia_codec_param_Object *)pjmedia_codec_param_new 6382 (&pjmedia_codec_param_Type, NULL, NULL); 6383 obj->info->avg_bps = param.info.avg_bps; 6384 obj->info->channel_cnt = param.info.channel_cnt; 6385 obj->info->clock_rate = param.info.clock_rate; 6386 obj->info->frm_ptime = param.info.frm_ptime; 6387 obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; 6388 obj->info->pt = param.info.pt; 6389 obj->setting->cng = param.setting.cng; 6390 obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; 6391 obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; 6392 obj->setting->frm_per_pkt = param.setting.frm_per_pkt; 6393 obj->setting->penh = param.setting.penh; 6394 obj->setting->plc = param.setting.plc; 6395 obj->setting->reserved = param.setting.reserved; 6396 obj->setting->vad = param.setting.vad; 6397 6398 return Py_BuildValue("O", obj); 6399 } 6400 /* 6401 * py_pjsua_codec_set_param 6402 */ 6403 static PyObject *py_pjsua_codec_set_param 6404 (PyObject *pSelf, PyObject *pArgs) 6405 { 6406 6407 int status; 6408 PyObject * id; 6409 pj_str_t str; 6410 pjmedia_codec_param param; 6411 pjmedia_codec_param_Object *obj; 6412 6413 6414 if (!PyArg_ParseTuple(pArgs, "OO", &id, &obj)) 6415 { 6416 return NULL; 6417 } 6418 str.ptr = PyString_AsString(id); 6419 str.slen = strlen(PyString_AsString(id)); 6420 param.info.avg_bps = obj->info->avg_bps; 6421 param.info.channel_cnt = obj->info->channel_cnt; 6422 param.info.clock_rate = obj->info->clock_rate; 6423 param.info.frm_ptime = obj->info->frm_ptime; 6424 param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample; 6425 param.info.pt = obj->info->pt; 6426 param.setting.cng = obj->setting->cng; 6427 param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode; 6428 param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode; 6429 param.setting.frm_per_pkt = obj->setting->frm_per_pkt; 6430 param.setting.penh = obj->setting->penh; 6431 param.setting.plc = obj->setting->plc; 6432 param.setting.reserved = obj->setting->reserved; 6433 param.setting.vad = obj->setting->vad; 6434 status = pjsua_codec_set_param(&str, ¶m); 6435 6436 return Py_BuildValue("i", status); 6437 } 6438 6439 static char pjsua_conf_get_max_ports_doc[] = 6440 "int py_pjsua.conf_get_max_ports () " 6441 "Get maxinum number of conference ports."; 6442 static char pjsua_conf_get_active_ports_doc[] = 6443 "int py_pjsua.conf_get_active_ports () " 6444 "Get current number of active ports in the bridge."; 6445 static char pjsua_enum_conf_ports_doc[] = 6446 "int[] py_pjsua.enum_conf_ports () " 6447 "Enumerate all conference ports."; 6448 static char pjsua_conf_get_port_info_doc[] = 6449 "py_pjsua.Conf_Port_Info py_pjsua.conf_get_port_info (int id) " 6450 "Get information about the specified conference port"; 6451 static char pjsua_conf_add_port_doc[] = 6452 "int, int py_pjsua.conf_add_port " 6453 "(py_pjsua.PJ_Pool pool, py_pjsua.PJMedia_Port port) " 6454 "Add arbitrary media port to PJSUA's conference bridge. " 6455 "Application can use this function to add the media port " 6456 "that it creates. For media ports that are created by PJSUA-LIB " 6457 "(such as calls, file player, or file recorder), PJSUA-LIB will " 6458 "automatically add the port to the bridge."; 6459 static char pjsua_conf_remove_port_doc[] = 6460 "int py_pjsua.conf_remove_port (int id) " 6461 "Remove arbitrary slot from the conference bridge. " 6462 "Application should only call this function " 6463 "if it registered the port manually."; 6464 static char pjsua_conf_connect_doc[] = 6465 "int py_pjsua.conf_connect (int source, int sink) " 6466 "Establish unidirectional media flow from souce to sink. " 6467 "One source may transmit to multiple destinations/sink. " 6468 "And if multiple sources are transmitting to the same sink, " 6469 "the media will be mixed together. Source and sink may refer " 6470 "to the same ID, effectively looping the media. " 6471 "If bidirectional media flow is desired, application " 6472 "needs to call this function twice, with the second " 6473 "one having the arguments reversed."; 6474 static char pjsua_conf_disconnect_doc[] = 6475 "int py_pjsua.conf_disconnect (int source, int sink) " 6476 "Disconnect media flow from the source to destination port."; 6477 static char pjsua_player_create_doc[] = 6478 "int, int py_pjsua.player_create (string filename, int options) " 6479 "Create a file player, and automatically connect " 6480 "this player to the conference bridge."; 6481 static char pjsua_player_get_conf_port_doc[] = 6482 "int py_pjsua.player_get_conf_port (int) " 6483 "Get conference port ID associated with player."; 6484 static char pjsua_player_set_pos_doc[] = 6485 "int py_pjsua.player_set_pos (int id, int samples) " 6486 "Set playback position."; 6487 static char pjsua_player_destroy_doc[] = 6488 "int py_pjsua.player_destroy (int id) " 6489 "Close the file, remove the player from the bridge, " 6490 "and free resources associated with the file player."; 6491 static char pjsua_recorder_create_doc[] = 6492 "int, int py_pjsua.recorder_create (string filename, " 6493 "int enc_type, int enc_param, int max_size, int options) " 6494 "Create a file recorder, and automatically connect this recorder " 6495 "to the conference bridge. The recorder currently supports recording " 6496 "WAV file, and on Windows, MP3 file. The type of the recorder to use " 6497 "is determined by the extension of the file (e.g. '.wav' or '.mp3')."; 6498 static char pjsua_recorder_get_conf_port_doc[] = 6499 "int py_pjsua.recorder_get_conf_port (int id) " 6500 "Get conference port associated with recorder."; 6501 static char pjsua_recorder_destroy_doc[] = 6502 "int py_pjsua.recorder_destroy (int id) " 6503 "Destroy recorder (this will complete recording)."; 6504 static char pjsua_enum_snd_devs_doc[] = 6505 "py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) " 6506 "Enum sound devices."; 6507 static char pjsua_get_snd_dev_doc[] = 6508 "int, int py_pjsua.get_snd_dev () " 6509 "Get currently active sound devices. " 6510 "If sound devices has not been created " 6511 "(for example when pjsua_start() is not called), " 6512 "it is possible that the function returns " 6513 "PJ_SUCCESS with -1 as device IDs."; 6514 static char pjsua_set_snd_dev_doc[] = 6515 "int py_pjsua.set_snd_dev (int capture_dev, int playback_dev) " 6516 "Select or change sound device. Application may call this function " 6517 "at any time to replace current sound device."; 6518 static char pjsua_set_null_snd_dev_doc[] = 6519 "int py_pjsua.set_null_snd_dev () " 6520 "Set pjsua to use null sound device. The null sound device only " 6521 "provides the timing needed by the conference bridge, and will not " 6522 "interract with any hardware."; 6523 static char pjsua_set_no_snd_dev_doc[] = 6524 "py_pjsua.PJMedia_Port py_pjsua.set_no_snd_dev () " 6525 "Disconnect the main conference bridge from any sound devices, " 6526 "and let application connect the bridge to it's " 6527 "own sound device/master port."; 6528 static char pjsua_set_ec_doc[] = 6529 "int py_pjsua.set_ec (int tail_ms, int options) " 6530 "Configure the echo canceller tail length of the sound port."; 6531 static char pjsua_get_ec_tail_doc[] = 6532 "int py_pjsua.get_ec_tail () " 6533 "Get current echo canceller tail length."; 6534 static char pjsua_enum_codecs_doc[] = 6535 "py_pjsua.Codec_Info[] py_pjsua.enum_codecs () " 6536 "Enum all supported codecs in the system."; 6537 static char pjsua_codec_set_priority_doc[] = 6538 "int py_pjsua.codec_set_priority (string id, int priority) " 6539 "Change codec priority."; 6540 static char pjsua_codec_get_param_doc[] = 6541 "py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) " 6542 "Get codec parameters"; 6543 static char pjsua_codec_set_param_doc[] = 6544 "int py_pjsua.codec_set_param (string id, " 6545 "py_pjsua.PJMedia_Codec_Param param) " 6546 "Set codec parameters."; 6547 6548 /* END OF LIB MEDIA */ 6549 6550 /* LIB CALL */ 6551 6552 /* 6553 * pj_time_val_Object 6554 * PJ Time Val 6555 */ 6556 typedef struct 6557 { 6558 PyObject_HEAD 6559 /* Type-specific fields go here. */ 6560 long sec; 6561 long msec; 6562 6563 } pj_time_val_Object; 6564 6565 6566 6567 /* 6568 * pj_time_val_members 6569 */ 6570 static PyMemberDef pj_time_val_members[] = 6571 { 6572 6573 { 6574 "sec", T_INT, 6575 offsetof(pj_time_val_Object, sec), 0, 6576 "The seconds part of the time" 6577 }, 6578 { 6579 "msec", T_INT, 6580 offsetof(pj_time_val_Object, sec), 0, 6581 "The milliseconds fraction of the time" 6582 }, 6583 6584 6585 {NULL} /* Sentinel */ 6586 }; 6587 6588 6589 6590 6591 /* 6592 * pj_time_val_Type 6593 */ 6594 static PyTypeObject pj_time_val_Type = 6595 { 6596 PyObject_HEAD_INIT(NULL) 6597 0, /*ob_size*/ 6598 "py_pjsua.PJ_Time_Val", /*tp_name*/ 6599 sizeof(pj_time_val_Object), /*tp_basicsize*/ 6600 0, /*tp_itemsize*/ 6601 0,/*tp_dealloc*/ 6602 0, /*tp_print*/ 6603 0, /*tp_getattr*/ 6604 0, /*tp_setattr*/ 6605 0, /*tp_compare*/ 6606 0, /*tp_repr*/ 6607 0, /*tp_as_number*/ 6608 0, /*tp_as_sequence*/ 6609 0, /*tp_as_mapping*/ 6610 0, /*tp_hash */ 6611 0, /*tp_call*/ 6612 0, /*tp_str*/ 6613 0, /*tp_getattro*/ 6614 0, /*tp_setattro*/ 6615 0, /*tp_as_buffer*/ 6616 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 6617 "PJ Time Val objects", /* tp_doc */ 6618 0, /* tp_traverse */ 6619 0, /* tp_clear */ 6620 0, /* tp_richcompare */ 6621 0, /* tp_weaklistoffset */ 6622 0, /* tp_iter */ 6623 0, /* tp_iternext */ 6624 0, /* tp_methods */ 6625 pj_time_val_members, /* tp_members */ 6626 6627 6628 }; 6629 6630 /* 6631 * call_info_Object 6632 * Call Info 6633 */ 6634 typedef struct 6635 { 6636 PyObject_HEAD 6637 /* Type-specific fields go here. */ 6638 6639 int id; 6640 int role; 6641 int acc_id; 6642 PyObject * local_info; 6643 PyObject * local_contact; 6644 PyObject * remote_info; 6645 PyObject * remote_contact; 6646 PyObject * call_id; 6647 int state; 6648 PyObject * state_text; 6649 int last_status; 6650 PyObject * last_status_text; 6651 int media_status; 6652 int media_dir; 6653 int conf_slot; 6654 pj_time_val_Object * connect_duration; 6655 pj_time_val_Object * total_duration; 6656 struct { 6657 char local_info[128]; 6658 char local_contact[128]; 6659 char remote_info[128]; 6660 char remote_contact[128]; 6661 char call_id[128]; 6662 char last_status_text[128]; 6663 } buf_; 6664 6665 } call_info_Object; 6666 6667 6668 /* 6669 * call_info_dealloc 6670 * deletes a call_info from memory 6671 */ 6672 static void call_info_dealloc(call_info_Object* self) 6673 { 6674 Py_XDECREF(self->local_info); 6675 Py_XDECREF(self->local_contact); 6676 Py_XDECREF(self->remote_info); 6677 Py_XDECREF(self->remote_contact); 6678 Py_XDECREF(self->call_id); 6679 Py_XDECREF(self->state_text); 6680 Py_XDECREF(self->last_status_text); 6681 Py_XDECREF(self->connect_duration); 6682 Py_XDECREF(self->total_duration); 6683 self->ob_type->tp_free((PyObject*)self); 6684 } 6685 6686 6687 /* 6688 * call_info_new 6689 * constructor for call_info object 6690 */ 6691 static PyObject * call_info_new(PyTypeObject *type, PyObject *args, 6692 PyObject *kwds) 6693 { 6694 call_info_Object *self; 6695 6696 self = (call_info_Object *)type->tp_alloc(type, 0); 6697 if (self != NULL) 6698 { 6699 self->local_info = PyString_FromString(""); 6700 if (self->local_info == NULL) 6701 { 6702 Py_DECREF(self); 6703 return NULL; 6704 } 6705 self->local_contact = PyString_FromString(""); 6706 if (self->local_contact == NULL) 6707 { 6708 Py_DECREF(self); 6709 return NULL; 6710 } 6711 self->remote_info = PyString_FromString(""); 6712 if (self->remote_info == NULL) 6713 { 6714 Py_DECREF(self); 6715 return NULL; 6716 } 6717 self->remote_contact = PyString_FromString(""); 6718 if (self->remote_contact == NULL) 6719 { 6720 Py_DECREF(self); 6721 return NULL; 6722 } 6723 self->call_id = PyString_FromString(""); 6724 if (self->call_id == NULL) 6725 { 6726 Py_DECREF(self); 6727 return NULL; 6728 } 6729 self->state_text = PyString_FromString(""); 6730 if (self->state_text == NULL) 6731 { 6732 Py_DECREF(self); 6733 return NULL; 6734 } 6735 self->last_status_text = PyString_FromString(""); 6736 if (self->last_status_text == NULL) 6737 { 6738 Py_DECREF(self); 6739 return NULL; 6740 } 6741 self->connect_duration = (pj_time_val_Object *)PyType_GenericNew 6742 (&pj_time_val_Type,NULL,NULL); 6743 if (self->connect_duration == NULL) 6744 { 6745 Py_DECREF(self); 6746 return NULL; 6747 } 6748 self->total_duration = (pj_time_val_Object *)PyType_GenericNew 6749 (&pj_time_val_Type,NULL,NULL); 6750 if (self->total_duration == NULL) 6751 { 6752 Py_DECREF(self); 6753 return NULL; 6754 } 6755 } 6756 return (PyObject *)self; 6757 } 6758 6759 /* 6760 * call_info_members 6761 */ 6762 static PyMemberDef call_info_members[] = 6763 { 6764 { 6765 "id", T_INT, 6766 offsetof(call_info_Object, id), 0, 6767 "Call identification" 6768 }, 6769 { 6770 "role", T_INT, 6771 offsetof(call_info_Object, role), 0, 6772 "Initial call role (UAC == caller)" 6773 }, 6774 { 6775 "acc_id", T_INT, 6776 offsetof(call_info_Object, acc_id), 0, 6777 "The account ID where this call belongs." 6778 }, 6779 { 6780 "local_info", T_OBJECT_EX, 6781 offsetof(call_info_Object, local_info), 0, 6782 "Local URI" 6783 }, 6784 { 6785 "local_contact", T_OBJECT_EX, 6786 offsetof(call_info_Object, local_contact), 0, 6787 "Local Contact" 6788 }, 6789 { 6790 "remote_info", T_OBJECT_EX, 6791 offsetof(call_info_Object, remote_info), 0, 6792 "Remote URI" 6793 }, 6794 { 6795 "remote_contact", T_OBJECT_EX, 6796 offsetof(call_info_Object, remote_contact), 0, 6797 "Remote Contact" 6798 }, 6799 { 6800 "call_id", T_OBJECT_EX, 6801 offsetof(call_info_Object, call_id), 0, 6802 "Dialog Call-ID string" 6803 }, 6804 { 6805 "state", T_INT, 6806 offsetof(call_info_Object, state), 0, 6807 "Call state" 6808 }, 6809 { 6810 "state_text", T_OBJECT_EX, 6811 offsetof(call_info_Object, state_text), 0, 6812 "Text describing the state " 6813 }, 6814 { 6815 "last_status", T_INT, 6816 offsetof(call_info_Object, last_status), 0, 6817 "Last status code heard, which can be used as cause code" 6818 }, 6819 { 6820 "last_status_text", T_OBJECT_EX, 6821 offsetof(call_info_Object, last_status_text), 0, 6822 "The reason phrase describing the status." 6823 }, 6824 { 6825 "media_status", T_INT, 6826 offsetof(call_info_Object, media_status), 0, 6827 "Call media status." 6828 }, 6829 { 6830 "media_dir", T_INT, 6831 offsetof(call_info_Object, media_dir), 0, 6832 "Media direction" 6833 }, 6834 { 6835 "conf_slot", T_INT, 6836 offsetof(call_info_Object, conf_slot), 0, 6837 "The conference port number for the call" 6838 }, 6839 { 6840 "connect_duration", T_OBJECT_EX, 6841 offsetof(call_info_Object, connect_duration), 0, 6842 "Up-to-date call connected duration (zero when call is not established)" 6843 }, 6844 { 6845 "total_duration", T_OBJECT_EX, 6846 offsetof(call_info_Object, total_duration), 0, 6847 "Total call duration, including set-up time" 6848 }, 6849 6850 {NULL} /* Sentinel */ 6851 }; 6852 6853 6854 6855 6856 /* 6857 * call_info_Type 6858 */ 6859 static PyTypeObject call_info_Type = 6860 { 6861 PyObject_HEAD_INIT(NULL) 6862 0, /*ob_size*/ 6863 "py_pjsua.Call_Info", /*tp_name*/ 6864 sizeof(call_info_Object), /*tp_basicsize*/ 6865 0, /*tp_itemsize*/ 6866 (destructor)call_info_dealloc,/*tp_dealloc*/ 6867 0, /*tp_print*/ 6868 0, /*tp_getattr*/ 6869 0, /*tp_setattr*/ 6870 0, /*tp_compare*/ 6871 0, /*tp_repr*/ 6872 0, /*tp_as_number*/ 6873 0, /*tp_as_sequence*/ 6874 0, /*tp_as_mapping*/ 6875 0, /*tp_hash */ 6876 0, /*tp_call*/ 6877 0, /*tp_str*/ 6878 0, /*tp_getattro*/ 6879 0, /*tp_setattro*/ 6880 0, /*tp_as_buffer*/ 6881 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 6882 "Call Info objects", /* tp_doc */ 6883 0, /* tp_traverse */ 6884 0, /* tp_clear */ 6885 0, /* tp_richcompare */ 6886 0, /* tp_weaklistoffset */ 6887 0, /* tp_iter */ 6888 0, /* tp_iternext */ 6889 0, /* tp_methods */ 6890 call_info_members, /* tp_members */ 6891 0, /* tp_getset */ 6892 0, /* tp_base */ 6893 0, /* tp_dict */ 6894 0, /* tp_descr_get */ 6895 0, /* tp_descr_set */ 6896 0, /* tp_dictoffset */ 6897 0, /* tp_init */ 6898 0, /* tp_alloc */ 6899 call_info_new, /* tp_new */ 6900 6901 }; 6902 6903 /* 6904 * py_pjsua_call_get_max_count 6905 */ 6906 static PyObject *py_pjsua_call_get_max_count 6907 (PyObject *pSelf, PyObject *pArgs) 6908 { 6909 int count; 6910 6911 if (!PyArg_ParseTuple(pArgs, "")) 6912 { 6913 return NULL; 6914 } 6915 6916 count = pjsua_call_get_max_count(); 6917 6918 6919 return Py_BuildValue("i", count); 6920 } 6921 6922 /* 6923 * py_pjsua_call_get_count 6924 */ 6925 static PyObject *py_pjsua_call_get_count 6926 (PyObject *pSelf, PyObject *pArgs) 6927 { 6928 6929 int count; 6930 6931 6932 if (!PyArg_ParseTuple(pArgs, "")) 6933 { 6934 return NULL; 6935 } 6936 6937 count = pjsua_call_get_count(); 6938 6939 6940 return Py_BuildValue("i", count); 6941 } 6942 6943 /* 6944 * py_pjsua_enum_calls 6945 */ 6946 static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs) 6947 { 6948 pj_status_t status; 6949 PyObject *list; 6950 6951 pjsua_transport_id id[PJSUA_MAX_CALLS]; 6952 int c, i; 6953 if (!PyArg_ParseTuple(pArgs, "")) 6954 { 6955 return NULL; 6956 } 6957 6958 c = PJ_ARRAY_SIZE(id); 6959 status = pjsua_enum_calls(id, &c); 6960 6961 list = PyList_New(c); 6962 for (i = 0; i < c; i++) 6963 { 6964 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 6965 if (ret == -1) 6966 { 6967 return NULL; 6968 } 6969 } 6970 6971 free(id); 6972 return Py_BuildValue("O",list); 6973 } 6974 6975 /* 6976 * py_pjsua_call_make_call 6977 */ 6978 static PyObject *py_pjsua_call_make_call 6979 (PyObject *pSelf, PyObject *pArgs) 6980 { 6981 int status; 6982 int acc_id; 6983 pj_str_t dst_uri; 6984 PyObject * sd; 6985 unsigned options; 6986 pjsua_msg_data msg_data; 6987 msg_data_Object * omd; 6988 int user_data; 6989 int call_id; 6990 pj_pool_t * pool; 6991 6992 if (!PyArg_ParseTuple(pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omd)) 6993 { 6994 return NULL; 6995 } 6996 6997 dst_uri.ptr = PyString_AsString(sd); 6998 dst_uri.slen = strlen(PyString_AsString(sd)); 6999 7000 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7001 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7002 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7003 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7004 pool = pjsua_pool_create("pjsua", 4000, 4000); 7005 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7006 status = pjsua_call_make_call(acc_id, &dst_uri, options, &user_data, &msg_data, &call_id); 7007 pj_pool_release(pool); 7008 return Py_BuildValue("ii",status, call_id); 7009 } 7010 7011 /* 7012 * py_pjsua_call_is_active 7013 */ 7014 static PyObject *py_pjsua_call_is_active 7015 (PyObject *pSelf, PyObject *pArgs) 7016 { 7017 int call_id; 7018 int isActive; 7019 7020 7021 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 7022 { 7023 return NULL; 7024 } 7025 7026 isActive = pjsua_call_is_active(call_id); 7027 7028 7029 return Py_BuildValue("i", isActive); 7030 } 7031 7032 /* 7033 * py_pjsua_call_has_media 7034 */ 7035 static PyObject *py_pjsua_call_has_media 7036 (PyObject *pSelf, PyObject *pArgs) 7037 { 7038 int call_id; 7039 int hasMedia; 7040 7041 7042 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 7043 { 7044 return NULL; 7045 } 7046 7047 hasMedia = pjsua_call_has_media(call_id); 7048 7049 7050 return Py_BuildValue("i", hasMedia); 7051 } 7052 7053 /* 7054 * py_pjsua_call_get_conf_port 7055 */ 7056 static PyObject *py_pjsua_call_get_conf_port 7057 (PyObject *pSelf, PyObject *pArgs) 7058 { 7059 int call_id; 7060 int port_id; 7061 7062 7063 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 7064 { 7065 return NULL; 7066 } 7067 7068 port_id = pjsua_call_get_conf_port(call_id); 7069 7070 7071 return Py_BuildValue("i", port_id); 7072 } 7073 7074 /* 7075 * py_pjsua_call_get_info 7076 */ 7077 static PyObject *py_pjsua_call_get_info 7078 (PyObject *pSelf, PyObject *pArgs) 7079 { 7080 int call_id; 7081 int status; 7082 call_info_Object * oi; 7083 pjsua_call_info info; 7084 int i; 7085 7086 7087 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 7088 { 7089 return NULL; 7090 } 7091 7092 7093 status = pjsua_call_get_info(call_id, &info); 7094 if (status == PJ_SUCCESS) 7095 { 7096 oi = (call_info_Object *)call_info_new(&call_info_Type, NULL, NULL); 7097 oi->acc_id = info.acc_id; 7098 for (i = 0; i < 128; i++) 7099 { 7100 oi->buf_.call_id[i] = info.buf_.call_id[i]; 7101 oi->buf_.last_status_text[i] = info.buf_.last_status_text[i]; 7102 oi->buf_.local_contact[i] = info.buf_.local_contact[i]; 7103 oi->buf_.local_info[i] = info.buf_.local_info[i]; 7104 oi->buf_.remote_contact[i] = info.buf_.remote_contact[i]; 7105 oi->buf_.remote_info[i] = info.buf_.remote_info[i]; 7106 } 7107 oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, 7108 info.call_id.slen); 7109 oi->conf_slot = info.conf_slot; 7110 oi->connect_duration->sec = info.connect_duration.sec; 7111 oi->connect_duration->msec = info.connect_duration.msec; 7112 oi->total_duration->sec = info.total_duration.sec; 7113 oi->total_duration->msec = info.total_duration.msec; 7114 oi->id = info.id; 7115 oi->last_status = info.last_status; 7116 oi->last_status_text = PyString_FromStringAndSize( 7117 info.last_status_text.ptr, info.last_status_text.slen); 7118 oi->local_contact = PyString_FromStringAndSize( 7119 info.local_contact.ptr, info.local_contact.slen); 7120 oi->local_info = PyString_FromStringAndSize( 7121 info.local_info.ptr, info.local_info.slen); 7122 oi->remote_contact = PyString_FromStringAndSize( 7123 info.remote_contact.ptr, info.remote_contact.slen); 7124 oi->remote_info = PyString_FromStringAndSize( 7125 info.remote_info.ptr, info.remote_info.slen); 7126 oi->media_dir = info.media_dir; 7127 oi->media_status = info.media_status; 7128 oi->role = info.role; 7129 oi->state = info.state; 7130 oi->state_text = PyString_FromStringAndSize( 7131 info.state_text.ptr, info.state_text.slen); 7132 7133 return Py_BuildValue("O", oi); 7134 } else { 7135 Py_INCREF(Py_None); 7136 return Py_None; 7137 } 7138 } 7139 7140 /* 7141 * py_pjsua_call_set_user_data 7142 */ 7143 static PyObject *py_pjsua_call_set_user_data 7144 (PyObject *pSelf, PyObject *pArgs) 7145 { 7146 int call_id; 7147 int user_data; 7148 int status; 7149 7150 if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data)) 7151 { 7152 return NULL; 7153 } 7154 7155 status = pjsua_call_set_user_data(call_id, &user_data); 7156 7157 7158 return Py_BuildValue("i", status); 7159 } 7160 7161 /* 7162 * py_pjsua_call_get_user_data 7163 */ 7164 static PyObject *py_pjsua_call_get_user_data 7165 (PyObject *pSelf, PyObject *pArgs) 7166 { 7167 int call_id; 7168 int * user_data; 7169 7170 7171 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 7172 { 7173 return NULL; 7174 } 7175 7176 user_data = pjsua_call_get_user_data(call_id); 7177 7178 7179 return Py_BuildValue("i", *user_data); 7180 } 7181 7182 /* 7183 * py_pjsua_call_answer 7184 */ 7185 static PyObject *py_pjsua_call_answer 7186 (PyObject *pSelf, PyObject *pArgs) 7187 { 7188 int status; 7189 int call_id; 7190 pj_str_t reason; 7191 PyObject * sr; 7192 unsigned code; 7193 pjsua_msg_data msg_data; 7194 msg_data_Object * omd; 7195 pj_pool_t * pool; 7196 7197 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omd)) 7198 { 7199 return NULL; 7200 } 7201 7202 reason.ptr = PyString_AsString(sr); 7203 reason.slen = strlen(PyString_AsString(sr)); 7204 7205 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7206 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7207 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7208 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7209 pool = pjsua_pool_create("pjsua", 4000, 4000); 7210 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7211 status = pjsua_call_answer(call_id, code, &reason, &msg_data); 7212 7213 pj_pool_release(pool); 7214 return Py_BuildValue("i",status); 7215 } 7216 7217 /* 7218 * py_pjsua_call_hangup 7219 */ 7220 static PyObject *py_pjsua_call_hangup 7221 (PyObject *pSelf, PyObject *pArgs) 7222 { 7223 int status; 7224 int call_id; 7225 pj_str_t reason; 7226 PyObject * sr; 7227 unsigned code; 7228 pjsua_msg_data msg_data; 7229 msg_data_Object * omd; 7230 pj_pool_t * pool; 7231 7232 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omd)) 7233 { 7234 return NULL; 7235 } 7236 7237 reason.ptr = PyString_AsString(sr); 7238 reason.slen = strlen(PyString_AsString(sr)); 7239 7240 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7241 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7242 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7243 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7244 pool = pjsua_pool_create("pjsua", 4000, 4000); 7245 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7246 status = pjsua_call_hangup(call_id, code, &reason, &msg_data); 7247 pj_pool_release(pool); 7248 return Py_BuildValue("i",status); 7249 } 7250 7251 /* 7252 * py_pjsua_call_set_hold 7253 */ 7254 static PyObject *py_pjsua_call_set_hold 7255 (PyObject *pSelf, PyObject *pArgs) 7256 { 7257 int status; 7258 int call_id; 7259 pjsua_msg_data msg_data; 7260 msg_data_Object * omd; 7261 pj_pool_t * pool; 7262 7263 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omd)) 7264 { 7265 return NULL; 7266 } 7267 7268 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7269 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7270 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7271 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7272 pool = pjsua_pool_create("pjsua", 4000, 4000); 7273 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7274 status = pjsua_call_set_hold(call_id, &msg_data); 7275 pj_pool_release(pool); 7276 return Py_BuildValue("i",status); 7277 } 7278 7279 /* 7280 * py_pjsua_call_reinvite 7281 */ 7282 static PyObject *py_pjsua_call_reinvite 7283 (PyObject *pSelf, PyObject *pArgs) 7284 { 7285 int status; 7286 int call_id; 7287 int unhold; 7288 pjsua_msg_data msg_data; 7289 msg_data_Object * omd; 7290 pj_pool_t * pool; 7291 7292 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omd)) 7293 { 7294 return NULL; 7295 } 7296 7297 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7298 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7299 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7300 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7301 pool = pjsua_pool_create("pjsua", 4000, 4000); 7302 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7303 status = pjsua_call_reinvite(call_id, unhold, &msg_data); 7304 pj_pool_release(pool); 7305 return Py_BuildValue("i",status); 7306 } 7307 7308 /* 7309 * py_pjsua_call_xfer 7310 */ 7311 static PyObject *py_pjsua_call_xfer 7312 (PyObject *pSelf, PyObject *pArgs) 7313 { 7314 int status; 7315 int call_id; 7316 pj_str_t dest; 7317 PyObject * sd; 7318 pjsua_msg_data msg_data; 7319 msg_data_Object * omd; 7320 pj_pool_t * pool; 7321 7322 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omd)) 7323 { 7324 return NULL; 7325 } 7326 7327 dest.ptr = PyString_AsString(sd); 7328 dest.slen = strlen(PyString_AsString(sd)); 7329 7330 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7331 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7332 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7333 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7334 pool = pjsua_pool_create("pjsua", 4000, 4000); 7335 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7336 status = pjsua_call_xfer(call_id, &dest, &msg_data); 7337 pj_pool_release(pool); 7338 return Py_BuildValue("i",status); 7339 } 7340 7341 /* 7342 * py_pjsua_call_xfer_replaces 7343 */ 7344 static PyObject *py_pjsua_call_xfer_replaces 7345 (PyObject *pSelf, PyObject *pArgs) 7346 { 7347 int status; 7348 int call_id; 7349 int dest_call_id; 7350 unsigned options; 7351 pjsua_msg_data msg_data; 7352 msg_data_Object * omd; 7353 pj_pool_t * pool; 7354 7355 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &dest_call_id, &options, &omd)) 7356 { 7357 return NULL; 7358 } 7359 7360 7361 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7362 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7363 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7364 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7365 pool = pjsua_pool_create("pjsua", 4000, 4000); 7366 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7367 status = pjsua_call_xfer_replaces(call_id, dest_call_id, options, &msg_data); 7368 pj_pool_release(pool); 7369 return Py_BuildValue("i",status); 7370 } 7371 7372 /* 7373 * py_pjsua_call_dial_dtmf 7374 */ 7375 static PyObject *py_pjsua_call_dial_dtmf 7376 (PyObject *pSelf, PyObject *pArgs) 7377 { 7378 int call_id; 7379 PyObject * sd; 7380 pj_str_t digits; 7381 int status; 7382 7383 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd)) 7384 { 7385 return NULL; 7386 } 7387 digits.ptr = PyString_AsString(sd); 7388 digits.slen = strlen(PyString_AsString(sd)); 7389 status = pjsua_call_dial_dtmf(call_id, &digits); 7390 7391 return Py_BuildValue("i", status); 7392 } 7393 7394 /* 7395 * py_pjsua_call_send_im 7396 */ 7397 static PyObject *py_pjsua_call_send_im 7398 (PyObject *pSelf, PyObject *pArgs) 7399 { 7400 int status; 7401 int call_id; 7402 pj_str_t mime_type, content; 7403 PyObject * sm; 7404 PyObject * sc; 7405 pjsua_msg_data msg_data; 7406 msg_data_Object * omd; 7407 int user_data; 7408 pj_pool_t * pool; 7409 7410 if (!PyArg_ParseTuple(pArgs, "iOOOi", &call_id, &sm, &sc, &omd, &user_data)) 7411 { 7412 return NULL; 7413 } 7414 7415 mime_type.ptr = PyString_AsString(sm); 7416 mime_type.slen = strlen(PyString_AsString(sm)); 7417 content.ptr = PyString_AsString(sc); 7418 content.slen = strlen(PyString_AsString(sc)); 7419 7420 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7421 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7422 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7423 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7424 pool = pjsua_pool_create("pjsua", 4000, 4000); 7425 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7426 status = pjsua_call_send_im(call_id, &mime_type, &content, &msg_data, &user_data); 7427 pj_pool_release(pool); 7428 return Py_BuildValue("i",status); 7429 } 7430 7431 /* 7432 * py_pjsua_call_send_typing_ind 7433 */ 7434 static PyObject *py_pjsua_call_send_typing_ind 7435 (PyObject *pSelf, PyObject *pArgs) 7436 { 7437 int status; 7438 int call_id; 7439 int is_typing; 7440 pjsua_msg_data msg_data; 7441 msg_data_Object * omd; 7442 pj_pool_t * pool; 7443 7444 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omd)) 7445 { 7446 return NULL; 7447 } 7448 7449 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7450 msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); 7451 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7452 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 7453 pool = pjsua_pool_create("pjsua", 4000, 4000); 7454 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7455 status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); 7456 pj_pool_release(pool); 7457 return Py_BuildValue("i",status); 7458 } 7459 7460 /* 7461 * py_pjsua_call_hangup_all 7462 */ 7463 static PyObject *py_pjsua_call_hangup_all 7464 (PyObject *pSelf, PyObject *pArgs) 7465 { 7466 7467 if (!PyArg_ParseTuple(pArgs, "")) 7468 { 7469 return NULL; 7470 } 7471 7472 pjsua_call_hangup_all(); 7473 7474 Py_INCREF(Py_None); 7475 return Py_None; 7476 } 7477 7478 /* 7479 * py_pjsua_call_dump 7480 */ 7481 static PyObject *py_pjsua_call_dump 7482 (PyObject *pSelf, PyObject *pArgs) 7483 { 7484 int call_id; 7485 int with_media; 7486 PyObject * sb; 7487 PyObject * si; 7488 char * buffer; 7489 char * indent; 7490 unsigned maxlen; 7491 int status; 7492 7493 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si)) 7494 { 7495 return NULL; 7496 } 7497 buffer = (char *) malloc (maxlen * sizeof(char)); 7498 indent = PyString_AsString(si); 7499 7500 status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); 7501 sb = PyString_FromStringAndSize(buffer, maxlen); 7502 return Py_BuildValue("O", sb); 7503 } 7504 7505 static char pjsua_call_get_max_count_doc[] = 7506 "int py_pjsua.call_get_max_count () " 7507 "Get maximum number of calls configured in pjsua."; 7508 static char pjsua_call_get_count_doc[] = 7509 "int py_pjsua.call_get_count () " 7510 "Get number of currently active calls."; 7511 static char pjsua_enum_calls_doc[] = 7512 "int[] py_pjsua.enum_calls () " 7513 "Get maximum number of calls configured in pjsua."; 7514 static char pjsua_call_make_call_doc[] = 7515 "int,int py_pjsua.call_make_call (int acc_id, string dst_uri, int options," 7516 "int user_data, py_pjsua.Msg_Data msg_data) " 7517 "Make outgoing call to the specified URI using the specified account."; 7518 static char pjsua_call_is_active_doc[] = 7519 "int py_pjsua.call_is_active (int call_id) " 7520 "Check if the specified call has active INVITE session and the INVITE " 7521 "session has not been disconnected."; 7522 static char pjsua_call_has_media_doc[] = 7523 "int py_pjsua.call_has_media (int call_id) " 7524 "Check if call has an active media session."; 7525 static char pjsua_call_get_conf_port_doc[] = 7526 "int py_pjsua.call_get_conf_port (int call_id) " 7527 "Get the conference port identification associated with the call."; 7528 static char pjsua_call_get_info_doc[] = 7529 "py_pjsua.Call_Info py_pjsua.call_get_info (int call_id) " 7530 "Obtain detail information about the specified call."; 7531 static char pjsua_call_set_user_data_doc[] = 7532 "int py_pjsua.call_set_user_data (int call_id, int user_data) " 7533 "Attach application specific data to the call."; 7534 static char pjsua_call_get_user_data_doc[] = 7535 "int py_pjsua.call_get_user_data (int call_id) " 7536 "Get user data attached to the call."; 7537 static char pjsua_call_answer_doc[] = 7538 "int py_pjsua.call_answer (int call_id, int code, string reason, " 7539 "py_pjsua.Msg_Data msg_data) " 7540 "Send response to incoming INVITE request."; 7541 static char pjsua_call_hangup_doc[] = 7542 "int py_pjsua.call_hangup (int call_id, int code, string reason, " 7543 "py_pjsua.Msg_Data msg_data) " 7544 "Hangup call by using method that is appropriate according " 7545 "to the call state."; 7546 static char pjsua_call_set_hold_doc[] = 7547 "int py_pjsua.call_set_hold (int call_id, py_pjsua.Msg_Data msg_data) " 7548 "Put the specified call on hold."; 7549 static char pjsua_call_reinvite_doc[] = 7550 "int py_pjsua.call_reinvite (int call_id, int unhold, " 7551 "py_pjsua.Msg_Data msg_data) " 7552 "Send re-INVITE (to release hold)."; 7553 static char pjsua_call_xfer_doc[] = 7554 "int py_pjsua.call_xfer (int call_id, string dest, " 7555 "py_pjsua.Msg_Data msg_data) " 7556 "Initiate call transfer to the specified address. " 7557 "This function will send REFER request to instruct remote call party " 7558 "to initiate a new INVITE session to the specified destination/target."; 7559 static char pjsua_call_xfer_replaces_doc[] = 7560 "int py_pjsua.call_xfer_replaces (int call_id, int dest_call_id, " 7561 "int options, py_pjsua.Msg_Data msg_data) " 7562 "Initiate attended call transfer. This function will send REFER request " 7563 "to instruct remote call party to initiate new INVITE session to the URL " 7564 "of dest_call_id. The party at dest_call_id then should 'replace' the call" 7565 "with us with the new call from the REFER recipient."; 7566 static char pjsua_call_dial_dtmf_doc[] = 7567 "int py_pjsua.call_dial_dtmf (int call_id, string digits) " 7568 "Send DTMF digits to remote using RFC 2833 payload formats."; 7569 static char pjsua_call_send_im_doc[] = 7570 "int py_pjsua.call_send_im (int call_id, string mime_type, string content," 7571 "py_pjsua.Msg_Data msg_data, int user_data) " 7572 "Send instant messaging inside INVITE session."; 7573 static char pjsua_call_send_typing_ind_doc[] = 7574 "int py_pjsua.call_send_typing_ind (int call_id, int is_typing, " 7575 "py_pjsua.Msg_Data msg_data) " 7576 "Send IM typing indication inside INVITE session."; 7577 static char pjsua_call_hangup_all_doc[] = 7578 "void py_pjsua.call_hangup_all () " 7579 "Terminate all calls."; 7580 static char pjsua_call_dump_doc[] = 7581 "int py_pjsua.call_dump (int call_id, int with_media, int maxlen, " 7582 "string indent) " 7583 "Dump call and media statistics to string."; 7584 7585 /* END OF LIB CALL */ 4949 7586 4950 7587 /* … … 5167 7804 pjsua_im_typing_doc 5168 7805 }, 5169 7806 { 7807 "conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS, 7808 pjsua_conf_get_max_ports_doc 7809 }, 7810 { 7811 "conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS, 7812 pjsua_conf_get_active_ports_doc 7813 }, 7814 { 7815 "enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS, 7816 pjsua_enum_conf_ports_doc 7817 }, 7818 { 7819 "conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS, 7820 pjsua_conf_get_port_info_doc 7821 }, 7822 { 7823 "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS, 7824 pjsua_conf_add_port_doc 7825 }, 7826 { 7827 "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, 7828 pjsua_conf_remove_port_doc 7829 }, 7830 { 7831 "conf_connect", py_pjsua_conf_connect, METH_VARARGS, 7832 pjsua_conf_connect_doc 7833 }, 7834 { 7835 "conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS, 7836 pjsua_conf_disconnect_doc 7837 }, 7838 { 7839 "player_create", py_pjsua_player_create, METH_VARARGS, 7840 pjsua_player_create_doc 7841 }, 7842 { 7843 "player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS, 7844 pjsua_player_get_conf_port_doc 7845 }, 7846 { 7847 "player_set_pos", py_pjsua_player_set_pos, METH_VARARGS, 7848 pjsua_player_set_pos_doc 7849 }, 7850 { 7851 "player_destroy", py_pjsua_player_destroy, METH_VARARGS, 7852 pjsua_player_destroy_doc 7853 }, 7854 { 7855 "recorder_create", py_pjsua_recorder_create, METH_VARARGS, 7856 pjsua_recorder_create_doc 7857 }, 7858 { 7859 "recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS, 7860 pjsua_recorder_get_conf_port_doc 7861 }, 7862 { 7863 "recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS, 7864 pjsua_recorder_destroy_doc 7865 }, 7866 { 7867 "enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS, 7868 pjsua_enum_snd_devs_doc 7869 }, 7870 /*{ 7871 "get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS, 7872 pjsua_get_snd_dev_doc 7873 },*/ 7874 { 7875 "set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS, 7876 pjsua_set_snd_dev_doc 7877 }, 7878 { 7879 "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, 7880 pjsua_set_null_snd_dev_doc 7881 }, 7882 { 7883 "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS, 7884 pjsua_set_no_snd_dev_doc 7885 }, 7886 { 7887 "set_ec", py_pjsua_set_ec, METH_VARARGS, 7888 pjsua_set_ec_doc 7889 }, 7890 { 7891 "get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS, 7892 pjsua_get_ec_tail_doc 7893 }, 7894 { 7895 "enum_codecs", py_pjsua_enum_codecs, METH_VARARGS, 7896 pjsua_enum_codecs_doc 7897 }, 7898 { 7899 "codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS, 7900 pjsua_codec_set_priority_doc 7901 }, 7902 { 7903 "codec_get_param", py_pjsua_codec_get_param, METH_VARARGS, 7904 pjsua_codec_get_param_doc 7905 }, 7906 { 7907 "codec_set_param", py_pjsua_codec_set_param, METH_VARARGS, 7908 pjsua_codec_set_param_doc 7909 }, 7910 { 7911 "call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS, 7912 pjsua_call_get_max_count_doc 7913 }, 7914 { 7915 "call_get_count", py_pjsua_call_get_count, METH_VARARGS, 7916 pjsua_call_get_count_doc 7917 }, 7918 { 7919 "enum_calls", py_pjsua_enum_calls, METH_VARARGS, 7920 pjsua_enum_calls_doc 7921 }, 7922 { 7923 "call_make_call", py_pjsua_call_make_call, METH_VARARGS, 7924 pjsua_call_make_call_doc 7925 }, 7926 { 7927 "call_is_active", py_pjsua_call_is_active, METH_VARARGS, 7928 pjsua_call_is_active_doc 7929 }, 7930 { 7931 "call_has_media", py_pjsua_call_has_media, METH_VARARGS, 7932 pjsua_call_has_media_doc 7933 }, 7934 { 7935 "call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS, 7936 pjsua_call_get_conf_port_doc 7937 }, 7938 { 7939 "call_get_info", py_pjsua_call_get_info, METH_VARARGS, 7940 pjsua_call_get_info_doc 7941 }, 7942 { 7943 "call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS, 7944 pjsua_call_set_user_data_doc 7945 }, 7946 { 7947 "call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS, 7948 pjsua_call_get_user_data_doc 7949 }, 7950 { 7951 "call_answer", py_pjsua_call_answer, METH_VARARGS, 7952 pjsua_call_answer_doc 7953 }, 7954 { 7955 "call_hangup", py_pjsua_call_hangup, METH_VARARGS, 7956 pjsua_call_hangup_doc 7957 }, 7958 { 7959 "call_set_hold", py_pjsua_call_set_hold, METH_VARARGS, 7960 pjsua_call_set_hold_doc 7961 }, 7962 { 7963 "call_reinvite", py_pjsua_call_reinvite, METH_VARARGS, 7964 pjsua_call_reinvite_doc 7965 }, 7966 { 7967 "call_xfer", py_pjsua_call_xfer, METH_VARARGS, 7968 pjsua_call_xfer_doc 7969 }, 7970 { 7971 "call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS, 7972 pjsua_call_xfer_replaces_doc 7973 }, 7974 { 7975 "call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS, 7976 pjsua_call_dial_dtmf_doc 7977 }, 7978 { 7979 "call_send_im", py_pjsua_call_send_im, METH_VARARGS, 7980 pjsua_call_send_im_doc 7981 }, 7982 { 7983 "call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS, 7984 pjsua_call_send_typing_ind_doc 7985 }, 7986 { 7987 "call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS, 7988 pjsua_call_hangup_all_doc 7989 }, 7990 { 7991 "call_dump", py_pjsua_call_dump, METH_VARARGS, 7992 pjsua_call_dump_doc 7993 }, 7994 7995 5170 7996 5171 7997 {NULL, NULL} /* end of function list */ … … 5255 8081 /* END OF LIB BUDDY */ 5256 8082 5257 8083 /* LIB MEDIA */ 8084 8085 if (PyType_Ready(&codec_info_Type) < 0) 8086 return; 8087 8088 if (PyType_Ready(&conf_port_info_Type) < 0) 8089 return; 8090 8091 pjmedia_port_Type.tp_new = PyType_GenericNew; 8092 if (PyType_Ready(&pjmedia_port_Type) < 0) 8093 return; 8094 8095 if (PyType_Ready(&pjmedia_snd_dev_info_Type) < 0) 8096 return; 8097 8098 pjmedia_codec_param_info_Type.tp_new = PyType_GenericNew; 8099 if (PyType_Ready(&pjmedia_codec_param_info_Type) < 0) 8100 return; 8101 pjmedia_codec_param_setting_Type.tp_new = PyType_GenericNew; 8102 if (PyType_Ready(&pjmedia_codec_param_setting_Type) < 0) 8103 return; 8104 8105 if (PyType_Ready(&pjmedia_codec_param_Type) < 0) 8106 return; 8107 8108 /* END OF LIB MEDIA */ 8109 8110 /* LIB CALL */ 8111 8112 pj_time_val_Type.tp_new = PyType_GenericNew; 8113 if (PyType_Ready(&pj_time_val_Type) < 0) 8114 return; 8115 8116 if (PyType_Ready(&call_info_Type) < 0) 8117 return; 8118 8119 /* END OF LIB CALL */ 5258 8120 5259 8121 m = Py_InitModule3( … … 5340 8202 /* END OF LIB BUDDY */ 5341 8203 5342 8204 /* LIB MEDIA */ 8205 8206 Py_INCREF(&codec_info_Type); 8207 PyModule_AddObject(m, "Codec_Info", (PyObject *)&codec_info_Type); 8208 Py_INCREF(&conf_port_info_Type); 8209 PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&conf_port_info_Type); 8210 Py_INCREF(&pjmedia_port_Type); 8211 PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&pjmedia_port_Type); 8212 Py_INCREF(&pjmedia_snd_dev_info_Type); 8213 PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", 8214 (PyObject *)&pjmedia_snd_dev_info_Type); 8215 Py_INCREF(&pjmedia_codec_param_info_Type); 8216 PyModule_AddObject(m, "PJMedia_Codec_Param_Info", 8217 (PyObject *)&pjmedia_codec_param_info_Type); 8218 Py_INCREF(&pjmedia_codec_param_setting_Type); 8219 PyModule_AddObject(m, "PJMedia_Codec_Param_Setting", 8220 (PyObject *)&pjmedia_codec_param_setting_Type); 8221 Py_INCREF(&pjmedia_codec_param_Type); 8222 PyModule_AddObject(m, "PJMedia_Codec_Param", 8223 (PyObject *)&pjmedia_codec_param_Type); 8224 8225 /* END OF LIB MEDIA */ 8226 8227 /* LIB CALL */ 8228 8229 Py_INCREF(&pj_time_val_Type); 8230 PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&pj_time_val_Type); 8231 8232 Py_INCREF(&call_info_Type); 8233 PyModule_AddObject(m, "Call_Info", (PyObject *)&call_info_Type); 8234 8235 /* END OF LIB CALL */ 5343 8236 5344 8237 #ifdef PJSUA_INVALID_ID … … 5403 8296 #endif 5404 8297 5405 5406 5407 5408 } 8298 #ifdef PJSUA_MAX_CONF_PORTS 8299 8300 /* 8301 * Max ports in the conference bridge. 8302 */ 8303 PyModule_AddIntConstant( 8304 m, "PJSUA_MAX_CONF_PORTS", PJSUA_MAX_CONF_PORTS 8305 ); 8306 8307 #endif 8308 8309 #ifdef PJSUA_DEFAULT_CLOCK_RATE 8310 8311 PyModule_AddIntConstant( 8312 m, "PJSUA_DEFAULT_CLOCK_RATE", PJSUA_DEFAULT_CLOCK_RATE 8313 ); 8314 8315 #endif 8316 8317 #ifdef PJSUA_DEFAULT_CODEC_QUALITY 8318 8319 PyModule_AddIntConstant( 8320 m, "PJSUA_DEFAULT_CODEC_QUALITY", PJSUA_DEFAULT_CODEC_QUALITY 8321 ); 8322 8323 #endif 8324 8325 #ifdef PJSUA_DEFAULT_ILBC_MODE 8326 8327 PyModule_AddIntConstant( 8328 m, "PJSUA_DEFAULT_ILBC_MODE", PJSUA_DEFAULT_ILBC_MODE 8329 ); 8330 8331 #endif 8332 8333 #ifdef PJSUA_DEFAULT_EC_TAIL_LEN 8334 8335 PyModule_AddIntConstant( 8336 m, "PJSUA_DEFAULT_EC_TAIL_LEN", PJSUA_DEFAULT_EC_TAIL_LEN 8337 ); 8338 8339 #endif 8340 8341 #ifdef PJSUA_MAX_CALLS 8342 8343 PyModule_AddIntConstant( 8344 m, "PJSUA_MAX_CALLS", PJSUA_MAX_CALLS 8345 ); 8346 8347 #endif 8348 8349 #ifdef PJSUA_XFER_NO_REQUIRE_REPLACES 8350 8351 PyModule_AddIntConstant( 8352 m, "PJSUA_XFER_NO_REQUIRE_REPLACES", PJSUA_XFER_NO_REQUIRE_REPLACES 8353 ); 8354 #endif 8355 8356 }
Note: See TracChangeset
for help on using the changeset viewer.