diff --git a/linphone/configure.in b/linphone/configure.in index 273bf8e8eb546ea891fec983016d1996bc541895..4f57caa77ea4980e97800a279105e24460eaeb2f 100644 --- a/linphone/configure.in +++ b/linphone/configure.in @@ -36,7 +36,7 @@ AM_PROG_CC_C_O case $target_os in *mingw32ce) - CFLAGS="$CFLAGS -D_WIN32_WCE -DORTP_STATIC -D_WIN32_WINNT=0x0501 -Dstrerror=" + CFLAGS="$CFLAGS -D_WIN32_WCE -DORTP_STATIC -D_WIN32_WINNT=0x0501" CXXFLAGS="$CXXFLAGS -DORTP_STATIC -D_WIN32_WINNT=0x0501" LIBS="$LIBS -lws2 -liphlpapi" mingw_found=yes diff --git a/linphone/console/commands.c b/linphone/console/commands.c index 486202d03a0da4a4099543d7b089ed9e2ee9f4cf..a022c3ff0f27950450b29478177f9c1ba1253672 100644 --- a/linphone/console/commands.c +++ b/linphone/console/commands.c @@ -26,10 +26,12 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> +#ifndef _WIN32_WCE #include <errno.h> +#include <unistd.h> +#endif /*_WIN32_WCE*/ #include <limits.h> #include <ctype.h> -#include <unistd.h> #include <linphonecore.h> #include "linphonec.h" @@ -282,7 +284,7 @@ linphonec_command_generator(const char *text, int state) if (strncmp(name, text, len) == 0) { - return strdup(name); + return ortp_strdup(name); } } @@ -577,10 +579,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args) args+=4; if ( ! *args ) return 0; friend_num = strtol(args, NULL, 10); +#ifndef _WIN32_WCE if ( errno == ERANGE ) { linphonec_out("Invalid friend number\n"); return 0; } +#endif /*_WIN32_WCE*/ linphonec_friend_call(lc, friend_num); return 1; } @@ -597,10 +601,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args) else { friend_num = strtol(args, NULL, 10); +#ifndef _WIN32_WCE if ( errno == ERANGE ) { linphonec_out("Invalid friend number\n"); return 0; } +#endif /*_WIN32_WCE*/ } linphonec_friend_delete(lc, friend_num); return 1; @@ -1401,9 +1407,9 @@ static int lpc_cmd_duration(LinphoneCore *lc, char *args){ static int lpc_cmd_status(LinphoneCore *lc, char *args) { - if ( ! args ) return 0; - LinphoneProxyConfig *cfg; + + if ( ! args ) return 0; linphone_core_get_default_proxy(lc,&cfg); if (strstr(args,"register")) { diff --git a/linphone/console/linphonec.c b/linphone/console/linphonec.c index 90a08f1983b568f04c45eff5ee3807c9030609ca..2e9d99cc5a3e375d565e15cff1d255f2441c1c7b 100644 --- a/linphone/console/linphonec.c +++ b/linphone/console/linphonec.c @@ -23,24 +23,28 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ****************************************************************************/ - -#include <errno.h> +#include <string.h> +#ifndef _WIN32_WCE #include <sys/time.h> #include <sys/types.h> #include <unistd.h> -#include <string.h> +#include <errno.h> #include <signal.h> +#include "private.h" /*coreapi/private.h, needed for LINPHONE_VERSION */ +#endif /*_WIN32_WCE*/ #include <limits.h> #include <ctype.h> #include <linphonecore.h> -#include "private.h" /*coreapi/private.h, needed for LINPHONE_VERSION */ + #include "linphonec.h" #ifdef WIN32 #include <ws2tcpip.h> #include <ctype.h> +#ifndef _WIN32_WCE #include <conio.h> +#endif /*_WIN32_WCE*/ #else #include <sys/socket.h> #include <netdb.h> @@ -48,6 +52,21 @@ #include <sys/stat.h> #endif +#if defined(_WIN32_WCE) + +#if !defined(PATH_MAX) +#define PATH_MAX 256 +#endif /*PATH_MAX*/ + +#if !defined(strdup) +#define strdup _strdup +#endif /*strdup*/ +/* +#if !defined(access) +#define access _access +#endif*/ /*access*/ + +#endif /*_WIN32_WCE*/ #ifdef HAVE_GETTEXT #include <libintl.h> @@ -71,14 +90,16 @@ typedef struct { /*************************************************************************** * - * Forward declarations + * Forward declarations * ***************************************************************************/ char *lpc_strip_blanks(char *input); static int handle_configfile_migration(void); +#if !defined(_WIN32_WCE) static int copy_file(const char *from, const char *to); +#endif /*_WIN32_WCE*/ static int linphonec_parse_cmdline(int argc, char **argv); static int linphonec_init(int argc, char **argv); static int linphonec_main_loop (LinphoneCore * opm, char * sipAddr); @@ -111,7 +132,7 @@ static void linphonec_dtmf_received(LinphoneCore *lc, int dtmf); static void print_prompt(LinphoneCore *opm); /*************************************************************************** * - * Global variables + * Global variables * ***************************************************************************/ @@ -135,18 +156,25 @@ static int trace_level = 0; static char *logfile_name = NULL; static char configfile_name[PATH_MAX]; static char *sipAddr = NULL; /* for autocall */ +#if !defined(_WIN32_WCE) static ortp_pipe_t client_sock=ORTP_PIPE_INVALID; +#endif /*_WIN32_WCE*/ char prompt[PROMPT_MAX_LEN]; - +#if !defined(_WIN32_WCE) static ortp_thread_t pipe_reader_th; static bool_t pipe_reader_run=FALSE; +#endif /*_WIN32_WCE*/ +#if !defined(_WIN32_WCE) static ortp_pipe_t server_sock; +#endif /*_WIN32_WCE*/ -LinphoneCoreVTable linphonec_vtable = { +LinphoneCoreVTable linphonec_vtable +#if !defined (_MSC_VER) += { .show =(ShowInterfaceCb) stub, .inv_recv = linphonec_call_received, - .bye_recv = linphonec_bye_received, + .bye_recv = linphonec_bye_received, .notify_recv = linphonec_notify_received, .new_unknown_subscriber = linphonec_new_unknown_subscriber, .auth_info_requested = linphonec_prompt_for_auth, @@ -162,7 +190,9 @@ LinphoneCoreVTable linphonec_vtable = { .text_received=linphonec_text_received, .general_state=linphonec_general_state, .dtmf_received=linphonec_dtmf_received -}; +} +#endif /*_WIN32_WCE*/ +; @@ -173,7 +203,7 @@ LinphoneCoreVTable linphonec_vtable = { ***************************************************************************/ /* - * Linphone core callback + * Linphone core callback */ static void linphonec_display_something (LinphoneCore * lc, const char *something) @@ -183,7 +213,7 @@ linphonec_display_something (LinphoneCore * lc, const char *something) } /* - * Linphone core callback + * Linphone core callback */ static void linphonec_display_status (LinphoneCore * lc, const char *something) @@ -193,7 +223,7 @@ linphonec_display_status (LinphoneCore * lc, const char *something) } /* - * Linphone core callback + * Linphone core callback */ static void linphonec_display_warning (LinphoneCore * lc, const char *something) @@ -203,7 +233,7 @@ linphonec_display_warning (LinphoneCore * lc, const char *something) } /* - * Linphone core callback + * Linphone core callback */ static void linphonec_display_url (LinphoneCore * lc, const char *something, const char *url) @@ -213,7 +243,7 @@ linphonec_display_url (LinphoneCore * lc, const char *something, const char *url /* - * Linphone core callback + * Linphone core callback */ static void linphonec_call_received(LinphoneCore *lc, const char *from) @@ -225,7 +255,7 @@ linphonec_call_received(LinphoneCore *lc, const char *from) } /* - * Linphone core callback + * Linphone core callback */ static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username) @@ -235,15 +265,15 @@ linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *usern linphone_core_abort_authentication(lc,NULL); }else{ LinphoneAuthInfo *pending_auth; - + if ( auth_stack.nitems+1 > MAX_PENDING_AUTH ) { fprintf(stderr, "Can't accept another authentication request.\n" "Consider incrementing MAX_PENDING_AUTH macro.\n"); return; - } - + } + pending_auth=linphone_auth_info_new(username,NULL,NULL,NULL,realm); auth_stack.elem[auth_stack.nitems++]=pending_auth; } @@ -268,8 +298,8 @@ linphonec_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url) { printf("Friend %s requested subscription " - "(accept/deny is not implemented yet)\n", url); - // This means that this person wishes to be notified + "(accept/deny is not implemented yet)\n", url); + // This means that this person wishes to be notified // of your presence information (online, busy, away...). } @@ -304,7 +334,7 @@ static void linphonec_dtmf_received(LinphoneCore *lc, int dtmf){ fflush(stdout); } -static void +static void linphonec_general_state (LinphoneCore * lc, LinphoneGeneralState *gstate) { if (show_general_state) { @@ -352,11 +382,11 @@ linphonec_general_state (LinphoneCore * lc, LinphoneGeneralState *gstate) printf("GSTATE_CALL_ERROR"); break; default: - printf("GSTATE_UNKNOWN_%d",gstate->new_state); + printf("GSTATE_UNKNOWN_%d",gstate->new_state); } if (gstate->message) printf(" %s", gstate->message); printf("\n"); - } + } } static char received_prompt[PROMPT_MAX_LEN]; @@ -380,14 +410,14 @@ static void start_prompt_reader(void){ ms_mutex_init(&prompt_mutex,NULL); ortp_thread_create(&th,NULL,prompt_reader_thread,NULL); } - +#if !defined(_WIN32_WCE) static ortp_pipe_t create_server_socket(void){ char path[128]; #ifndef WIN32 snprintf(path,sizeof(path)-1,"linphonec-%i",getuid()); #else { - char username[128]; + TCHAR username[128]; DWORD size=sizeof(username)-1; GetUserName(username,&size); snprintf(path,sizeof(path)-1,"linphonec-%s",username); @@ -396,6 +426,7 @@ static ortp_pipe_t create_server_socket(void){ return ortp_server_pipe_create(path); } + static void *pipe_thread(void*p){ char tmp[250]; server_sock=create_server_socket(); @@ -424,7 +455,7 @@ static void *pipe_thread(void*p){ ortp_server_pipe_close_client(client_sock); client_sock=ORTP_PIPE_INVALID; } - + }else{ if (pipe_reader_run) fprintf(stderr,"accept() failed: %s\n",strerror(errno)); } @@ -446,6 +477,7 @@ static void stop_pipe_reader(void){ ortp_server_pipe_close(server_sock); ortp_thread_join(pipe_reader_th,NULL); } +#endif /*_WIN32_WCE*/ #ifdef HAVE_READLINE #define BOOL_HAVE_READLINE 1 @@ -462,8 +494,10 @@ char *linphonec_readline(char *prompt){ prompt_reader_started=TRUE; } if (unix_socket && !pipe_reader_started){ +#if !defined(_WIN32_WCE) start_pipe_reader(); pipe_reader_started=TRUE; +#endif /*_WIN32_WCE*/ } fprintf(stdout,"%s",prompt); fflush(stdout); @@ -498,19 +532,23 @@ void linphonec_out(const char *fmt,...){ va_end (args); printf("%s",res); fflush(stdout); +#if !defined(_WIN32_WCE) if (client_sock!=ORTP_PIPE_INVALID){ if (ortp_pipe_write(client_sock,(uint8_t*)res,strlen(res))==-1){ fprintf(stderr,"Fail to send output via pipe: %s",strerror(errno)); } } +#endif /*_WIN32_WCE*/ ortp_free(res); } void linphonec_command_finished(void){ +#if !defined(_WIN32_WCE) if (client_sock!=ORTP_PIPE_INVALID){ ortp_server_pipe_close_client(client_sock); client_sock=ORTP_PIPE_INVALID; } +#endif /*_WIN32_WCE*/ } void linphonec_set_autoanswer(bool_t enabled){ @@ -530,9 +568,35 @@ bool_t linphonec_get_autoanswer(){ * - char *histfile_name * - FILE *mylogfile */ +#if defined (_MSC_VER) +int _tmain(int argc, _TCHAR* argv[]) { + trace_level=1; + linphonec_vtable.show =(ShowInterfaceCb) stub; + linphonec_vtable.inv_recv = linphonec_call_received; + linphonec_vtable.bye_recv = linphonec_bye_received; + linphonec_vtable.notify_recv = linphonec_notify_received; + linphonec_vtable.new_unknown_subscriber = linphonec_new_unknown_subscriber; + linphonec_vtable.auth_info_requested = linphonec_prompt_for_auth; + linphonec_vtable.display_status = linphonec_display_status; + linphonec_vtable.display_message=linphonec_display_something; +#ifdef VINCENT_MAURY_RSVP + /* the yes/no dialog box */ + linphonec_vtable.display_yes_no= (DisplayMessageCb) stub; +#endif + linphonec_vtable.display_warning=linphonec_display_warning; + linphonec_vtable.display_url=linphonec_display_url; + linphonec_vtable.display_question=(DisplayQuestionCb)stub; + linphonec_vtable.text_received=linphonec_text_received; + linphonec_vtable.general_state=linphonec_general_state; + linphonec_vtable.dtmf_received=linphonec_dtmf_received; + +#else int -main (int argc, char *argv[]) -{ +main (int argc, char *argv[]) { +#endif + + + if (! linphonec_init(argc, argv) ) exit(EXIT_FAILURE); @@ -556,9 +620,13 @@ linphonec_init(int argc, char **argv) * Set initial values for global variables */ mylogfile = NULL; - snprintf(configfile_name, PATH_MAX, "%s/.linphonerc", - getenv("HOME")); + snprintf(configfile_name, PATH_MAX, "%s/.linphonerc", +#if !defined(_WIN32_WCE) + getenv("HOME")); +#else + "."); +#endif /*_WIN32_WCE*/ /* Handle configuration filename changes */ switch (handle_configfile_migration()) @@ -623,12 +691,13 @@ linphonec_init(int argc, char **argv) */ linphonec_initialize_readline(); #endif +#if !defined(_WIN32_WCE) /* * Initialize signal handlers */ - signal(SIGTERM, linphonec_finish); - signal(SIGINT, linphonec_finish); - + signal(SIGTERM, linphonec_finish); + signal(SIGINT, linphonec_finish); +#endif /*_WIN32_WCE*/ return 1; } @@ -645,16 +714,17 @@ void linphonec_finish(int exit_status) { printf("Terminating...\n"); - + /* Terminate any pending call */ linphonec_parse_command_line(&linphonec, "terminate"); linphonec_command_finished(); #ifdef HAVE_READLINE linphonec_finish_readline(); #endif +#if !defined(_WIN32_WCE) if (pipe_reader_run) stop_pipe_reader(); - +#endif /*_WIN32_WCE*/ linphone_core_uninit (&linphonec); @@ -672,7 +742,7 @@ linphonec_finish(int exit_status) * pending_auth != NULL. * * It prompts user for a password. - * Hitting ^D (EOF) would make this function + * Hitting ^D (EOF) would make this function * return 0 (Cancel). * Any other input would try to set linphone core * auth_password for the pending_auth, add the auth_info @@ -715,7 +785,7 @@ linphonec_prompt_for_auth_final(LinphoneCore *lc) */ if ( ! input ) { - printf("Cancel requested, but not implemented.\n"); + printf("Cancel requested, but not implemented.\n"); continue; } @@ -834,7 +904,7 @@ linphonec_initialize_readline() rl_readline_name = "linphonec"; /* Call idle_call() every second */ - rl_set_keyboard_input_timeout(LPC_READLINE_TIMEOUT); + rl_set_keyboard_input_timeout(LPC_READLINE_TIMEOUT); rl_event_hook=linphonec_idle_call; /* Set history file and read it */ @@ -849,7 +919,7 @@ linphonec_initialize_readline() rl_attempted_completion_function = linephonec_readline_completion; /* printf("Readline initialized.\n"); */ - setlinebuf(stdout); + setlinebuf(stdout); return 0; } @@ -976,7 +1046,7 @@ linphonec_parse_cmdline(int argc, char **argv) else if (strncmp ("-c", argv[arg_num], 2) == 0) { if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE); - +#if !defined(_WIN32_WCE) if (access(argv[arg_num],F_OK)!=0 ) { fprintf (stderr, @@ -984,6 +1054,7 @@ linphonec_parse_cmdline(int argc, char **argv) argv[arg_num]); exit(EXIT_FAILURE); } +#endif /*_WIN32_WCE*/ snprintf(configfile_name, PATH_MAX, "%s", argv[arg_num]); } else if (strncmp ("-s", argv[arg_num], 2) == 0) @@ -1016,7 +1087,9 @@ linphonec_parse_cmdline(int argc, char **argv) ("--version", argv[arg_num], strlen ("--version")) == 0)) { +#if !defined(_WIN32_WCE) printf ("version: " LINPHONE_VERSION "\n"); +#endif exit (EXIT_SUCCESS); } else if (strncmp ("-S", argv[arg_num], 2) == 0) @@ -1053,16 +1126,20 @@ linphonec_parse_cmdline(int argc, char **argv) * Returns: * 0 if it did nothing * 1 if it migrated successfully - * -1 on error + * -1 on error */ static int handle_configfile_migration() { +#if !defined(_WIN32_WCE) char *old_cfg_gui; - char *old_cfg_cli; + char *old_cfg_cli; char *new_cfg; +#if !defined(_WIN32_WCE) const char *home = getenv("HOME"); - +#else + const char *home = "."; +#endif /*_WIN32_WCE*/ new_cfg = ms_strdup_printf("%s/.linphonerc", home); /* @@ -1119,9 +1196,10 @@ handle_configfile_migration() free(old_cfg_gui); free(new_cfg); +#endif /*_WIN32_WCE*/ return 0; } - +#if !defined(_WIN32_WCE) /* * Copy file "from" to file "to". * Destination file is truncated if existing. @@ -1162,13 +1240,14 @@ copy_file(const char *from, const char *to) { return 0; } - } + } fclose(in); fclose(out); return 1; } +#endif /*_WIN32_WCE*/ #ifdef HAVE_READLINE static char ** @@ -1332,3 +1411,4 @@ lpc_strip_blanks(char *input) * * ****************************************************************************/ + diff --git a/linphone/console/linphonec.h b/linphone/console/linphonec.h index 8c1c7ca32f6acdb849f4819b9070d2b3e24efdf9..732c99a6a8dacbc8b19c15e64242841ca5d1f7ca 100644 --- a/linphone/console/linphonec.h +++ b/linphone/console/linphonec.h @@ -46,6 +46,7 @@ #endif #endif + /************************************************************************** * * Compile-time defines @@ -98,7 +99,7 @@ typedef struct { /*************************************************************************** * - * Forward declarations + * Forward declarations * ***************************************************************************/ diff --git a/linphone/coreapi/Makefile.am b/linphone/coreapi/Makefile.am index d2506730e99f842f18df0571bff8256270ba5659..65db8c02467f403f98b01e7dede4fc114d88d26d 100644 --- a/linphone/coreapi/Makefile.am +++ b/linphone/coreapi/Makefile.am @@ -42,9 +42,9 @@ endif AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \ + $(ORTP_CFLAGS) \ $(OSIP_CFLAGS) \ $(EXOSIP_CFLAGS) \ - $(ORTP_CFLAGS) \ -DENABLE_TRACE \ -DLOG_DOMAIN=\"LinphoneCore\" \ $(IPV6_CFLAGS) \ diff --git a/linphone/coreapi/exevents.c b/linphone/coreapi/exevents.c index 9178b970827b839c5715430dc0abd95fefa2ccea..834c914f1571fd834742169c04fb610b714a6111 100644 --- a/linphone/coreapi/exevents.c +++ b/linphone/coreapi/exevents.c @@ -116,7 +116,7 @@ int linphone_call_terminated(LinphoneCore *lc, eXosip_event_t *ev) return 0; } } - + ms_message("Current call terminated..."); if (lc->ringstream!=NULL) { ring_stop(lc->ringstream); @@ -143,7 +143,7 @@ int linphone_call_terminated(LinphoneCore *lc, eXosip_event_t *ev) int linphone_call_released(LinphoneCore *lc, int cid){ LinphoneCall *call=lc->call; if (call!=NULL && call->cid==cid){ - + linphone_call_destroy(lc->call); lc->call=NULL; lc->vtable.display_status(lc,_("Could not reach destination.")); @@ -178,7 +178,7 @@ int linphone_call_failure(LinphoneCore *lc, eXosip_event_t *ev) reason=osip_message_get_reason_phrase(ev->response); }else code=-110; lc->vtable.show(lc); - + switch(code) { case 401: @@ -211,12 +211,12 @@ int linphone_call_failure(LinphoneCore *lc, eXosip_event_t *ev) sprintf(umsg,retrymsg,tmpmsg,atoi(retry->hvalue)/60); lc->vtable.display_message(lc,umsg); ms_free(umsg); - }*/ + }*/ lc->vtable.display_message(lc,tmpmsg); break; case 487: lc->vtable.display_status(lc,msg487); - break; + break; case 600: lc->vtable.display_message(lc,msg600); break; @@ -229,13 +229,13 @@ int linphone_call_failure(LinphoneCore *lc, eXosip_event_t *ev) case -111: lc->vtable.display_status(lc,_("Remote host was found but refused connection.")); break; - + default: if (code>0) { lc->vtable.display_status(lc,reason); } - else ms_warning("failure_cb unknown code=%i\n",code); + else ms_warning("failure_cb unknown code=%i\n",code); } if (lc->ringstream!=NULL) { ring_stop(lc->ringstream); @@ -255,7 +255,7 @@ extern sdp_handler_t linphone_sdphandler; static int linphone_answer_sdp(LinphoneCore *lc, eXosip_event_t *ev, sdp_message_t *sdp){ int status=200; sdp_context_t *ctx=NULL; - + ctx=lc->call->sdpctx; /* get the result of the negociation */ sdp_context_get_answer(ctx,sdp); @@ -280,8 +280,8 @@ int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev) int err; osip_from_to_str(ev->request->from,&from); - osip_to_to_str(ev->request->to,&to); - + osip_to_to_str(ev->request->to,&to); + /* first check if we can answer successfully to this invite */ if (lc->presence_mode!=LINPHONE_STATUS_ONLINE){ ms_message("Not present !! presence mode : %d\n",lc->presence_mode); @@ -322,7 +322,7 @@ int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev) goto end; } lc->call=linphone_call_new_incoming(lc,from,to,ev); - + sdp=eXosip_get_sdp_info(ev->request); if (sdp==NULL){ ms_message("No sdp body in invite, 200-ack scheme"); @@ -352,7 +352,7 @@ int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev) lc->vtable.inv_recv(lc,tmp); ms_free(barmesg); - osip_free(tmp); + osip_free(tmp); }else{ ms_error("Error during sdp negociation. "); eXosip_lock(); @@ -459,8 +459,8 @@ int linphone_set_audio_offer(sdp_context_t *ctx) PayloadType *codec; MSList *elem; sdp_payload_t payload; - - + + elem=lc->codecs_conf.audio_codecs; while(elem!=NULL){ codec=(PayloadType*) elem->data; @@ -468,7 +468,7 @@ int linphone_set_audio_offer(sdp_context_t *ctx) sdp_payload_init(&payload); payload.a_rtpmap=ortp_strdup_printf("%s/%i/1",codec->mime_type,codec->clock_rate); payload.pt=rtp_profile_get_payload_number_from_rtpmap(lc->local_profile,payload.a_rtpmap); - payload.localport=call->audio_params.natd_port > 0 ? + payload.localport=call->audio_params.natd_port > 0 ? call->audio_params.natd_port : lc->rtp_conf.audio_rtp_port; if (strcasecmp(codec->mime_type,"iLBC")==0){ /* prefer the 30 ms mode */ @@ -494,7 +494,7 @@ static int find_payload_type_number(RtpProfile *prof, PayloadType *pt){ PayloadType *it; for(i=0;i<127;++i){ it=rtp_profile_get_payload(prof,i); - if (it!=NULL && strcasecmp(pt->mime_type,it->mime_type)==0 + if (it!=NULL && strcasecmp(pt->mime_type,it->mime_type)==0 && (pt->clock_rate==it->clock_rate || pt->clock_rate<=0) ){ if ( (pt->recv_fmtp && it->recv_fmtp && strcasecmp(pt->recv_fmtp,it->recv_fmtp)==0) || (pt->recv_fmtp==NULL && it->recv_fmtp==NULL) ){ @@ -533,7 +533,7 @@ int linphone_set_video_offer(sdp_context_t *ctx) LinphoneCore *lc=call->core; PayloadType *codec; MSList *elem; - bool_t firsttime=TRUE; + bool_t firsttime=TRUE; if (!linphone_core_video_enabled(lc)) return -1; @@ -544,7 +544,7 @@ int linphone_set_video_offer(sdp_context_t *ctx) sdp_payload_init(&payload); payload.line=1; payload.a_rtpmap=ortp_strdup_printf("%s/%i",codec->mime_type,codec->clock_rate); - payload.localport=call->video_params.natd_port>0 ? + payload.localport=call->video_params.natd_port>0 ? call->video_params.natd_port : lc->rtp_conf.video_rtp_port; payload.pt=find_payload_type_number(lc->local_profile,codec); payload.a_fmtp=codec->recv_fmtp; @@ -576,7 +576,7 @@ SupportLevel linphone_payload_is_supported(LinphoneCore *lc, sdp_payload_t *payl localpt=payload->pt; ms_warning("payload has no rtpmap."); } - + if (localpt>=0 && localpt <128 ){ /* this payload is understood, but does the user want to use it ?? */ PayloadType *rtppayload; @@ -610,7 +610,7 @@ SupportLevel linphone_payload_is_supported(LinphoneCore *lc, sdp_payload_t *payl if (rtppayload->type==PAYLOAD_VIDEO){ dbw=lc->dw_video_bw; ubw=lc->up_video_bw; - }else{ + }else{ dbw=lc->dw_audio_bw; ubw=lc->up_audio_bw; } @@ -665,11 +665,11 @@ int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload) ms_message("Only one codec has to be accepted."); return -1; } - if (supported==SupportedAndValid) { + if (supported==SupportedAndValid) { if (params->initialized==0){ /* this is the first codec we accept, it is going to be used*/ params->localport=lc->rtp_conf.audio_rtp_port; - payload->localport=params->natd_port>0 ? + payload->localport=params->natd_port>0 ? params->natd_port : lc->rtp_conf.audio_rtp_port; params->line=payload->line; params->pt=payload->pt; /* remember the first payload accepted */ @@ -692,7 +692,9 @@ int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload) /* refuse all other audio lines*/ if(params->line!=payload->line) { ms_message("Only one audio line can be accepted."); +#if !defined(_WIN32_WCE) abort(); +#endif /*_WIN32_WCE*/ return -1; } } @@ -761,7 +763,7 @@ int linphone_read_audio_answer(sdp_context_t *ctx,sdp_payload_t *payload) StreamParams *params; SupportLevel supported; PayloadType *lpt=NULL; - + /* paranoid check: see if this codec is supported in our local rtp profile*/ supported=linphone_payload_is_supported(lc, payload,lc->local_profile,call->profile,FALSE,&lpt); if (supported==Unsupported) { @@ -801,7 +803,7 @@ int linphone_read_video_answer(sdp_context_t *ctx,sdp_payload_t *payload) StreamParams *params; SupportLevel supported; PayloadType *lpt=NULL; - + /* paranoid check: see if this codec is supported in our local rtp profile*/ supported=linphone_payload_is_supported(lc, payload,lc->local_profile,call->profile,FALSE,&lpt); if (supported==Unsupported) { @@ -834,7 +836,7 @@ int linphone_read_video_answer(sdp_context_t *ctx,sdp_payload_t *payload) void linphone_call_ringing(LinphoneCore *lc, eXosip_event_t *ev){ sdp_message_t *sdp=eXosip_get_sdp_info(ev->response); LinphoneCall *call=lc->call; - + linphone_call_proceeding(lc,ev); if (call==NULL) return; if (sdp==NULL){ @@ -909,7 +911,7 @@ static void linphone_process_dtmf_relay(LinphoneCore *lc, eXosip_event_t *ev){ lc->vtable.dtmf_received(lc, tmp[0]); } } - + eXosip_call_build_answer(ev->tid,200,&ans); if (ans) eXosip_call_send_answer(ev->tid,200,ans); @@ -951,7 +953,7 @@ void linphone_registration_faillure(LinphoneCore *lc, eXosip_event_t *ev){ osip_uri_t *requri=osip_message_get_uri(ev->request); char *ru; LinphoneProxyConfig *cfg; - + if (ev->response){ status_code=osip_message_get_status_code(ev->response); reason=osip_message_get_reason_phrase(ev->response); @@ -993,7 +995,7 @@ void linphone_registration_success(LinphoneCore *lc,eXosip_event_t *ev){ cfg->registered=TRUE; linphone_proxy_config_register_again_with_updated_contact(cfg,ev->request,ev->response); }else cfg->registered=FALSE; - + osip_uri_to_str(requri,&ru); if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),ru); else msg=ms_strdup_printf(_("Unregistration on %s done."),ru); @@ -1012,7 +1014,7 @@ static bool_t comes_from_local_if(osip_message_t *msg){ osip_generic_param_t *param=NULL; osip_via_param_get_byname(via,"received",¶m); if (param==NULL) return TRUE; - if (param->gvalue && + if (param->gvalue && (strcmp(param->gvalue,"127.0.0.1")==0 || strcmp(param->gvalue,"::1")==0)){ return TRUE; } @@ -1056,10 +1058,10 @@ static void linphone_other_request(LinphoneCore *lc, eXosip_event_t *ev){ osip_message_header_get_byname(ev->request,"Refer-To",0,&h); eXosip_message_send_answer(ev->tid,200,NULL); if (h){ - if (lc->vtable.refer_received) + if (lc->vtable.refer_received) lc->vtable.refer_received(lc,h->hvalue); } - + }else ms_warning("Ignored REFER not coming from this local loopback interface."); }else if (strncmp(ev->request->sip_method, "UPDATE", 6) == 0){ linphone_inc_update(lc,ev); @@ -1102,7 +1104,7 @@ void linphone_core_process_event(LinphoneCore *lc,eXosip_event_t *ev) break; case EXOSIP_CALL_INVITE: ms_message("CALL_NEW\n"); - /* CALL_NEW is used twice in qos mode : + /* CALL_NEW is used twice in qos mode : * when you receive invite (textinfo = "With QoS" or "Without QoS") * and when you receive update (textinfo = "New Call") */ linphone_inc_new_call(lc,ev); @@ -1131,7 +1133,7 @@ void linphone_core_process_event(LinphoneCore *lc,eXosip_event_t *ev) linphone_call_message_new(lc,ev); break; case EXOSIP_CALL_MESSAGE_REQUESTFAILURE: - if (ev->did<0 && ev->response && + if (ev->did<0 && ev->response && (ev->response->status_code==407 || ev->response->status_code==401)){ eXosip_default_action(ev); } diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index 661fc771e542c779910d0d2873a89c95cc11bbdf..ed7aa718ddc905f357f7a89a7599fcea00df099e 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -163,7 +163,12 @@ void linphone_call_destroy(LinphoneCall *obj) /*prevent a gcc bug with %c*/ static size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm){ +#if !defined(_WIN32_WCE) return strftime(s, max, fmt, tm); +#else + return 0; + /*FIXME*/ +#endif /*_WIN32_WCE*/ } LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to){ @@ -171,7 +176,10 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to struct tm loctime; cl->dir=call->dir; #ifdef WIN32 +#if !defined(_WIN32_WCE) loctime=*localtime(&call->start_time); + /*FIXME*/ +#endif /*_WIN32_WCE*/ #else localtime_r(&call->start_time,&loctime); #endif @@ -396,7 +404,7 @@ void sound_config_read(LinphoneCore *lc) tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING; tmpbuf=lp_config_get_string(lc->config,"sound","local_ring",tmpbuf); - if (access(tmpbuf,F_OK)==-1) { + if (ortp_file_exist(tmpbuf)==-1) { tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING; } if (strstr(tmpbuf,".wav")==NULL){ @@ -408,7 +416,7 @@ void sound_config_read(LinphoneCore *lc) tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING; tmpbuf=lp_config_get_string(lc->config,"sound","remote_ring",tmpbuf); - if (access(tmpbuf,F_OK)==-1){ + if (ortp_file_exist(tmpbuf)==-1){ tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING; } if (strstr(tmpbuf,".wav")==NULL){ diff --git a/linphone/coreapi/lpconfig.c b/linphone/coreapi/lpconfig.c index 08abcd5e811089edc85b714aa08616eace94cbfd..044f02267631f0980a9a7b04e506afcc9f95c74d 100644 --- a/linphone/coreapi/lpconfig.c +++ b/linphone/coreapi/lpconfig.c @@ -30,7 +30,9 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#if !defined(_WIN32_WCE) #include <errno.h> +#endif /*_WIN32_WCE*/ #include <sys/types.h> #include <sys/stat.h> @@ -76,8 +78,8 @@ void list_node_foreach(ListNode *head, ListNodeForEachFunc func){ #define LIST_PREPEND(e1,e2) ( (e2)->_prev=NULL,(e2)->_next=(e1),(e1)->_prev=(e2),(e2) ) -#define LIST_APPEND(head,elem) ((head)==0 ? (elem) : (list_node_append((ListNode*)(head),(ListNode*)(elem)), (head)) ) -#define LIST_REMOVE(head,elem) +#define LIST_APPEND(head,elem) ((head)==0 ? (elem) : (list_node_append((ListNode*)(head),(ListNode*)(elem)), (head)) ) +#define LIST_REMOVE(head,elem) /* returns void */ #define LIST_FOREACH(head) list_node_foreach((ListNode*)head) @@ -102,14 +104,14 @@ struct _LpConfig{ LpItem * lp_item_new(const char *key, const char *value){ LpItem *item=lp_new0(LpItem,1); - item->key=strdup(key); - item->value=strdup(value); + item->key=ortp_strdup(key); + item->value=ortp_strdup(value); return item; } LpSection *lp_section_new(const char *name){ LpSection *sec=lp_new0(LpSection,1); - sec->name=strdup(name); + sec->name=ortp_strdup(name); return sec; } @@ -151,9 +153,9 @@ static bool_t is_first_char(const char *start, const char *pos){ void lp_config_parse(LpConfig *lpconfig){ char tmp[MAX_LEN]; LpSection *cur=NULL; - + if (lpconfig->file==NULL) return; - + while(fgets(tmp,MAX_LEN,lpconfig->file)!=NULL){ char *pos1,*pos2; pos1=strchr(tmp,'['); @@ -180,10 +182,10 @@ void lp_config_parse(LpConfig *lpconfig){ if (pos1!=NULL){ char key[MAX_LEN]; key[0]='\0'; - + *pos1='\0'; if (sscanf(tmp,"%s",key)>0){ - + pos1++; pos2=strchr(pos1,'\n'); if (pos2==NULL) pos2=pos1+strlen(pos1); @@ -211,16 +213,18 @@ void lp_config_parse(LpConfig *lpconfig){ LpConfig * lp_config_new(const char *filename){ LpConfig *lpconfig=lp_new0(LpConfig,1); if (filename!=NULL){ - lpconfig->filename=strdup(filename); + lpconfig->filename=ortp_strdup(filename); lpconfig->file=fopen(filename,"rw"); if (lpconfig->file!=NULL){ lp_config_parse(lpconfig); fclose(lpconfig->file); +#if !defined(_WIN32_WCE) /* make existing configuration files non-group/world-accessible */ if (chmod(filename, S_IRUSR | S_IWUSR) == -1) ms_warning("unable to correct permissions on " "configuration file: %s", strerror(errno)); +#endif /*_WIN32_WCE*/ lpconfig->file=NULL; lpconfig->modified=0; } @@ -230,7 +234,7 @@ LpConfig * lp_config_new(const char *filename){ void lp_item_set_value(LpItem *item, const char *value){ free(item->value); - item->value=strdup(value); + item->value=ortp_strdup(value); } diff --git a/linphone/coreapi/misc.c b/linphone/coreapi/misc.c index eca072491b21671562d7fb1a9314e042dfa27543..68fa5569e44ce04672e8a99cecf865c95efe8acb 100644 --- a/linphone/coreapi/misc.c +++ b/linphone/coreapi/misc.c @@ -30,7 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <unistd.h> #include <fcntl.h> #include <strings.h> +#if !defined(_WIN32_WCE) #include <errno.h> +#endif /*_WIN32_WCE*/ #undef snprintf #include <ortp/stun.h> @@ -100,15 +102,17 @@ char *int2str(int number) void check_sound_device(LinphoneCore *lc) { - int fd,len; + int fd=0; + int len; int a; char *file=NULL; char *i810_audio=NULL; char *snd_pcm_oss=NULL; char *snd_mixer_oss=NULL; char *snd_pcm=NULL; - +#if !defined(_WIN32_WCE) fd=open("/proc/modules",O_RDONLY); +#endif /*_WIN32_WCE*/ if (fd>0){ /* read the entire /proc/modules file and check if sound conf seems correct */ /*a=fstat(fd,&statbuf); @@ -158,7 +162,9 @@ void check_sound_device(LinphoneCore *lc) */ end: if (file!=NULL) ms_free(file); +#if !defined(_WIN32_WCE) if (fd>0) close(fd); +#endif /*_WIN32_WCE*/ } #define UDP_HDR_SZ 8 @@ -353,12 +359,10 @@ void linphone_core_setup_local_rtp_profile(LinphoneCore *lc) PayloadType *payload; bool_t prepend; lc->local_profile=rtp_profile_clone_full(&av_profile); - /* first look at the list given by configuration file to see if it is correct */ audiopt=fix_codec_list(lc->local_profile,lc->codecs_conf.audio_codecs); videopt=fix_codec_list(lc->local_profile,lc->codecs_conf.video_codecs); - /* now find and add payloads that are not listed in the configuration codec list */ for (i=0;i<127;i++) @@ -798,7 +802,7 @@ int linphone_core_get_local_ip_for(const char *dest, char *result){ if (err<0) { ms_error("Error in connect: %s",strerror(errno)); freeaddrinfo(res); - close(sock); + close_socket(sock); return -1; } freeaddrinfo(res); @@ -807,14 +811,14 @@ int linphone_core_get_local_ip_for(const char *dest, char *result){ err=getsockname(sock,(struct sockaddr*)&addr,&s); if (err!=0) { ms_error("Error in getsockname: %s",strerror(errno)); - close(sock); + close_socket(sock); return -1; } err=getnameinfo((struct sockaddr *)&addr,s,result,LINPHONE_IPADDR_SIZE,NULL,0,NI_NUMERICHOST); if (err!=0){ ms_error("getnameinfo error: %s",strerror(errno)); } - close(sock); + close_socket(sock); ms_message("Local interface to reach %s is %s.",dest,result); return 0; } diff --git a/linphone/coreapi/sdphandler.c b/linphone/coreapi/sdphandler.c index 4c0337c3ebc563c300e4aaee4282f72fcddbe37f..8902172895672eea115de522549e0204f9ba56d0 100644 --- a/linphone/coreapi/sdphandler.c +++ b/linphone/coreapi/sdphandler.c @@ -174,7 +174,7 @@ sdp_context_generate_template (sdp_context_t * ctx) } static void add_relay_info(sdp_message_t *sdp, int mline, const char *relay, const char *relay_session_id){ - + if (relay) sdp_message_a_attribute_add(sdp, mline, osip_strdup ("relay-addr"),osip_strdup(relay)); if (relay_session_id) sdp_message_a_attribute_add(sdp, mline, @@ -191,7 +191,12 @@ sdp_context_add_payload (sdp_context_t * ctx, sdp_payload_t * payload, char *med { eXosip_trace (OSIP_ERROR, ("You must not call sdp_context_add_*_payload outside the write_offer callback\n")); - abort (); +#if !defined(_WIN32_WCE) + abort(); +#else + exit(-1); +#endif /*_WIN32_WCE*/ + } if (payload->proto == NULL) payload->proto = "RTP/AVP"; @@ -225,7 +230,7 @@ sdp_context_add_payload (sdp_context_t * ctx, sdp_payload_t * payload, char *med attr_field); } if (payload->b_as_bandwidth != 0) - { + { if (sdp_message_bandwidth_get(offer,payload->line,0)==NULL){ attr_field = sstrdup_sprintf ("%i", payload->b_as_bandwidth); @@ -326,7 +331,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) else eXosip_trace(OSIP_INFO1,("Using firewall address in sdp.")); answer = sdp_context_generate_template (ctx); - + /* for each m= line */ for (i = 0; !sdp_message_endof_media (remote, i); i++){ sdp_payload_init(&init_payload); @@ -373,7 +378,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) sdp_message_a_attr_value_get_with_pt (remote, i, payload.pt, "fmtp"); - + /* ask the application if this codec is supported */ err = sdph->accept_audio_codecs (ctx, &payload); @@ -447,7 +452,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) { /* refuse the line */ refuse_mline(answer,mtype,proto,i); - + } else m_lines_accepted++; diff --git a/linphone/mediastreamer2/configure.ac b/linphone/mediastreamer2/configure.ac index 2dd9ed7e0280629174814590640ffca23e020e86..21db5d414131bdebe1717a32c1a08e73d89dfc8a 100644 --- a/linphone/mediastreamer2/configure.ac +++ b/linphone/mediastreamer2/configure.ac @@ -125,6 +125,7 @@ if test $GCC = yes && test $wall_werror = yes; then fi macosx_found=no +mingw32ce_found=no dnl add thread flags case $target_os in @@ -138,8 +139,9 @@ case $target_os in CFLAGS="$CFLAGS -DINET6 -DORTP_INET6 -D_WIN32_WINNT=0x0501 -D_WIN32_WCE -DORTP_STATIC" CXXFLAGS="$CXXFLAGS -DINET6 -DORTP_INET6 -D_WIN32_WINNT=0x0501 -DORTP_STATIC -D_WIN32_WCE" dnl ORTP_STATIC to tell ortp not to export its variable with dllexport, as if we were building statically, or dynamically on linux - LIBS="$LIBS -lws2" + LIBS="$LIBS -lws2" mingw_found=yes + mingw32ce_found=yes build_tests=no ;; *mingw*) @@ -480,6 +482,7 @@ MS_CHECK_VIDEO AM_CONDITIONAL(BUILD_VIDEO, test "$video" = "true") AM_CONDITIONAL(BUILD_THEORA, test "$have_theora" = "yes") AM_CONDITIONAL(BUILD_WIN32, test "$mingw_found" = "yes") +AM_CONDITIONAL(BUILD_WIN32_WCE, test "$mingw32ce_found" = "yes") dnl ********************************************* dnl setup oRTP dependency diff --git a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h index eadff1495849fdcc82332a2c7ca7a69879c212a3..9ac66933747e07e2bda77f83bebc32051bf4f0f4 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h +++ b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h @@ -30,6 +30,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ortp/event.h" #include <time.h> +#if defined(_WIN32_WCE) +#define time ms_time +time_t ms_time (time_t *t); +#endif /*_WIN32_WCE*/ + typedef enum EchoLimiterType{ ELInactive, ELControlMic, @@ -100,7 +105,7 @@ void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno); /* those two function do the same as audio_stream_start() but in two steps -this is useful to make sure that sockets are open before sending an invite; +this is useful to make sure that sockets are open before sending an invite; or to start to stream only after receiving an ack.*/ AudioStream *audio_stream_new(int locport, bool_t ipv6); int audio_stream_start_now(AudioStream * stream, RtpProfile * prof, const char *remip, int remport, int rem_rtcp_port, int payload_type, int jitt_comp,MSSndCard *playcard, MSSndCard *captcard, bool_t echo_cancel); diff --git a/linphone/mediastreamer2/src/Makefile.am b/linphone/mediastreamer2/src/Makefile.am index c85f158464cde725c1ce4a0fe48543e7ddd9f306..d5bf394ac3f98c8c01a41bbaf46d7c1b44428fd6 100644 --- a/linphone/mediastreamer2/src/Makefile.am +++ b/linphone/mediastreamer2/src/Makefile.am @@ -162,7 +162,9 @@ libmediastreamer_la_LIBADD+= -lole32 \ endif endif - +if BUILD_WIN32_WCE +libmediastreamer_la_LIBADD+= -lmmtimer +endif AM_CFLAGS= -I$(top_srcdir) \ $(ORTP_CFLAGS) \ diff --git a/linphone/mediastreamer2/src/audiostream.c b/linphone/mediastreamer2/src/audiostream.c index fd5c3d3bc2b243d0b5a41a597d9a794ff0e3eb24..323ec99ce1f68c64549dcf722a0eefc332654665 100644 --- a/linphone/mediastreamer2/src/audiostream.c +++ b/linphone/mediastreamer2/src/audiostream.c @@ -95,7 +95,7 @@ bool_t ms_is_ipv6(const char *remote){ bool_t ret=FALSE; #ifdef INET6 struct addrinfo hints, *res0; - + int err; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; @@ -105,7 +105,7 @@ bool_t ms_is_ipv6(const char *remote){ ms_warning ("get_local_addr_for: %s", gai_strerror(err)); return FALSE; } - ret=(res0->ai_addr->sa_family==AF_INET6); + ret=(res0->ai_addr->sa_family==AF_INET6); freeaddrinfo(res0); #endif return ret; @@ -127,7 +127,7 @@ RtpSession * create_duplex_rtpsession( int locport, bool_t ipv6){ #if defined(_WIN32_WCE) time_t -time (time_t *t) +ms_time (time_t *t) { DWORD timemillis = GetTickCount(); if (timemillis>0) @@ -179,7 +179,7 @@ void audio_stream_change_decoder(AudioStream *stream, int payload){ ms_filter_link (stream->rtprecv, 0, stream->decoder, 0); ms_filter_link (stream->decoder,0 , stream->dtmfgen, 0); ms_filter_preprocess(stream->decoder,stream->ticker); - + }else{ ms_warning("No decoder found for %s",pt->mime_type); } @@ -208,17 +208,17 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char if (remport>0) rtp_session_set_remote_addr_full(rtps,remip,remport,rem_rtcp_port); rtp_session_set_payload_type(rtps,payload); rtp_session_set_jitter_compensation(rtps,jitt_comp); - + if (remport>0) ms_filter_call_method(stream->rtpsend,MS_RTP_SEND_SET_SESSION,rtps); stream->rtprecv=ms_filter_new(MS_RTP_RECV_ID); ms_filter_call_method(stream->rtprecv,MS_RTP_RECV_SET_SESSION,rtps); stream->session=rtps; - + stream->dtmfgen=ms_filter_new(MS_DTMF_GEN_ID); rtp_session_signal_connect(rtps,"telephone-event",(RtpCallback)on_dtmf_received,(unsigned long)stream); rtp_session_signal_connect(rtps,"payload_type_changed",(RtpCallback)payload_type_changed,(unsigned long)stream); - + /* creates the local part */ if (captcard!=NULL) stream->soundread=ms_snd_card_create_reader(captcard); else { @@ -231,7 +231,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char stream->soundwrite=ms_filter_new(MS_FILE_REC_ID); if (outfile!=NULL) audio_stream_record(stream,outfile); } - + /* creates the couple of encoder/decoder */ pt=rtp_profile_get_payload(profile,payload); if (pt==NULL){ @@ -245,7 +245,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char ms_error("mediastream.c: No decoder available for payload %i.",payload); return -1; } - + if (use_ec) { stream->ec=ms_filter_new(MS_SPEEX_EC_ID); ms_filter_call_method(stream->ec,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); @@ -283,7 +283,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); tmp=1; ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_NCHANNELS, &tmp); - + /* give the encoder/decoder some parameters*/ ms_filter_call_method(stream->encoder,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); ms_message("Payload's bitrate is %i",pt->normal_bitrate); @@ -292,10 +292,10 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char ms_filter_call_method(stream->encoder,MS_FILTER_SET_BITRATE,&pt->normal_bitrate); } ms_filter_call_method(stream->decoder,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); - + if (pt->send_fmtp!=NULL) ms_filter_call_method(stream->encoder,MS_FILTER_ADD_FMTP, (void*)pt->send_fmtp); if (pt->recv_fmtp!=NULL) ms_filter_call_method(stream->decoder,MS_FILTER_ADD_FMTP,(void*)pt->recv_fmtp); - + /*create the equalizer*/ stream->equalizer=ms_filter_new(MS_EQUALIZER_ID); tmp=stream->eq_active; @@ -303,7 +303,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char /* and then connect all */ /* tip: draw yourself the picture if you don't understand */ - + /*sending graph*/ ms_connection_helper_start(&h); ms_connection_helper_link(&h,stream->soundread,-1,0); @@ -328,13 +328,13 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char if (stream->ec) ms_connection_helper_link(&h,stream->ec,0,0); ms_connection_helper_link(&h,stream->soundwrite,0,-1); - + /* create ticker */ stream->ticker=ms_ticker_new(); ms_ticker_set_name(stream->ticker,"Audio MSTicker"); ms_ticker_attach(stream->ticker,stream->soundread); ms_ticker_attach(stream->ticker,stream->rtprecv); - + return 0; } @@ -490,9 +490,9 @@ void audio_stream_stop(AudioStream * stream) MSConnectionHelper h; ms_ticker_detach(stream->ticker,stream->soundread); ms_ticker_detach(stream->ticker,stream->rtprecv); - + rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics"); - + /*dismantle the outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->soundread,-1,0); diff --git a/linphone/mediastreamer2/src/msvolume.c b/linphone/mediastreamer2/src/msvolume.c index ba8b068eec4c774178eae6ac044f2ff8d5691a1e..c281191d425e5c173991d5f22cbef384799b11ae 100644 --- a/linphone/mediastreamer2/src/msvolume.c +++ b/linphone/mediastreamer2/src/msvolume.c @@ -103,7 +103,7 @@ static void volume_uninit(MSFilter *f){ static int volume_get(MSFilter *f, void *arg){ float *farg=(float*)arg; Volume *v=(Volume*)f->data; - *farg=10*log10f((v->energy+1)/max_e); + *farg=10*ortp_log10f((v->energy+1)/max_e); return 0; } @@ -138,10 +138,10 @@ static inline float compute_gain(float static_gain, float energy, float weight){ } /* -The principle of this algorithm is that we apply a gain to the input signal which is opposite to the +The principle of this algorithm is that we apply a gain to the input signal which is opposite to the energy measured by the peer MSVolume. For example if some noise is played by the speaker, then the signal captured by the microphone will be lowered. -The gain changes smoothly when the peer energy is decreasing, but is immediately changed when the peer energy is +The gain changes smoothly when the peer energy is decreasing, but is immediately changed when the peer energy is increasing. */ @@ -340,7 +340,7 @@ static void volume_process(MSFilter *f){ om->b_wptr+=nbytes; en=update_energy((int16_t*)om->b_rptr,v->nsamples,en); volume_agc_process(v,om); - + if (v->peer){ volume_echo_avoider_process(v,f->ticker->time); }else v->target_gain=v->static_gain; @@ -355,7 +355,7 @@ static void volume_process(MSFilter *f){ while((m=ms_queue_get(f->inputs[0]))!=NULL){ en=update_energy((int16_t*)m->b_rptr,(m->b_wptr-m->b_rptr)/2,en); if (v->peer){ - volume_echo_avoider_process(v,f->ticker->time); + volume_echo_avoider_process(v,f->ticker->time); }else v->target_gain=v->static_gain; if (v->noise_gate_enabled) diff --git a/linphone/oRTP/include/ortp/port.h b/linphone/oRTP/include/ortp/port.h index 5d2a2d3f33d2c55f95fbd800c8e3c126a2f6f2da..f3fe9b48d66be0e430ccf0866b0a5b5b62bb1538 100644 --- a/linphone/oRTP/include/ortp/port.h +++ b/linphone/oRTP/include/ortp/port.h @@ -147,7 +147,7 @@ typedef HANDLE ortp_thread_t; #define ortp_thread_create WIN_thread_create #define ortp_thread_join WIN_thread_join -#define ortp_thread_exit(arg) +#define ortp_thread_exit(arg) #define ortp_mutex_init WIN_mutex_init #define ortp_mutex_lock WIN_mutex_lock #define ortp_mutex_unlock WIN_mutex_unlock @@ -163,12 +163,12 @@ typedef HANDLE ortp_thread_t; extern "C" { #endif - + int WIN_mutex_init(ortp_mutex_t *m, void *attr_unused); int WIN_mutex_lock(ortp_mutex_t *mutex); int WIN_mutex_unlock(ortp_mutex_t *mutex); int WIN_mutex_destroy(ortp_mutex_t *mutex); -int WIN_thread_create(ortp_thread_t *t, void *attr_unused, void *(*func)(void*), void *arg); +int WIN_thread_create(ortp_thread_t *t, void *attr_unused, void *(*func)(void*), void *arg); int WIN_thread_join(ortp_thread_t thread, void **unused); int WIN_cond_init(ortp_cond_t *cond, void *attr_unused); int WIN_cond_wait(ortp_cond_t * cond, ortp_mutex_t * mutex); @@ -183,6 +183,28 @@ int WIN_cond_destroy(ortp_cond_t * cond); #define SOCKET_OPTION_VALUE char * #define inline __inline +#if defined(_WIN32_WCE) + +#define ortp_log10f(x) (float)log10 ((double)x) + +#ifdef assert + #undef assert +#endif /*assert*/ +#define assert(exp) ((void)0) + +#ifdef errno + #undef errno +#endif /*errno*/ +#define errno GetLastError() +#ifdef strerror + #undef strerror +#endif /*strerror*/ +const char * ortp_strerror(DWORD value); +#define strerror ortp_strerror + + +#endif /*_WIN32_WCE*/ + const char *getWinSocketError(int error); #define getSocketErrorCode() WSAGetLastError() #define getSocketError() getWinSocketError(WSAGetLastError()) @@ -240,6 +262,8 @@ char *ortp_strndup(const char *str,int n); char *ortp_strdup_printf(const char *fmt,...); char *ortp_strdup_vprintf(const char *fmt, va_list ap); +int ortp_file_exist(const char *pathname); + /* portable named pipes */ #if !defined(_WIN32_WCE) #ifdef WIN32 @@ -269,6 +293,7 @@ int ortp_pipe_write(ortp_pipe_t p, const uint8_t *buf, int len); #ifdef __cplusplus } + #endif diff --git a/linphone/oRTP/src/b64.c b/linphone/oRTP/src/b64.c index b8d92535159376b5b910a67ce49cb834a036dcd0..08b0ed3e6254b19af5048a2137125efdf25deec2 100644 --- a/linphone/oRTP/src/b64.c +++ b/linphone/oRTP/src/b64.c @@ -60,7 +60,7 @@ #include <assert.h> #include <string.h> - +#include "ortp/port.h" /* ///////////////////////////////////////////////////////////////////////////// * Constants and definitions */ diff --git a/linphone/oRTP/src/port.c b/linphone/oRTP/src/port.c index 73680f6594f73fa1aebf3aa018c203cedcae0c40..de14a38123ddced62a5222188195bda539679464 100644 --- a/linphone/oRTP/src/port.c +++ b/linphone/oRTP/src/port.c @@ -100,7 +100,7 @@ char * ortp_strdup(const char *tmp){ */ int set_non_blocking_socket (ortp_socket_t sock) { - + #if !defined(_WIN32) && !defined(_WIN32_WCE) return fcntl (sock, F_SETFL, O_NONBLOCK); @@ -124,7 +124,23 @@ int close_socket(ortp_socket_t sock){ #endif } - +#if defined (_WIN32_WCE) +int ortp_file_exist(const char *pathname) { + FILE* fd; + if (pathname==NULL) return -1; + fd=fopen(pathname,"r"); + if (fd==NULL) { + return -1; + } else { + fclose(fd); + return 0; + } +} +#else +int ortp_file_exist(const char *pathname) { + return access(pathname,F_OK); +} +#endif /*_WIN32_WCE*/ #if !defined(_WIN32) && !defined(_WIN32_WCE) /* Use UNIX inet_aton method */ @@ -132,10 +148,10 @@ int close_socket(ortp_socket_t sock){ int inet_aton (const char * cp, struct in_addr * addr) { unsigned long retval; - + retval = inet_addr (cp); - if (retval == INADDR_NONE) + if (retval == INADDR_NONE) { return -1; } @@ -180,7 +196,7 @@ int __ortp_thread_create(pthread_t *thread, pthread_attr_t *attr, void * (*routi #if defined(_WIN32) || defined(_WIN32_WCE) int WIN_mutex_init(ortp_mutex_t *mutex, void *attr) -{ +{ *mutex=CreateMutex(NULL, FALSE, NULL); return 0; } @@ -248,7 +264,7 @@ int WIN_cond_init(ortp_cond_t *cond, void *attr) int WIN_cond_wait(ortp_cond_t* hCond, ortp_mutex_t * hMutex) { //gulp: this is not very atomic ! bug here ? - WIN_mutex_unlock(hMutex); + WIN_mutex_unlock(hMutex); WaitForSingleObject(*hCond, INFINITE); WIN_mutex_lock(hMutex); return 0; @@ -276,6 +292,21 @@ int WIN_cond_destroy(ortp_cond_t * hCond) #if defined(_WIN32_WCE) #include <time.h> +const char * ortp_strerror(DWORD value) { + static TCHAR msgBuf[256]; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + value, + 0, // Default language + (LPTSTR) &msgBuf, + 0, + NULL + ); + return (const char *)msgBuf; +} + int gettimeofday (struct timeval *tv, void *tz) { @@ -287,19 +318,19 @@ gettimeofday (struct timeval *tv, void *tz) #else -int gettimeofday (struct timeval *tv, void* tz) -{ - union - { - __int64 ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME fileTime; - } now; +int gettimeofday (struct timeval *tv, void* tz) +{ + union + { + __int64 ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME fileTime; + } now; - GetSystemTimeAsFileTime (&now.fileTime); - tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL); - tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL); - return (0); -} + GetSystemTimeAsFileTime (&now.fileTime); + tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL); + tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL); + return (0); +} #endif @@ -405,6 +436,7 @@ int ortp_client_pipe_close(ortp_socket_t sock){ return close(sock); } + #elif defined(WIN32) && !defined(_WIN32_WCE) static char *make_pipe_name(const char *name){ @@ -462,15 +494,15 @@ int ortp_server_pipe_close(ortp_pipe_t spipe){ ortp_pipe_t ortp_client_pipe_connect(const char *name){ char *pipename=make_pipe_name(name); - ortp_pipe_t hpipe = CreateFile( - pipename, // pipe name - GENERIC_READ | // read and write access - GENERIC_WRITE, - 0, // no sharing + ortp_pipe_t hpipe = CreateFile( + pipename, // pipe name + GENERIC_READ | // read and write access + GENERIC_WRITE, + 0, // no sharing NULL, // default security attributes - OPEN_EXISTING, // opens existing pipe - 0, // default attributes - NULL); // no template file + OPEN_EXISTING, // opens existing pipe + 0, // default attributes + NULL); // no template file ortp_free(pipename); return hpipe; } @@ -496,4 +528,5 @@ int ortp_client_pipe_close(ortp_pipe_t sock){ return CloseHandle(sock); } + #endif