Commit 32d04b26 authored by smorlat's avatar smorlat

a few fixes.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@118 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 96e05f19
...@@ -1670,7 +1670,7 @@ static MSSndCard *get_card_from_string_id(const char *devid, unsigned int cap){ ...@@ -1670,7 +1670,7 @@ static MSSndCard *get_card_from_string_id(const char *devid, unsigned int cap){
if (sndcard==NULL){/*looks like a bug! take the first one !*/ if (sndcard==NULL){/*looks like a bug! take the first one !*/
const MSList *elem=ms_snd_card_manager_get_list(ms_snd_card_manager_get()); const MSList *elem=ms_snd_card_manager_get_list(ms_snd_card_manager_get());
sndcard=(MSSndCard*)elem->data; sndcard=(MSSndCard*)elem->data;
} }
} }
if (sndcard==NULL) ms_error("Could not find a suitable soundcard !"); if (sndcard==NULL) ms_error("Could not find a suitable soundcard !");
return sndcard; return sndcard;
......
...@@ -485,7 +485,7 @@ static MSWebCamDesc * ms_web_cam_descs[]={ ...@@ -485,7 +485,7 @@ static MSWebCamDesc * ms_web_cam_descs[]={
#ifdef __linux #ifdef __linux
&v4l_desc, &v4l_desc,
#endif #endif
#ifdef WIN32 #if defined(WIN32) && !defined(HAVE_DIRECTSHOW)
&ms_vfw_cam_desc, &ms_vfw_cam_desc,
#endif #endif
&mire_desc, &mire_desc,
......
...@@ -47,11 +47,8 @@ static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen ...@@ -47,11 +47,8 @@ static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen
static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_family, bool_t reuse_addr){ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_family, bool_t reuse_addr){
int err; int err;
int optval = 1; int optval = 1;
#if defined(WIN32) || defined(_WIN32_WCE) ortp_socket_t sock=-1;
ortp_socket_t sock=INVALID_SOCKET;
#else
ortp_socket_t sock=-1;
#endif
#ifdef ORTP_INET6 #ifdef ORTP_INET6
char num[8]; char num[8];
struct addrinfo hints, *res0, *res; struct addrinfo hints, *res0, *res;
...@@ -68,22 +65,14 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -68,22 +65,14 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
err = getaddrinfo(addr,num, &hints, &res0); err = getaddrinfo(addr,num, &hints, &res0);
if (err!=0) { if (err!=0) {
ortp_warning ("Error in getaddrinfo on (addr=%s port=%i): %s", addr, port, gai_strerror(err)); ortp_warning ("Error in getaddrinfo on (addr=%s port=%i): %s", addr, port, gai_strerror(err));
#if defined(WIN32) || defined(_WIN32_WCE)
return INVALID_SOCKET;
#else
return -1; return -1;
#endif
} }
for (res = res0; res; res = res->ai_next) { for (res = res0; res; res = res->ai_next) {
sock = socket(res->ai_family, res->ai_socktype, 0); sock = socket(res->ai_family, res->ai_socktype, 0);
#if defined(WIN32) || defined(_WIN32_WCE) if (sock==-1)
if (sock==INVALID_SOCKET) continue;
continue;
#else
if (sock < 0)
continue;
#endif
if (reuse_addr){ if (reuse_addr){
err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(SOCKET_OPTION_VALUE)&optval, sizeof (optval)); (SOCKET_OPTION_VALUE)&optval, sizeof (optval));
...@@ -95,17 +84,12 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -95,17 +84,12 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
*sock_family=res->ai_family; *sock_family=res->ai_family;
err = bind (sock, res->ai_addr, res->ai_addrlen); err = bind (sock, res->ai_addr, res->ai_addrlen);
if (err != 0) if (err != 0){
{ ortp_warning ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr,port, getSocketError());
ortp_warning ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr,port, getSocketError()); close_socket (sock);
close_socket (sock); sock=-1;
#if defined(WIN32) || defined(_WIN32_WCE) continue;
sock=INVALID_SOCKET; }
#else
sock=-1;
#endif
continue;
}
#ifndef __hpux #ifndef __hpux
switch (res->ai_family) switch (res->ai_family)
{ {
...@@ -116,16 +100,11 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -116,16 +100,11 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *) res->ai_addr)->sin_addr.s_addr; mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *) res->ai_addr)->sin_addr.s_addr;
mreq.imr_interface.s_addr = INADDR_ANY; mreq.imr_interface.s_addr = INADDR_ANY;
err = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (SOCKET_OPTION_VALUE) &mreq, sizeof(mreq)); err = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (SOCKET_OPTION_VALUE) &mreq, sizeof(mreq));
if (err < 0) if (err < 0){
{ ortp_warning ("Fail to join address group: %s.", getSocketError());
ortp_warning ("Fail to join address group: %s.", getSocketError()); close_socket (sock);
close_socket (sock); sock=-1;
#if defined(WIN32) || defined(_WIN32_WCE) continue;
sock=INVALID_SOCKET;
#else
sock=-1;
#endif
continue;
} }
} }
break; break;
...@@ -140,11 +119,7 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -140,11 +119,7 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
{ {
ortp_warning ("Fail to join address group: %s.", getSocketError()); ortp_warning ("Fail to join address group: %s.", getSocketError());
close_socket (sock); close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
sock=INVALID_SOCKET;
#else
sock=-1; sock=-1;
#endif
continue; continue;
} }
} }
...@@ -161,23 +136,14 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -161,23 +136,14 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
if (err < 0) if (err < 0)
{ {
ortp_warning ("Error in socket address:%s.", getSocketError()); ortp_warning ("Error in socket address:%s.", getSocketError());
#if defined(WIN32) || defined(_WIN32_WCE) return -1;
return INVALID_SOCKET;
#else
return err;
#endif
} }
saddr.sin_port = htons (port); saddr.sin_port = htons (port);
sock = socket (PF_INET, SOCK_DGRAM, 0); sock = socket (PF_INET, SOCK_DGRAM, 0);
#if defined(WIN32) || defined(_WIN32_WCE) if (sock==-1) return -1;
if (sock==INVALID_SOCKET)
return INVALID_SOCKET;
#else
if (sock<0) return -1;
#endif
if (reuse_addr){ if (reuse_addr){
err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(SOCKET_OPTION_VALUE)&optval, sizeof (optval)); (SOCKET_OPTION_VALUE)&optval, sizeof (optval));
if (err < 0) if (err < 0)
...@@ -194,22 +160,12 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil ...@@ -194,22 +160,12 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
{ {
ortp_warning ("Fail to bind rtp socket to port %i: %s.", port, getSocketError()); ortp_warning ("Fail to bind rtp socket to port %i: %s.", port, getSocketError());
close_socket (sock); close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
return INVALID_SOCKET;
#else
return -1; return -1;
#endif
} }
#endif #endif
#if defined(WIN32) || defined(_WIN32_WCE) if (sock!=-1){
if (sock!=INVALID_SOCKET){
set_non_blocking_socket (sock);
}
#else
if (sock>=0){
set_non_blocking_socket (sock); set_non_blocking_socket (sock);
} }
#endif
return sock; return sock;
} }
...@@ -261,17 +217,10 @@ static ortp_socket_t create_and_bind_random(const char *localip, int *sock_famil ...@@ -261,17 +217,10 @@ static ortp_socket_t create_and_bind_random(const char *localip, int *sock_famil
while ((localport < 5000) || (localport > 0xffff)); while ((localport < 5000) || (localport > 0xffff));
/*do not set REUSEADDR in case of random allocation */ /*do not set REUSEADDR in case of random allocation */
sock = create_and_bind(localip, localport, sock_family,FALSE); sock = create_and_bind(localip, localport, sock_family,FALSE);
#if defined(WIN32) || defined(_WIN32_WCE) if (sock!=-1) {
if (sock!=INVALID_SOCKET) {
*port=localport;
return sock;
}
#else
if (sock>=0) {
*port=localport; *port=localport;
return sock; return sock;
} }
#endif
} }
ortp_warning("create_and_bind_random: Could not find a random port for %s !",localip); ortp_warning("create_and_bind_random: Could not find a random port for %s !",localip);
return -1; return -1;
...@@ -306,24 +255,14 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int port) ...@@ -306,24 +255,14 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int port)
sock=create_and_bind(addr,port,&sockfamily,TRUE); sock=create_and_bind(addr,port,&sockfamily,TRUE);
else else
sock=create_and_bind_random(addr,&sockfamily,&port); sock=create_and_bind_random(addr,&sockfamily,&port);
#if defined(WIN32) || defined(_WIN32_WCE) if (sock!=-1){
if (sock!=INVALID_SOCKET)
#else
if (sock>=0)
#endif
{
set_socket_sizes(sock,session->rtp.snd_socket_size,session->rtp.rcv_socket_size); set_socket_sizes(sock,session->rtp.snd_socket_size,session->rtp.rcv_socket_size);
session->rtp.sockfamily=sockfamily; session->rtp.sockfamily=sockfamily;
session->rtp.socket=sock; session->rtp.socket=sock;
session->rtp.loc_port=port; session->rtp.loc_port=port;
/*try to bind rtcp port */ /*try to bind rtcp port */
sock=create_and_bind(addr,port+1,&sockfamily,TRUE); sock=create_and_bind(addr,port+1,&sockfamily,TRUE);
#if defined(WIN32) || defined(_WIN32_WCE) if (sock!=-1){
if (sock!=INVALID_SOCKET)
#else
if (sock>=0)
#endif
{
session->rtcp.sockfamily=sockfamily; session->rtcp.sockfamily=sockfamily;
session->rtcp.socket=sock; session->rtcp.socket=sock;
}else{ }else{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment