]> git.sesse.net Git - vlc/blobdiff - modules/demux/sgimb.c
* skins2: Do not paint on the embedded video output, when a video is
[vlc] / modules / demux / sgimb.c
index e02a2523ebacf4dbeb7e399eeba308b4413f40f9..ce59ceab1ce5535698a9403628887f7437694202 100644 (file)
@@ -2,7 +2,7 @@
  * sgimb.c: a meta demux to parse sgimb referrer files
  *****************************************************************************
  * Copyright (C) 2004 VideoLAN
- * $Id$
+ * $Id$
  *
  * Authors: Derk-Jan Hartman <hartman at videolan dot org>
  *
  * their MPEG streams (MIME: application/x-sgimb). Very few applications
  * understand this format and the format is not really documented on the net.
  * Following a typical MediaBase file. Notice the sgi prefix of all the elements.
- * This stems from the fact that the MediaBase server were first introduced by SGI?????.
+ * This stems from the fact that the MediaBase servers were first introduced by SGI?????.
  *
  * sgiNameServerHost=host.name.tld
+ *     Obvious: the host hosting this stream
  * Stream="xdma://host.name.tld/demo/a_very_cool.mpg"
+ *     Not always present. xdma can be read as RTSP.
  * sgiMovieName=/demo/a_very_cool.mpg
- * sgiAuxState=1
+ *     The path to the asset
+ * sgiAuxState=1|2
+ *     AuxState=2 is always Video On Demand (so not Scheduled)
+ *     Not present with Live streams
+ * sgiLiveFeed=True|False
+ *     Denounces if the stream is live or from assets (Canned?)
+ *     Live appears as a little sattelite dish in the web interface of Kasenna
  * sgiFormatName=PARTNER_41_MPEG-4
+ *     The type of stream. One of:
+ *       PARTNER_41_MPEG-4 (RTSP MPEG-4 fully compliant)
+ *       MPEG1-Audio       (MP3 Audio streams in MPEG TS)
+ *       MPEG-1            (MPEG 1 A/V in MPEG TS)
+ *       MPEG-2            (MPEG 2 A/V in MPEG TS)
+ * sgiWidth=720
+ *     The width of the to be received stream. Only present if stream is not Live.
+ * sgiHeight=576
+ *     The height of the to be received stream. Only present if stream is not Live.
  * sgiBitrate=1630208
+ *     The bitrate of the to be received stream. Only present if stream is not Live.
  * sgiDuration=378345000
+ *     The duration of the to be received stream. Only present if stream is not Live.
  * sgiQTFileBegin
  * rtsptext
  * rtsp://host.name.tld/demo/a_very_cool.mpg
  * sgiQTFileEnd
+ *     Sometimes present. QT will recognize this as a RTSP reference file, if present.
  * sgiApplicationName=MediaBaseURL
+ *     Beats me !! :)
  * sgiElapsedTime=0
+ *     Time passed since the asset was started (resets for repeating non live assets?)
+ * sgiMulticastAddress=233.81.233.15
+ *     The multicast IP used for the Multicast feed.
+ *     Also defines if a stream is multicast or not. (blue dot in kasenna web interface)
+ * sgiMulticastPort=1234
+ *     The multicast port for the same Multicast feed.
+ * sgiPacketSize=16384
+ *     The packetsize of the UDP frames that Kasenna sends. They should have used a default
+ *     that is a multiple of 188 (TS frame size). Most networks don't support more than 1500 anyways.
+ *     Also, when you loose a frame of this size, imagecorruption is more likely then with smaller
+ *     frames.
  * sgiServerVersion=6.1.2
+ *     Version of the server
  * sgiRtspPort=554
+ *     TCP port used for RTSP communication
  * AutoStart=True
+ *     Start playing automatically
+ * DeliveryService=cds
+ *     Simulcasted (scheduled unicast) content. (Green dot in Kasenna web interface) 
+ * sgiShowingName=A nice name that everyone likes
+ *     A human readible descriptive title for this stream.
+ * sgiSid=2311
+ *     Looks like this is the ID of the scheduled asset?
  * sgiUserAccount=pid=1724&time=1078527309&displayText=You%20are%20logged%20as%20guest&
+ *     User Authentication. Above is a default guest entry. Not required for RTSP communication.
  * sgiUserPassword=
+ *     Password :)
  *
  *****************************************************************************/
 
@@ -68,6 +111,8 @@ static void Deactivate( vlc_object_t * );
 
 vlc_module_begin();
     set_description( _("Kasenna MediaBase metademux") );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_DEMUX );
     set_capability( "demux2", 170 );
     set_callbacks( Activate, Deactivate );
     add_shortcut( "sgimb" );
@@ -86,9 +131,14 @@ struct demux_sys_t
     char        *psz_name;      /* sgiShowingName= */
     char        *psz_user;      /* sgiUserAccount= */
     char        *psz_password;  /* sgiUserPassword= */
+    char        *psz_mcast_ip;  /* sgiMulticastAddress= */
+    int         i_mcast_port;   /* sgiMulticastPort= */
+    int         i_packet_size;  /* sgiPacketSize= */
     mtime_t     i_duration;     /* sgiDuration= */
     int         i_port;         /* sgiRtspPort= */
     int         i_sid;          /* sgiSid= */
+    vlc_bool_t  b_concert;      /* DeliveryService=cds */
+    vlc_bool_t  b_rtsp_kasenna; /* kasenna style RTSP */
 };
 
 static int Demux ( demux_t *p_demux );
@@ -101,33 +151,42 @@ static int Activate( vlc_object_t * p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys;
-
-    p_demux->pf_demux = Demux;
-    p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
-    p_sys->psz_uri = NULL;
-    p_sys->psz_server = NULL;
-    p_sys->psz_location = NULL;
-    p_sys->psz_name = NULL;
-    p_sys->psz_user = NULL;
-    p_sys->psz_password = NULL;
-    p_sys->i_duration = (mtime_t)0;
-    p_sys->i_port = 0;
-
+    byte_t *p_peek;
+    int i_size;
 
     /* Lets check the content to see if this is a sgi mediabase file */
-    byte_t *p_peek;
-    int i_size = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
+    i_size = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
     i_size -= sizeof("sgiNameServerHost=") - 1;
-    if ( i_size > 0 ) {
-        while ( i_size
-            && strncasecmp( p_peek, "sgiNameServerHost=", sizeof("sgiNameServerHost=") - 1 ) )
+    if ( i_size > 0 )
+    {
+        while ( i_size && strncasecmp( p_peek, "sgiNameServerHost=",
+                                       sizeof("sgiNameServerHost=") - 1 ) )
         {
             p_peek++;
             i_size--;
         }
-        if ( !strncasecmp( p_peek, "sgiNameServerHost=", sizeof("sgiNameServerHost=") -1 ) )
+        if ( !strncasecmp( p_peek, "sgiNameServerHost=",
+                           sizeof("sgiNameServerHost=") -1 ) )
         {
+            p_demux->pf_demux = Demux;
+            p_demux->pf_control = Control;
+
+            p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+            p_sys->psz_uri = NULL;
+            p_sys->psz_server = NULL;
+            p_sys->psz_location = NULL;
+            p_sys->psz_name = NULL;
+            p_sys->psz_user = NULL;
+            p_sys->psz_password = NULL;
+            p_sys->psz_mcast_ip = NULL;
+            p_sys->i_mcast_port = 0;
+            p_sys->i_packet_size = 0;
+            p_sys->i_duration = 0;
+            p_sys->i_port = 0;
+            p_sys->i_sid = 0;
+            p_sys->b_rtsp_kasenna = VLC_FALSE;
+            p_sys->b_concert = VLC_FALSE;
+
             return VLC_SUCCESS;
         }
     }
@@ -153,6 +212,8 @@ static void Deactivate( vlc_object_t *p_this )
         free( p_sys->psz_user );
     if( p_sys->psz_password )
         free( p_sys->psz_password );
+    if( p_sys->psz_mcast_ip )
+        free( p_sys->psz_mcast_ip );
     free( p_demux->p_sys );
     return;
 }
@@ -217,6 +278,27 @@ static int ParseLine ( demux_t *p_demux, char *psz_line )
         psz_bol += sizeof("sgiShowingName=") - 1;
         p_sys->psz_name = strdup( psz_bol );
     }
+    else if( !strncasecmp( psz_bol, "sgiFormatName=", sizeof("sgiFormatName=") - 1 ) )
+    {
+        psz_bol += sizeof("sgiFormatName=") - 1;
+        if( strcasestr( psz_bol, "MPEG-4") == NULL ) /*not mpeg4 found in string */
+            p_sys->b_rtsp_kasenna = VLC_TRUE;
+    }
+    else if( !strncasecmp( psz_bol, "sgiMulticastAddress=", sizeof("sgiMulticastAddress=") - 1 ) )
+    {
+        psz_bol += sizeof("sgiMulticastAddress=") - 1;
+        p_sys->psz_mcast_ip = strdup( psz_bol );
+    }
+    else if( !strncasecmp( psz_bol, "sgiMulticastPort=", sizeof("sgiMulticastPort=") - 1 ) )
+    {
+        psz_bol += sizeof("sgiMulticastPort=") - 1;
+        p_sys->i_mcast_port = (int) strtol( psz_bol, NULL, 0 );
+    }
+    else if( !strncasecmp( psz_bol, "sgiPacketSize=", sizeof("sgiPacketSize=") - 1 ) )
+    {
+        psz_bol += sizeof("sgiPacketSize=") - 1;
+        p_sys->i_packet_size = (int) strtol( psz_bol, NULL, 0 );
+    }
     else if( !strncasecmp( psz_bol, "sgiDuration=", sizeof("sgiDuration=") - 1 ) )
     {
         psz_bol += sizeof("sgiDuration=") - 1;
@@ -226,7 +308,17 @@ static int ParseLine ( demux_t *p_demux, char *psz_line )
     {
         psz_bol += sizeof("sgiRtspPort=") - 1;
         p_sys->i_port = (int) strtol( psz_bol, NULL, 0 );
-    }else
+    }
+    else if( !strncasecmp( psz_bol, "sgiSid=", sizeof("sgiSid=") - 1 ) )
+    {
+        psz_bol += sizeof("sgiSid=") - 1;
+        p_sys->i_sid = (int) strtol( psz_bol, NULL, 0 );
+    }
+    else if( !strncasecmp( psz_bol, "DeliveryService=cds", sizeof("DeliveryService=cds") - 1 ) )
+    {
+        p_sys->b_concert = VLC_TRUE;
+    }
+    else
     {
         /* This line isn't really important */
         return 0;
@@ -243,6 +335,7 @@ static int Demux ( demux_t *p_demux )
 {
     demux_sys_t     *p_sys = p_demux->p_sys;
     playlist_t      *p_playlist;
+    playlist_item_t *p_item;
     
     char            *psz_line;
     int             i_position;
@@ -255,34 +348,95 @@ static int Demux ( demux_t *p_demux )
         return -1;
     }
 
-    p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
-    i_position = p_playlist->i_index + 1;
+    p_playlist->status.p_item->i_flags = PLAYLIST_DEL_FLAG;
+    i_position = -1;  /* FIXME p_playlist->i_index + 1; */
 
     while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
     {
         ParseLine( p_demux, psz_line );
         if( psz_line ) free( psz_line );
     }
-    
+
+    if( p_sys->psz_mcast_ip )
+    {
+        /* Definetly schedules multicast session */
+        /* We don't care if it's live or not */
+        char *temp;
+
+        asprintf( &temp, "udp://@" "%s:%i", p_sys->psz_mcast_ip, p_sys->i_mcast_port );
+        if( p_sys->psz_uri ) free( p_sys->psz_uri );
+        p_sys->psz_uri = strdup( temp );
+        free( temp );
+    }
+
     if( p_sys->psz_uri == NULL )
     {
         if( p_sys->psz_server && p_sys->psz_location )
         {
             char *temp;
             
-            temp = (char *)malloc( sizeof("rtsp/live://" ":" "123456789") +
-                                       strlen( p_sys->psz_server ) + strlen( p_sys->psz_location ) );
-            sprintf( temp, "rtsp/live://" "%s:%i%s",
+            asprintf( &temp, "rtsp://" "%s:%i%s",
                      p_sys->psz_server, p_sys->i_port > 0 ? p_sys->i_port : 554, p_sys->psz_location );
             
             p_sys->psz_uri = strdup( temp );
             free( temp );
         }
     }
-    
-    playlist_AddExt( p_playlist, p_sys->psz_uri,
-        p_sys->psz_name ? p_sys->psz_name : p_sys->psz_uri,
-        PLAYLIST_INSERT, i_position, p_sys->i_duration, NULL, 0 );
+
+    if( p_sys->b_concert )
+    {
+        /* It's definetly a simulcasted scheduled stream */
+        /* We don't care if it's live or not */
+        char *temp;
+
+        if( p_sys->psz_uri == NULL )
+        {
+            msg_Err( p_demux, "no URI was found" );
+            return -1;
+        }
+        
+        asprintf( &temp, "%s%%3FMeDiAbAsEshowingId=%d%%26MeDiAbAsEconcert%%3FMeDiAbAsE",
+                p_sys->psz_uri, p_sys->i_sid );
+
+        free( p_sys->psz_uri );
+        p_sys->psz_uri = strdup( temp );
+        free( temp );
+    }
+
+    p_item = playlist_ItemNew( p_playlist, p_sys->psz_uri,
+                      p_sys->psz_name ? p_sys->psz_name : p_sys->psz_uri );
+
+    if( !p_item || !p_item->input.psz_uri )
+    {
+        msg_Err( p_demux, "A valid playlistitem could not be created" );
+        return VLC_EGENERIC;
+    }
+
+    if( p_sys->i_packet_size && p_sys->psz_mcast_ip )
+    {
+        char *psz_option;
+        p_sys->i_packet_size += 1000;
+        asprintf( &psz_option, "mtu=%i", p_sys->i_packet_size );
+        playlist_ItemAddOption( p_item, psz_option );
+        free( psz_option );
+    }
+    if( !p_sys->psz_mcast_ip )
+    {
+        char *psz_option;
+       asprintf( &psz_option, "rtsp-caching=5000" );
+       playlist_ItemAddOption( p_item, psz_option );
+       free( psz_option );
+    }
+    if( !p_sys->psz_mcast_ip && p_sys->b_rtsp_kasenna )
+    {
+        char *psz_option;
+        asprintf( &psz_option, "rtsp-kasenna" );
+        playlist_ItemAddOption( p_item, psz_option );
+        free( psz_option );
+    }
+
+    playlist_ItemSetDuration( p_item, p_sys->i_duration );
+    playlist_AddItem( p_playlist, p_item, PLAYLIST_INSERT, i_position );
 
     vlc_object_release( p_playlist );
     return VLC_SUCCESS;