static char * generating_no_sdp_answer(eXosip_call_t *jc, eXosip_dialog_t *jd, osip_message_t *orig_request, char *local_sdp_port, char *local_video_port) { sdp_message_t *local_sdp = NULL; char *local_body = NULL; char *size; int i; jc->c_ack_sdp = 1; if(osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &local_sdp, local_sdp_port, local_video_port) != 0) return NULL; if (local_sdp!=NULL) { int pos=0; while (!sdp_message_endof_media (local_sdp, pos)) { int k = 0; char *tmp = sdp_message_m_media_get (local_sdp, pos); if (0 == strncmp (tmp, "audio", 5)) { char *payload = NULL; do { payload = sdp_message_m_payload_get (local_sdp, pos, k); if (payload == NULL) { } else if (0==strncmp("110",payload,3)) { sdp_message_a_attribute_add (local_sdp, pos, osip_strdup ("AS"), osip_strdup ("110 20")); } else if (0==strncmp("111",payload,3)) { sdp_message_a_attribute_add (local_sdp, pos, osip_strdup ("AS"), osip_strdup ("111 20")); } k++; } while (payload != NULL); } pos++; } } i = sdp_message_to_str(local_sdp, &local_body); if (local_body!=NULL) { size= (char *)osip_malloc(7*sizeof(char)); #ifdef __APPLE_CC__ sprintf(size,"%li",strlen(local_body)); #else sprintf(size,"%i",strlen(local_body)); #endif osip_message_set_content_length(orig_request, size); osip_free(size); osip_message_set_body(orig_request, local_body, strlen(local_body)); osip_message_set_content_type(orig_request, "application/sdp"); } else osip_message_set_content_length(orig_request, "0"); osip_negotiation_ctx_set_local_sdp(jc->c_ctx, local_sdp); OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO3,NULL,"200 OK w/ SDP (RESPONSE TO INVITE w/ NO SDP)=\n%s\n", local_body)); return local_body; }
int eXosip_answer_options_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) { osip_event_t *evt_answer; osip_transaction_t *tr; osip_message_t *response; sdp_message_t *sdp; char *body; char size[10]; int i; tr = eXosip_find_last_inc_options(jc, jd); if (tr==NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot find transaction to answer")); return -1; } osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &sdp, "10400", NULL); if (sdp==NULL) { return -1; } if (jd!=NULL) { i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); } else { i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); } if (i!=0) { OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for options\n")); sdp_message_free(sdp); /* not used */ return -1; } i = sdp_message_to_str(sdp, &body); sdp_message_free(sdp); if ( ( i!=0 ) || ( ! body ) ) { osip_message_free(response); return -1; } i = osip_message_set_body(response, body, strlen(body)); if (i!=0) { osip_message_free(response); return -1; } #ifdef __APPLE_CC__ snprintf(size, 9,"%li",strlen(body)); #else snprintf(size, 9,"%i",strlen(body)); #endif i = osip_message_set_content_length(response, size); if (i!=0) { osip_free(body); osip_message_free(response); return -1; } osip_free(body); i = osip_message_set_content_type(response, "application/sdp"); if (i!=0) { osip_message_free(response); return -1; } evt_answer = osip_new_outgoing_sipmessage(response); evt_answer->transactionid = tr->transactionid; osip_transaction_add_event(tr, evt_answer); __eXosip_wakeup(); return 0; }
int test_sdp_message (char *msg, int verbose) { sdp_message_t *sdp; { char *result; sdp_message_init (&sdp); if (sdp_message_parse (sdp, msg) != 0) { fprintf (stdout, "ERROR: failed while parsing!\n"); sdp_message_free (sdp); /* try to free msg, even if it failed! */ /* this seems dangerous..... */ return -1; } else { int i; i = sdp_message_to_str (sdp, &result); test_accessor_get_api (sdp); if (i == -1) { fprintf (stdout, "ERROR: failed while printing message!\n"); sdp_message_free (sdp); return -1; } else { if (verbose) fprintf (stdout, "%s", result); if (strlen (result) != strlen (msg)) fprintf (stdout, "length differ from original message!\n"); if (0 == strncmp (result, msg, strlen (result))) fprintf (stdout, "result equals msg!!\n"); osip_free (result); { osip_negotiation_ctx_t *context; sdp_message_t *dest; i = osip_negotiation_ctx_init (&context); i = osip_negotiation_ctx_set_mycontext (context, (void *) ua_context); { sdp_message_t *sdp; osip_negotiation_sdp_build_offer (osip_negotiation, context, &sdp, ua_context->m_audio_port, ua_context->m_video_port); sdp_message_to_str (sdp, &result); fprintf (stdout, "Here is the offer:\n%s\n", result); osip_free (result); osip_negotiation_sdp_message_put_on_hold (sdp); sdp_message_to_str (sdp, &result); fprintf (stdout, "Here is the offer on hold:\n%s\n", result); osip_free (result); sdp_message_free (sdp); } i = osip_negotiation_ctx_set_remote_sdp (context, sdp); if (i != 0) { fprintf (stdout, "Initialisation of context failed. Could not negociate\n"); } else { fprintf (stdout, "Trying to execute a SIP negotiation:\n"); i = osip_negotiation_ctx_execute_negotiation (osip_negotiation, context); fprintf (stdout, "return code: %i\n", i); if (i == 200) { dest = osip_negotiation_ctx_get_local_sdp (context); fprintf (stdout, "SDP answer:\n"); i = sdp_message_to_str (dest, &result); if (i != 0) fprintf (stdout, "Error found in SDP answer while printing\n"); else fprintf (stdout, "%s\n", result); osip_free (result); } osip_negotiation_ctx_free (context); return 0; } } } sdp_message_free (sdp); } } return 0; }