Changeset 914


Ignore:
Timestamp:
Jan 29, 2007 5:07:41 AM (17 years ago)
Author:
fahris
Message:

revisi py_pjsua.c 290107

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c

    r870 r914  
    31733173    } 
    31743174     
    3175     free(id); 
     3175     
    31763176    return Py_BuildValue("O",list); 
    31773177} 
     
    41284128    } 
    41294129     
    4130     free(id); 
     4130     
    41314131    return Py_BuildValue("O",list); 
    41324132} 
     
    41764176    } 
    41774177     
    4178     free(info); 
     4178     
    41794179    return Py_BuildValue("O",list); 
    41804180} 
     
    47014701    } 
    47024702     
    4703     free(id); 
     4703     
    47044704    return Py_BuildValue("O",list); 
    47054705} 
     
    58265826    } 
    58275827     
    5828     free(id); 
     5828     
    58295829    return Py_BuildValue("O",list); 
    58305830} 
     
    61256125    PyObject *list; 
    61266126     
    6127     pjmedia_snd_dev_info *info; 
     6127    pjmedia_snd_dev_info info[64]; 
    61286128    int c, i; 
    6129     if (!PyArg_ParseTuple(pArgs, "i", &c)) 
     6129    if (!PyArg_ParseTuple(pArgs, "")) 
    61306130    { 
    61316131        return NULL; 
    61326132    }    
    61336133     
    6134     info = (pjmedia_snd_dev_info *)malloc(c * sizeof(pjmedia_snd_dev_info)); 
     6134    c = PJ_ARRAY_SIZE(info); 
    61356135    status = pjsua_enum_snd_devs(info, &c); 
    61366136     
     
    61616161    } 
    61626162     
    6163     free(info); 
     6163     
    61646164    return Py_BuildValue("O",list); 
    61656165} 
     
    63306330    } 
    63316331     
    6332     free(info); 
     6332     
    63336333    return Py_BuildValue("O",list); 
    63346334} 
     
    69696969    } 
    69706970     
    6971     free(id); 
     6971     
    69726972    return Py_BuildValue("O",list); 
    69736973} 
     
    75857585/* END OF LIB CALL */ 
    75867586 
     7587/* For testing purpose only */ 
     7588 
     7589struct call_data 
     7590{ 
     7591    pj_timer_entry          timer; 
     7592}; 
     7593 
     7594/* 
     7595 * call_data_Object 
     7596 */ 
     7597typedef struct 
     7598{ 
     7599    PyObject_HEAD 
     7600    /* Type-specific fields go here. */ 
     7601    struct call_data * data; 
     7602} call_data_Object; 
     7603 
     7604 
     7605/* 
     7606 * call_data_Type 
     7607 */ 
     7608static PyTypeObject call_data_Type = 
     7609{ 
     7610    PyObject_HEAD_INIT(NULL) 
     7611    0,                              /*ob_size*/ 
     7612    "py_pjsua.Call_Data",       /*tp_name*/ 
     7613    sizeof(call_data_Object),   /*tp_basicsize*/ 
     7614    0,                              /*tp_itemsize*/ 
     7615    0,                              /*tp_dealloc*/ 
     7616    0,                              /*tp_print*/ 
     7617    0,                              /*tp_getattr*/ 
     7618    0,                              /*tp_setattr*/ 
     7619    0,                              /*tp_compare*/ 
     7620    0,                              /*tp_repr*/ 
     7621    0,                              /*tp_as_number*/ 
     7622    0,                              /*tp_as_sequence*/ 
     7623    0,                              /*tp_as_mapping*/ 
     7624    0,                              /*tp_hash */ 
     7625    0,                              /*tp_call*/ 
     7626    0,                              /*tp_str*/ 
     7627    0,                              /*tp_getattro*/ 
     7628    0,                              /*tp_setattro*/ 
     7629    0,                              /*tp_as_buffer*/ 
     7630    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
     7631    "call_data objects",        /*tp_doc*/ 
     7632}; 
     7633 
     7634static void call_timeout_callback(pj_timer_heap_t *timer_heap, 
     7635                                  struct pj_timer_entry *entry, unsigned duration) 
     7636{ 
     7637    pjsua_call_id call_id = entry->id; 
     7638    pjsua_msg_data msg_data; 
     7639    pjsip_generic_string_hdr warn; 
     7640    pj_str_t hname = pj_str("Warning"); 
     7641    pj_str_t hvalue = pj_str("399 pjsua \"Call duration exceeded\""); 
     7642 
     7643    PJ_UNUSED_ARG(timer_heap); 
     7644 
     7645    if (call_id == PJSUA_INVALID_ID) { 
     7646        PJ_LOG(1,(THIS_FILE, "Invalid call ID in timer callback")); 
     7647        return; 
     7648    } 
     7649     
     7650    /* Add warning header */ 
     7651    pjsua_msg_data_init(&msg_data); 
     7652    pjsip_generic_string_hdr_init2(&warn, &hname, &hvalue); 
     7653    pj_list_push_back(&msg_data.hdr_list, &warn); 
     7654 
     7655    /* Call duration has been exceeded; disconnect the call */ 
     7656    PJ_LOG(3,(THIS_FILE, "Duration (%d seconds) has been exceeded " 
     7657                         "for call %d, disconnecting the call", 
     7658                         duration, call_id)); 
     7659    entry->id = PJSUA_INVALID_ID; 
     7660    pjsua_call_hangup(call_id, 200, NULL, &msg_data); 
     7661} 
     7662 
     7663/*static PyObject *py_pjsua_call_timeout_callback 
     7664(PyObject *pSelf, PyObject *pArgs) 
     7665{        
     7666 
     7667    if (!PyArg_ParseTuple(pArgs, "")) 
     7668    { 
     7669        return NULL; 
     7670    }    
     7671     
     7672    call_timeout_callback(); 
     7673     
     7674    Py_INCREF(Py_None); 
     7675    return Py_None; 
     7676}*/ 
     7677 
     7678static void on_call_state_1() { 
     7679/*      if app_config.call_data[call_id].timer.id != PJSUA_INVALID_ID) { 
     7680            struct call_data *cd = &app_config.call_data[call_id]; 
     7681            pjsip_endpoint *endpt = pjsua_get_pjsip_endpt(); 
     7682 
     7683            cd->timer.id = PJSUA_INVALID_ID; 
     7684            pjsip_endpt_cancel_timer(endpt, &cd->timer); 
     7685        } 
     7686 
     7687        PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]",  
     7688                  call_id, 
     7689                  call_info.last_status, 
     7690                  call_info.last_status_text.ptr));*/ 
     7691} 
     7692 
     7693/* END OF Testing section */ 
     7694 
    75877695/* 
    75887696 * Map of function names to functions 
Note: See TracChangeset for help on using the changeset viewer.