]> git.sesse.net Git - vlc/commitdiff
* src/misc/vlm.c: added support for the 'mux' option for VOD.
authorGildas Bazin <gbazin@videolan.org>
Wed, 20 Oct 2004 12:01:09 +0000 (12:01 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 20 Oct 2004 12:01:09 +0000 (12:01 +0000)
   This option tells the vod server to send an encapsulated stream.
* modules/misc/rtsp.c: support for mp2t (MPEG TS) and mp2p (MPEG PS) mux types.
* doc/vlm.txt: update for the mux option.

doc/vlm.txt
include/vlc_vlm.h
modules/misc/rtsp.c
src/misc/vlm.c

index 76bb0a0c3ec2c65d671c85c28597ab3f4ce5d023..72e4950c8a4e172686998b41852fae442490ab56 100644 (file)
@@ -102,6 +102,12 @@ Note: an element is a media or a schedule.
             If a media with "loop" option receives the "play" command
             and finally finishes to play the last input of the list, it
             will automatically restart to play the input list.
+        mux (mux_name)
+            Used for vod only.
+            Only needs to be specified if you want the elementary streams
+            to be sent encapsulated instead of raw. The (mux_name) should be
+            a fourcc describing the encapsulation type (eg. mp2t for MPEG TS,
+            or mp2t for MPEG PS).
 
     Schedule Properties Syntax:
         enabled|disabled
index 255e9659420894685a4c5a631c67d17f962ebe00..ed3bacac5ac23298c7e6c6e5327b46b363e89278 100644 (file)
@@ -70,6 +70,7 @@ typedef struct
     /* only for vod */
     vod_media_t *vod_media;
     char *psz_vod_output;
+    char *psz_mux;
 
     /* actual input instances */
     int                  i_instance;
index 9c079d65beb15fe341097b7a21f7ff8d4a0d2ea6..de6815de2910f85925749c37b35fa80c42ca1ab0 100644 (file)
@@ -127,6 +127,7 @@ struct vod_media_t
     /* ES list */
     int        i_es;
     media_es_t **es;
+    char       *psz_mux;
 
     /* RTSP client */
     int           i_rtsp;
@@ -265,6 +266,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, char *psz_name,
 
     memset( p_media, 0, sizeof(vod_media_t) );
     p_media->es = 0;
+    p_media->psz_mux = 0;
     p_media->rtsp = 0;
 
     asprintf( &p_media->psz_rtsp_path, "%s%s", p_sys->psz_path, psz_name );
@@ -347,6 +349,7 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
     char *psz_urlc;
 
     memset( p_es, 0, sizeof(media_es_t) );
+    p_media->psz_mux = NULL;
 
     /* TODO: update SDP, etc... */
     asprintf( &psz_urlc, "%s/trackid=%d",
@@ -424,6 +427,16 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
             free( p_hexa );
         }
         break;
+    case VLC_FOURCC( 'm', 'p', '2', 't' ):
+        p_media->psz_mux = "ts";
+        p_es->i_payload_type = 33;
+        p_es->psz_rtpmap = strdup( "MP2T/90000" );
+        break;
+    case VLC_FOURCC( 'm', 'p', '2', 'p' ):
+        p_media->psz_mux = "ps";
+        p_es->i_payload_type = p_media->i_payload_type++;
+        p_es->psz_rtpmap = strdup( "MP2P/90000" );
+        break;
 
     default:
         msg_Err( p_vod, "cannot add this stream (unsupported "
@@ -648,8 +661,17 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
                     i_port_video = p_rtsp->es[i]->i_port;
             }
 
-            asprintf( &psz_output, "rtp{dst=%s,port-video=%i,port-audio=%i}",
-                      ip, i_port_video, i_port_audio );
+            if( p_media->psz_mux )
+            {
+                asprintf( &psz_output, "rtp{dst=%s,port=%i,mux=%s}",
+                          ip, i_port_video, p_media->psz_mux );
+            }
+            else
+            {
+                asprintf( &psz_output, "rtp{dst=%s,port-video=%i,"
+                          "port-audio=%i}", ip, i_port_video, i_port_audio );
+            }
+
             vod_MediaControl( p_vod, p_media, psz_session, VOD_MEDIA_PLAY,
                               psz_output );
             free( psz_output );
index 923b4fa957d5c3f81ad4f5b651772707d2541489..6461071b2e277f1e28fae9cd4d818ee9127cead7 100644 (file)
@@ -27,6 +27,7 @@
  * Preamble
  *****************************************************************************/
 #include <stdlib.h>                                      /* malloc(), free() */
+#include <ctype.h>                                              /* tolower() */
 
 #include <vlc/vlc.h>
 
@@ -648,6 +649,20 @@ static int ExecuteCommand(vlm_t *vlm, char *command, vlm_message_t **p_message)
                 {
                     vlm_MediaSetup( vlm, media, p_command[i], NULL );
                 }
+                else if( i + 1 >= i_command && !strcmp( p_command[i], "mux" ) )
+                {
+                    if( media->i_type != VOD_TYPE )
+                    {
+                        message = vlm_MessageNew( p_command[0],
+                                  "mux only available for broadcast" );
+                    }
+                    else
+                    {
+                        vlm_MediaSetup( vlm, media, p_command[i],
+                                       p_command[i+1] );
+                       i++;
+                    }
+                }
                 else if( strcmp( p_command[i], "loop" ) == 0 ||
                          strcmp( p_command[i], "unloop" ) == 0 )
                 {
@@ -771,6 +786,7 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type )
     media->b_loop = VLC_FALSE;
     media->vod_media = NULL;
     media->psz_vod_output = NULL;
+    media->psz_mux = NULL;
     media->i_input = 0;
     media->input = NULL;
     media->psz_output = NULL;
@@ -824,6 +840,7 @@ static void vlm_MediaDelete( vlm_t *vlm, vlm_media_t *media, char *psz_name )
     if( media->input ) free( media->input );
 
     if( media->psz_output ) free( media->psz_output );
+    if( media->psz_mux ) free( media->psz_mux );
 
     while( media->i_option-- ) free( media->option[media->i_option] );
     if( media->option ) free( media->option );
@@ -852,6 +869,12 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd,
     {
         media->b_enabled = VLC_FALSE;
     }
+    else if( strcmp( psz_cmd, "mux" ) == 0 )
+    {
+        if( media->psz_mux ) free( media->psz_mux );
+        media->psz_mux = NULL;
+        if( psz_value ) media->psz_mux = strdup( psz_value );
+    }
     else if( strcmp( psz_cmd, "input" ) == 0 )
     {
         char *input;
@@ -941,6 +964,26 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd,
             }
             free( psz_output );
 
+            if( media->psz_mux )
+            {
+                input_item_t item;
+                es_format_t es, *p_es = &es;
+                char fourcc[5];
+
+                sprintf( fourcc, "%4.4s", media->psz_mux );
+                fourcc[0] = tolower(fourcc[0]); fourcc[1] = tolower(fourcc[1]);
+                fourcc[2] = tolower(fourcc[2]); fourcc[3] = tolower(fourcc[3]);
+
+                item = media->item;
+                item.i_es = 1;
+                item.es = &p_es;
+                es_format_Init( &es, VIDEO_ES, *((int *)fourcc) );
+
+                media->vod_media =
+                  vlm->vod->pf_media_new( vlm->vod, media->psz_name, &item );
+                return VLC_SUCCESS;
+            }
+
             media->vod_media =
                 vlm->vod->pf_media_new( vlm->vod, media->psz_name,
                                         &media->item );
@@ -1396,6 +1439,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
                         vlm_MessageNew( "loop", media->b_loop ?
                                         "yes" : "no" ) );
 
+        if( media->i_type == VOD_TYPE && media->psz_mux )
+            vlm_MessageAdd( msg_media,
+                            vlm_MessageNew( "mux", media->psz_mux ) );
+
         msg_child = vlm_MessageAdd( msg_media,
                                     vlm_MessageNew( "inputs", NULL ) );
 
@@ -1529,7 +1576,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
 
     }
 
-    else if( psz_filter && strcmp( psz_filter, "media") == 0 )
+    else if( psz_filter && strcmp( psz_filter, "media" ) == 0 )
     {
         int i, j;
         vlm_message_t *msg;
@@ -1554,6 +1601,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
                             vlm_MessageNew( "enabled", m->b_enabled ?
                                             "yes" : "no" ) );
 
+            if( m->i_type == VOD_TYPE && m->psz_mux )
+                vlm_MessageAdd( msg_media,
+                                vlm_MessageNew( "mux", m->psz_mux ) );
+
             msg_instance = vlm_MessageAdd( msg_media,
                                            vlm_MessageNew( "instances", 0 ) );