コード例 #1
0
ファイル: sipomatic.c プロジェクト: Accontech/ace-ios
void call_accept(Call *call)
{
	sdp_context_t *ctx;
	PayloadType *payload;
	char *hellofile;
	static int call_count=0;	
	char record_file[250];
	osip_message_t *msg=NULL;
	sprintf(record_file,"/tmp/sipomatic%i.wav",call_count);

	ctx=call->sdpc;
	payload=rtp_profile_get_payload(call->profile,call->audio.pt);
	if (strcmp(payload->mime_type,"telephone-event")==0){
		/* telephone-event is not enough to accept a call */
		ms_message("Cannot accept call with only telephone-event.\n");
		eXosip_call_send_answer(call->did,415,NULL);
		call->state=CALL_STATE_FINISHED;
		return;
	}
	if (payload->clock_rate==16000){
		hellofile=call->root->file_path16000hz;
	}else hellofile=call->root->file_path8000hz;
	eXosip_call_build_answer(call->tid,200,&msg);
	osip_message_set_content_type(msg,"application/sdp");
	osip_message_set_body(msg,call->sdpc->answerstr,strlen(call->sdpc->answerstr));
	eXosip_call_send_answer(call->tid,200,msg);
	call->audio_stream=audio_stream_new(call->audio.localport,call->audio.localport+1,call->root->ipv6);
	audio_stream_start_with_files(call->audio_stream, call->profile,
				call->audio.remaddr,call->audio.remoteport,call->audio.remoteport+1,
				 call->audio.pt,20,hellofile,record_file);
	call_count++;
#ifdef VIDEO_ENABLED
	if (call->video.remoteport!=0){
		video_stream_send_only_start(call->video_stream,call->profile,
			call->video.remaddr,call->video.remoteport,call->video.remoteport+1,call->video.pt, 60, 
			ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get()));
	}
#endif
	call->time=time(NULL);
	call->state=CALL_STATE_RUNNING;
	ms_filter_set_notify_callback(call->audio_stream->soundread,endoffile_cb,(void*)call);
}
コード例 #2
0
Call * call_new(Sipomatic *root, eXosip_event_t *ev)
{
	Call *obj;
	char *sdpans;
	int status;
	sdp_message_t *sdp;
	sdp_context_t *sdpc;
	
	sdp=eXosip_get_sdp_info(ev->request);
	sdpc=sdp_handler_create_context(&sipomatic_sdp_handler,NULL,"sipomatic");
	obj=ms_new0(Call,1);
	obj->profile=rtp_profile_new("remote");
	eXosip_call_send_answer(ev->tid,100,NULL);
	sdp_context_set_user_pointer(sdpc,obj);
	sdpans=sdp_context_get_answer(sdpc,sdp);
	if (sdpans!=NULL){
		eXosip_call_send_answer(ev->tid,180,NULL);
		
	}else{
		status=sdp_context_get_status(sdpc);
		eXosip_call_send_answer(ev->tid,status,NULL);
		sdp_context_free(sdpc);
		rtp_profile_destroy(obj->profile);
		ms_free(obj);
		return NULL;
	}
	obj->sdpc=sdpc;
	obj->did=ev->did;
	obj->tid=ev->tid;
	obj->time=time(NULL);
	obj->audio_stream=NULL;
	obj->state=CALL_STATE_INIT;
	obj->eof=0;
	obj->root=root;
	root->calls=ms_list_append(root->calls,obj);
	return obj;
}
コード例 #3
0
int
eXosip_call_terminate (int cid, int did)
{
  int i;
  osip_transaction_t *tr;
  osip_message_t *request = NULL;
  eXosip_dialog_t *jd = NULL;
  eXosip_call_t *jc = NULL;

  if (did <= 0 && cid <= 0)
    return OSIP_BADPARAMETER;
  if (did > 0)
    {
      eXosip_call_dialog_find (did, &jc, &jd);
      if (jd == NULL)
        {
          OSIP_TRACE (osip_trace
                      (__FILE__, __LINE__, OSIP_ERROR, NULL,
                       "eXosip: No call here?\n"));
          return OSIP_NOTFOUND;
        }
  } else
    {
      eXosip_call_find (cid, &jc);
    }

  if (jc == NULL)
    {
      return OSIP_NOTFOUND;
    }

  tr = eXosip_find_last_out_invite (jc, jd);
  if (jd != NULL && jd->d_dialog != NULL
      && jd->d_dialog->state == DIALOG_CONFIRMED)
    {
      /* don't send CANCEL on re-INVITE: send BYE instead */
  } else if (tr != NULL && tr->last_response != NULL
             && MSG_IS_STATUS_1XX (tr->last_response))
    {
      i = generating_cancel (&request, tr->orig_request);
      if (i != 0)
        {
          OSIP_TRACE (osip_trace
                      (__FILE__, __LINE__, OSIP_ERROR, NULL,
                       "eXosip: cannot terminate this call!\n"));
          return i;
        }
      i = eXosip_create_cancel_transaction (jc, jd, request);
      if (i != 0)
        {
          OSIP_TRACE (osip_trace
                      (__FILE__, __LINE__, OSIP_ERROR, NULL,
                       "eXosip: cannot initiate SIP transaction!\n"));
          return i;
        }
      if (jd != NULL)
        {
          osip_dialog_free (jd->d_dialog);
          jd->d_dialog = NULL;
          eXosip_update ();     /* AMD 30/09/05 */
        }
      return OSIP_SUCCESS;
    }

  if (jd == NULL || jd->d_dialog == NULL)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: No established dialog!\n"));
      return OSIP_WRONG_STATE;
    }

  if (tr == NULL)
    {
      /*this may not be enough if it's a re-INVITE! */
      tr = eXosip_find_last_inc_invite (jc, jd);
      if (tr != NULL && tr->last_response != NULL &&
          MSG_IS_STATUS_1XX (tr->last_response))
        {                       /* answer with 603 */
          osip_generic_param_t *to_tag;
          osip_from_param_get_byname (tr->orig_request->to, "tag", &to_tag);

          i = eXosip_call_send_answer (tr->transactionid, 603, NULL);

          if (to_tag == NULL)
            return i;
        }
    }

  if (jd->d_dialog == NULL)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: cannot terminate this call!\n"));
      return OSIP_WRONG_STATE;
    }

  i = generating_bye (&request, jd->d_dialog, eXosip.transport);

  if (i != 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: cannot terminate this call!\n"));
      return i;
    }

  eXosip_add_authentication_information (request, NULL);

  i = eXosip_create_transaction (jc, jd, request);
  if (i != 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: cannot initiate SIP transaction!\n"));
      return i;
    }

  osip_dialog_free (jd->d_dialog);
  jd->d_dialog = NULL;
  eXosip_update ();             /* AMD 30/09/05 */
  return OSIP_SUCCESS;
}