char *psz_group;
- sap_session_t *p_sap; /* If we have a sap session, remember it */
char *psz_sdp;
vlc_bool_t b_rtp;
};
-#define METHOD_TYPE_SAP 1
-
-struct announce_method_t
-{
- int i_type;
-};
-
VLC_EXPORT( int, sout_AnnounceRegister, (sout_instance_t *,session_descriptor_t*, announce_method_t* ) );
VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *,const char *, const char *, announce_method_t* ) );
VLC_EXPORT( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) );
VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (void) );
VLC_EXPORT(void, sout_AnnounceSessionDestroy, (session_descriptor_t *) );
-VLC_EXPORT(announce_method_t*, sout_AnnounceMethodCreate, (int) );
+VLC_EXPORT(announce_method_t*, sout_SAPMethod, (void) );
#ifdef __cplusplus
}
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout;
- announce_method_t *p_method = sout_AnnounceMethodCreate( METHOD_TYPE_SAP );
+ announce_method_t *p_method = sout_SAPMethod();
/* Remove the previous session */
if( p_sys->p_session != NULL)
( strstr( psz_access, "udp" ) || strstr( psz_access , "rtp" ) ) )
{
session_descriptor_t *p_session = sout_AnnounceSessionCreate();
- announce_method_t *p_method =
- sout_AnnounceMethodCreate( METHOD_TYPE_SAP );
+ announce_method_t *p_method = sout_SAPMethod();
vlc_url_t url;
var_Get( p_stream, SOUT_CFG_PREFIX "name", &val );
/*****************************************************************************
* announce.c : announce handler
*****************************************************************************
- * Copyright (C) 2002-2004 the VideoLAN team
+ * Copyright (C) 2002-2007 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
#include <vlc_sout.h>
#include "stream_output.h"
+struct announce_method_t
+{
+} sap_method;
+
/****************************************************************************
* Sout-side functions
****************************************************************************/
vlc_object_yield( p_announce );
}
- if( p_method->i_type != METHOD_TYPE_SAP )
- {
- msg_Warn( p_sout, "forcing SAP announcement");
- }
-
p_session = sout_AnnounceSessionCreate();
p_session->psz_sdp = strdup( psz_sdp );
p_session->psz_uri = strdup( psz_uri );
}
/**
- * Create and initialize an announcement method structure
- *
- * \param i_type METHOD_TYPE_SAP
- * \return a new announce_method structure
+ * \return the SAP announce method
*/
-announce_method_t * sout_AnnounceMethodCreate( int i_type )
+announce_method_t * sout_SAPMethod (void)
{
- announce_method_t *p_method;
-
- p_method = (announce_method_t *)malloc( sizeof(announce_method_t) );
- if( p_method == NULL )
- return NULL;
-
- p_method->i_type = i_type;
- return p_method;
+ return &sap_method;
}
/************************************************************************
*/
int announce_HandlerDestroy( announce_handler_t *p_announce )
{
-
if( p_announce->p_sap )
{
- p_announce->p_sap->b_die = VLC_TRUE;
+ ((vlc_object_t *)p_announce->p_sap)->b_die = VLC_TRUE;
/* Wait for the SAP thread to exit */
- vlc_thread_join( p_announce->p_sap );
+ vlc_thread_join( (vlc_object_t *)p_announce->p_sap );
announce_SAPHandlerDestroy( p_announce->p_sap );
}
{
msg_Dbg( p_announce, "registering announce");
- if( p_method->i_type == METHOD_TYPE_SAP )
+ if( p_method == &sap_method )
{
/* Do we already have a SAP announce handler ? */
if( !p_announce->p_sap )
}
else
{
- msg_Dbg( p_announce, "announce type unsupported" );
+ msg_Err( p_announce, "announce type unsupported" );
return VLC_EGENERIC;
}
return VLC_SUCCESS;;
session_descriptor_t *p_session )
{
msg_Dbg( p_announce, "unregistering announce" );
- if( p_session->p_sap != NULL ) /* SAP Announce */
- {
- if( !p_announce->p_sap )
- {
- msg_Err( p_announce, "can't remove announce, no SAP handler");
- return VLC_ENOOBJ;
- }
+ if( p_announce->p_sap )
p_announce->p_sap->pf_del( p_announce->p_sap, p_session );
- }
return VLC_SUCCESS;
}
int i_limit;
};
+/* A SAP session descriptor, enqueued in the SAP handler queue */
+struct sap_session_t {
+ char *psz_sdp;
+ uint8_t *psz_data;
+ unsigned i_length;
+ sap_address_t *p_address;
+ session_descriptor_t *p_sd;
+
+ /* Last and next send */
+ mtime_t i_last;
+ mtime_t i_next;
+};
+
/*****************************************************************************
* Local prototypes
*****************************************************************************/
msg_Err( p_sap, "This should not happen. VLC needs fixing." );
return VLC_EGENERIC;
}
-
/* Determine SAP multicast address automatically */
memset( &hints, 0, sizeof( hints ) );
hints.ai_socktype = SOCK_DGRAM;
/* SSM <=> ff3x::/32 */
b_ssm = (U32_AT (a6->s6_addr) & 0xfff0ffff) == 0xff300000;
- /* force flags to zero, preserve scope */
+ /* force flags to zero, preserve scope */
a6->s6_addr[1] &= 0xf;
}
else
/* XXX: Check for dupes */
p_sap_session = (sap_session_t*)malloc(sizeof(sap_session_t));
+ p_sap_session->p_sd = p_session;
p_sap_session->p_address = NULL;
/* Add the address to the buffer */
msg_Dbg( p_sap,"%i addresses, %i sessions",
p_sap->i_addresses,p_sap->i_sessions);
- /* Remember the SAP session for later deletion */
- p_session->p_sap = p_sap_session;
-
vlc_mutex_unlock( &p_sap->object_lock );
return VLC_SUCCESS;
int i;
vlc_mutex_lock( &p_sap->object_lock );
- msg_Dbg( p_sap,"removing SAP announce %p",p_session->p_sap);
+ msg_Dbg( p_sap, "removing session %p from SAP", p_session);
/* Dequeue the announce */
for( i = 0; i< p_sap->i_sessions; i++)
{
- if( p_session->p_sap == p_sap->pp_sessions[i] )
+ if( p_session == p_sap->pp_sessions[i]->p_sd )
{
+ sap_session_t *p_mysession = p_sap->pp_sessions[i];
REMOVE_ELEM( p_sap->pp_sessions,
p_sap->i_sessions,
i );
- FREENULL( p_session->p_sap->psz_sdp );
- FREENULL( p_session->p_sap->psz_data );
- free( p_session->p_sap );
+ free( p_mysession->psz_sdp );
+ free( p_mysession->psz_data );
+ free( p_mysession );
break;
}
}
/* Announce system */
-/* A SAP session descriptor, enqueued in the SAP handler queue */
-struct sap_session_t {
- char *psz_sdp;
- uint8_t *psz_data;
- unsigned i_length;
- sap_address_t *p_address;
-
- /* Last and next send */
- mtime_t i_last;
- mtime_t i_next;
-};
-
/* The SAP handler, running in a separate thread */
struct sap_handler_t
{