Commit 1896a794 authored by Jehan Monnier's avatar Jehan Monnier

prepare wince port

parent 798b8e72
......@@ -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
......
......@@ -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"))
{
......
This diff is collapsed.
......@@ -46,6 +46,7 @@
#endif
#endif
/**************************************************************************
*
* Compile-time defines
......@@ -98,7 +99,7 @@ typedef struct {
/***************************************************************************
*
* Forward declarations
* Forward declarations
*
***************************************************************************/
......
......@@ -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) \
......
This diff is collapsed.
......@@ -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){
......
......@@ -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);
}
......
......@@ -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;
}
......@@ -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++;
......
......@@ -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
......
......@@ -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);
......
......@@ -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) \
......
......@@ -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);
......
......@@ -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)
......
......@@ -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
......
......@@ -60,7 +60,7 @@
#include <assert.h>
#include <string.h>
#include "ortp/port.h"
/* /////////////////////////////////////////////////////////////////////////////
* Constants and definitions
*/
......
......@@ -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 |