]> git.sesse.net Git - vlc/blobdiff - modules/access/slp.c
* modules/access/v4l/v4l.c: fixed small mem leak.
[vlc] / modules / access / slp.c
index 39cadd3e365ca8176f878a8d9bf2660039eda63c..1ed54052677ebe738c9f0c1bc9760e72fee27b71 100644 (file)
@@ -2,7 +2,7 @@
  * slp.c: SLP access plugin
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: slp.c,v 1.12 2003/06/17 16:09:16 gbazin Exp $
+ * $Id: slp.c,v 1.17 2003/10/29 17:32:54 zorglub Exp $
  *
  * Authors: Loïc Minier <lool@videolan.org>
  *
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -44,6 +44,8 @@ static int  Init  ( vlc_object_t * );
 static void End   ( vlc_object_t * );
 static int  Demux ( input_thread_t * );
 
+int i_group;
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -112,10 +114,12 @@ static SLPBoolean AttrCallback( SLPHandle slph_slp,
     /* or there was a problem with getting the data we requested */
     if( (slpe_errcode != SLP_OK) )
     {
-/*        msg_Err( (vlc_object_t*)NULL,
+#if 0
+        msg_Err( (vlc_object_t*)NULL,
                  "AttrCallback got an error %i with attribute %s",
                  slpe_errcode,
-                 psz_attrlist ); */
+                 psz_attrlist );
+#endif
         return SLP_TRUE;
     }
 
@@ -134,7 +138,7 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp,
 {
     input_thread_t * p_input = (input_thread_t  *)p_cookie;
     playlist_t * p_playlist;
-    char psz_item[42] = "udp:@";
+    char psz_item[42] = ""; //"udp:@";
     char * psz_s;                           /* to hold the uri of the stream */
     SLPHandle slph_slp3;
     SLPError slpe_result;
@@ -146,6 +150,8 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp,
         return SLP_TRUE;
     }
 
+    msg_Dbg(p_input,"URL: %s",psz_srvurl);
+
     /* or there was a problem with getting the data we requested */
     if( (slpe_errcode != SLP_OK) )
     {
@@ -184,6 +190,11 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp,
     p_playlist_item->i_type = 0;
     p_playlist_item->i_status = 0;
     p_playlist_item->b_autodeletion = VLC_FALSE;
+    p_playlist_item->i_options = 0;
+    p_playlist_item->ppsz_options = 0;
+    p_playlist_item->psz_author = NULL;
+    p_playlist_item->i_group = i_group;
+    p_playlist_item->b_enabled = VLC_TRUE;
 
     /* search the description of the stream */
     if( SLPOpen( config_GetPsz( p_input, "slp-lang" ),
@@ -245,13 +256,18 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp,
     input_thread_t * p_input = (input_thread_t  *)p_cookie;
     SLPError slpe_result;
     SLPHandle slph_slp2;
+    char *psz_eos;
+    char *psz_service;
 
+    msg_Dbg(p_input,"Services: %s",psz_srvurl);
     /* our callback was only called to tell us there's nothing more to read */
     if( slpe_errcode == SLP_LAST_CALL )
     {
         return SLP_TRUE;
     }
 
+    msg_Dbg(p_input,"Services: %s",psz_srvurl);
+
     /* or there was a problem with getting the data we requested */
     if( slpe_errcode != SLP_OK )
     {
@@ -268,23 +284,51 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp,
                  &slph_slp2 ) == SLP_OK )
     {
         /* search for services */
-        slpe_result = SLPFindSrvs( slph_slp2,
-                                   psz_srvurl,
+        while(1)
+        {
+            if( *psz_srvurl == '\0')  break;
+
+            if( !strncasecmp( psz_srvurl, "service:", 8 ) )
+            {
+                while(1)
+                {
+                    psz_eos = strchr( psz_srvurl, ',');
+                    if(!psz_eos) break;
+                    if(!strncasecmp(psz_eos+1,"service:",8)) break;
+                }
+
+                if(psz_eos)
+                    *psz_eos = '\0';
+
+                psz_service = strdup( psz_srvurl);
+
+                msg_Dbg(p_input,"Getting details for %s",psz_service);
+
+                slpe_result = SLPFindSrvs( slph_slp2,
+                                   psz_service,
                                    config_GetPsz( p_input, "slp-scopelist" ),
                                    config_GetPsz( p_input, "slp-filter" ),
                                    SrvUrlCallback,
                                    p_input );
 
-        SLPClose( slph_slp2 );
-
-        if( slpe_result != SLP_OK )
-        {
-            msg_Err( p_input,
-                     "SLPFindSrvs error %i finding servers of type %s",
-                     slpe_result,
-                     psz_srvurl );
+                if(psz_eos)
+                    psz_srvurl = psz_eos;
+
+#if 0
+                SLPClose( slph_slp2 );
+#endif
+                if( slpe_result != SLP_OK )
+                {
+                   msg_Err( p_input,
+                           "SLPFindSrvs error %i finding servers of type %s",
+                           slpe_result,
+                           psz_service );
+                }
+            }
+            psz_srvurl++;
         }
     }
+                SLPClose( slph_slp2 );
 
     return SLP_TRUE;
 }
@@ -294,10 +338,11 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp,
  *****************************************************************************/
 static int Open( vlc_object_t * p_this )
 {
-    input_thread_t * p_input = (input_thread_t *)p_this;
-    SLPError         slpe_result;
-    SLPHandle        slph_slp;
-    playlist_t *     p_playlist;
+    input_thread_t *   p_input = (input_thread_t *)p_this;
+    SLPError           slpe_result;
+    SLPHandle          slph_slp;
+    playlist_t *       p_playlist;
+    playlist_group_t * p_group;
 
     /* remove the "slp:" entry of the playlist */
     p_playlist = (playlist_t *) vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
@@ -308,6 +353,8 @@ static int Open( vlc_object_t * p_this )
         return VLC_FALSE;
     }
 
+    p_group = playlist_CreateGroup( p_playlist , "SLP" );
+    i_group = p_group->i_id;
     p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
     vlc_object_release( (vlc_object_t *)p_playlist );
 
@@ -379,6 +426,7 @@ static int Init ( vlc_object_t *p_this )
     }
 
     p_input->pf_demux  = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
     p_input->pf_rewind = NULL;
 
     return VLC_SUCCESS;