Commit 0336f134 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Partial announce API cleanup

To be continued
parent c1ebd402
...@@ -220,25 +220,17 @@ struct session_descriptor_t ...@@ -220,25 +220,17 @@ struct session_descriptor_t
char *psz_group; char *psz_group;
sap_session_t *p_sap; /* If we have a sap session, remember it */
char *psz_sdp; char *psz_sdp;
vlc_bool_t b_rtp; 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( 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(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( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) );
VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (void) ); VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (void) );
VLC_EXPORT(void, sout_AnnounceSessionDestroy, (session_descriptor_t *) ); 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 #ifdef __cplusplus
} }
......
...@@ -1533,7 +1533,7 @@ static int SapSetup( sout_stream_t *p_stream ) ...@@ -1533,7 +1533,7 @@ static int SapSetup( sout_stream_t *p_stream )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout; 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 */ /* Remove the previous session */
if( p_sys->p_session != NULL) if( p_sys->p_session != NULL)
......
...@@ -316,8 +316,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -316,8 +316,7 @@ static int Open( vlc_object_t *p_this )
( strstr( psz_access, "udp" ) || strstr( psz_access , "rtp" ) ) ) ( strstr( psz_access, "udp" ) || strstr( psz_access , "rtp" ) ) )
{ {
session_descriptor_t *p_session = sout_AnnounceSessionCreate(); session_descriptor_t *p_session = sout_AnnounceSessionCreate();
announce_method_t *p_method = announce_method_t *p_method = sout_SAPMethod();
sout_AnnounceMethodCreate( METHOD_TYPE_SAP );
vlc_url_t url; vlc_url_t url;
var_Get( p_stream, SOUT_CFG_PREFIX "name", &val ); var_Get( p_stream, SOUT_CFG_PREFIX "name", &val );
......
/***************************************************************************** /*****************************************************************************
* announce.c : announce handler * announce.c : announce handler
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2004 the VideoLAN team * Copyright (C) 2002-2007 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
#include <vlc_sout.h> #include <vlc_sout.h>
#include "stream_output.h" #include "stream_output.h"
struct announce_method_t
{
} sap_method;
/**************************************************************************** /****************************************************************************
* Sout-side functions * Sout-side functions
****************************************************************************/ ****************************************************************************/
...@@ -103,11 +107,6 @@ session_descriptor_t *sout_AnnounceRegisterSDP( sout_instance_t *p_sout, ...@@ -103,11 +107,6 @@ session_descriptor_t *sout_AnnounceRegisterSDP( sout_instance_t *p_sout,
vlc_object_yield( p_announce ); 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 = sout_AnnounceSessionCreate();
p_session->psz_sdp = strdup( psz_sdp ); p_session->psz_sdp = strdup( psz_sdp );
p_session->psz_uri = strdup( psz_uri ); p_session->psz_uri = strdup( psz_uri );
...@@ -180,21 +179,11 @@ void sout_AnnounceSessionDestroy( session_descriptor_t *p_session ) ...@@ -180,21 +179,11 @@ void sout_AnnounceSessionDestroy( session_descriptor_t *p_session )
} }
/** /**
* Create and initialize an announcement method structure * \return the SAP announce method
*
* \param i_type METHOD_TYPE_SAP
* \return a new announce_method structure
*/ */
announce_method_t * sout_AnnounceMethodCreate( int i_type ) announce_method_t * sout_SAPMethod (void)
{ {
announce_method_t *p_method; return &sap_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;
} }
/************************************************************************ /************************************************************************
...@@ -233,12 +222,11 @@ announce_handler_t *__announce_HandlerCreate( vlc_object_t *p_this ) ...@@ -233,12 +222,11 @@ announce_handler_t *__announce_HandlerCreate( vlc_object_t *p_this )
*/ */
int announce_HandlerDestroy( announce_handler_t *p_announce ) int announce_HandlerDestroy( announce_handler_t *p_announce )
{ {
if( p_announce->p_sap ) 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 */ /* 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 ); announce_SAPHandlerDestroy( p_announce->p_sap );
} }
...@@ -255,7 +243,7 @@ int announce_Register( announce_handler_t *p_announce, ...@@ -255,7 +243,7 @@ int announce_Register( announce_handler_t *p_announce,
{ {
msg_Dbg( p_announce, "registering announce"); 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 ? */ /* Do we already have a SAP announce handler ? */
if( !p_announce->p_sap ) if( !p_announce->p_sap )
...@@ -275,7 +263,7 @@ int announce_Register( announce_handler_t *p_announce, ...@@ -275,7 +263,7 @@ int announce_Register( announce_handler_t *p_announce,
} }
else else
{ {
msg_Dbg( p_announce, "announce type unsupported" ); msg_Err( p_announce, "announce type unsupported" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
return VLC_SUCCESS;; return VLC_SUCCESS;;
...@@ -287,14 +275,7 @@ int announce_UnRegister( announce_handler_t *p_announce, ...@@ -287,14 +275,7 @@ int announce_UnRegister( announce_handler_t *p_announce,
session_descriptor_t *p_session ) session_descriptor_t *p_session )
{ {
msg_Dbg( p_announce, "unregistering announce" ); msg_Dbg( p_announce, "unregistering announce" );
if( p_session->p_sap != NULL ) /* SAP Announce */ if( p_announce->p_sap )
{
if( !p_announce->p_sap )
{
msg_Err( p_announce, "can't remove announce, no SAP handler");
return VLC_ENOOBJ;
}
p_announce->p_sap->pf_del( p_announce->p_sap, p_session ); p_announce->p_sap->pf_del( p_announce->p_sap, p_session );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -72,6 +72,19 @@ struct sap_address_t ...@@ -72,6 +72,19 @@ struct sap_address_t
int i_limit; 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 * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -252,7 +265,6 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -252,7 +265,6 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
msg_Err( p_sap, "This should not happen. VLC needs fixing." ); msg_Err( p_sap, "This should not happen. VLC needs fixing." );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Determine SAP multicast address automatically */ /* Determine SAP multicast address automatically */
memset( &hints, 0, sizeof( hints ) ); memset( &hints, 0, sizeof( hints ) );
hints.ai_socktype = SOCK_DGRAM; hints.ai_socktype = SOCK_DGRAM;
...@@ -296,7 +308,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -296,7 +308,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
/* SSM <=> ff3x::/32 */ /* SSM <=> ff3x::/32 */
b_ssm = (U32_AT (a6->s6_addr) & 0xfff0ffff) == 0xff300000; 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; a6->s6_addr[1] &= 0xf;
} }
else else
...@@ -369,6 +381,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -369,6 +381,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
/* XXX: Check for dupes */ /* XXX: Check for dupes */
p_sap_session = (sap_session_t*)malloc(sizeof(sap_session_t)); p_sap_session = (sap_session_t*)malloc(sizeof(sap_session_t));
p_sap_session->p_sd = p_session;
p_sap_session->p_address = NULL; p_sap_session->p_address = NULL;
/* Add the address to the buffer */ /* Add the address to the buffer */
...@@ -510,9 +523,6 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -510,9 +523,6 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
msg_Dbg( p_sap,"%i addresses, %i sessions", msg_Dbg( p_sap,"%i addresses, %i sessions",
p_sap->i_addresses,p_sap->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 ); vlc_mutex_unlock( &p_sap->object_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -525,20 +535,21 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap, ...@@ -525,20 +535,21 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
int i; int i;
vlc_mutex_lock( &p_sap->object_lock ); 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 */ /* Dequeue the announce */
for( i = 0; i< p_sap->i_sessions; i++) 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, REMOVE_ELEM( p_sap->pp_sessions,
p_sap->i_sessions, p_sap->i_sessions,
i ); i );
FREENULL( p_session->p_sap->psz_sdp ); free( p_mysession->psz_sdp );
FREENULL( p_session->p_sap->psz_data ); free( p_mysession->psz_data );
free( p_session->p_sap ); free( p_mysession );
break; break;
} }
} }
......
...@@ -47,18 +47,6 @@ VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t ...@@ -47,18 +47,6 @@ VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t
/* Announce system */ /* 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 */ /* The SAP handler, running in a separate thread */
struct sap_handler_t struct sap_handler_t
{ {
......
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