dnl Autoconf settings for vlc
-dnl $Id: configure.ac,v 1.56 2003/08/12 08:19:20 sam Exp $
+dnl $Id: configure.ac,v 1.57 2003/08/13 14:17:25 zorglub Exp $
AC_INIT(vlc,0.6.2)
[ --with-slp=PATH libslp headers and libraries])
if test -z "${with_slp}"
then
- AC_CHECK_HEADER(slp.h, have_slp="true", have_slp="false")
+ AC_CHECK_HEADERS(slp.h, have_slp="true", have_slp="false")
if test "${have_slp}" = "true"
then
AX_ADD_PLUGINS([slp])
AX_ADD_LDFLAGS([slp],[-lslp])
+ AX_ADD_LDFLAGS([vlc],[-lslp])
fi
else
AC_MSG_CHECKING(for slp headers in ${with_slp})
AC_MSG_RESULT(yes)
AX_ADD_PLUGINS([slp])
AX_ADD_LDFLAGS([slp],[-L${with_slp} -lslp])
+ AX_ADD_LDFLAGS([vlc],[-L${with_slp} -lslp])
AX_ADD_CPPFLAGS([slp],[-I${with_slp}])
+ AC_DEFINE(HAVE_SLP_H)
else
dnl No libslp could be found, sorry
AC_MSG_RESULT(no)
* announce.h : Session announcement
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: announce.h,v 1.7 2003/07/17 14:10:08 sam Exp $
+ * $Id: announce.h,v 1.8 2003/08/13 14:17:26 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@via.ecp.fr>
*
};
+struct slp_session_t
+{
+ char *psz_url;
+ char *psz_name;
+};
+
/*****************************************************************************
* Prototypes
VLC_EXPORT( sap_session_t *, sout_SAPNew, ( sout_instance_t *,char * , char * , int , char *) );
VLC_EXPORT( void, sout_SAPSend, ( sout_instance_t *,sap_session_t *) );
VLC_EXPORT( void, sout_SAPDelete, ( sout_instance_t *,sap_session_t * ) );
+
+#ifdef HAVE_SLP_H
+VLC_EXPORT( int, sout_SLPReg, (sout_instance_t*,char*,char*) );
+VLC_EXPORT( int, sout_SLPDereg, (sout_instance_t*,char*,char*) );
+#endif
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.70 2003/08/01 00:00:12 fenrir Exp $
+ * $Id: vlc_common.h,v 1.71 2003/08/13 14:17:26 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
typedef struct sout_cfg_t sout_cfg_t;
typedef struct sout_format_t sout_format_t;
typedef struct sap_session_t sap_session_t;
+typedef struct slp_session_t slp_session_t;
+
/* Decoders */
typedef struct decoder_fifo_t decoder_fifo_t;
* standard.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: standard.c,v 1.8 2003/07/07 15:50:43 gbazin Exp $
+ * $Id: standard.c,v 1.9 2003/08/13 14:17:26 zorglub Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
struct sout_stream_sys_t
{
sout_mux_t *p_mux;
+ slp_session_t *p_slp;
sap_session_t *p_sap;
};
char *psz_url = sout_cfg_find_value( p_stream->p_cfg, "url" );
char *psz_ipv = sout_cfg_find_value( p_stream->p_cfg, "sap_ipv" );
char *psz_v6_scope = sout_cfg_find_value( p_stream->p_cfg, "sap_v6scope" );
+
sout_cfg_t *p_sap_cfg = sout_cfg_find( p_stream->p_cfg, "sap" );
-
+ sout_cfg_t *p_slp_cfg = sout_cfg_find( p_stream->p_cfg, "slp" );
+
sout_access_out_t *p_access;
sout_mux_t *p_mux;
msg_Err( p_sout,"Unable to initialize SAP. SAP disabled");
}
+ /* *** Register with slp *** */
+ #ifdef HAVE_SLP_H
+ if( p_slp_cfg && ( strstr( psz_access, "udp" ) ||
+ strstr( psz_access , "rtp" ) ) )
+ {
+ p_sys->p_slp = NULL ;
+ msg_Info( p_this, "SLP Enabled");
+ if( sout_SLPReg( p_sout, psz_url,
+ p_slp_cfg->psz_value ? p_slp_cfg->psz_value : psz_url) )
+ {
+ msg_Warn( p_sout, "SLP Registering failed");
+ }
+ else
+ {
+ p_sys->p_slp = (slp_session_t*)malloc(sizeof(slp_session_t));
+ if(!p_sys->p_slp)
+ {
+ msg_Warn(p_sout,"Out of memory");
+ return -1;
+ }
+ p_sys->p_slp->psz_url= strdup(psz_url);
+ p_sys->p_slp->psz_name = strdup(
+ p_slp_cfg->psz_value ? p_slp_cfg->psz_value : psz_url);
+ }
+ }
+ #endif
+
/* XXX beurk */
p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
if( p_sys->p_sap )
sout_SAPDelete( (sout_instance_t *)p_this , p_sys->p_sap );
+ #ifdef HAVE_SLP_H
+ if( p_sys->p_slp )
+ {
+ sout_SLPDereg( (sout_instance_t *)p_this,
+ p_sys->p_slp->psz_url,
+ p_sys->p_slp->psz_name);
+ free( p_sys->p_slp);
+ }
+ #endif
+
+
sout_MuxDelete( p_sys->p_mux );
sout_AccessOutDelete( p_access );
# include <sys/socket.h>
#endif
+#ifdef HAVE_SLP_H
+# include <slp.h>
+#endif
+
#include "announce.h"
#include "network.h"
free( psz_head );
}
+
+
+/*****************************************************************************
+ * sout_SLPBuildName: Builds a service name according to SLP standard
+ *****************************************************************************/
+char * sout_SLPBuildName(char *psz_url,char *psz_name)
+{
+ char *psz_service;
+ unsigned int i_size;
+
+ /* name to build is: service:$(name).videolan://$(url) */
+
+ i_size = 8 + strlen(psz_name) + 12 + strlen(psz_url) + 1;
+
+ psz_service=(char *)malloc(i_size * sizeof(char));
+
+ snprintf( psz_service , i_size,
+ "service:%s.videolan://%s",
+ psz_name,psz_url);
+ psz_service[i_size]='\0'; /* Just to make sure */
+
+ return psz_service;
+
+}
+
+/*****************************************************************************
+ * sout_SLPReport: Reporting function. Unused at the moment but needed
+ *****************************************************************************/
+#ifdef HAVE_SLP_H
+void sout_SLPReport(SLPHandle slp_handle,SLPError slp_error,void* cookie)
+{
+}
+#endif
+
+/*****************************************************************************
+ * sout_SLPReg: Registers the program with SLP
+ *****************************************************************************/
+int sout_SLPReg( sout_instance_t *p_sout, char * psz_url,
+ char * psz_name)
+{
+#ifdef HAVE_SLP_H
+ SLPHandle slp_handle;
+ SLPError slp_res;
+ char *psz_service= sout_SLPBuildName(psz_url,psz_name);
+
+ if( SLPOpen( NULL, SLP_FALSE, &slp_handle ) != SLP_OK)
+ {
+ msg_Warn(p_sout,"Unable to initialize SLP");
+ return -1;
+ }
+
+ msg_Info(p_sout , "Registering %s (name: %s) in SLP",
+ psz_service , psz_name);
+
+ slp_res = SLPReg ( slp_handle,
+ psz_service,
+ SLP_LIFETIME_MAXIMUM,
+ NULL,
+ psz_name,
+ SLP_TRUE,
+ sout_SLPReport,
+ NULL );
+
+ if( slp_res != SLP_OK )
+ {
+ msg_Warn(p_sout,"Error while registering service: %i", slp_res );
+ return -1;
+ }
+
+ return 0;
+
+#else /* This function should never be called if this is false */
+ return -1
+#endif
+}
+
+
+/*****************************************************************************
+ * sout_SLDePReg: Unregisters the program from SLP
+ *****************************************************************************/
+int sout_SLPDereg( sout_instance_t *p_sout, char * psz_url,
+ char * psz_name)
+{
+#ifdef HAVE_SLP_H
+
+ SLPHandle slp_handle;
+ SLPError slp_res;
+ char *psz_service= sout_SLPBuildName(psz_url,psz_name);
+
+ if( SLPOpen( NULL, SLP_FALSE, &slp_handle ) != SLP_OK)
+ {
+ msg_Warn(p_sout,"Unable to initialize SLP");
+ return -1;
+ }
+
+ msg_Info(p_sout , "Unregistering %s from SLP",
+ psz_service);
+
+ slp_res = SLPDereg ( slp_handle,
+ psz_service,
+ sout_SLPReport,
+ NULL );
+
+ if( slp_res != SLP_OK )
+ {
+ msg_Warn(p_sout,"Error while registering service: %i", slp_res );
+ return -1;
+ }
+
+ return 0;
+
+#else /* This function should never be called if this is false */
+ return -1
+#endif
+}