- Timestamp:
- Oct 2, 2013 3:19:54 AM (11 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python/_pjsua.c
r4422 r4609 132 132 */ 133 133 static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, 134 pjsip_rx_data *rdata) 135 { 136 PJ_UNUSED_ARG(rdata); 137 134 pjsip_rx_data *rdata) 135 { 138 136 if (PyCallable_Check(g_obj_callback->on_incoming_call)) { 139 PyObj ect*obj;140 137 PyObj_pjsip_rx_data *obj; 138 141 139 ENTER_PYTHON(); 142 143 obj = Py_BuildValue(""); 144 145 PyObject_CallFunction( 146 g_obj_callback->on_incoming_call, 147 "iiO", 148 acc_id, 149 call_id, 150 obj, 151 NULL 152 ); 140 141 obj = (PyObj_pjsip_rx_data*) 142 PyObj_pjsip_rx_data_new(&PyTyp_pjsip_rx_data, 143 NULL, NULL); 144 PyObj_pjsip_rx_data_import(obj, rdata); 145 146 PyObject_CallFunction( 147 g_obj_callback->on_incoming_call, 148 "iiO", 149 acc_id, 150 call_id, 151 obj, 152 NULL 153 ); 153 154 154 155 Py_DECREF(obj); … … 4454 4455 if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0) 4455 4456 return; 4457 PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew; 4458 if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0) 4459 return; 4456 4460 4457 4461 /* LIB TRANSPORT */ … … 4536 4540 PyModule_AddObject(m, "Pjsip_Cred_Info", 4537 4541 (PyObject *)&PyTyp_pjsip_cred_info 4542 ); 4543 4544 Py_INCREF(&PyTyp_pjsip_rx_data); 4545 PyModule_AddObject(m, "Pjsip_Rx_Data", 4546 (PyObject *)&PyTyp_pjsip_rx_data 4538 4547 ); 4539 4548 -
pjproject/trunk/pjsip-apps/src/python/_pjsua.h
r4581 r4609 1770 1770 const pjsua_acc_config *cfg) 1771 1771 { 1772 PyObj_pjsua_transport_config *tconf; 1772 1773 unsigned i; 1773 1774 … … 1826 1827 1827 1828 Py_XDECREF(obj->rtp_transport_cfg); 1828 PyObj_pjsua_transport_config *tconf; 1829 tconf = (PyObj_pjsua_transport_config*) PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config,NULL, NULL); 1829 tconf = (PyObj_pjsua_transport_config*) 1830 PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config, 1831 NULL, NULL); 1830 1832 PyObj_pjsua_transport_config_import(tconf, &cfg->rtp_cfg); 1831 1833 obj->rtp_transport_cfg = (PyObject *) tconf; … … 1835 1837 PyObj_pjsua_acc_config *obj) 1836 1838 { 1839 PyObj_pjsua_transport_config *tconf; 1837 1840 unsigned i; 1838 1841 … … 1881 1884 cfg->srtp_secure_signaling = obj->srtp_secure_signaling; 1882 1885 1883 PyObj_pjsua_transport_config *tconf; 1884 tconf = (PyObj_pjsua_transport_config*) obj->rtp_transport_cfg; 1885 PyObj_pjsua_transport_config_export(&cfg->rtp_cfg, tconf); 1886 tconf = (PyObj_pjsua_transport_config*)obj->rtp_transport_cfg; 1887 PyObj_pjsua_transport_config_export(&cfg->rtp_cfg, tconf); 1886 1888 } 1887 1889 … … 3585 3587 3586 3588 3587 3588 3589 ////////////////////////////////////////////////////////////////////////////// 3590 /* 3591 * PyObj_pjsip_rx_data 3592 */ 3593 typedef struct 3594 { 3595 PyObject_HEAD 3596 3597 /* Type-specific fields go here. */ 3598 PyObject *msg_info_buffer; // string 3599 PyObject *msg_info_info; // string 3600 3601 } PyObj_pjsip_rx_data; 3602 3603 /* 3604 * PyObj_pjsip_rx_data_dealloc 3605 * deletes rx_data from memory 3606 */ 3607 static void PyObj_pjsip_rx_data_delete(PyObj_pjsip_rx_data* self) 3608 { 3609 Py_XDECREF(self->msg_info_buffer); 3610 Py_XDECREF(self->msg_info_info); 3611 3612 self->ob_type->tp_free((PyObject*)self); 3613 } 3614 3615 3616 static void PyObj_pjsip_rx_data_import(PyObj_pjsip_rx_data *obj, pjsip_rx_data *rx_data) 3617 { 3618 Py_XDECREF(obj->msg_info_buffer); 3619 obj->msg_info_buffer = PyString_FromString(rx_data->msg_info.msg_buf); 3620 Py_XDECREF(obj->msg_info_info); 3621 obj->msg_info_info = PyString_FromString(pjsip_rx_data_get_info(rx_data)); 3622 } 3623 3624 3625 /* 3626 * PyObj_pjsip_rx_data_new 3627 * constructor for PyObj_pjsip_rx_data object 3628 */ 3629 static PyObject * PyObj_pjsip_rx_data_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 3630 { 3631 PyObj_pjsip_rx_data *self; 3632 3633 PJ_UNUSED_ARG(args); 3634 PJ_UNUSED_ARG(kwds); 3635 3636 self = (PyObj_pjsip_rx_data *)type->tp_alloc(type, 0); 3637 if (self != NULL) { 3638 self->msg_info_buffer = PyString_FromString(""); 3639 self->msg_info_info = PyString_FromString(""); 3640 } 3641 3642 return (PyObject *)self; 3643 } 3644 3645 3646 3647 /* 3648 * PyObj_pjsip_rx_data_members 3649 */ 3650 static PyMemberDef PyObj_pjsip_rx_data_members[] = 3651 { 3652 { 3653 "msg_info_buffer", T_OBJECT_EX, 3654 offsetof(PyObj_pjsip_rx_data, msg_info_buffer), 0, 3655 "Entire SIP-Message" 3656 }, 3657 { 3658 "msg_info_info", T_OBJECT_EX, 3659 offsetof(PyObj_pjsip_rx_data, msg_info_info), 0, 3660 "Message Info" 3661 }, 3662 3663 {NULL} /* Sentinel */ 3664 }; 3665 3666 /* 3667 * PyTyp_pjsip_rx_data 3668 */ 3669 static PyTypeObject PyTyp_pjsip_rx_data = 3670 { 3671 PyObject_HEAD_INIT(NULL) 3672 0, /*ob_size*/ 3673 "_pjsua.Pjsip_Rx_Data", /*tp_name*/ 3674 sizeof(PyObj_pjsip_rx_data), /*tp_basicsize*/ 3675 0, /*tp_itemsize*/ 3676 (destructor)PyObj_pjsip_rx_data_delete,/*tp_dealloc*/ 3677 0, /*tp_print*/ 3678 0, /*tp_getattr*/ 3679 0, /*tp_setattr*/ 3680 0, /*tp_compare*/ 3681 0, /*tp_repr*/ 3682 0, /*tp_as_number*/ 3683 0, /*tp_as_sequence*/ 3684 0, /*tp_as_mapping*/ 3685 0, /*tp_hash */ 3686 0, /*tp_call*/ 3687 0, /*tp_str*/ 3688 0, /*tp_getattro*/ 3689 0, /*tp_setattro*/ 3690 0, /*tp_as_buffer*/ 3691 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 3692 "PJSIP request data information", /* tp_doc */ 3693 0, /* tp_traverse */ 3694 0, /* tp_clear */ 3695 0, /* tp_richcompare */ 3696 0, /* tp_weaklistoffset */ 3697 0, /* tp_iter */ 3698 0, /* tp_iternext */ 3699 0, /* tp_methods */ 3700 PyObj_pjsip_rx_data_members, /* tp_members */ 3701 0, /* tp_getset */ 3702 0, /* tp_base */ 3703 0, /* tp_dict */ 3704 0, /* tp_descr_get */ 3705 0, /* tp_descr_set */ 3706 0, /* tp_dictoffset */ 3707 0, /* tp_init */ 3708 0, /* tp_alloc */ 3709 PyObj_pjsip_rx_data_new, /* tp_new */ 3710 3711 }; 3712 3713 3714 3715 ////////////////////////////////////////////////////////////////////////////// 3589 3716 3590 3717 #endif /* __PY_PJSUA_H__ */ -
pjproject/trunk/pjsip-apps/src/python/pjsua.py
r4581 r4609 898 898 cfg.srtp_secure_signaling = self.srtp_secure_signaling 899 899 900 cfg.rtp_transport_cfg = self.rtp_transport_cfg._cvt_to_pjsua() 900 if (self.rtp_transport_cfg is not None): 901 cfg.rtp_transport_cfg = self.rtp_transport_cfg._cvt_to_pjsua() 901 902 902 903 return cfg … … 979 980 """Notification about incoming call. 980 981 981 Unless this callback is implemented, the default behavior is to 982 reject the call with default status code. 982 Application should implement one of on_incoming_call() or 983 on_incoming_call2(), otherwise, the default behavior is to 984 reject the call with default status code. Note that if both are 985 implemented, only on_incoming_call2() will be called. 983 986 984 987 Keyword arguments: … … 987 990 call.hangup() 988 991 992 def on_incoming_call2(self, call, rdata): 993 """Notification about incoming call, with received SIP message info. 994 995 Application should implement one of on_incoming_call() or 996 on_incoming_call2(), otherwise, the default behavior is to 997 reject the call with default status code. Note that if both are 998 implemented, only on_incoming_call2() will be called. 999 1000 Keyword arguments: 1001 call -- the new incoming call 1002 rdata -- the received message 1003 """ 1004 call.hangup() 1005 989 1006 def on_incoming_subscribe(self, buddy, from_uri, contact_uri, pres_obj): 990 1007 """Notification when incoming SUBSCRIBE request is received. … … 2742 2759 acc = self._lookup_account(acc_id) 2743 2760 if acc: 2744 acc._cb.on_incoming_call( Call(self, call_id) ) 2761 if 'on_incoming_call2' in acc._cb.__class__.__dict__: 2762 acc._cb.on_incoming_call2( Call(self, call_id), rdata ) 2763 else: 2764 acc._cb.on_incoming_call( Call(self, call_id) ) 2745 2765 else: 2746 2766 _pjsua.call_hangup(call_id, 603, None, None)
Note: See TracChangeset
for help on using the changeset viewer.