Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
Visualizer.cpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: Visualizer.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #include "Visualizer.hpp" 00045 #ifdef ENABLE_SDL 00046 #include "io/SDLRenderer.hpp" 00047 #endif 00048 #ifdef ENABLE_QT 00049 #include "io/QLabelRenderer.hpp" 00050 #endif 00051 #ifdef ENABLE_X11 00052 #include "io/X11Renderer.hpp" 00053 #endif 00054 00055 Visualizer::Visualizer(const VideoESInfo * esi, OutputMethod out, UncompressedVideoFrame::ColorSpace colorSpace) { 00056 firstFrame = true; 00057 initialized = false; 00058 this->colorSpace = colorSpace; 00059 output = out; 00060 assert(esi); 00061 es = esi; 00062 switch (output) { 00063 case SDL: 00064 #ifdef ENABLE_SDL 00065 //this renderer automatically creates an output-SDL-surface (window) 00066 renderer = new SDLRenderer(es, colorSpace, 0,0, 00067 #ifdef BUILD_ARCH_ARM 00068 true //enable fullScreen 00069 #else 00070 false //no fullScreen 00071 #endif 00072 ,true /* pollEvents */, true /* isLabelResizable */, 00073 true /* fixAspectRatio */ , false /* allowUpscaleX */, 00074 false /* rotateXDisplay */ ); 00075 #else 00076 dprintf_err("Visualizer: ViTooKi was compiled without SDL support!\n"); 00077 ::exit(1); 00078 #endif 00079 break; 00080 00081 case Qt: 00082 #ifdef ENABLE_QT 00083 #else 00084 dprintf_err("Visualizer: ViTooKi was compiled without Qt support!\n"); 00085 ::exit(1); 00086 #endif 00087 00088 case X11: 00089 #ifdef ENABLE_X11 00090 //this renderer automatically creates an output-X11-window on the default display 00091 renderer = new X11Renderer(es, colorSpace, 0,0, true, true, true, false ); 00092 #else 00093 dprintf_err("Visualizer: ViTooKi was compiled without X11 support!\n"); 00094 ::exit(1); 00095 #endif 00096 break; 00097 00098 default: 00099 //make compiler happy 00100 break; 00101 } 00102 00103 dprintf_full("Visualizer created (%ix%i) for outputIO: %s\n", es->getWidth(), es->getHeight(), renderer->getURL()); 00104 strcpy(name,"Visualizer"); 00105 } 00106 00107 00108 void Visualizer::initialize() { 00109 firstFrame = true; 00110 00111 width = es->getWidth(); 00112 height = es->getHeight(); 00113 00114 initialized = true; 00115 dprintf_full("Visualizer initialized\n"); 00116 } 00117 00118 00119 list < Frame * >Visualizer::adapt(Frame * frm) { 00120 list < Frame * >f; 00121 if (!initialized) 00122 initialize(); 00123 00124 if (!(frm && frm->getAU() && frm->getAU()->payload)) 00125 return f; //don't forward frame 00126 00127 if (firstFrame) { 00128 if (!renderer->open()) { 00129 dprintf_err("Visualizer: FATAL: could not open outputIO %s\n",renderer->getURL()); 00130 } else 00131 firstFrame = false; 00132 } 00133 00134 if (renderer->writeFrame(frm) < 1) { //couldn't be displayed! 00135 //don't forward frame 00136 if (renderer->getState() == IO::STREAMERR) 00137 ::exit(0); 00138 } else 00139 f.push_front(frm); 00140 00141 00142 return f; 00143 } 00144 00145 00146 list < Frame * >Visualizer::close() { 00147 list < Frame * >f; 00148 return f; 00149 }