vdr  1.7.27
hdffcmd.c
Go to the documentation of this file.
00001 /*
00002  * hdffcmd.c: TODO(short description)
00003  *
00004  * See the README file for copyright information and how to reach the author.
00005  *
00006  * $Id: hdffcmd.c 1.24 2012/02/28 09:19:09 kls Exp $
00007  */
00008 
00009 #include <stdint.h>
00010 
00011 #include "hdffcmd.h"
00012 #include "libhdffcmd/hdffcmd.h"
00013 #include <stdio.h>
00014 #include <string.h>
00015 #include <vdr/tools.h>
00016 
00017 
00018 namespace HDFF
00019 {
00020 
00021 cHdffCmdIf::cHdffCmdIf(int OsdDev)
00022 {
00023     mOsdDev = OsdDev;
00024     if (mOsdDev < 0)
00025     {
00026         //printf("ERROR: invalid OSD device handle (%d)!\n", mOsdDev);
00027     }
00028 }
00029 
00030 cHdffCmdIf::~cHdffCmdIf(void)
00031 {
00032 }
00033 
00034 
00035 uint32_t cHdffCmdIf::CmdGetFirmwareVersion(char * pString, uint32_t MaxLength)
00036 {
00037     uint32_t version;
00038     int err;
00039 
00040     err = HdffCmdGetFirmwareVersion(mOsdDev, &version, pString, MaxLength);
00041     if (err == 0)
00042         return version;
00043     return 0;
00044 }
00045 
00046 uint32_t cHdffCmdIf::CmdGetInterfaceVersion(char * pString, uint32_t MaxLength)
00047 {
00048     uint32_t version;
00049     int err;
00050 
00051     err = HdffCmdGetInterfaceVersion(mOsdDev, &version, pString, MaxLength);
00052     if (err == 0)
00053         return version;
00054     return 0;
00055 }
00056 
00057 uint32_t cHdffCmdIf::CmdGetCopyrights(uint8_t Index, char * pString, uint32_t MaxLength)
00058 {
00059     int err;
00060 
00061     err = HdffCmdGetCopyrights(mOsdDev, Index, pString, MaxLength);
00062     if (err == 0)
00063         return strlen(pString);
00064     return 0;
00065 }
00066 
00067 
00068 void cHdffCmdIf::CmdAvSetPlayMode(uint8_t PlayMode, bool Realtime)
00069 {
00070     HdffCmdAvSetPlayMode(mOsdDev, PlayMode, Realtime);
00071 }
00072 
00073 void cHdffCmdIf::CmdAvSetVideoPid(uint8_t DecoderIndex, uint16_t VideoPid, HdffVideoStreamType_t StreamType, bool PlaybackMode)
00074 {
00075     //printf("SetVideoPid %d %d\n", VideoPid, StreamType);
00076     HdffCmdAvSetVideoPid(mOsdDev, DecoderIndex, VideoPid, StreamType);
00077 }
00078 
00079 void cHdffCmdIf::CmdAvSetAudioPid(uint8_t DecoderIndex, uint16_t AudioPid, HdffAudioStreamType_t StreamType, HdffAvContainerType_t ContainerType)
00080 {
00081     //printf("SetAudioPid %d %d %d\n", AudioPid, StreamType, ContainerType);
00082     HdffCmdAvSetAudioPid(mOsdDev, DecoderIndex, AudioPid, StreamType,
00083                          ContainerType);
00084 }
00085 
00086 void cHdffCmdIf::CmdAvSetPcrPid(uint8_t DecoderIndex, uint16_t PcrPid)
00087 {
00088     //printf("SetPcrPid %d\n", PcrPid);
00089     HdffCmdAvSetPcrPid(mOsdDev, DecoderIndex, PcrPid);
00090 }
00091 
00092 void cHdffCmdIf::CmdAvSetTeletextPid(uint8_t DecoderIndex, uint16_t TeletextPid)
00093 {
00094     HdffCmdAvSetTeletextPid(mOsdDev, DecoderIndex, TeletextPid);
00095 }
00096 
00097 void cHdffCmdIf::CmdAvSetVideoWindow(uint8_t DecoderIndex, bool Enable, uint16_t X, uint16_t Y, uint16_t Width, uint16_t Height)
00098 {
00099     HdffCmdAvSetVideoWindow(mOsdDev, DecoderIndex, Enable, X, Y, Width, Height);
00100 }
00101 
00102 void cHdffCmdIf::CmdAvShowStillImage(uint8_t DecoderIndex, const uint8_t * pStillImage, int Size, HdffVideoStreamType_t StreamType)
00103 {
00104     HdffCmdAvShowStillImage(mOsdDev, DecoderIndex, pStillImage, Size,
00105                             StreamType);
00106 }
00107 
00108 void cHdffCmdIf::CmdAvSetDecoderInput(uint8_t DecoderIndex, uint8_t DemultiplexerIndex)
00109 {
00110     HdffCmdAvSetDecoderInput(mOsdDev, DecoderIndex, DemultiplexerIndex);
00111 }
00112 
00113 void cHdffCmdIf::CmdAvSetDemultiplexerInput(uint8_t DemultiplexerIndex, uint8_t TsInputIndex)
00114 {
00115     HdffCmdAvSetDemultiplexerInput(mOsdDev, DemultiplexerIndex, TsInputIndex);
00116 }
00117 
00118 void cHdffCmdIf::CmdAvSetVideoFormat(uint8_t DecoderIndex, const HdffVideoFormat_t * pVideoFormat)
00119 {
00120     HdffCmdAvSetVideoFormat(mOsdDev, DecoderIndex, pVideoFormat);
00121 }
00122 
00123 void cHdffCmdIf::CmdAvSetVideoOutputMode(uint8_t DecoderIndex, HdffVideoOutputMode_t OutputMode)
00124 {
00125     HdffCmdAvSetVideoOutputMode(mOsdDev, DecoderIndex, OutputMode);
00126 }
00127 
00128 void cHdffCmdIf::CmdAvSetStc(uint8_t DecoderIndex, uint64_t Stc)
00129 {
00130     HdffCmdAvSetStc(mOsdDev, DecoderIndex, Stc);
00131 }
00132 
00133 void cHdffCmdIf::CmdAvFlushBuffer(uint8_t DecoderIndex, bool FlushAudio, bool FlushVideo)
00134 {
00135     HdffCmdAvFlushBuffer(mOsdDev, DecoderIndex, FlushAudio, FlushVideo);
00136 }
00137 
00138 void cHdffCmdIf::CmdAvEnableSync(uint8_t DecoderIndex, bool EnableSync)
00139 {
00140     HdffCmdAvEnableSync(mOsdDev, DecoderIndex, EnableSync, EnableSync);
00141 }
00142 
00143 void cHdffCmdIf::CmdAvSetVideoSpeed(uint8_t DecoderIndex, int32_t Speed)
00144 {
00145     HdffCmdAvSetVideoSpeed(mOsdDev, DecoderIndex, Speed);
00146 }
00147 
00148 void cHdffCmdIf::CmdAvSetAudioSpeed(uint8_t DecoderIndex, int32_t Speed)
00149 {
00150     HdffCmdAvSetAudioSpeed(mOsdDev, DecoderIndex, Speed);
00151 }
00152 
00153 void cHdffCmdIf::CmdAvEnableVideoAfterStop(uint8_t DecoderIndex, bool EnableVideoAfterStop)
00154 {
00155     HdffCmdAvEnableVideoAfterStop(mOsdDev, DecoderIndex, EnableVideoAfterStop);
00156 }
00157 
00158 void cHdffCmdIf::CmdAvSetAudioDelay(int16_t Delay)
00159 {
00160     HdffCmdAvSetAudioDelay(mOsdDev, Delay);
00161 }
00162 
00163 void cHdffCmdIf::CmdAvSetAudioDownmix(HdffAudioDownmixMode_t DownmixMode)
00164 {
00165     HdffCmdAvSetAudioDownmix(mOsdDev, DownmixMode);
00166 }
00167 
00168 void cHdffCmdIf::CmdAvSetAudioChannel(uint8_t AudioChannel)
00169 {
00170     HdffCmdAvSetAudioChannel(mOsdDev, AudioChannel);
00171 }
00172 
00173 
00174 void cHdffCmdIf::CmdOsdConfigure(const HdffOsdConfig_t * pConfig)
00175 {
00176     HdffCmdOsdConfigure(mOsdDev, pConfig);
00177 }
00178 
00179 void cHdffCmdIf::CmdOsdReset(void)
00180 {
00181     HdffCmdOsdReset(mOsdDev);
00182 }
00183 
00184 uint32_t cHdffCmdIf::CmdOsdCreateDisplay(uint32_t Width, uint32_t Height, HdffColorType_t ColorType)
00185 {
00186     //printf("CreateDisplay %d %d %d\n", Width, Height, ColorType);
00187     uint32_t newDisplay;
00188 
00189     if (HdffCmdOsdCreateDisplay(mOsdDev, Width, Height, ColorType, &newDisplay) == 0)
00190         return newDisplay;
00191     LOG_ERROR_STR("Error creating display");
00192     return HDFF_INVALID_HANDLE;
00193 }
00194 
00195 void cHdffCmdIf::CmdOsdDeleteDisplay(uint32_t hDisplay)
00196 {
00197     //printf("DeleteDisplay\n");
00198     HdffCmdOsdDeleteDisplay(mOsdDev, hDisplay);
00199 }
00200 
00201 void cHdffCmdIf::CmdOsdEnableDisplay(uint32_t hDisplay, bool Enable)
00202 {
00203     //printf("EnableDisplay\n");
00204     HdffCmdOsdEnableDisplay(mOsdDev, hDisplay, Enable);
00205 }
00206 
00207 void cHdffCmdIf::CmdOsdSetDisplayOutputRectangle(uint32_t hDisplay, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
00208 {
00209     //printf("SetOutputRect %d %d %d %d %d\n", hDisplay, X, Y, Width, Height);
00210     HdffCmdOsdSetDisplayOutputRectangle(mOsdDev, hDisplay, X, Y, Width, Height);
00211 }
00212 
00213 void cHdffCmdIf::CmdOsdSetDisplayClippingArea(uint32_t hDisplay, bool Enable, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
00214 {
00215     //printf("SetClippingArea %d %d %d %d %d %d\n", hDisplay, Enable, X, Y, Width, Height);
00216     HdffCmdOsdSetDisplayClippingArea(mOsdDev, hDisplay, Enable, X, Y, Width, Height);
00217 }
00218 
00219 void cHdffCmdIf::CmdOsdRenderDisplay(uint32_t hDisplay)
00220 {
00221     //printf("Render %08X\n", hDisplay);
00222     HdffCmdOsdRenderDisplay(mOsdDev, hDisplay);
00223 }
00224 
00225 uint32_t cHdffCmdIf::CmdOsdCreatePalette(HdffColorType_t ColorType, HdffColorFormat_t ColorFormat,
00226                                          uint32_t NumColors, const uint32_t * pColors)
00227 {
00228     uint32_t newPalette;
00229     int err;
00230 
00231     err = HdffCmdOsdCreatePalette(mOsdDev, ColorType, ColorFormat, NumColors,
00232                                   pColors, &newPalette);
00233     if (err == 0)
00234         return newPalette;
00235     LOG_ERROR_STR("Error creating palette");
00236     return HDFF_INVALID_HANDLE;
00237 }
00238 
00239 void cHdffCmdIf::CmdOsdDeletePalette(uint32_t hPalette)
00240 {
00241     HdffCmdOsdDeletePalette(mOsdDev, hPalette);
00242 }
00243 
00244 void cHdffCmdIf::CmdOsdSetDisplayPalette(uint32_t hDisplay, uint32_t hPalette)
00245 {
00246     HdffCmdOsdSetDisplayPalette(mOsdDev, hDisplay, hPalette);
00247 }
00248 
00249 void cHdffCmdIf::CmdOsdSetPaletteColors(uint32_t hPalette, HdffColorFormat_t ColorFormat,
00250                                         uint8_t StartColor, uint32_t NumColors, const uint32_t * pColors)
00251 {
00252     HdffCmdOsdSetPaletteColors(mOsdDev, hPalette, ColorFormat, StartColor,
00253                                NumColors, pColors);
00254 }
00255 
00256 uint32_t cHdffCmdIf::CmdOsdCreateFontFace(const uint8_t * pFontData, uint32_t DataSize)
00257 {
00258     //printf("CreateFontFace %d\n", DataSize);
00259     uint32_t newFontFace;
00260     int err;
00261 
00262     err = HdffCmdOsdCreateFontFace(mOsdDev, pFontData, DataSize, &newFontFace);
00263     if (err == 0)
00264         return newFontFace;
00265     LOG_ERROR_STR("Error creating font face");
00266     return HDFF_INVALID_HANDLE;
00267 }
00268 
00269 void cHdffCmdIf::CmdOsdDeleteFontFace(uint32_t hFontFace)
00270 {
00271     //printf("DeleteFontFace %08X\n", hFontFace);
00272     HdffCmdOsdDeleteFontFace(mOsdDev, hFontFace);
00273 }
00274 
00275 uint32_t cHdffCmdIf::CmdOsdCreateFont(uint32_t hFontFace, uint32_t Size)
00276 {
00277     //printf("CreateFont %d\n", Size);
00278     uint32_t newFont;
00279     int err;
00280 
00281     err = HdffCmdOsdCreateFont(mOsdDev, hFontFace, Size, &newFont);
00282     if (err == 0)
00283         return newFont;
00284     LOG_ERROR_STR("Error creating font");
00285     return HDFF_INVALID_HANDLE;
00286 }
00287 
00288 void cHdffCmdIf::CmdOsdDeleteFont(uint32_t hFont)
00289 {
00290     //printf("DeleteFont %08X\n", hFont);
00291     HdffCmdOsdDeleteFont(mOsdDev, hFont);
00292 }
00293 
00294 void cHdffCmdIf::CmdOsdDrawRectangle(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color)
00295 {
00296     //printf("Rect (%d,%d) %d x %d, %08X\n", X, Y, Width, Height, Color);
00297     HdffCmdOsdDrawRectangle(mOsdDev, hDisplay, X, Y, Width, Height, Color);
00298 }
00299 
00300 void cHdffCmdIf::CmdOsdDrawEllipse(uint32_t hDisplay, int CX, int CY, int RadiusX, int RadiusY,
00301                                  uint32_t Color, uint32_t Flags)
00302 {
00303     //printf("Ellipse (%d,%d) %d x %d, %08X, %d\n", CX, CY, RadiusX, RadiusY, Color, Flags);
00304     HdffCmdOsdDrawEllipse(mOsdDev, hDisplay, CX, CY, RadiusX, RadiusY, Color, Flags);
00305 }
00306 
00307 void cHdffCmdIf::CmdOsdDrawText(uint32_t hDisplay, uint32_t hFont, int X, int Y, const char * pText, uint32_t Color)
00308 {
00309     //printf("Text %08X (%d,%d), %s, %08X\n", hFont, X, Y, pText, Color);
00310     HdffCmdOsdDrawText(mOsdDev, hDisplay, hFont, X, Y, pText, Color);
00311 }
00312 
00313 void cHdffCmdIf::CmdOsdDrawTextW(uint32_t hDisplay, uint32_t hFont, int X, int Y, const uint16_t * pText, uint32_t Color)
00314 {
00315     //printf("TextW %08X (%d,%d), %08X\n", hFont, X, Y, Color);
00316     HdffCmdOsdDrawWideText(mOsdDev, hDisplay, hFont, X, Y, pText, Color);
00317 }
00318 
00319 void cHdffCmdIf::CmdOsdDrawBitmap(uint32_t hDisplay, int X, int Y, const uint8_t * pBitmap,
00320                                   int BmpWidth, int BmpHeight, int BmpSize,
00321                                   HdffColorType_t ColorType, uint32_t hPalette)
00322 {
00323     //printf("Bitmap %08X (%d,%d) %d x %d, %08X\n", hDisplay, X, Y, BmpWidth, BmpHeight, hPalette);
00324     HdffCmdOsdDrawBitmap(mOsdDev, hDisplay, X, Y, pBitmap, BmpWidth, BmpHeight,
00325                          BmpSize, ColorType, hPalette);
00326 }
00327 
00328 void cHdffCmdIf::CmdOsdSaveRegion(uint32_t hDisplay, int X, int Y, int Width, int Height)
00329 {
00330     HdffCmdOsdSaveRegion(mOsdDev, hDisplay, X, Y, Width, Height);
00331 }
00332 
00333 void cHdffCmdIf::CmdOsdRestoreRegion(uint32_t hDisplay)
00334 {
00335     HdffCmdOsdRestoreRegion(mOsdDev, hDisplay);
00336 }
00337 
00338 void cHdffCmdIf::CmdMuxSetVideoOut(HdffVideoOut_t VideoOut)
00339 {
00340     HdffCmdMuxSetVideoOut(mOsdDev, VideoOut);
00341 }
00342 
00343 void cHdffCmdIf::CmdMuxSetVolume(uint8_t Volume)
00344 {
00345     HdffCmdMuxSetVolume(mOsdDev, Volume);
00346 }
00347 
00348 void cHdffCmdIf::CmdMuxMuteAudio(bool Mute)
00349 {
00350     HdffCmdMuxMuteAudio(mOsdDev, Mute);
00351 }
00352 
00353 void cHdffCmdIf::CmdHdmiSetVideoMode(HdffVideoMode_t VideoMode)
00354 {
00355     //printf("HdmiSetVideoMode %d\n", VideoMode);
00356     HdffCmdHdmiSetVideoMode(mOsdDev, VideoMode);
00357 }
00358 
00359 void cHdffCmdIf::CmdHdmiConfigure(const HdffHdmiConfig_t * pConfig)
00360 {
00361     HdffCmdHdmiConfigure(mOsdDev, pConfig);
00362 }
00363 
00364 void cHdffCmdIf::CmdHdmiSendCecCommand(HdffCecCommand_t Command)
00365 {
00366     HdffCmdHdmiSendCecCommand(mOsdDev, Command);
00367 }
00368 
00369 void cHdffCmdIf::CmdRemoteSetProtocol(HdffRemoteProtocol_t Protocol)
00370 {
00371     //printf("%s %d\n", __func__, Protocol);
00372     HdffCmdRemoteSetProtocol(mOsdDev, Protocol);
00373 }
00374 
00375 void cHdffCmdIf::CmdRemoteSetAddressFilter(bool Enable, uint32_t Address)
00376 {
00377     //printf("%s %d %d\n", __func__, Enable, Address);
00378     HdffCmdRemoteSetAddressFilter(mOsdDev, Enable, Address);
00379 }
00380 
00381 } // end of namespace