Changeset 3019
- Timestamp:
- Nov 20, 2009 4:18:27 AM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2998 r3019 102 102 unsigned auto_answer; 103 103 unsigned duration; 104 pj_bool_t unsolicited_mwi; 104 105 105 106 #ifdef STEREO_DEMO … … 145 146 static pj_status_t create_ipv6_media_transports(void); 146 147 pj_status_t app_destroy(void); 148 static void enable_unsolicited_mwi(void); 147 149 148 150 static void ringback_start(pjsua_call_id call_id); … … 195 197 puts (" --publish Send presence PUBLISH for this account"); 196 198 puts (" --mwi Subscribe to message summary/waiting indication"); 199 puts (" --unsolicited-mwi Handle unsolicited MWI requests"); 197 200 puts (" --use-100rel Require reliable provisional response (100rel)"); 198 201 puts (" --use-timer Require SIP session timers"); … … 485 488 OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, 486 489 OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 487 OPT_MWI, OPT_ NAMESERVER, OPT_STUN_SRV,490 OPT_MWI, OPT_UNSOLICITED_MWI, OPT_NAMESERVER, OPT_STUN_SRV, 488 491 OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 489 492 OPT_AUTO_ANSWER, OPT_AUTO_PLAY, OPT_AUTO_PLAY_HANGUP, OPT_AUTO_LOOP, … … 538 541 { "publish", 0, 0, OPT_PUBLISH}, 539 542 { "mwi", 0, 0, OPT_MWI}, 543 { "unsolicited-mwi", 0, 0, OPT_UNSOLICITED_MWI}, 540 544 { "use-100rel", 0, 0, OPT_100REL}, 541 545 { "use-ims", 0, 0, OPT_USE_IMS}, … … 840 844 break; 841 845 846 case OPT_UNSOLICITED_MWI: 847 cfg->unsolicited_mwi = PJ_TRUE; 848 break; 849 842 850 case OPT_100REL: /** 100rel */ 843 851 cur_acc->require_100rel = PJ_TRUE; … … 1991 1999 { 1992 2000 pj_strcat2(&cfg, "--use-compact-form\n"); 2001 } 2002 2003 if (config->unsolicited_mwi) { 2004 pj_strcat2(&cfg, "--unsolicited-mwi\n"); 1993 2005 } 1994 2006 … … 4396 4408 return status; 4397 4409 4410 /* Initialize unsolicited MWI */ 4411 if (app_config.unsolicited_mwi) 4412 enable_unsolicited_mwi(); 4413 4398 4414 /* Initialize our module to handle otherwise unhandled request */ 4399 4415 status = pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), … … 4999 5015 return pjsua_media_transports_attach(tp, i, PJ_TRUE); 5000 5016 } 5017 5018 /***************************************************************************** 5019 * Asterisk unsolicited MWI module 5020 */ 5021 static pj_bool_t mwi_on_rx_request(pjsip_rx_data *rdata) 5022 { 5023 pjsip_msg *msg = rdata->msg_info.msg; 5024 pj_str_t EVENT_HDR = { "Event", 5 }; 5025 pj_str_t MWI = { "message-summary", 15 }; 5026 pjsip_event_hdr *eh; 5027 pj_str_t body; 5028 5029 if (pjsip_method_cmp(&msg->line.req.method, &pjsip_notify_method)!=0) { 5030 /* Only interested with NOTIFY request */ 5031 return PJ_FALSE; 5032 } 5033 5034 eh = (pjsip_event_hdr*) pjsip_msg_find_hdr_by_name(msg, &EVENT_HDR, NULL); 5035 if (!eh) { 5036 /* Something wrong with the request, it has no Event hdr */ 5037 return PJ_FALSE; 5038 } 5039 5040 if (pj_stricmp(&eh->event_type, &MWI) != 0) { 5041 /* Not MWI event */ 5042 return PJ_FALSE; 5043 } 5044 5045 /* Got unsolicited MWI request, respond with 200/OK first */ 5046 pjsip_endpt_respond(pjsua_get_pjsip_endpt(), NULL, rdata, 200, NULL, 5047 NULL, NULL, NULL); 5048 5049 5050 PJ_LOG(3,(THIS_FILE, "Received MWI info:")); 5051 5052 if (rdata->msg_info.ctype) { 5053 const pjsip_ctype_hdr *ctype = rdata->msg_info.ctype; 5054 5055 PJ_LOG(3,(THIS_FILE, " Content-Type: %.*s/%.*s", 5056 (int)ctype->media.type.slen, 5057 ctype->media.type.ptr, 5058 (int)ctype->media.subtype.slen, 5059 ctype->media.subtype.ptr)); 5060 } 5061 5062 if (!rdata->msg_info.msg->body) { 5063 PJ_LOG(3,(THIS_FILE, " no message body")); 5064 return PJ_TRUE; 5065 } 5066 5067 body.ptr = rdata->msg_info.msg->body->data; 5068 body.slen = rdata->msg_info.msg->body->len; 5069 5070 PJ_LOG(3,(THIS_FILE, " Body:\n%.*s", (int)body.slen, body.ptr)); 5071 5072 return PJ_TRUE; 5073 } 5074 5075 /* The module instance. */ 5076 static pjsip_module pjsua_mwi_mod = 5077 { 5078 NULL, NULL, /* prev, next. */ 5079 { "mod-unsolicited-mwi", 19 }, /* Name. */ 5080 -1, /* Id */ 5081 PJSIP_MOD_PRIORITY_UA_PROXY_LAYER-1,/* Priority */ 5082 NULL, /* load() */ 5083 NULL, /* start() */ 5084 NULL, /* stop() */ 5085 NULL, /* unload() */ 5086 &mwi_on_rx_request, /* on_rx_request() */ 5087 NULL, /* on_rx_response() */ 5088 NULL, /* on_tx_request. */ 5089 NULL, /* on_tx_response() */ 5090 NULL, /* on_tsx_state() */ 5091 }; 5092 5093 static void enable_unsolicited_mwi(void) 5094 { 5095 pj_status_t status; 5096 5097 status = pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), 5098 &pjsua_mwi_mod); 5099 if (status != PJ_SUCCESS) 5100 pjsua_perror(THIS_FILE, "Error registering MWI module", status); 5101 } 5102 -
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r2973 r3019 214 214 */ 215 215 #ifndef PJSIP_MAX_MODULE 216 # define PJSIP_MAX_MODULE 16216 # define PJSIP_MAX_MODULE 32 217 217 #endif 218 218
Note: See TracChangeset
for help on using the changeset viewer.