Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

stream_output.h

00001 /*****************************************************************************
00002  * stream_output.h : stream output module
00003  *****************************************************************************
00004  * Copyright (C) 2002-2005 the VideoLAN team
00005  * $Id: stream_output.h 12932 2005-10-23 10:58:24Z zorglub $
00006  *
00007  * Authors: Christophe Massiot <[email protected]>
00008  *          Laurent Aimar <[email protected]>
00009  *          Eric Petit <[email protected]>
00010  *          Jean-Paul Saman <jpsaman #_at_# m2x.nl>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00025  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028  * sout_instance_t: stream output thread descriptor
00029  *****************************************************************************/
00030 
00031 #include "vlc_es.h"
00032 
00033 /****************************************************************************
00034  * sout_instance_t: p_sout
00035  ****************************************************************************/
00036 struct sout_instance_t
00037 {
00038     VLC_COMMON_MEMBERS
00039 
00040     char *psz_sout;
00041     char *psz_chain;
00042 
00043     /* meta data (Read only) XXX it won't be set before the first packet received */
00044     vlc_meta_t          *p_meta;
00045 
00046     int                 i_out_pace_nocontrol;   /* count of output that can't control the space */
00047 
00048     vlc_mutex_t         lock;
00049     sout_stream_t       *p_stream;
00050 
00051     /* sout private */
00052     sout_instance_sys_t *p_sys;
00053 };
00054 
00055 /****************************************************************************
00056  * sout_cfg_t:
00057  ****************************************************************************/
00058 struct sout_cfg_t
00059 {
00060     sout_cfg_t  *p_next;
00061 
00062     char        *psz_name;
00063     char        *psz_value;
00064 };
00065 
00066 #define sout_CfgParse( a, b, c, d ) __sout_CfgParse( VLC_OBJECT(a), b, c, d )
00067 VLC_EXPORT( void,   __sout_CfgParse, ( vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t * ) );
00068 VLC_EXPORT( char *, sout_CfgCreate, ( char **, sout_cfg_t **, char * ) );
00069 
00070 /****************************************************************************
00071  * sout_stream_id_t: opaque (private for all sout_stream_t)
00072  ****************************************************************************/
00073 typedef struct sout_stream_id_t  sout_stream_id_t;
00074 
00075 /****************************************************************************
00076  * sout_packetizer_input_t: p_sout <-> p_packetizer
00077  ****************************************************************************/
00078 struct sout_packetizer_input_t
00079 {
00080     sout_instance_t     *p_sout;
00081 
00082     es_format_t         *p_fmt;
00083 
00084     sout_stream_id_t    *id;
00085 };
00086 
00087 #define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
00088 VLC_EXPORT( sout_instance_t *,  __sout_NewInstance,  ( vlc_object_t *, char * ) );
00089 VLC_EXPORT( void,               sout_DeleteInstance, ( sout_instance_t * ) );
00090 
00091 VLC_EXPORT( sout_packetizer_input_t *, sout_InputNew,( sout_instance_t *, es_format_t * ) );
00092 VLC_EXPORT( int,                sout_InputDelete,      ( sout_packetizer_input_t * ) );
00093 VLC_EXPORT( int,                sout_InputSendBuffer,  ( sout_packetizer_input_t *, block_t* ) );
00094 
00095 /****************************************************************************
00096  * sout_access_out_t:
00097  ****************************************************************************/
00098 struct sout_access_out_t
00099 {
00100     VLC_COMMON_MEMBERS
00101 
00102     module_t                *p_module;
00103 
00104     sout_instance_t         *p_sout;
00105 
00106     char                    *psz_access;
00107     sout_cfg_t              *p_cfg;
00108 
00109     char                    *psz_name;
00110     sout_access_out_sys_t   *p_sys;
00111     int                     (*pf_seek)( sout_access_out_t *, off_t );
00112     int                     (*pf_read)( sout_access_out_t *, block_t * );
00113     int                     (*pf_write)( sout_access_out_t *, block_t * );
00114 };
00115 
00116 VLC_EXPORT( sout_access_out_t *,sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
00117 VLC_EXPORT( void,               sout_AccessOutDelete, ( sout_access_out_t * ) );
00118 VLC_EXPORT( int,                sout_AccessOutSeek,   ( sout_access_out_t *, off_t ) );
00119 VLC_EXPORT( int,                sout_AccessOutRead,   ( sout_access_out_t *, block_t * ) );
00120 VLC_EXPORT( int,                sout_AccessOutWrite,  ( sout_access_out_t *, block_t * ) );
00121 
00122 /****************************************************************************
00123  * mux:
00124  ****************************************************************************/
00125 struct  sout_mux_t
00126 {
00127     VLC_COMMON_MEMBERS
00128     module_t            *p_module;
00129 
00130     sout_instance_t     *p_sout;
00131 
00132     char                *psz_mux;
00133     sout_cfg_t          *p_cfg;
00134 
00135     sout_access_out_t   *p_access;
00136 
00137     int                 (*pf_addstream)( sout_mux_t *, sout_input_t * );
00138     int                 (*pf_delstream)( sout_mux_t *, sout_input_t * );
00139     int                 (*pf_mux)      ( sout_mux_t * );
00140     int                 (*pf_control)  ( sout_mux_t *, int, va_list );
00141 
00142     /* here are all inputs accepted by muxer */
00143     int                 i_nb_inputs;
00144     sout_input_t        **pp_inputs;
00145 
00146 
00147     /* mux private */
00148     sout_mux_sys_t      *p_sys;
00149 
00150     /* XXX private to stream_output.c */
00151     /* if muxer doesn't support adding stream at any time then we first wait
00152      *  for stream then we refuse all stream and start muxing */
00153     vlc_bool_t  b_add_stream_any_time;
00154     vlc_bool_t  b_waiting_stream;
00155     /* we wait one second after first stream added */
00156     mtime_t     i_add_stream_start;
00157 };
00158 
00159 enum sout_mux_query_e
00160 {
00161     /* capabilities */
00162     MUX_CAN_ADD_STREAM_WHILE_MUXING,    /* arg1= vlc_bool_t *,      res=cannot fail */
00163     /* properties */
00164     MUX_GET_ADD_STREAM_WAIT,            /* arg1= vlc_bool_t *,      res=cannot fail */
00165     MUX_GET_MIME,                       /* arg1= char **            res=can fail    */
00166 };
00167 
00168 struct sout_input_t
00169 {
00170     sout_instance_t *p_sout;
00171 
00172     es_format_t     *p_fmt;
00173     block_fifo_t    *p_fifo;
00174 
00175     void            *p_sys;
00176 };
00177 
00178 
00179 VLC_EXPORT( sout_mux_t *,   sout_MuxNew,          ( sout_instance_t*, char *, sout_access_out_t * ) );
00180 VLC_EXPORT( sout_input_t *, sout_MuxAddStream,    ( sout_mux_t *, es_format_t * ) );
00181 VLC_EXPORT( void,           sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
00182 VLC_EXPORT( void,           sout_MuxDelete,       ( sout_mux_t * ) );
00183 VLC_EXPORT( void,           sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t  *, block_t * ) );
00184 
00185 static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
00186 {
00187     va_list args;
00188     int     i_result;
00189 
00190     va_start( args, i_query );
00191     i_result = p_mux->pf_control( p_mux, i_query, args );
00192     va_end( args );
00193     return i_result;
00194 }
00195 
00196 /****************************************************************************
00197  * sout_stream:
00198  ****************************************************************************/
00199 struct sout_stream_t
00200 {
00201     VLC_COMMON_MEMBERS
00202 
00203     module_t          *p_module;
00204     sout_instance_t   *p_sout;
00205 
00206     char              *psz_name;
00207     sout_cfg_t        *p_cfg;
00208     char              *psz_next;
00209 
00210     /* Subpicture unit */
00211     spu_t             *p_spu;
00212     
00213     /* add, remove a stream */
00214     sout_stream_id_t *(*pf_add)( sout_stream_t *, es_format_t * );
00215     int               (*pf_del)( sout_stream_t *, sout_stream_id_t * );
00216     /* manage a packet */
00217     int               (*pf_send)( sout_stream_t *, sout_stream_id_t *, block_t* );
00218 
00219     /* private */
00220     sout_stream_sys_t *p_sys;
00221 };
00222 
00223 VLC_EXPORT( sout_stream_t *, sout_StreamNew, ( sout_instance_t *, char *psz_chain ) );
00224 VLC_EXPORT( void,            sout_StreamDelete, ( sout_stream_t * ) );
00225 
00226 static inline sout_stream_id_t *sout_StreamIdAdd( sout_stream_t *s, es_format_t *fmt )
00227 {
00228     return s->pf_add( s, fmt );
00229 }
00230 static inline int sout_StreamIdDel( sout_stream_t *s, sout_stream_id_t *id )
00231 {
00232     return s->pf_del( s, id );
00233 }
00234 static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, block_t *b )
00235 {
00236     return s->pf_send( s, id, b );
00237 }
00238 
00239 /****************************************************************************
00240  * Announce handler mess
00241  ****************************************************************************/
00242 struct sap_session_t;
00243 
00244 struct session_descriptor_t
00245 {
00246     char *psz_name;
00247     char *psz_uri;
00248     int i_port;
00249     int i_ttl;
00250     int i_payload;   /* SAP Payload type */
00251 
00252     char *psz_group;
00253 
00254     sap_session_t *p_sap; /* If we have a sap session, remember it */
00255     char *psz_sdp;
00256     vlc_bool_t b_rtp;
00257 };
00258 
00259 #define METHOD_TYPE_SAP 1
00260 #define METHOD_TYPE_SLP 2
00261 
00262 struct announce_method_t
00263 {
00264     int i_type;
00265 };
00266 
00267 
00268 /* A SAP session descriptor, enqueued in the SAP handler queue */
00269 struct sap_session_t
00270 {
00271     char          *psz_sdp;
00272     uint8_t       *psz_data;
00273     unsigned      i_length;
00274     sap_address_t *p_address;
00275 
00276     /* Last and next send */
00277     mtime_t        i_last;
00278     mtime_t        i_next;
00279 };
00280 
00281 /* The SAP handler, running in a separate thread */
00282 struct sap_handler_t
00283 {
00284     VLC_COMMON_MEMBERS /* needed to create a thread */
00285 
00286     sap_session_t **pp_sessions;
00287     sap_address_t **pp_addresses;
00288 
00289     vlc_bool_t b_control;
00290 
00291     int i_sessions;
00292     int i_addresses;
00293 
00294     int i_current_session;
00295 
00296     int (*pf_add)  ( sap_handler_t*, session_descriptor_t *);
00297     int (*pf_del)  ( sap_handler_t*, session_descriptor_t *);
00298 
00299     /* private data, not in p_sys as there is one kind of sap_handler_t */
00300 };
00301 
00302 /* The main announce handler object */
00303 struct announce_handler_t
00304 {
00305     VLC_COMMON_MEMBERS
00306 
00307     sap_handler_t *p_sap;
00308 };
00309 
00310 /* End */
00311 
00312 
00313 static inline sout_cfg_t *sout_cfg_find( sout_cfg_t *p_cfg, char *psz_name )
00314 {
00315     while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
00316     {
00317         p_cfg = p_cfg->p_next;
00318     }
00319 
00320     return p_cfg;
00321 }
00322 
00323 static inline char *sout_cfg_find_value( sout_cfg_t *p_cfg, char *psz_name )
00324 {
00325     while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
00326     {
00327         p_cfg = p_cfg->p_next;
00328     }
00329 
00330     if( p_cfg && p_cfg->psz_value )
00331     {
00332         return( p_cfg->psz_value );
00333     }
00334 
00335     return NULL;
00336 }
00337 
00338 /* Announce system */
00339 VLC_EXPORT( int,                sout_AnnounceRegister, (sout_instance_t *,session_descriptor_t*, announce_method_t* ) );
00340 VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *,const char *, const char *, announce_method_t* ) );
00341 VLC_EXPORT( int,                sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) );
00342 
00343 VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (void) );
00344 VLC_EXPORT(void,                 sout_AnnounceSessionDestroy, (session_descriptor_t *) );
00345 VLC_EXPORT(announce_method_t*,   sout_AnnounceMethodCreate, (int) );
00346 
00347 #define announce_HandlerCreate(a) __announce_HandlerCreate(VLC_OBJECT(a))
00348 announce_handler_t*  __announce_HandlerCreate( vlc_object_t *);
00349 
00350 /* Private functions for the announce handler */
00351 int announce_HandlerDestroy( announce_handler_t * );
00352 int announce_Register( announce_handler_t *p_announce,
00353                 session_descriptor_t *p_session,
00354                 announce_method_t *p_method );
00355 int announce_UnRegister( announce_handler_t *p_announce,
00356                 session_descriptor_t *p_session );
00357 
00358 sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce );
00359 void announce_SAPHandlerDestroy( sap_handler_t *p_sap );

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2