vlc_sout.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_sout.h : stream output module
00003  *****************************************************************************
00004  * Copyright (C) 2002-2008 VLC authors and VideoLAN
00005  * $Id: 011ba023f170c34fad600b7b1cf6799b7320afa4 $
00006  *
00007  * Authors: Christophe Massiot <massiot@via.ecp.fr>
00008  *          Laurent Aimar <fenrir@via.ecp.fr>
00009  *          Eric Petit <titer@videolan.org>
00010  *          Jean-Paul Saman <jpsaman #_at_# m2x.nl>
00011  *          Rémi Denis-Courmont
00012  *
00013  * This program is free software; you can redistribute it and/or modify it
00014  * under the terms of the GNU Lesser General Public License as published by
00015  * the Free Software Foundation; either version 2.1 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program; if not, write to the Free Software Foundation,
00025  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00026  *****************************************************************************/
00027 
00028 #ifndef VLC_SOUT_H_
00029 #define VLC_SOUT_H_
00030 
00031 /**
00032  * \file
00033  * This file defines structures and functions for stream output in vlc
00034  */
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #include <sys/types.h>
00041 #include <vlc_es.h>
00042 
00043 /** Stream output instance */
00044 struct sout_instance_t
00045 {
00046     VLC_COMMON_MEMBERS
00047 
00048     char *psz_sout;
00049 
00050     /* meta data (Read only) XXX it won't be set before the first packet received */
00051     vlc_meta_t          *p_meta;
00052 
00053     /** count of output that can't control the space */
00054     int                 i_out_pace_nocontrol;
00055 
00056     vlc_mutex_t         lock;
00057     sout_stream_t       *p_stream;
00058 
00059     /** Private */
00060     sout_instance_sys_t *p_sys;
00061 };
00062 
00063 /****************************************************************************
00064  * sout_stream_id_t: opaque (private for all sout_stream_t)
00065  ****************************************************************************/
00066 typedef struct sout_stream_id_t  sout_stream_id_t;
00067 
00068 /** Stream output access_output */
00069 struct sout_access_out_t
00070 {
00071     VLC_COMMON_MEMBERS
00072 
00073     module_t                *p_module;
00074     char                    *psz_access;
00075 
00076     int                      i_writes;
00077     /** Local counter reset each time it is transferred to stats */
00078     int64_t                  i_sent_bytes;
00079 
00080     char                    *psz_path;
00081     sout_access_out_sys_t   *p_sys;
00082     int                     (*pf_seek)( sout_access_out_t *, off_t );
00083     ssize_t                 (*pf_read)( sout_access_out_t *, block_t * );
00084     ssize_t                 (*pf_write)( sout_access_out_t *, block_t * );
00085     int                     (*pf_control)( sout_access_out_t *, int, va_list );
00086 
00087     config_chain_t          *p_cfg;
00088 };
00089 
00090 enum access_out_query_e
00091 {
00092     ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
00093 };
00094 
00095 VLC_API sout_access_out_t * sout_AccessOutNew( vlc_object_t *, const char *psz_access, const char *psz_name ) VLC_USED;
00096 #define sout_AccessOutNew( obj, access, name ) \
00097         sout_AccessOutNew( VLC_OBJECT(obj), access, name )
00098 VLC_API void sout_AccessOutDelete( sout_access_out_t * );
00099 VLC_API int sout_AccessOutSeek( sout_access_out_t *, off_t );
00100 VLC_API ssize_t sout_AccessOutRead( sout_access_out_t *, block_t * );
00101 VLC_API ssize_t sout_AccessOutWrite( sout_access_out_t *, block_t * );
00102 VLC_API int sout_AccessOutControl( sout_access_out_t *, int, ... );
00103 
00104 static inline bool sout_AccessOutCanControlPace( sout_access_out_t *p_ao )
00105 {
00106     bool b;
00107     if( sout_AccessOutControl( p_ao, ACCESS_OUT_CONTROLS_PACE, &b ) )
00108         return true;
00109     return b;
00110 }
00111 
00112 /** Muxer structure */
00113 struct  sout_mux_t
00114 {
00115     VLC_COMMON_MEMBERS
00116     module_t            *p_module;
00117 
00118     sout_instance_t     *p_sout;
00119 
00120     char                *psz_mux;
00121     config_chain_t          *p_cfg;
00122 
00123     sout_access_out_t   *p_access;
00124 
00125     int                 (*pf_addstream)( sout_mux_t *, sout_input_t * );
00126     int                 (*pf_delstream)( sout_mux_t *, sout_input_t * );
00127     int                 (*pf_mux)      ( sout_mux_t * );
00128     int                 (*pf_control)  ( sout_mux_t *, int, va_list );
00129 
00130     /* here are all inputs accepted by muxer */
00131     int                 i_nb_inputs;
00132     sout_input_t        **pp_inputs;
00133 
00134     /* mux private */
00135     sout_mux_sys_t      *p_sys;
00136 
00137     /* XXX private to stream_output.c */
00138     /* if muxer doesn't support adding stream at any time then we first wait
00139      *  for stream then we refuse all stream and start muxing */
00140     bool  b_add_stream_any_time;
00141     bool  b_waiting_stream;
00142     /* we wait one second after first stream added */
00143     mtime_t     i_add_stream_start;
00144 };
00145 
00146 enum sout_mux_query_e
00147 {
00148     /* capabilities */
00149     MUX_CAN_ADD_STREAM_WHILE_MUXING,    /* arg1= bool *,      res=cannot fail */
00150     /* properties */
00151     MUX_GET_ADD_STREAM_WAIT,            /* arg1= bool *,      res=cannot fail */
00152     MUX_GET_MIME,                       /* arg1= char **            res=can fail    */
00153 };
00154 
00155 struct sout_input_t
00156 {
00157     sout_instance_t *p_sout;
00158 
00159     es_format_t     *p_fmt;
00160     block_fifo_t    *p_fifo;
00161 
00162     void            *p_sys;
00163 };
00164 
00165 
00166 VLC_API sout_mux_t * sout_MuxNew( sout_instance_t*, const char *, sout_access_out_t * ) VLC_USED;
00167 VLC_API sout_input_t * sout_MuxAddStream( sout_mux_t *, es_format_t * ) VLC_USED;
00168 VLC_API void sout_MuxDeleteStream( sout_mux_t *, sout_input_t * );
00169 VLC_API void sout_MuxDelete( sout_mux_t * );
00170 VLC_API void sout_MuxSendBuffer( sout_mux_t *, sout_input_t  *, block_t * );
00171 VLC_API int sout_MuxGetStream(sout_mux_t *, int , mtime_t *);
00172 
00173 static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
00174 {
00175     va_list args;
00176     int     i_result;
00177 
00178     va_start( args, i_query );
00179     i_result = p_mux->pf_control( p_mux, i_query, args );
00180     va_end( args );
00181     return i_result;
00182 }
00183 
00184 /****************************************************************************
00185  * sout_stream:
00186  ****************************************************************************/
00187 struct sout_stream_t
00188 {
00189     VLC_COMMON_MEMBERS
00190 
00191     module_t          *p_module;
00192     sout_instance_t   *p_sout;
00193 
00194     char              *psz_name;
00195     config_chain_t        *p_cfg;
00196     sout_stream_t     *p_next;
00197 
00198     /* Subpicture unit */
00199     spu_t             *p_spu;
00200 
00201     /* add, remove a stream */
00202     sout_stream_id_t *(*pf_add)( sout_stream_t *, es_format_t * );
00203     int               (*pf_del)( sout_stream_t *, sout_stream_id_t * );
00204     /* manage a packet */
00205     int               (*pf_send)( sout_stream_t *, sout_stream_id_t *, block_t* );
00206 
00207     /* private */
00208     sout_stream_sys_t *p_sys;
00209 };
00210 
00211 VLC_API void sout_StreamChainDelete(sout_stream_t *p_first, sout_stream_t *p_last );
00212 VLC_API sout_stream_t *sout_StreamChainNew(sout_instance_t *p_sout,
00213         char *psz_chain, sout_stream_t *p_next, sout_stream_t **p_last) VLC_USED;
00214 
00215 static inline sout_stream_id_t *sout_StreamIdAdd( sout_stream_t *s, es_format_t *fmt )
00216 {
00217     return s->pf_add( s, fmt );
00218 }
00219 static inline int sout_StreamIdDel( sout_stream_t *s, sout_stream_id_t *id )
00220 {
00221     return s->pf_del( s, id );
00222 }
00223 static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, block_t *b )
00224 {
00225     return s->pf_send( s, id, b );
00226 }
00227 
00228 /****************************************************************************
00229  * Encoder
00230  ****************************************************************************/
00231 
00232 VLC_API encoder_t * sout_EncoderCreate( vlc_object_t *obj );
00233 #define sout_EncoderCreate(o) sout_EncoderCreate(VLC_OBJECT(o))
00234 
00235 /****************************************************************************
00236  * Announce handler
00237  ****************************************************************************/
00238 VLC_API session_descriptor_t* sout_AnnounceRegisterSDP( vlc_object_t *, const char *, const char * ) VLC_USED;
00239 VLC_API int sout_AnnounceUnRegister(vlc_object_t *,session_descriptor_t* );
00240 #define sout_AnnounceRegisterSDP(o, sdp, addr) \
00241         sout_AnnounceRegisterSDP(VLC_OBJECT (o), sdp, addr)
00242 #define sout_AnnounceUnRegister(o, a) \
00243         sout_AnnounceUnRegister(VLC_OBJECT (o), a)
00244 
00245 /** SDP */
00246 
00247 struct sockaddr;
00248 
00249 VLC_API char * vlc_sdp_Start( vlc_object_t *obj, const char *cfgpref, const struct sockaddr *src, size_t srclen, const struct sockaddr *addr, size_t addrlen ) VLC_USED;
00250 VLC_API char * sdp_AddMedia(char **sdp, const char *type, const char *protocol, int dport, unsigned pt, bool bw_indep, unsigned bw, const char *ptname, unsigned clockrate, unsigned channels, const char *fmtp);
00251 VLC_API char * sdp_AddAttribute(char **sdp, const char *name, const char *fmt, ...) VLC_FORMAT( 3, 4 );
00252 
00253 /** Description module */
00254 typedef struct sout_description_data_t
00255 {
00256     int i_es;
00257     es_format_t **es;
00258     vlc_sem_t *sem;
00259 } sout_description_data_t;
00260 
00261 #ifdef __cplusplus
00262 }
00263 #endif
00264 
00265 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines