vlc_sout.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * stream_output.h : stream output module
00003  *****************************************************************************
00004  * Copyright (C) 2002-2008 the VideoLAN team
00005  * $Id: 3a336bb1a4af70105d67112ca381c84882dd0be5 $
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
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 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 General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, 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 ouput in vlc
00034  */
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #include <vlc_es.h>
00041 
00042 /** Stream output instance */
00043 struct sout_instance_t
00044 {
00045     VLC_COMMON_MEMBERS
00046 
00047     char *psz_sout;
00048 
00049     /* meta data (Read only) XXX it won't be set before the first packet received */
00050     vlc_meta_t          *p_meta;
00051 
00052     /** count of output that can't control the space */
00053     int                 i_out_pace_nocontrol;
00054 
00055     vlc_mutex_t         lock;
00056     sout_stream_t       *p_stream;
00057 
00058     /** Private */
00059     sout_instance_sys_t *p_sys;
00060 };
00061 
00062 /** Stream output statistics */
00063 typedef enum
00064 {
00065     SOUT_STATISTIC_DECODED_VIDEO,
00066     SOUT_STATISTIC_DECODED_AUDIO,
00067     SOUT_STATISTIC_DECODED_SUBTITLE,
00068 
00069     /* Use them only if you do not goes through a access_out module */
00070     SOUT_STATISTIC_SENT_PACKET,
00071     SOUT_STATISTIC_SENT_BYTE,
00072 
00073 } sout_statistic_t;
00074 
00075 VLC_EXPORT( void, sout_UpdateStatistic, ( sout_instance_t *p_sout, sout_statistic_t, int ) );
00076 
00077 /****************************************************************************
00078  * sout_stream_id_t: opaque (private for all sout_stream_t)
00079  ****************************************************************************/
00080 typedef struct sout_stream_id_t  sout_stream_id_t;
00081 
00082 /** Stream output access_output */
00083 struct sout_access_out_t
00084 {
00085     VLC_COMMON_MEMBERS
00086 
00087     module_t                *p_module;
00088     char                    *psz_access;
00089 
00090     int                      i_writes;
00091     /** Local counter reset each time it is transferred to stats */
00092     int64_t                  i_sent_bytes;
00093 
00094     char                    *psz_path;
00095     sout_access_out_sys_t   *p_sys;
00096     int                     (*pf_seek)( sout_access_out_t *, off_t );
00097     ssize_t                 (*pf_read)( sout_access_out_t *, block_t * );
00098     ssize_t                 (*pf_write)( sout_access_out_t *, block_t * );
00099     int                     (*pf_control)( sout_access_out_t *, int, va_list );
00100 
00101     config_chain_t          *p_cfg;
00102 };
00103 
00104 enum access_out_query_e
00105 {
00106     ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
00107 };
00108 
00109 VLC_EXPORT( sout_access_out_t *,sout_AccessOutNew, ( vlc_object_t *, const char *psz_access, const char *psz_name ) LIBVLC_USED );
00110 #define sout_AccessOutNew( obj, access, name ) \
00111         sout_AccessOutNew( VLC_OBJECT(obj), access, name )
00112 VLC_EXPORT( void, sout_AccessOutDelete, ( sout_access_out_t * ) );
00113 VLC_EXPORT( int, sout_AccessOutSeek, ( sout_access_out_t *, off_t ) );
00114 VLC_EXPORT( ssize_t, sout_AccessOutRead, ( sout_access_out_t *, block_t * ) );
00115 VLC_EXPORT( ssize_t, sout_AccessOutWrite, ( sout_access_out_t *, block_t * ) );
00116 VLC_EXPORT( int, sout_AccessOutControl, ( sout_access_out_t *, int, ... ) );
00117 
00118 static inline bool sout_AccessOutCanControlPace( sout_access_out_t *p_ao )
00119 {
00120     bool b;
00121     if( sout_AccessOutControl( p_ao, ACCESS_OUT_CONTROLS_PACE, &b ) )
00122         return true;
00123     return b;
00124 }
00125 
00126 /** Muxer structure */
00127 struct  sout_mux_t
00128 {
00129     VLC_COMMON_MEMBERS
00130     module_t            *p_module;
00131 
00132     sout_instance_t     *p_sout;
00133 
00134     char                *psz_mux;
00135     config_chain_t          *p_cfg;
00136 
00137     sout_access_out_t   *p_access;
00138 
00139     int                 (*pf_addstream)( sout_mux_t *, sout_input_t * );
00140     int                 (*pf_delstream)( sout_mux_t *, sout_input_t * );
00141     int                 (*pf_mux)      ( sout_mux_t * );
00142     int                 (*pf_control)  ( sout_mux_t *, int, va_list );
00143 
00144     /* here are all inputs accepted by muxer */
00145     int                 i_nb_inputs;
00146     sout_input_t        **pp_inputs;
00147 
00148     /* mux private */
00149     sout_mux_sys_t      *p_sys;
00150 
00151     /* XXX private to stream_output.c */
00152     /* if muxer doesn't support adding stream at any time then we first wait
00153      *  for stream then we refuse all stream and start muxing */
00154     bool  b_add_stream_any_time;
00155     bool  b_waiting_stream;
00156     /* we wait one second after first stream added */
00157     mtime_t     i_add_stream_start;
00158 };
00159 
00160 enum sout_mux_query_e
00161 {
00162     /* capabilities */
00163     MUX_CAN_ADD_STREAM_WHILE_MUXING,    /* arg1= bool *,      res=cannot fail */
00164     /* properties */
00165     MUX_GET_ADD_STREAM_WAIT,            /* arg1= bool *,      res=cannot fail */
00166     MUX_GET_MIME,                       /* arg1= char **            res=can fail    */
00167 };
00168 
00169 struct sout_input_t
00170 {
00171     sout_instance_t *p_sout;
00172 
00173     es_format_t     *p_fmt;
00174     block_fifo_t    *p_fifo;
00175 
00176     void            *p_sys;
00177 };
00178 
00179 
00180 VLC_EXPORT( sout_mux_t *,   sout_MuxNew,          ( sout_instance_t*, const char *, sout_access_out_t * ) LIBVLC_USED );
00181 VLC_EXPORT( sout_input_t *, sout_MuxAddStream,    ( sout_mux_t *, es_format_t * ) LIBVLC_USED );
00182 VLC_EXPORT( void,           sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
00183 VLC_EXPORT( void,           sout_MuxDelete,       ( sout_mux_t * ) );
00184 VLC_EXPORT( void,           sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t  *, block_t * ) );
00185 VLC_EXPORT( int,            sout_MuxGetStream, (sout_mux_t *, int , mtime_t *));
00186 
00187 static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
00188 {
00189     va_list args;
00190     int     i_result;
00191 
00192     va_start( args, i_query );
00193     i_result = p_mux->pf_control( p_mux, i_query, args );
00194     va_end( args );
00195     return i_result;
00196 }
00197 
00198 /****************************************************************************
00199  * sout_stream:
00200  ****************************************************************************/
00201 struct sout_stream_t
00202 {
00203     VLC_COMMON_MEMBERS
00204 
00205     module_t          *p_module;
00206     sout_instance_t   *p_sout;
00207 
00208     char              *psz_name;
00209     config_chain_t        *p_cfg;
00210     sout_stream_t     *p_next;
00211 
00212     /* Subpicture unit */
00213     spu_t             *p_spu;
00214 
00215     /* add, remove a stream */
00216     sout_stream_id_t *(*pf_add)( sout_stream_t *, es_format_t * );
00217     int               (*pf_del)( sout_stream_t *, sout_stream_id_t * );
00218     /* manage a packet */
00219     int               (*pf_send)( sout_stream_t *, sout_stream_id_t *, block_t* );
00220 
00221     /* private */
00222     sout_stream_sys_t *p_sys;
00223 };
00224 
00225 VLC_EXPORT( void, sout_StreamChainDelete, (sout_stream_t *p_first, sout_stream_t *p_last ) );
00226 VLC_EXPORT( sout_stream_t *, sout_StreamChainNew, (sout_instance_t *p_sout,
00227         char *psz_chain, sout_stream_t *p_next, sout_stream_t **p_last) LIBVLC_USED );
00228 
00229 static inline sout_stream_id_t *sout_StreamIdAdd( sout_stream_t *s, es_format_t *fmt )
00230 {
00231     return s->pf_add( s, fmt );
00232 }
00233 static inline int sout_StreamIdDel( sout_stream_t *s, sout_stream_id_t *id )
00234 {
00235     return s->pf_del( s, id );
00236 }
00237 static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, block_t *b )
00238 {
00239     return s->pf_send( s, id, b );
00240 }
00241 
00242 /****************************************************************************
00243  * Encoder
00244  ****************************************************************************/
00245 
00246 VLC_EXPORT( encoder_t *, sout_EncoderCreate, ( vlc_object_t *obj ) );
00247 #define sout_EncoderCreate(o) sout_EncoderCreate(VLC_OBJECT(o))
00248 
00249 /****************************************************************************
00250  * Announce handler
00251  ****************************************************************************/
00252 VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, ( vlc_object_t *, const char *, const char *, announce_method_t* ) LIBVLC_USED );
00253 VLC_EXPORT( int,                sout_AnnounceUnRegister, (vlc_object_t *,session_descriptor_t* ) );
00254 #define sout_AnnounceRegisterSDP(o, sdp, addr, m) \
00255         sout_AnnounceRegisterSDP(VLC_OBJECT (o), sdp, addr, m)
00256 #define sout_AnnounceUnRegister(o, a) \
00257         sout_AnnounceUnRegister(VLC_OBJECT (o), a)
00258 
00259 VLC_EXPORT(announce_method_t*,   sout_SAPMethod, (void) LIBVLC_USED );
00260 VLC_EXPORT(void,                 sout_MethodRelease, (announce_method_t *) );
00261 
00262 /** SDP */
00263 
00264 VLC_EXPORT( 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 ) LIBVLC_USED );
00265 VLC_EXPORT( 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) );
00266 VLC_EXPORT( char *, sdp_AddAttribute, (char **sdp, const char *name, const char *fmt, ...) LIBVLC_FORMAT( 3, 4 ) );
00267 
00268 
00269 #ifdef __cplusplus
00270 }
00271 #endif
00272 
00273 #endif

Generated on Mon Nov 22 07:55:20 2010 for VLC by  doxygen 1.5.6