00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
00046
00047
00048
00049 MMSVideoCtrl::MMSVideoCtrl() {
00050 DFBResult dfbres;
00051
00052
00053 this->dfb = NULL;
00054 this->layer = NULL;
00055
00056
00057
00058 if ((dfbres = DirectFBCreate(&this->dfb)) != DFB_OK)
00059 THROW_DFB_ERROR(dfbres, "DirectFBCreate() failed");
00060
00061
00062 if ((dfbres = this->dfb->GetDisplayLayer(this->dfb,DLID_PRIMARY,&this->layer)) != DFB_OK)
00063 THROW_DFB_ERROR(dfbres, "IDirectFB::GetDisplayLayer() failed");
00064
00065
00066 if ((dfbres = this->layer->SetCooperativeLevel(this->layer, DLSCL_ADMINISTRATIVE)) != DFB_OK)
00067 THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::SetCooperativeLevel() failed");
00068
00069
00070 if ((dfbres = this->layer->GetDescription(this->layer, &this->desc)) != DFB_OK)
00071 THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::GetDescription() failed");
00072
00073
00074 if ((dfbres = this->layer->GetColorAdjustment(this->layer, &this->cadj)) != DFB_OK)
00075 THROW_DFB_ERROR(dfbres, "IDirectFBDisplayLayer::GetColorAdjustment() failed");
00076 }
00077
00078
00079
00080
00081 MMSVideoCtrl::~MMSVideoCtrl() {
00082
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
00095
00096
00097
00098
00099 DFBDisplayLayerDescription MMSVideoCtrl::getDisplayLayerDescription() {
00100 return this->desc;
00101 }
00102
00103
00104
00105
00106
00107
00108
00109 DFBColorAdjustment MMSVideoCtrl::getColorAdjustment() {
00110 return this->cadj;
00111 }
00112
00113
00114
00115
00116
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
00131
00132
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
00147
00148
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
00163
00164
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