Example #1
0
int
eXosip_call_init(eXosip_call_t **jc)
{
  *jc = (eXosip_call_t *)osip_malloc(sizeof(eXosip_call_t));
  if (*jc == NULL) return -1;
  memset(*jc, 0, sizeof(eXosip_call_t));

  (*jc)->c_id = -1;   /* make sure the eXosip_update will assign a valid id to the call */
  osip_negotiation_ctx_init(&(*jc)->c_ctx);
  return 0;
}
Example #2
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;
}