Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsav.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSAV_H_
00034 #define MMSAV_H_
00035 
00036 #include <sys/stat.h>
00037 #include <sigc++/sigc++.h>
00038 #ifdef __HAVE_GSTREAMER__
00039 #include <gst/gst.h>
00040 //#include <gst/interfaces/navigation.h>
00041 #endif
00042 #ifdef __HAVE_XINE__
00043 #include <xine.h>
00044 #endif
00045 #include <map>
00046 #include "mmsgui/mmsgui.h"
00047 #include "mmstools/mmstools.h"
00048 #ifdef __HAVE_XV__
00049 #include <X11/extensions/Xv.h>
00050 #include <X11/extensions/Xvlib.h>
00051 #endif
00052 
00053 
00054 #ifdef __HAVE_GSTREAMER__
00055 
00056 typedef struct {
00057     //! uri which is to play
00058     string      uri;
00059 
00060     //! top-level gst element
00061     GstElement  *pipeline;
00062 } GST_DISKOVIDEOSINK_DATA;
00063 
00064 
00065 
00066 #endif
00067 
00068 #ifdef __HAVE_XINE__
00069 
00070 /**
00071  * @brief   Video output description structure.
00072  *
00073  * This structure is needed for the callbacks that are used by the
00074  * xine video output driver.
00075  */
00076 typedef struct {
00077     MMSFBSurface            *winsurface;        /**< surface of window          */
00078 #ifdef __HAVE_DIRECTFB__
00079     DFBWindowDescription    windsc;             /**< description of window      */
00080     DFBSurfacePixelFormat   format;             /**< pixel format of surface    */
00081 #endif
00082     double                  ratio;              /**< ratio of video stream      */
00083     int                     width;              /**< width of video stream      */
00084     int                     height;             /**< height of video stream     */
00085     MMSFBRectangle          rect;               /**< rectangle for video stream  */
00086 } VODESC;
00087 
00088 #ifdef __HAVE_DIRECTFB__
00089 
00090 typedef void (*DVOutputCallback) (void *cdata, int width, int height,
00091                                   double ratio, DFBSurfacePixelFormat format,
00092                                   DFBRectangle *dest_rect);
00093 
00094 /**
00095  * @brief   Structure needed by xine_open_video_driver().
00096  *
00097  * This structure holds surfaces and callbacks that handle
00098  * video playback.
00099  */
00100 typedef struct {
00101     IDirectFBSurface    *destination;           /**< destination surface                                */
00102     IDirectFBSurface    *subpicture;            /**< subpicture surface                                 */
00103     DVOutputCallback    output_cb;              /**< output callback for DirectFB's xine video driver   */
00104     void                *output_cdata;          /**< data given as an argument to output_cb             */
00105     DVFrameCallback     frame_cb;               /**< frame callback for DirectFB's xine video driver    */
00106     void                *frame_cdata;           /**< data given as an argument to frame_cb              */
00107 } dfb_visual_t;
00108 
00109 #endif /* __HAVE_DIRECTFB__ */
00110 #endif /* __HAVE_XINE__ */
00111 
00112 typedef struct {
00113     MMSFBSurface *surf;
00114     MMSFBSurfacePixelFormat surf_pixelformat;
00115     MMSFBRectangle size;
00116     MMSFBRectangle dest;
00117     double lastaspect;
00118     MMSFBSurface *interim;
00119     //! interim overlay surface
00120     MMSFBSurface *overlayInterim;
00121     //! number of currently available overlays
00122     int numOverlays;
00123 #ifdef __HAVE_XINE__
00124     //! array of numOverlays overlays
00125     raw_overlay_t *overlays;
00126 #endif
00127 } MMSRAW_USERDATA;
00128 
00129 /**
00130  * @brief   MMS Audio/Video handling class.
00131  *
00132  * @ingroup     mmsmedia
00133  *
00134  * @author      Stefan Schwarzer (stefan.schwarzer@diskohq.org)
00135  * @author      Matthias Hardt (matthias.hardt@diskohq.org)
00136  * @author      Jens Schneider (pupeider@gmx.de)
00137  * @author      Guido Madaus (guido.madaus@diskohq.org)
00138  * @author      Patrick Helterhoff (patrick.helterhoff@diskohq.org)
00139  * @author      René Bählkow (rene.baehlkow@diskohq.org)
00140  *
00141  * It is the base class for all audio and video related
00142  * classes.
00143  */
00144 class MMSAV
00145 {
00146     private:
00147         sigc::connection onHandleInputConnection;
00148 
00149         MMSRAW_USERDATA                 userd;
00150 
00151 #ifdef __HAVE_GSTREAMER__
00152         GST_DISKOVIDEOSINK_DATA         gst_diskovideosink_data;
00153 #endif
00154 
00155 #ifdef __HAVE_XINE__
00156 #ifdef __HAVE_DIRECTFB__
00157         VODESC                          vodesc;                                 /**< video output settings              */
00158         dfb_visual_t                    visual;                                 /**< visual structure for video output  */
00159 #endif /* __HAVE_DIRECTFB__ */
00160         raw_visual_t                    rawvisual;
00161 
00162         pthread_mutex_t                 lock;
00163 
00164         bool setPostPluginParameter(map<string, xine_post_t*> plugins, string name, string parameter, string value);
00165 #endif /* __HAVE_XINE__ */
00166 
00167     protected:
00168 
00169         //! backend which is used to stream any sources
00170         MMSMEDIABackend     backend;
00171 
00172         //! window which displays the stream
00173         MMSWindow           *window;
00174 
00175         //! surface of the window
00176         MMSFBSurface        *surface;
00177 
00178         bool                            verbose;                                /**< should logging be verbose?         */
00179         short                           status;                                 /**< current playback status            */
00180         int                             pos;                                    /**< remember position where the stream stopped last time */
00181 
00182 
00183 #ifdef __HAVE_GSTREAMER__
00184         //! init gstreamer
00185         void gstInit(const string uri);
00186 
00187         //! current mrl
00188 #endif
00189         string currentMRL;
00190 
00191 #ifdef __HAVE_XINE__
00192 
00193 
00194         // xine related attributes
00195         xine_t                          *xine;                                  /**< global xine structure                  */
00196         xine_video_port_t               *vo;                                    /**< xine video ports                       */
00197         xine_audio_port_t               *ao;                                    /**< xine audio ports                       */
00198         xine_stream_t                   *stream;                                /**< xine stream                            */
00199         xine_event_queue_t              *queue;                                 /**< xine event queue                       */
00200         map<string, xine_post_t*>       audioPostPlugins,                       /**< map of registered audio post plugins   */
00201                                         videoPostPlugins;                       /**< map of registered video post plugins   */
00202 
00203 
00204 
00205         void xineInit();
00206         void xineOpen(xine_event_listener_cb_t queue_cb = NULL, void *userData = NULL);
00207 
00208 #endif
00209 
00210         // internal methods
00211         void initialize(const bool verbose = false, MMSWindow *window = NULL);
00212         void setStatus(int status);
00213         void sendEvent(int type, void *data = NULL, int datalen = 0);
00214 
00215 
00216         bool sendKeyPress(MMSKeySymbol key);
00217         bool sendKeyRelease(MMSKeySymbol key);
00218         bool sendButtonPress(int posx, int posy);
00219         bool sendButtonRelease(int posx, int posy);
00220         bool sendAxisMotion(int posx, int posy);
00221 
00222         bool sendEvent(MMSInputEvent *input);
00223 
00224         bool onHandleInput(MMSWindow *window, MMSInputEvent *input);
00225 
00226     public:
00227         /* status constants */
00228         static const unsigned short STATUS_NONE                     =  0;       /**< status not set                         */
00229         static const unsigned short STATUS_PLAYING                  =  1;       /**< stream is being played                 */
00230         static const unsigned short STATUS_PAUSED                   =  2;       /**< stream is being paused                 */
00231         static const unsigned short STATUS_STOPPED                  =  3;       /**< stream was stopped                     */
00232         static const unsigned short STATUS_REWIND                   =  4;       /**< stream is being rewinded               */
00233         static const unsigned short STATUS_FFWD                     =  5;       /**< stream is being fast forwarded (2x)    */
00234         static const unsigned short STATUS_FFWD2                    =  6;       /**< stream is being fast forwarded (4x)    */
00235         static const unsigned short STATUS_SLOW                     =  7;       /**< stream is being played slowly (2x)     */
00236         static const unsigned short STATUS_SLOW2                    =  8;       /**< stream is being played slowly (4x)     */
00237 
00238 #ifdef __HAVE_GSTREAMER__
00239         MMSAV(MMSMEDIABackend backend = MMSMEDIA_BE_GST);
00240 #else
00241         MMSAV(MMSMEDIABackend backend = MMSMEDIA_BE_XINE);
00242 #endif
00243         virtual ~MMSAV();
00244 
00245         bool registerAudioPostPlugin(string name);
00246         bool registerVideoPostPlugin(string name);
00247         bool setAudioPostPluginParameter(string name, string parameter, string value);
00248         bool setVideoPostPluginParameter(string name, string parameter, string value);
00249 
00250         /* playing methods */
00251         bool isPlaying();
00252         bool isPaused();
00253         bool isStopped();
00254         void startPlaying(const string mrl, const bool cont = true);
00255         void play();
00256         void stop(const bool savePosition = true);
00257         void pause();
00258         void ffwd();
00259         void slow();
00260 
00261         bool getTimes(int *pos, int *length);
00262 
00263         void setBrightness(int count);
00264         void brightnessUp(int count);
00265         void brightnessDown(int count);
00266         void setContrast(int count);
00267         void contrastUp(int count);
00268         void contrastDown(int count);
00269         void setSaturation(int count);
00270         void saturationUp(int count);
00271         void saturationDown(int count);
00272         void setHue(int count);
00273         void hueUp(int count);
00274         void hueDown(int count);
00275 
00276         void setVolume(int percent);
00277 
00278         bool hasVideo();
00279         bool hasAudio();
00280 
00281         /**
00282          * Callback that is used to receive errors.
00283          */
00284         sigc::signal<void, string> *onError;
00285         /**
00286          * Callback that is used to receive status changes.
00287          */
00288         sigc::signal<void, const unsigned short, const unsigned short> *onStatusChange;
00289 
00290 };
00291 
00292 #endif /*MMSAV_H_*/

Generated by doxygen