Commit b866ece2 authored by smorlat's avatar smorlat

* merge patch to disable usage of REUSEADDR as a configure option

* implement reloading of soundcards and webcams.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@408 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent ef11e6c7
......@@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct _MSSndCardManager{
MSList *cards;
MSList *descs;
};
/**
......@@ -206,6 +207,12 @@ void ms_snd_card_manager_add_card(MSSndCardManager *m, MSSndCard *c);
*/
void ms_snd_card_manager_register_desc(MSSndCardManager *m, MSSndCardDesc *desc);
/**
* Ask all registered MSSndCardDesc to re-detect their soundcards.
* @param m The sound card manager.
**/
void ms_snd_card_manager_reload(MSSndCardManager *m);
/** @} */
/**
......
......@@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct _MSWebCamManager{
MSList *cams;
MSList *descs;
};
/**
......@@ -94,15 +95,15 @@ extern "C"{
MSWebCamManager * ms_web_cam_manager_get(void);
/**
* Destroy a sound card manager object.
* Destroy the webcam manager object.
*
*/
void ms_web_cam_manager_destroy(void);
/**
* Retreive a sound card object based on its name.
* Retreive a webcam object based on its name.
*
* @param m A sound card manager containing sound cards.
* @param m A webcam manager containing webcam.
* @param id A name for card to search.
*
* Returns: MSWebCam if successfull, NULL otherwise.
......@@ -110,9 +111,9 @@ void ms_web_cam_manager_destroy(void);
MSWebCam * ms_web_cam_manager_get_cam(MSWebCamManager *m, const char *id);
/**
* Retreive the default sound card object.
* Retreive the default webcam object.
*
* @param m A sound card manager containing sound cards.
* @param m A webcam manager containing webcams.
*
* Returns: MSWebCam if successfull, NULL otherwise.
*/
......@@ -128,7 +129,7 @@ MSWebCam * ms_web_cam_manager_get_default_cam(MSWebCamManager *m);
const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m);
/**
* Add a sound card object in a webcam manager's list.
* Add a webcam object in a webcam manager's list.
*
* @param m A webcam manager containing webcams
* @param c A web cam object.
......@@ -137,7 +138,7 @@ const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m);
void ms_web_cam_manager_add_cam(MSWebCamManager *m, MSWebCam *c);
/**
* Add a sound card object on top of list of the webcam manager's list.
* Add a webcam object on top of list of the webcam manager's list.
*
* @param m A webcam manager containing webcams
* @param c A web cam object.
......@@ -147,18 +148,26 @@ void ms_web_cam_manager_prepend_cam(MSWebCamManager *m, MSWebCam *c);
/**
* Register a sound card description in a sound card manager.
* Register a webcam descriptor in a webcam manager.
*
* @param m A sound card manager containing sound cards.
* @param desc A sound card description object.
* @param m A webcam manager containing sound cards.
* @param desc A webcam descriptor object.
*
*/
void ms_web_cam_manager_register_desc(MSWebCamManager *m, MSWebCamDesc *desc);
/**
* Ask all registered MSWebCamDesc to detect the webcams again.
*
* @param m A webcam manager
**/
void ms_web_cam_manager_reload(MSWebCamManager *m);
/**
* Create an INPUT filter based on the selected camera.
*
* @param obj A sound card object.
* @param obj A webcam object.
*
* Returns: A MSFilter if successfull, NULL otherwise.
*/
......
......@@ -27,6 +27,7 @@ static MSSndCardManager *scm=NULL;
static MSSndCardManager * create_manager(){
MSSndCardManager *obj=(MSSndCardManager *)ms_new(MSSndCardManager,1);
obj->cards=NULL;
obj->descs=NULL;
return obj;
}
......@@ -34,6 +35,7 @@ void ms_snd_card_manager_destroy(void){
if (scm!=NULL){
ms_list_for_each(scm->cards,(void (*)(void*))ms_snd_card_destroy);
ms_list_free(scm->cards);
ms_list_free(scm->descs);
}
ms_free(scm);
scm=NULL;
......@@ -96,11 +98,25 @@ void ms_snd_card_manager_add_card(MSSndCardManager *m, MSSndCard *c){
m->cards=ms_list_append(m->cards,c);
}
void ms_snd_card_manager_register_desc(MSSndCardManager *m, MSSndCardDesc *desc){
static void card_detect(MSSndCardManager *m, MSSndCardDesc *desc){
if (desc->detect!=NULL)
desc->detect(m);
}
void ms_snd_card_manager_register_desc(MSSndCardManager *m, MSSndCardDesc *desc){
m->descs=ms_list_append(m->descs,desc);
card_detect(m,desc);
}
void ms_snd_card_manager_reload(MSSndCardManager *m){
MSList *elem;
ms_list_for_each(m->cards,(void (*)(void*))ms_snd_card_destroy);
ms_list_free(m->cards);
m->cards=NULL;
for(elem=m->descs;elem!=NULL;elem=elem->next)
card_detect(m,(MSSndCardDesc*)elem->data);
}
MSSndCard * ms_snd_card_dup(MSSndCard *card){
MSSndCard *obj=NULL;
if (card->desc->duplicate!=NULL)
......
......@@ -29,6 +29,7 @@ static MSWebCamManager *scm=NULL;
static MSWebCamManager * create_manager(){
MSWebCamManager *obj=(MSWebCamManager *)ms_new(MSWebCamManager,1);
obj->cams=NULL;
obj->descs=NULL;
return obj;
}
......@@ -36,6 +37,7 @@ void ms_web_cam_manager_destroy(void){
if (scm!=NULL){
ms_list_for_each(scm->cams,(void (*)(void*))ms_web_cam_destroy);
ms_list_free(scm->cams);
ms_list_free(scm->descs);
}
ms_free(scm);
scm=NULL;
......@@ -58,9 +60,9 @@ MSWebCam * ms_web_cam_manager_get_cam(MSWebCamManager *m, const char *id){
}
MSWebCam * ms_web_cam_manager_get_default_cam(MSWebCamManager *m){
if (m->cams!=NULL)
return (MSWebCam*)m->cams->data;
return NULL;
if (m->cams!=NULL)
return (MSWebCam*)m->cams->data;
return NULL;
}
const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m){
......@@ -77,11 +79,25 @@ void ms_web_cam_manager_prepend_cam(MSWebCamManager *m, MSWebCam *c){
m->cams=ms_list_prepend(m->cams,c);
}
void ms_web_cam_manager_register_desc(MSWebCamManager *m, MSWebCamDesc *desc){
static void cam_detect(MSWebCamManager *m, MSWebCamDesc *desc){
if (desc->detect!=NULL)
desc->detect(m);
}
void ms_web_cam_manager_register_desc(MSWebCamManager *m, MSWebCamDesc *desc){
m->descs=ms_list_append(m->descs,desc);
cam_detect(m,desc);
}
void ms_web_cam_manager_reload(MSWebCamManager *m){
MSList *elem;
ms_list_for_each(m->cams,(void (*)(void*))ms_web_cam_destroy);
ms_list_free(m->cams);
m->cams=NULL;
for(elem=m->descs;elem!=NULL;elem=elem->next)
cam_detect(m,(MSWebCamDesc*)elem->data);
}
MSWebCam * ms_web_cam_new(MSWebCamDesc *desc){
MSWebCam *obj=(MSWebCam *)ms_new(MSWebCam,1);
obj->desc=desc;
......
......@@ -202,6 +202,20 @@ if test "$memcheck_enabled" = "yes" ; then
fi
fi
AC_ARG_ENABLE(so-reuseaddr,
[ --enable-so-reuseaddr=[yes/no] enables SO_REUSEADDR socket option in the rtp_session_set_local_addr() function.],
[case "${enableval}" in
yes) so_reuseaddr_enabled=yes;;
no) so_reuseaddr_enabled=no;;
*) AC_MSG_ERROR("Bad value for --enable-so-reuseaddr");;
esac],
[so_reuseaddr_enabled=yes])
if test "$so_reuseaddr_enabled" = "yes" ; then
AC_DEFINE(SO_REUSE_ADDR,1,[Defined when SO_REUSEADDR socket option in the rtp_session_set_local_addr() function is enabled])
fi
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(poll.h sys/poll.h sys/uio.h fcntl.h sys/time.h unistd.h sys/audio.h linux/soundcard.h)
......
......@@ -29,3 +29,6 @@
#define RTP_DEBUG 1
#define HAVE_SRTP 1
/* enables SO_REUSEADDR socket option in the rtp_session_set_local_addr() function */
#define SO_REUSE_ADDR 1
......@@ -246,13 +246,19 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int port)
{
ortp_socket_t sock;
int sockfamily;
bool_t reuse_addr;
if (session->rtp.socket>=0){
/* don't rebind, but close before*/
rtp_session_release_sockets(session);
}
#ifdef SO_REUSE_ADDR
reuse_addr=TRUE;
#else
reuse_addr=FALSE;
#endif
/* try to bind the rtp port */
if (port>0)
sock=create_and_bind(addr,port,&sockfamily,TRUE);
sock=create_and_bind(addr,port,&sockfamily,reuse_addr);
else
sock=create_and_bind_random(addr,&sockfamily,&port);
if (sock!=-1){
......@@ -261,7 +267,7 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int port)
session->rtp.socket=sock;
session->rtp.loc_port=port;
/*try to bind rtcp port */
sock=create_and_bind(addr,port+1,&sockfamily,TRUE);
sock=create_and_bind(addr,port+1,&sockfamily,reuse_addr);
if (sock!=-1){
session->rtcp.sockfamily=sockfamily;
session->rtcp.socket=sock;
......
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