home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / VLC Media Player / vlc-1.0.3-win32.exe / sdk / include / vlc / plugins / vlc_vlm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-10-30  |  11.5 KB  |  362 lines

  1. /*****************************************************************************
  2.  * vlc_vlm.h: VLM core structures
  3.  *****************************************************************************
  4.  * Copyright (C) 2000, 2001 the VideoLAN team
  5.  * $Id$
  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;     /*< numeric id for vlm_media_t item */
  47.     bool  b_enabled;    /*< vlm_media_t is enabled */
  48.  
  49.     char *psz_name;     /*< descriptive name of vlm_media_t item */
  50.  
  51.     int  i_input;       /*< number of input options */
  52.     char **ppsz_input;  /*< array of input options */
  53.  
  54.     int  i_option;      /*< number of output options */
  55.     char **ppsz_option; /*< array of output options */
  56.  
  57.     char *psz_output;   /*< */
  58.  
  59.     bool b_vod;         /*< vlm_media_t is of type VOD */
  60.     struct
  61.     {
  62.         bool b_loop;    /*< this vlc_media_t broadcast item should loop */
  63.     } broadcast;        /*< Broadcast specific information */
  64.     struct
  65.     {
  66.         char *psz_mux;  /*< name of muxer to use */
  67.     } vod;              /*< VOD specific information */
  68.  
  69. } vlm_media_t;
  70.  
  71. /** VLM media instance */
  72. typedef struct
  73. {
  74.     char *psz_name;         /*< vlm media instance descriptive name */
  75.  
  76.     int64_t     i_time;     /*< vlm media instance vlm media current time */
  77.     int64_t     i_length;   /*< vlm media instance vlm media item length */
  78.     double      d_position; /*< vlm media instance position in stream */
  79.     bool        b_paused;   /*< vlm media instance is paused */
  80.     int         i_rate;     // normal is INPUT_RATE_DEFAULT
  81. } vlm_media_instance_t;
  82.  
  83. #if 0
  84. typedef struct
  85. {
  86.  
  87. } vlm_schedule_t
  88. #endif
  89.  
  90. /** VLM events
  91.  * You can catch vlm event by adding a callback on the variable "intf-event"
  92.  * of the VLM object.
  93.  * This variable is an address that will hold a vlm_event_t* value.
  94.  */
  95. enum vlm_event_type_e
  96. {
  97.     /* */
  98.     VLM_EVENT_MEDIA_ADDED   = 0x100,
  99.     VLM_EVENT_MEDIA_REMOVED,
  100.     VLM_EVENT_MEDIA_CHANGED,
  101.  
  102.     /* */
  103.     VLM_EVENT_MEDIA_INSTANCE_STARTED    = 0x200,
  104.     VLM_EVENT_MEDIA_INSTANCE_STOPPED,
  105. };
  106.  
  107. typedef struct
  108. {
  109.     int         i_type;     /* a vlm_event_type_e value */
  110.     int64_t     id;         /* Media ID */
  111.     const char *psz_name;   /* Media name */
  112. } vlm_event_t;
  113.  
  114. /** VLM control query */
  115. enum vlm_query_e
  116. {
  117.     /* --- Media control */
  118.     /* Get all medias */
  119.     VLM_GET_MEDIAS,                     /* arg1=vlm_media_t ***, int *pi_media      */
  120.     /* Delete all medias */
  121.     VLM_CLEAR_MEDIAS,                   /* no arg */
  122.  
  123.     /* Add a new media */
  124.     VLM_ADD_MEDIA,                      /* arg1=vlm_media_t* arg2=int64_t *p_id         res=can fail */
  125.     /* Delete an existing media */
  126.     VLM_DEL_MEDIA,                      /* arg1=int64_t id */
  127.     /* Change properties of an existing media (all fields but id and b_vod) */
  128.     VLM_CHANGE_MEDIA,                   /* arg1=vlm_media_t*                            res=can fail */
  129.     /* Get 1 media by it's ID */
  130.     VLM_GET_MEDIA,                      /* arg1=int64_t id arg2=vlm_media_t **  */
  131.     /* Get media ID from its name */
  132.     VLM_GET_MEDIA_ID,                   /* arg1=const char *psz_name arg2=int64_t*  */
  133.  
  134.     /* Media instance control XXX VOD control are for internal use only */
  135.     /* Get all media instances */
  136.     VLM_GET_MEDIA_INSTANCES,            /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
  137.     /* Delete all media instances */
  138.     VLM_CLEAR_MEDIA_INSTANCES,          /* arg1=int64_t id */
  139.     /* Control broadcast instance */
  140.     VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index  res=can fail */
  141.     /* Control VOD instance */
  142.     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 */
  143.     /* Stop an instance */
  144.     VLM_STOP_MEDIA_INSTANCE,            /* arg1=int64_t id, arg2=const char *psz_instance_name      res=can fail */
  145.     /* Pause an instance */
  146.     VLM_PAUSE_MEDIA_INSTANCE,           /* arg1=int64_t id, arg2=const char *psz_instance_name      res=can fail */
  147.     /* Get instance position time (in microsecond) */
  148.     VLM_GET_MEDIA_INSTANCE_TIME,        /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t *   */
  149.     /* Set instance position time (in microsecond) */
  150.     VLM_SET_MEDIA_INSTANCE_TIME,        /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t     */
  151.     /* Get instance position ([0.0 .. 1.0]) */
  152.     VLM_GET_MEDIA_INSTANCE_POSITION,    /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double *   */
  153.     /* Set instance position ([0.0 .. 1.0]) */
  154.     VLM_SET_MEDIA_INSTANCE_POSITION,    /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double     */
  155.  
  156.     /* Schedule control */
  157.     VLM_CLEAR_SCHEDULES,                /* no arg */
  158.     /* TODO: missing schedule control */
  159.  
  160.     /* */
  161. };
  162.  
  163.  
  164. /* VLM specific - structures and functions */
  165.  
  166. /* ok, here is the structure of a vlm_message:
  167.    The parent node is ( name_of_the_command , NULL ), or
  168.    ( name_of_the_command , message_error ) on error.
  169.    If a node has children, it should not have a value (=NULL).*/
  170. struct vlm_message_t
  171. {
  172.     char *psz_name;         /*< message name */
  173.     char *psz_value;        /*< message value */
  174.  
  175.     int           i_child;  /*< number of child messages */
  176.     vlm_message_t **child;  /*< array of vlm_message_t */
  177. };
  178.  
  179.  
  180. #ifdef __cpluplus
  181. extern "C" {
  182. #endif
  183.  
  184. #define vlm_New( a ) __vlm_New( VLC_OBJECT(a) )
  185. VLC_EXPORT( vlm_t *, __vlm_New, ( vlc_object_t * ) );
  186. VLC_EXPORT( void,      vlm_Delete, ( vlm_t * ) );
  187. VLC_EXPORT( int,       vlm_ExecuteCommand, ( vlm_t *, const char *, vlm_message_t ** ) );
  188. VLC_EXPORT( int,       vlm_Control, ( vlm_t *p_vlm, int i_query, ... ) );
  189.  
  190. VLC_EXPORT( vlm_message_t *, vlm_MessageSimpleNew, ( const char * ) );
  191. VLC_EXPORT( vlm_message_t *, vlm_MessageNew, ( const char *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
  192. VLC_EXPORT( vlm_message_t *, vlm_MessageAdd, ( vlm_message_t *, vlm_message_t * ) );
  193. VLC_EXPORT( void,            vlm_MessageDelete, ( vlm_message_t * ) );
  194.  
  195. /* media helpers */
  196.  
  197. /**
  198.  * Initialize a vlm_media_t instance
  199.  * \param p_media vlm_media_t instance to initialize
  200.  */
  201. static inline void vlm_media_Init( vlm_media_t *p_media )
  202. {
  203.     memset( p_media, 0, sizeof(vlm_media_t) );
  204.     p_media->id = 0;    // invalid id
  205.     p_media->psz_name = NULL;
  206.     TAB_INIT( p_media->i_input, p_media->ppsz_input );
  207.     TAB_INIT( p_media->i_option, p_media->ppsz_option );
  208.     p_media->psz_output = NULL;
  209.     p_media->b_vod = false;
  210.  
  211.     p_media->vod.psz_mux = NULL;
  212.     p_media->broadcast.b_loop = false;
  213. }
  214.  
  215. /**
  216.  * Copy a vlm_media_t instance into another vlm_media_t instance
  217.  * \param p_dst vlm_media_t instance to copy to
  218.  * \param p_src vlm_media_t instance to copy from
  219.  */
  220. static inline void vlm_media_Copy( vlm_media_t *p_dst, vlm_media_t *p_src )
  221. {
  222.     int i;
  223.  
  224.     memset( p_dst, 0, sizeof(vlm_media_t) );
  225.     p_dst->id = p_src->id;
  226.     p_dst->b_enabled = p_src->b_enabled;
  227.     if( p_src->psz_name )
  228.         p_dst->psz_name = strdup( p_src->psz_name );
  229.  
  230.     for( i = 0; i < p_src->i_input; i++ )
  231.         TAB_APPEND_CPP( char, p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
  232.     for( i = 0; i < p_src->i_option; i++ )
  233.         TAB_APPEND_CPP( char, p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
  234.  
  235.     if( p_src->psz_output )
  236.         p_dst->psz_output = strdup( p_src->psz_output );
  237.  
  238.     p_dst->b_vod = p_src->b_vod;
  239.     if( p_src->b_vod )
  240.     {
  241.         if( p_src->vod.psz_mux )
  242.             p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
  243.     }
  244.     else
  245.     {
  246.         p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
  247.     }
  248. }
  249.  
  250. /**
  251.  * Cleanup and release memory associated with this vlm_media_t instance.
  252.  * You still need to release p_media itself with vlm_media_Delete().
  253.  * \param p_media vlm_media_t to cleanup
  254.  */
  255. static inline void vlm_media_Clean( vlm_media_t *p_media )
  256. {
  257.     int i;
  258.     free( p_media->psz_name );
  259.  
  260.     for( i = 0; i < p_media->i_input; i++ )
  261.         free( p_media->ppsz_input[i]) ;
  262.     TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
  263.  
  264.     for( i = 0; i < p_media->i_option; i++ )
  265.         free( p_media->ppsz_option[i]) ;
  266.     TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
  267.  
  268.     free( p_media->psz_output );
  269.     if( p_media->b_vod )
  270.         free( p_media->vod.psz_mux );
  271. }
  272.  
  273. /**
  274.  * Allocate a new vlm_media_t instance
  275.  * \return vlm_media_t instance
  276.  */
  277. static inline vlm_media_t *vlm_media_New(void)
  278. {
  279.     vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
  280.     if( p_media )
  281.         vlm_media_Init( p_media );
  282.     return p_media;
  283. }
  284.  
  285. /**
  286.  * Delete a vlm_media_t instance
  287.  * \param p_media vlm_media_t instance to delete
  288.  */
  289. static inline void vlm_media_Delete( vlm_media_t *p_media )
  290. {
  291.     vlm_media_Clean( p_media );
  292.     free( p_media );
  293. }
  294.  
  295. /**
  296.  * Copy a vlm_media_t instance
  297.  * \param p_src vlm_media_t instance to copy
  298.  * \return vlm_media_t duplicate of p_src
  299.  */
  300. static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
  301. {
  302.     vlm_media_t *p_dst = vlm_media_New();
  303.     if( p_dst )
  304.         vlm_media_Copy( p_dst, p_src );
  305.     return p_dst;
  306. }
  307.  
  308. /* media instance helpers */
  309. /**
  310.  * Initialize vlm_media_instance_t
  311.  * \param p_instance vlm_media_instance_t to initialize
  312.  */
  313. static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
  314. {
  315.     memset( p_instance, 0, sizeof(vlm_media_instance_t) );
  316.     p_instance->psz_name = NULL;
  317.     p_instance->i_time = 0;
  318.     p_instance->i_length = 0;
  319.     p_instance->d_position = 0.0;
  320.     p_instance->b_paused = false;
  321.     p_instance->i_rate = INPUT_RATE_DEFAULT;
  322. }
  323.  
  324. /**
  325.  * Cleanup vlm_media_instance_t
  326.  * \param p_instance vlm_media_instance_t to cleanup
  327.  */
  328. static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
  329. {
  330.     free( p_instance->psz_name );
  331. }
  332.  
  333. /**
  334.  * Allocate a new vlm_media_instance_t
  335.  * \return a new vlm_media_instance_t
  336.  */
  337. static inline vlm_media_instance_t *vlm_media_instance_New(void)
  338. {
  339.     vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
  340.     if( p_instance )
  341.         vlm_media_instance_Init( p_instance );
  342.     return p_instance;
  343. }
  344.  
  345. /**
  346.  * Delete a vlm_media_instance_t
  347.  * \param p_instance vlm_media_instance_t to delete
  348.  */
  349. static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
  350. {
  351.     vlm_media_instance_Clean( p_instance );
  352.     free( p_instance );
  353. }
  354.  
  355. #ifdef __cpluplus
  356. }
  357. #endif
  358.  
  359. /**@}*/
  360.  
  361. #endif
  362.