]> git.sesse.net Git - vlc/blobdiff - src/stream_output/announce.c
Add ACCESS_OUT_CAN_CONTROL_PACE, fix AccessOutControl prototype
[vlc] / src / stream_output / announce.c
index b1d6d97d50b8dfbb0210d01656b39e1b49b8f1c1..7dedc1e0508c412716c6c08213d29f5bd8243f11 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include <vlc_sout.h>
 #include "stream_output.h"
 
@@ -46,30 +50,18 @@ struct announce_method_t
  * Sout-side functions
  ****************************************************************************/
 
-/**
- * Create and initialize a session descriptor
- *
- * \return a new session descriptor
- */
-static session_descriptor_t * sout_AnnounceSessionCreate (vlc_object_t *obj,
-                                                   const char *cfgpref)
-{
-    return calloc (1, sizeof (session_descriptor_t));
-}
-
 /**
  *  Register a new session with the announce handler, using a pregenerated SDP
  *
  * \param p_sout a sout instance structure
  * \param psz_sdp the SDP to register
- * \param psz_uri session address (needed for SAP address auto detection)
+ * \param psz_dst session address (needed for SAP address auto detection)
  * \param p_method an announce method descriptor
  * \return the new session descriptor structure
  */
 session_descriptor_t *
-sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref,
-                          const char *psz_sdp, const char *psz_uri,
-                          announce_method_t *p_method )
+sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *psz_sdp,
+                            const char *psz_dst, announce_method_t *p_method )
 {
     session_descriptor_t *p_session;
     announce_handler_t *p_announce = (announce_handler_t*)
@@ -88,12 +80,13 @@ sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref,
         vlc_object_yield( p_announce );
     }
 
-    p_session = sout_AnnounceSessionCreate(VLC_OBJECT (p_sout), cfgpref);
+    p_session = malloc( sizeof( *p_session ) );
+    memset( p_session, 0, sizeof( *p_session ) );
     p_session->psz_sdp = strdup( psz_sdp );
 
     /* GRUIK. We should not convert back-and-forth from string to numbers */
     struct addrinfo *res;
-    if (vlc_getaddrinfo (VLC_OBJECT (p_sout), psz_uri, 0, NULL, &res) == 0)
+    if (vlc_getaddrinfo (VLC_OBJECT (p_sout), psz_dst, 0, NULL, &res) == 0)
     {
         if (res->ai_addrlen <= sizeof (p_session->addr))
             memcpy (&p_session->addr, res->ai_addr,
@@ -128,23 +121,14 @@ int sout_AnnounceUnRegister( sout_instance_t *p_sout,
         return VLC_ENOOBJ;
     }
     i_ret  = announce_UnRegister( p_announce, p_session );
+    if( i_ret == 0 )
+        free( p_session );
 
     vlc_object_release( p_announce );
 
     return i_ret;
 }
 
-/**
- * Destroy a session descriptor and free all
- *
- * \param p_session the session to destroy
- * \return Nothing
- */
-void sout_AnnounceSessionDestroy( session_descriptor_t *p_session )
-{
-    free( p_session );
-}
-
 /**
  * \return the SAP announce method
  */
@@ -175,10 +159,7 @@ static announce_handler_t *announce_HandlerCreate( vlc_object_t *p_this )
     p_announce = vlc_object_create( p_this, VLC_OBJECT_ANNOUNCE );
 
     if( !p_announce )
-    {
-        msg_Err( p_this, "out of memory" );
         return NULL;
-    }
 
     p_announce->p_sap = NULL;
     vlc_object_attach( p_announce, p_this->p_libvlc);
@@ -196,14 +177,12 @@ int announce_HandlerDestroy( announce_handler_t *p_announce )
 {
     if( p_announce->p_sap )
     {
-        vlc_object_kill ((vlc_object_t *)p_announce->p_sap);
-        /* Wait for the SAP thread to exit */
-        vlc_thread_join( (vlc_object_t *)p_announce->p_sap );
-        announce_SAPHandlerDestroy( p_announce->p_sap );
+        /* Exit the SAP */
+        vlc_object_release( p_announce->p_sap );
     }
 
     /* Free the structure */
-    vlc_object_destroy( p_announce );
+    vlc_object_release( p_announce );
 
     return VLC_SUCCESS;
 }