Main Page   Modules   Compound List   File List   Compound Members   File Members  

xlv_pipeline.h

Go to the documentation of this file.
00001 /*
00002  * xlv_pipeline.h
00003  *
00004  * Copyright (C) 2001 Guilhem Lavaux - guilhem.lavaux@free.fr
00005  *
00006  * This file is part of XLV, a free middleware audio-video stream coder/decoder.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * XLV is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00025 #ifndef _XLV_PIPELINE_H
00026 #define _XLV_PIPELINE_H
00027 #include <glib.h>
00028 #include "xlv_plugin_mgr.h"
00029 #include "xlv_codec.h"
00030 #include "xlv_session.h"
00031 
00059 typedef struct _XLV_Pipeline XLV_Pipeline;
00060 typedef struct _XLV_PipelineElement XLV_PipelineElement;
00061 typedef struct _XLV_PipelineFrame XLV_PipelineFrame;
00062 
00066 #define XLV_ELEMENT_SOURCE     0
00067 #define XLV_ELEMENT_PARSER     1
00068 #define XLV_ELEMENT_RENDERER   2
00069 #define XLV_ELEMENT_CODEC      3
00070 #define XLV_ELEMENT_TRANSLATOR 4
00071 #define XLV_ELEMENT_WRITER     5
00072 #define XLV_ELEMENT_MUXER      6
00073 /* @} */
00074 
00078 #define XLV_PIPELINE_FRAME_NOERROR 0
00079 #define XLV_PIPELINE_FRAME_EOS     1
00080 #define XLV_PIPELINE_FRAME_SKIP    2
00081 #define XLV_PIPELINE_FRAME_ERROR   3
00082 
00087 #define XLV_PIPELINE_FLAGS_KEY_FRAME 0x0001
00088 #define XLV_PIPELINE_FLAGS_SPECIFIC  0x8000
00089 
00091 #ifdef XLV_INTERNAL
00092 struct _XLV_Pipeline {
00093     GList *m_elements;
00094     GList *m_leaves;
00095 };
00096 #endif
00097 
00099 struct _XLV_PipelineFrame {
00101     gpointer m_data;
00103     guint32 m_length;
00106     guint8 m_state;
00109     guint32 m_timestamp;
00111     guint16 m_generic_flags;
00113     guint16 m_specific_flags;
00114 };
00115 
00116 typedef gboolean (*XLV_PipelineElement_InitFunc) (XLV_PipelineElement *
00117                                                   element, gpointer udata);
00118 typedef gboolean (*XLV_PipelineElement_StopFunc) (XLV_PipelineElement *
00119                                                   element);
00120 typedef gboolean (*XLV_PipelineElement_SetupFunc) (XLV_PipelineElement *
00121                                                    element,
00122                                                    XLV_PipelineElement *
00123                                                    caller,
00124                                                    gpointer setup_data);
00125 typedef gboolean (*XLV_PipelineElement_ChainTo) (XLV_PipelineElement *
00126                                                  element, guint16 id);
00127 typedef gboolean (*XLV_PipelineElement_GetFrame) (XLV_PipelineElement *
00128                                                   element,
00129                                                   XLV_PipelineFrame * frame);
00130 typedef gboolean (*XLV_PipelineElement_GetFastFrame) (XLV_PipelineElement *
00131                                                       element,
00132                                                       XLV_PipelineFrame *
00133                                                       frame);
00134 typedef gboolean (*XLV_PipelineElement_PutFrame) (XLV_PipelineElement *
00135                                                   element,
00136                                                   XLV_PipelineFrame * frame);
00137 typedef gboolean (*XLV_PipelineElement_PutFastFrame) (XLV_PipelineElement *
00138                                                       element,
00139                                                       XLV_PipelineFrame *
00140                                                       frame);
00141 typedef gboolean (*XLV_PipelineElement_SkipFrame) (XLV_PipelineElement *
00142                                                    element);
00143 typedef gboolean (*XLV_PipelineElement_Execute) (XLV_PipelineElement *
00144                                                  element);
00151 struct _XLV_PipelineElement {
00155     const gchar *m_element_name;
00166     guint8 m_element_type;
00170     gpointer m_elt_data;
00171 
00175     XLV_PipelineElement_InitFunc m_element_init;
00178     XLV_PipelineElement_StopFunc m_element_stop;
00181     XLV_PipelineElement_SetupFunc m_element_setup;
00183     XLV_PipelineElement_ChainTo m_element_chain_to;
00185     XLV_PipelineElement_ChainTo m_element_unchain_to;
00187     XLV_PipelineElement_ChainTo m_element_chain_from;
00189     XLV_PipelineElement_ChainTo m_element_unchain_from;
00190     XLV_PipelineElement_GetFrame m_element_get_frame;
00191     XLV_PipelineElement_GetFastFrame m_element_get_fast_frame;
00192     XLV_PipelineElement_PutFrame m_element_put_frame;
00193     XLV_PipelineElement_PutFastFrame m_element_put_fast_frame;
00194     XLV_PipelineElement_SkipFrame m_element_skip_frame;
00195     XLV_PipelineElement_Execute m_element_execute;
00196 
00197     guint16 m_id;
00198 
00199     XLV_Pipeline *m_pipeline;
00200     XLV_Stream *m_element_implementation;
00201 #ifdef XLV_INTERNAL
00202     GList *m_output_chain;
00203     GList *m_parents_element;
00204 #endif
00205 };
00206 
00207 #ifdef __cplusplus
00208 extern "C" {
00209 #endif
00210 
00218     XLV_Pipeline *xlv_pipeline_new ();
00219 
00228     void xlv_pipeline_release (XLV_Pipeline * pipeline);
00229 
00243     glong xlv_pipeline_add_element (XLV_Pipeline * pipeline,
00244                                     XLV_PipelineElement * e,
00245                                     XLV_Stream * s, gpointer udata);
00246 
00249     XLV_Stream *xlv_pipeline_get_implementation (XLV_Pipeline * pipeline,
00250                                                  guint16 id);
00251 
00259     GList *xlv_pipeline_get_parents (XLV_PipelineElement * element);
00267     GList *xlv_pipeline_get_outputs (XLV_PipelineElement * element);
00275     XLV_PipelineElement *xlv_pipeline_get_type_next (XLV_Pipeline * pipeline,
00276                                                      guint8 type,
00277                                                      XLV_PipelineElement *
00278                                                      element);
00279 
00289     XLV_PipelineElement *xlv_pipeline_get_element (XLV_Pipeline * pipeline,
00290                                                    guint16 id);
00291 
00299     gboolean xlv_pipeline_chain (XLV_Pipeline * pipeline,
00300                                  guint16 id_orig, guint16 id_dest);
00302     gboolean xlv_pipeline_unchain (XLV_Pipeline * pipeline,
00303                                    guint16 id_orig, guint16 id_dest);
00304 
00306     GList *xlv_pipeline_get_leaves (XLV_Pipeline * pipeline);
00307 
00309     XLV_Stream *xlv_pipeline_to_stream (XLV_Pipeline * pipeline, guint16 id);
00310 
00312     gboolean xlv_pipeline_propagate_setup (XLV_PipelineElement * pipeline,
00313                                            gpointer udata);
00314 
00316     gboolean xlv_pipeline_setup (XLV_Pipeline * pipeline);
00317 
00319     gboolean xlv_pipeline_execute (XLV_Pipeline * pipeline, gboolean all);
00320 
00322     gboolean xlv_pipeline_spawn (XLV_Pipeline * pipeline);
00323 
00324 /* This is a library of default elements */
00325     glong xlv_pipeline_add_source (XLV_Pipeline * pipeline, XLV_Stream * s);
00326     glong xlv_pipeline_add_writer (XLV_Pipeline * pipeline, XLV_Stream * s);
00327     glong xlv_pipeline_add_parser (XLV_Pipeline * pipeline,
00328                                    XLV_Session * session);
00329     glong xlv_pipeline_add_codec (XLV_Pipeline * pipeline, XLV_Stream * s);
00330     glong xlv_pipeline_add_translator (XLV_Pipeline * pipeline,
00331                                        XLV_Stream * s);
00332     glong xlv_pipeline_add_video_output (XLV_Pipeline * pipeline,
00333                                          XLV_Stream * s);
00334     glong xlv_pipeline_add_audio_output (XLV_Pipeline * pipeline,
00335                                          XLV_Stream * s);
00336 
00337     /* Some elements more clever */
00338     glong xlv_pipeline_add_video_translator (XLV_Pipeline * pipeline,
00339                                              XLV_Session * session,
00340                                              guint32 coding_req, glong id);
00341 
00343     gboolean xlv_pipeline_default_build (XLV_Pipeline * pipeline,
00344                                          XLV_Session * session,
00345                                          XLV_Stream * source);
00346     XLV_Pipeline *xlv_pipeline_load_file (XLV_Session * session,
00347                                           const gchar * filename);
00348 
00349 #ifdef __cplusplus
00350 }
00351 #endif
00352 static inline gboolean
00353 xlv_pipeline_get_fast_frame (XLV_PipelineElement * element,
00354                              XLV_PipelineFrame * frame)
00355 {
00356     if (element->m_element_get_fast_frame)
00357         return element->m_element_get_fast_frame (element, frame);
00358     else if (element->m_element_get_frame)
00359         return element->m_element_get_frame (element, frame);
00360     else
00361         return FALSE;
00362 }
00363 
00364 static inline gboolean
00365 xlv_pipeline_get_frame (XLV_PipelineElement * element,
00366                         XLV_PipelineFrame * frame)
00367 {
00368     if (element->m_element_get_frame)
00369         return element->m_element_get_frame (element, frame);
00370     return FALSE;
00371 }
00372 
00373 static inline gboolean
00374 xlv_pipeline_put_fast_frame (XLV_PipelineElement * element,
00375                              XLV_PipelineFrame * frame)
00376 {
00377     if (element->m_element_put_fast_frame)
00378         return element->m_element_put_fast_frame (element, frame);
00379     else if (element->m_element_put_frame)
00380         return element->m_element_put_frame (element, frame);
00381     else
00382         return FALSE;
00383 }
00384 
00385 static inline gboolean
00386 xlv_pipeline_elt_execute (XLV_PipelineElement * element)
00387 {
00388     if (element->m_element_execute)
00389         return element->m_element_execute (element);
00390     else
00391         return FALSE;
00392 }
00393 
00396 #endif

Generated on Mon Jul 1 19:39:06 2002 for XLV by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002