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){
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());
sndcard=(MSSndCard*)elem->data;
}
}
}
if (sndcard==NULL) ms_error("Could not find a suitable soundcard !");
return sndcard;
......
......@@ -485,7 +485,7 @@ static MSWebCamDesc * ms_web_cam_descs[]={
#ifdef __linux
&v4l_desc,
#endif
#ifdef WIN32
#if defined(WIN32) && !defined(HAVE_DIRECTSHOW)
&ms_vfw_cam_desc,
#endif
&mire_desc,
......
......@@ -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){
int err;
int optval = 1;
#if defined(WIN32) || defined(_WIN32_WCE)
ortp_socket_t sock=INVALID_SOCKET;
#else
ortp_socket_t sock=-1;
#endif
ortp_socket_t sock=-1;
#ifdef ORTP_INET6
char num[8];
struct addrinfo hints, *res0, *res;
......@@ -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);
if (err!=0) {
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;
#endif
}
for (res = res0; res; res = res->ai_next) {
sock = socket(res->ai_family, res->ai_socktype, 0);
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock==INVALID_SOCKET)
continue;
#else
if (sock < 0)
continue;
#endif
if (sock==-1)
continue;
if (reuse_addr){
err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(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
*sock_family=res->ai_family;
err = bind (sock, res->ai_addr, res->ai_addrlen);
if (err != 0)
{
ortp_warning ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr,port, getSocketError());
close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
sock=INVALID_SOCKET;
#else
sock=-1;
#endif
continue;
}
if (err != 0){
ortp_warning ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr,port, getSocketError());
close_socket (sock);
sock=-1;
continue;
}
#ifndef __hpux
switch (res->ai_family)
{
......@@ -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_interface.s_addr = INADDR_ANY;
err = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (SOCKET_OPTION_VALUE) &mreq, sizeof(mreq));
if (err < 0)
{
ortp_warning ("Fail to join address group: %s.", getSocketError());
close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
sock=INVALID_SOCKET;
#else
sock=-1;
#endif
continue;
if (err < 0){
ortp_warning ("Fail to join address group: %s.", getSocketError());
close_socket (sock);
sock=-1;
continue;
}
}
break;
......@@ -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());
close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
sock=INVALID_SOCKET;
#else
sock=-1;
#endif
continue;
}
}
......@@ -161,23 +136,14 @@ static ortp_socket_t create_and_bind(const char *addr, int port, int *sock_famil
if (err < 0)
{
ortp_warning ("Error in socket address:%s.", getSocketError());
#if defined(WIN32) || defined(_WIN32_WCE)
return INVALID_SOCKET;
#else
return err;
#endif
return -1;
}
saddr.sin_port = htons (port);
sock = socket (PF_INET, SOCK_DGRAM, 0);
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock==INVALID_SOCKET)
return INVALID_SOCKET;
#else
if (sock<0) return -1;
#endif
if (sock==-1) return -1;
if (reuse_addr){
if (reuse_addr){
err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(SOCKET_OPTION_VALUE)&optval, sizeof (optval));
if (err < 0)
......@@ -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());
close_socket (sock);
#if defined(WIN32) || defined(_WIN32_WCE)
return INVALID_SOCKET;
#else
return -1;
#endif
}
#endif
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock!=INVALID_SOCKET){
set_non_blocking_socket (sock);
}
#else
if (sock>=0){
if (sock!=-1){
set_non_blocking_socket (sock);
}
#endif
return sock;
}
......@@ -261,17 +217,10 @@ static ortp_socket_t create_and_bind_random(const char *localip, int *sock_famil
while ((localport < 5000) || (localport > 0xffff));
/*do not set REUSEADDR in case of random allocation */
sock = create_and_bind(localip, localport, sock_family,FALSE);
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock!=INVALID_SOCKET) {
*port=localport;
return sock;
}
#else
if (sock>=0) {
if (sock!=-1) {
*port=localport;
return sock;
}
#endif
}
ortp_warning("create_and_bind_random: Could not find a random port for %s !",localip);
return -1;
......@@ -306,24 +255,14 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int port)
sock=create_and_bind(addr,port,&sockfamily,TRUE);
else
sock=create_and_bind_random(addr,&sockfamily,&port);
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock!=INVALID_SOCKET)
#else
if (sock>=0)
#endif
{
if (sock!=-1){
set_socket_sizes(sock,session->rtp.snd_socket_size,session->rtp.rcv_socket_size);
session->rtp.sockfamily=sockfamily;
session->rtp.socket=sock;
session->rtp.loc_port=port;
/*try to bind rtcp port */
sock=create_and_bind(addr,port+1,&sockfamily,TRUE);
#if defined(WIN32) || defined(_WIN32_WCE)
if (sock!=INVALID_SOCKET)
#else
if (sock>=0)
#endif
{
if (sock!=-1){
session->rtcp.sockfamily=sockfamily;
session->rtcp.socket=sock;
}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