SimpleMxPEGRenderer.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 15:34:53 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/MxPEGCoreComponent/trunk/include/SimpleMxPEGRenderer.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licensed under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MX_SIMPLEMXPEGRENDERER_H__
00061 #define __MX_SIMPLEMXPEGRENDERER_H__
00062 
00063 
00064 
00065 #define MX_SIMPLEMXPEGRENDERER_ID "SimpleMxPEGRenderer"
00066 
00067 
00068 
00069 #include "BufferedMxPEGDecoderBackEnd.h"
00070 
00071 #include <interfaces/IComponent.h>
00072 #include <interfaces/IComponentInvoker.h>
00073 #include <interfaces/ISimpleMxPEGRenderer.h>
00074 
00075 #include <Framework/Framework.h>
00076 
00077 #include <mxm/core/mxmStringList.h>
00078 #include <mxm/core/mxmString.h>
00079 #include <mxm/core/mxm_smart.h>
00080 
00081 #include <QObject>
00082 #include <QTime>
00083 #include <QGLWidget>
00084 
00085 
00086 
00087 namespace mx {
00088    
00092 
00097    class SimpleMxPEGRenderer : public QObject,
00098                                public BufferedMxPEGDecoderBackEnd,
00099                                public virtual IComponent,
00100                                public virtual ISimpleMxPEGRenderer {
00101    
00102       Q_OBJECT
00103       
00104     private:
00105       bool Active;
00106       QGLWidget *Viewer;
00107       int CenterX, CenterY,
00108           OffsetX, OffsetY;
00109       int FrameCount;
00110       int FramerateMeasureInterval;
00111       QTime FramerateMeasureTime;
00112       int FramerateFrameCount;
00113       bool ScaleToFit;
00114       bool SignalledFirstFrame;
00115       bool ErrorEncountered;
00116       
00120     private:
00121       static mxm::smart<mxmStringList> _enumerateInterfaces() {
00122          return(new mxmStringList((mxmString(MX_SIMPLEMXPEGRENDERER_ID),
00123                                    MX_ICOMPONENT_ID,
00124                                    MX_ISIMPLEMXPEGRENDERER_ID,
00125                                    MX_IMXPEGTILERECEIVER_ID,
00126                                    MX_IERRORSTATE_ID)));
00127       }
00128       static mxm::smart<mxmStringList> _enumerateCapabilities(
00129                                          const mxmString &interface_id) {
00130          if(interface_id == mx::Framework::IdHintKey)
00131           return(new mxmStringList(MX_SIMPLEMXPEGRENDERER_ID));
00132          else
00133           return(new mxmStringList());
00134       }
00135       
00136     private:
00137       class Invoker : public mxmObject, public virtual IComponentInvoker {
00138        public:
00139          mxm::smart<mxmStringList> enumerateInterfaces() {
00140             return(_enumerateInterfaces());
00141          }
00142          mxm::smart<mxmStringList> enumerateCapabilities(
00143                                      const mxmString &interface_id) {
00144             return(_enumerateCapabilities(interface_id));
00145          }
00146          IComponent *newComponent() {
00147             return(new SimpleMxPEGRenderer());
00148          }
00149       };
00150     public:
00152       static IComponentInvoker *newInvoker() {
00153          return(new Invoker());
00154       }
00155       
00156     public:
00159       SimpleMxPEGRenderer();
00160       ~SimpleMxPEGRenderer();
00161       
00162     signals:
00166       void framerateMeasured(float fps);
00168       void firstFrameRendered();
00169       
00170     public:
00172       mxm::smart<mxmStringList> enumerateInterfaces() {
00173          return(_enumerateInterfaces());
00174       }
00176       mxm::smart<mxmStringList> enumerateCapabilities(
00177                                    const mxmString &interface_id) {
00178          return(_enumerateCapabilities(interface_id));
00179       }
00180       
00182       void setGLWidget(QGLWidget *viewer_display);
00184       void setFramerateMeasureModeEnabled(bool enabled,
00185                                           int measure_interval_ms = 10000);
00187       void enableScaleToFit(bool enabled);
00189       void drawFrame();
00191       mxmQtSignal framerateMeasuredSignal();
00193       mxmQtSignal firstFrameRenderedSignal();
00194       
00196       void videoResolutionChanged(int width, int height);
00198       void errorEncountered();
00200       void frameComplete();
00202       void videoTileTransferred();
00204       mxm::u8 *provideAudioBlockTarget(const mxmAudioBlockInfo
00205                                        &audio_block_info);
00207       void audioBlockTransferred();
00209       int frameCounter();
00210       
00212       void setErrorState();
00214       bool errorState();
00215       
00216     private:
00217       bool activate();
00218    };
00219 };
00220 
00221 
00222 
00223 #endif   // __MX_SIMPLEMXPEGRENDERER_H__

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6