home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 May / maximum-cd-2009-05.iso / DiscContents / vlc-0.9.8a-win32.exe / sdk / include / vlc / plugins / vlc_vlm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-12-06  |  9.0 KB  |  289 lines

  1. /*****************************************************************************
  2.  * vlc_vlm.h: VLM core structures
  3.  *****************************************************************************
  4.  * Copyright (C) 2000, 2001 the VideoLAN team
  5.  * $Id: 665cf2db9fa08651be180a317adfcc024a46d0d5 $
  6.  *
  7.  * Authors: Simon Latapie <garf@videolan.org>
  8.  *          Laurent Aimar <fenrir@videolan.org>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24.  
  25. #ifndef VLC_VLM_H
  26. #define VLC_VLM_H 1
  27.  
  28. /**
  29.  * \file
  30.  * This file defines VLM core functions and structures in vlc
  31.  */
  32.  
  33. #include <vlc_input.h>
  34.  
  35. /**
  36.  * \defgroup server VLM
  37.  * VLM is the server core in vlc that allows streaming of multiple media streams
  38.  * at the same time. It provides broadcast, schedule and video on demand features
  39.  * for streaming using several streaming and network protocols.
  40.  * @{
  41.  */
  42.  
  43. /* VLM media */
  44. typedef struct
  45. {
  46.     int64_t     id;
  47.     bool  b_enabled;
  48.  
  49.     /* */
  50.     char *psz_name;
  51.  
  52.     /* */
  53.     int  i_input;
  54.     char **ppsz_input;
  55.  
  56.     int  i_option;
  57.     char **ppsz_option;
  58.  
  59.     char *psz_output;
  60.  
  61.     /* */
  62.     bool b_vod;
  63.     struct
  64.     {
  65.         bool b_loop;
  66.     } broadcast;
  67.     struct
  68.     {
  69.         char *psz_mux;
  70.     } vod;
  71.  
  72. } vlm_media_t;
  73.  
  74. /* VLM media instance */
  75. typedef struct
  76. {
  77.     char *psz_name;
  78.  
  79.     int64_t     i_time;
  80.     int64_t     i_length;
  81.     double      d_position;
  82.     bool  b_paused;
  83.     int         i_rate;     // normal is INPUT_RATE_DEFAULT
  84. } vlm_media_instance_t;
  85.  
  86. #if 0
  87. typedef struct
  88. {
  89.  
  90. } vlm_schedule_t
  91. #endif
  92.  
  93. /* VLM control query */
  94. enum vlm_query_e
  95. {
  96.     /* --- Media control */
  97.     /* Get all medias */
  98.     VLM_GET_MEDIAS,                     /* arg1=vlm_media_t ***, int *pi_media      */
  99.     /* Delete all medias */
  100.     VLM_CLEAR_MEDIAS,                   /* no arg */
  101.  
  102.     /* Add a new media */
  103.     VLM_ADD_MEDIA,                      /* arg1=vlm_media_t* arg2=int64_t *p_id         res=can fail */
  104.     /* Delete an existing media */
  105.     VLM_DEL_MEDIA,                      /* arg1=int64_t id */
  106.     /* Change properties of an existing media (all fields but id and b_vod) */
  107.     VLM_CHANGE_MEDIA,                   /* arg1=vlm_media_t*                            res=can fail */
  108.     /* Get 1 media by it's ID */
  109.     VLM_GET_MEDIA,                      /* arg1=int64_t id arg2=vlm_media_t **  */
  110.     /* Get media ID from its name */
  111.     VLM_GET_MEDIA_ID,                   /* arg1=const char *psz_name arg2=int64_t*  */
  112.  
  113.     /* Media instance control XXX VOD control are for internal use only */
  114.     /* Get all media instances */
  115.     VLM_GET_MEDIA_INSTANCES,            /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
  116.     /* Delete all media instances */
  117.     VLM_CLEAR_MEDIA_INSTANCES,          /* arg1=int64_t id */
  118.     /* Control broadcast instance */
  119.     VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index  res=can fail */
  120.     /* Control VOD instance */
  121.     VLM_START_MEDIA_VOD_INSTANCE,       /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index char *psz_vod_output res=can fail */
  122.     /* Stop an instance */
  123.     VLM_STOP_MEDIA_INSTANCE,            /* arg1=int64_t id, arg2=const char *psz_instance_name      res=can fail */
  124.     /* Pause an instance */
  125.     VLM_PAUSE_MEDIA_INSTANCE,           /* arg1=int64_t id, arg2=const char *psz_instance_name      res=can fail */
  126.     /* Get instance position time (in microsecond) */
  127.     VLM_GET_MEDIA_INSTANCE_TIME,        /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t *   */
  128.     /* Set instance position time (in microsecond) */
  129.     VLM_SET_MEDIA_INSTANCE_TIME,        /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t     */
  130.     /* Get instance position ([0.0 .. 1.0]) */
  131.     VLM_GET_MEDIA_INSTANCE_POSITION,    /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double *   */
  132.     /* Set instance position ([0.0 .. 1.0]) */
  133.     VLM_SET_MEDIA_INSTANCE_POSITION,    /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double     */
  134.  
  135.     /* Schedule control */
  136.     VLM_CLEAR_SCHEDULES,                /* no arg */
  137.     /* TODO: missing schedule control */
  138.  
  139.     /* */
  140. };
  141.  
  142.  
  143. /* VLM specific - structures and functions */
  144.  
  145. /* ok, here is the structure of a vlm_message:
  146.    The parent node is ( name_of_the_command , NULL ), or
  147.    ( name_of_the_command , message_error ) on error.
  148.    If a node has children, it should not have a value (=NULL).*/
  149. struct vlm_message_t
  150. {
  151.     char *psz_name;
  152.     char *psz_value;
  153.  
  154.     int           i_child;
  155.     vlm_message_t **child;
  156. };
  157.  
  158.  
  159. #ifdef __cpluplus
  160. extern "C" {
  161. #endif
  162.  
  163. #define vlm_New( a ) __vlm_New( VLC_OBJECT(a) )
  164. VLC_EXPORT( vlm_t *, __vlm_New, ( vlc_object_t * ) );
  165. VLC_EXPORT( void,      vlm_Delete, ( vlm_t * ) );
  166. VLC_EXPORT( int,       vlm_ExecuteCommand, ( vlm_t *, const char *, vlm_message_t ** ) );
  167. VLC_EXPORT( int,       vlm_Control, ( vlm_t *p_vlm, int i_query, ... ) );
  168.  
  169. VLC_EXPORT( vlm_message_t *, vlm_MessageNew, ( const char *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
  170. VLC_EXPORT( vlm_message_t *, vlm_MessageAdd, ( vlm_message_t *, vlm_message_t * ) );
  171. VLC_EXPORT( void,            vlm_MessageDelete, ( vlm_message_t * ) );
  172.  
  173. /* media helpers */
  174. static inline void vlm_media_Init( vlm_media_t *p_media )
  175. {
  176.     memset( p_media, 0, sizeof(vlm_media_t) );
  177.     p_media->id = 0;    // invalid id
  178.     p_media->psz_name = NULL;
  179.     TAB_INIT( p_media->i_input, p_media->ppsz_input );
  180.     TAB_INIT( p_media->i_option, p_media->ppsz_option );
  181.     p_media->psz_output = NULL;
  182.     p_media->b_vod = false;
  183.  
  184.     p_media->vod.psz_mux = NULL;
  185.     p_media->broadcast.b_loop = false;
  186. }
  187.  
  188. static inline void vlm_media_Copy( vlm_media_t *p_dst, vlm_media_t *p_src )
  189. {
  190.     int i;
  191.  
  192.     memset( p_dst, 0, sizeof(vlm_media_t) );
  193.     p_dst->id = p_src->id;
  194.     p_dst->b_enabled = p_src->b_enabled;
  195.     if( p_src->psz_name )
  196.         p_dst->psz_name = strdup( p_src->psz_name );
  197.  
  198.     for( i = 0; i < p_src->i_input; i++ )
  199.         TAB_APPEND_CPP( char, p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
  200.     for( i = 0; i < p_src->i_option; i++ )
  201.         TAB_APPEND_CPP( char, p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
  202.  
  203.     if( p_src->psz_output )
  204.         p_dst->psz_output = strdup( p_src->psz_output );
  205.  
  206.     p_dst->b_vod = p_src->b_vod;
  207.     if( p_src->b_vod )
  208.     {
  209.         if( p_src->vod.psz_mux )
  210.             p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
  211.     }
  212.     else
  213.     {
  214.         p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
  215.     }
  216. }
  217. static inline void vlm_media_Clean( vlm_media_t *p_media )
  218. {
  219.     int i;
  220.     free( p_media->psz_name );
  221.  
  222.     for( i = 0; i < p_media->i_input; i++ )
  223.         free( p_media->ppsz_input[i]) ;
  224.     TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
  225.  
  226.     for( i = 0; i < p_media->i_option; i++ )
  227.         free( p_media->ppsz_option[i]) ;
  228.     TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
  229.  
  230.     free( p_media->psz_output );
  231.     if( p_media->b_vod )
  232.         free( p_media->vod.psz_mux );
  233. }
  234. static inline vlm_media_t *vlm_media_New(void)
  235. {
  236.     vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
  237.     if( p_media )
  238.         vlm_media_Init( p_media );
  239.     return p_media;
  240. }
  241. static inline void vlm_media_Delete( vlm_media_t *p_media )
  242. {
  243.     vlm_media_Clean( p_media );
  244.     free( p_media );
  245. }
  246. static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
  247. {
  248.     vlm_media_t *p_dst = vlm_media_New();
  249.     if( p_dst )
  250.         vlm_media_Copy( p_dst, p_src );
  251.     return p_dst;
  252. }
  253.  
  254. /* media instance helpers */
  255. static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
  256. {
  257.     memset( p_instance, 0, sizeof(vlm_media_instance_t) );
  258.     p_instance->psz_name = NULL;
  259.     p_instance->i_time = 0;
  260.     p_instance->i_length = 0;
  261.     p_instance->d_position = 0.0;
  262.     p_instance->b_paused = false;
  263.     p_instance->i_rate = INPUT_RATE_DEFAULT;
  264. }
  265. static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
  266. {
  267.     free( p_instance->psz_name );
  268. }
  269. static inline vlm_media_instance_t *vlm_media_instance_New(void)
  270. {
  271.     vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
  272.     if( p_instance )
  273.         vlm_media_instance_Init( p_instance );
  274.     return p_instance;
  275. }
  276. static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
  277. {
  278.     vlm_media_instance_Clean( p_instance );
  279.     free( p_instance );
  280. }
  281.  
  282. #ifdef __cpluplus
  283. }
  284. #endif
  285.  
  286. /**@}*/
  287.  
  288. #endif
  289.