Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

streammgr.hh

00001 /*
00002  * PIAVE - PIAVE Is A Video Editor
00003  *
00004  * Copyright (C) 2002 Rolf Dubitzky, rolf@dubitzky.de
00005  *
00006  */
00007 
00008 /*
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023 
00024 
00029 #if ! defined( STREAMMGR_HH )
00030 #define STREAMMGR_HH
00031 
00032 // stdc
00033 #include <signal.h>
00034 #include <unistd.h>
00035 #include <fcntl.h>
00036 #include <sys/stat.h>
00037 
00038 // stdc++
00039 #include <string>
00040 #include <map>
00041 #include <vector>
00042 
00043 // PIAVE
00044 #include "piave_base.hh"
00045 
00046 namespace PIAVE {
00047 
00048     class PropertyNode;
00049     class Stream;
00050     class InAVStreamIFace;
00051     class InAudioStreamIFace;
00052     class InAVFStream;
00053     class InAudioFStream;
00054     class OutAVStreamIFace;
00055     class OutAudioStreamIFace;
00056 
00070     class StreamMgr
00071     {
00072       private:
00073         StreamMgr();
00074 
00075       public:
00076         static StreamMgr * Inst() {
00077             if (!_singleton) _singleton = new StreamMgr();
00078             return _singleton;
00079         }
00080 
00081         /* get video input, with properties described in p */        
00082         static InAVStreamIFace * getAVInput( const PropertyNode * p );
00083         /* get audio input, with properties described in p */        
00084         static InAudioStreamIFace * getAudioInput( const PropertyNode * p );
00085 
00086         /* shortcut for above to get input direct from file
00087          * the StreamMgr will try to find a plugin that can handle
00088          * the format of <filename>.
00089          */
00090         static InAVFStream * getAVInput( const std::string& fileName );
00091         static InAudioFStream * getAudioInput( const std::string& fileName );
00092 
00093         /* in case we don't know if it's audio or video */
00094         static Stream * getInput( const std::string& fileName );
00095 
00096         /* get av output, with properties described in p */        
00097         static OutAVStreamIFace * getOutAVStream( const PropertyNode * p );
00098         static OutAudioStreamIFace * getOutAudioStream( const PropertyNode * p );
00099 
00100         /* try to expand a given filename with all existing path entries
00101          * \return true if file was found, false otherwise
00102          */
00103         static bool expandFileName( const::string fileName );
00104         
00105         /* add a directory to the list of dirs to search for files */
00106         static void addPathEntry( const::string path ) { Inst()->_pathList.push_back( path ); }
00107         
00108       private:
00109         /* try to find the appropriate stream plugin */
00110         InAVFStream * openInAVFStream( const std::string& fileName );
00111         
00112       private:
00113         static StreamMgr * _singleton;
00114 
00115         /* files are opened just once. _One_ stream per file.
00116          * this stream may be used in many AVChunks
00117          */
00118         std::map< std::string, InAVFStream* > _inAVStreams;
00119 
00120         /* a list of paths to search for files */
00121         std::vector< string > _pathList;
00122     };
00123 
00124 };
00125 
00126 #endif

Generated on Tue Oct 14 20:45:37 2003 for piave by doxygen1.2.18