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

mmsvideoctrl.cpp

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 #ifdef  __HAVE_DIRECTFB__
00034 
00035 #include "mmsmedia/mmsvideoctrl.h"
00036 
00037 MMS_CREATEERROR(MMSVideoCtrlError);
00038 
00039 #define THROW_DFB_ERROR(dfbres,msg) {if (dfbres) { string s1 = msg; string s2 = DirectFBErrorString((DFBResult)dfbres); throw MMSVideoCtrlError(dfbres,s1 + " [" + s2 + "]"); }else{ throw MMSVideoCtrlError(0,msg); }}
00040 
00041 DFBDisplayLayerDescription    MMSVideoCtrl::desc;
00042 DFBColorAdjustment           MMSVideoCtrl::cadj;
00043 
00044 /**
00045  * Constructor of class MMSVideoCtrl.
00046  *
00047  * It initializes some DirectFB stuff.
00048  */
00049 MMSVideoCtrl::MMSVideoCtrl() {
00050     DFBResult   dfbres;
00051 
00052     /* init */
00053     this->dfb = NULL;
00054     this->layer = NULL;
00055 
00056     /* create a dfb access object */
00057     /* NOTE: DirectFBInit(); must be called before using this class */
00058     if ((dfbres = DirectFBCreate(&this->dfb)) != DFB_OK)
00059         THROW_DFB_ERROR(dfbres, "DirectFBCreate() failed");
00060 
00061     /* get layer */
00062     if ((dfbres = this->dfb->GetDisplayLayer(this->dfb,DLID_PRIMARY,&this->layer)) != DFB_OK)
00063         THROW_DFB_ERROR(dfbres, "IDirectFB::GetDisplayLayer() failed");
00064 
00065     /* set cooperative level */
00066     if ((dfbres = this->layer->SetCooperativeLevel(this->layer, DLSCL_ADMINISTRATIVE)) != DFB_OK)
00067         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetCooperativeLevel() failed");
00068 
00069     /* get description of the layer */
00070     if ((dfbres = this->layer->GetDescription(this->layer, &this->desc)) != DFB_OK)
00071         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::GetDescription() failed");
00072 
00073     /* get color settings */
00074     if ((dfbres = this->layer->GetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00075         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::GetColorAdjustment() failed");
00076 }
00077 
00078 /**
00079  * Destructor of class MMSVideoCtrl.
00080  */
00081 MMSVideoCtrl::~MMSVideoCtrl() {
00082     /* close all relevant objects */
00083     if (this->layer) {
00084         delete (this->layer);
00085         this->layer = NULL;
00086     }
00087     if (this->dfb) {
00088         delete (this->dfb);
00089         this->dfb = NULL;
00090     }
00091 }
00092 
00093 /**
00094  * Gets the description of the Display Layer.
00095  *
00096  * @note Take a look at http://www.directfb.org for the
00097  * documentation of this structure.
00098  */
00099 DFBDisplayLayerDescription MMSVideoCtrl::getDisplayLayerDescription() {
00100     return this->desc;
00101 }
00102 
00103 /**
00104  * Gets the color adjustment.
00105  *
00106  * @note Take a look at http://www.directfb.org for the
00107  * documentation of this structure.
00108  */
00109 DFBColorAdjustment MMSVideoCtrl::getColorAdjustment() {
00110     return this->cadj;
00111 }
00112 
00113 /**
00114  * Sets the brightness.
00115  *
00116  * @param   val [in]    amount of brightness
00117  */
00118 void MMSVideoCtrl::adjustBrightness(unsigned val) {
00119     DFBResult   dfbres;
00120 
00121     if (!(this->desc.caps & DLCAPS_BRIGHTNESS))
00122         throw MMSVideoCtrlError(0, "Adjustment of brightness is not supported.");
00123     this->cadj.flags        = DCAF_BRIGHTNESS;
00124     this->cadj.brightness   = val;
00125     if ((dfbres = this->layer->SetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00126         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetColorAdjustment(brightness) failed");
00127 }
00128 
00129 /**
00130  * Sets the contrast.
00131  *
00132  * @param   val [in]    amount of contrast
00133  */
00134 void MMSVideoCtrl::adjustContrast(unsigned val) {
00135     DFBResult   dfbres;
00136 
00137     if (!(this->desc.caps & DLCAPS_CONTRAST))
00138         throw MMSVideoCtrlError(0, "Adjustment of contrast is not supported.");
00139     this->cadj.flags        = DCAF_CONTRAST;
00140     this->cadj.contrast     = val;
00141     if ((dfbres = this->layer->SetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00142         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetColorAdjustment(contrast) failed");
00143 }
00144 
00145 /**
00146  * Sets the hue.
00147  *
00148  * @param   val [in]    amount of hue
00149  */
00150 void MMSVideoCtrl::adjustHue(unsigned val) {
00151     DFBResult   dfbres;
00152 
00153     if (!(this->desc.caps & DLCAPS_HUE))
00154         throw MMSVideoCtrlError(0, "Adjustment of hue is not supported.");
00155     this->cadj.flags        = DCAF_HUE;
00156     this->cadj.hue          = val;
00157     if ((dfbres = this->layer->SetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00158         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetColorAdjustment(hue) failed");
00159 }
00160 
00161 /**
00162  * Sets the saturation.
00163  *
00164  * @param   val [in]    amount of saturation
00165  */
00166 void MMSVideoCtrl::adjustSaturation(unsigned val) {
00167     DFBResult   dfbres;
00168 
00169     if (!(this->desc.caps & DLCAPS_SATURATION))
00170         throw MMSVideoCtrlError(0, "Adjustment of saturation is not supported.");
00171     this->cadj.flags        = DCAF_SATURATION;
00172     this->cadj.saturation   = val;
00173     if ((dfbres = this->layer->SetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00174         THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetColorAdjustment(saturation) failed");
00175 }
00176 
00177 #endif

Generated by doxygen