libUPnP  1.6.17
tv_ctrlpt.h
Go to the documentation of this file.
00001 #ifndef UPNP_TV_CTRLPT_H
00002 #define UPNP_TV_CTRLPT_H
00003 
00004 /**************************************************************************
00005  *
00006  * Copyright (c) 2000-2003 Intel Corporation 
00007  * All rights reserved. 
00008  *
00009  * Redistribution and use in source and binary forms, with or without 
00010  * modification, are permitted provided that the following conditions are met: 
00011  *
00012  * - Redistributions of source code must retain the above copyright notice, 
00013  * this list of conditions and the following disclaimer. 
00014  * - Redistributions in binary form must reproduce the above copyright notice, 
00015  * this list of conditions and the following disclaimer in the documentation 
00016  * and/or other materials provided with the distribution. 
00017  * - Neither name of Intel Corporation nor the names of its contributors 
00018  * may be used to endorse or promote products derived from this software 
00019  * without specific prior written permission.
00020  * 
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00022  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00024  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 
00025  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00027  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00028  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
00029  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00030  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00031  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  **************************************************************************/
00034 
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050 
00051 #include "sample_util.h"
00052 
00053 #include "upnp.h"
00054 #include "UpnpString.h"
00055 #include "upnptools.h"
00056 
00057 #include <signal.h>
00058 #include <stdarg.h>
00059 #include <stdio.h>
00060 
00061 #define TV_SERVICE_SERVCOUNT    2
00062 #define TV_SERVICE_CONTROL      0
00063 #define TV_SERVICE_PICTURE      1
00064 
00065 #define TV_CONTROL_VARCOUNT     3
00066 #define TV_CONTROL_POWER        0
00067 #define TV_CONTROL_CHANNEL      1
00068 #define TV_CONTROL_VOLUME       2
00069 
00070 #define TV_PICTURE_VARCOUNT     4
00071 #define TV_PICTURE_COLOR        0
00072 #define TV_PICTURE_TINT         1
00073 #define TV_PICTURE_CONTRAST     2
00074 #define TV_PICTURE_BRIGHTNESS   3
00075 
00076 #define TV_MAX_VAL_LEN          5
00077 
00078 #define TV_SUCCESS              0
00079 #define TV_ERROR                (-1)
00080 #define TV_WARNING              1
00081 
00082 /* This should be the maximum VARCOUNT from above */
00083 #define TV_MAXVARS              TV_PICTURE_VARCOUNT
00084 
00085 extern const char *TvServiceName[];
00086 extern const char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS];
00087 extern char TvVarCount[];
00088 
00089 struct tv_service {
00090     char ServiceId[NAME_SIZE];
00091     char ServiceType[NAME_SIZE];
00092     char *VariableStrVal[TV_MAXVARS];
00093     char EventURL[NAME_SIZE];
00094     char ControlURL[NAME_SIZE];
00095     char SID[NAME_SIZE];
00096 };
00097 
00098 extern struct TvDeviceNode *GlobalDeviceList;
00099 
00100 struct TvDevice {
00101     char UDN[250];
00102     char DescDocURL[250];
00103     char FriendlyName[250];
00104     char PresURL[250];
00105     int  AdvrTimeOut;
00106     struct tv_service TvService[TV_SERVICE_SERVCOUNT];
00107 };
00108 
00109 struct TvDeviceNode {
00110     struct TvDevice device;
00111     struct TvDeviceNode *next;
00112 };
00113 
00114 extern ithread_mutex_t DeviceListMutex;
00115 
00116 extern UpnpClient_Handle ctrlpt_handle;
00117 
00118 void    TvCtrlPointPrintHelp(void);
00119 int             TvCtrlPointDeleteNode(struct TvDeviceNode *);
00120 int             TvCtrlPointRemoveDevice(const char *);
00121 int             TvCtrlPointRemoveAll(void);
00122 int             TvCtrlPointRefresh(void);
00123 
00124 int             TvCtrlPointSendAction(int, int, const char *, const char **, char **, int);
00125 int             TvCtrlPointSendActionNumericArg(int devnum, int service, const char *actionName, const char *paramName, int paramValue);
00126 int             TvCtrlPointSendPowerOn(int devnum);
00127 int             TvCtrlPointSendPowerOff(int devnum);
00128 int             TvCtrlPointSendSetChannel(int, int);
00129 int             TvCtrlPointSendSetVolume(int, int);
00130 int             TvCtrlPointSendSetColor(int, int);
00131 int             TvCtrlPointSendSetTint(int, int);
00132 int             TvCtrlPointSendSetContrast(int, int);
00133 int             TvCtrlPointSendSetBrightness(int, int);
00134 
00135 int             TvCtrlPointGetVar(int, int, const char *);
00136 int             TvCtrlPointGetPower(int devnum);
00137 int             TvCtrlPointGetChannel(int);
00138 int             TvCtrlPointGetVolume(int);
00139 int             TvCtrlPointGetColor(int);
00140 int             TvCtrlPointGetTint(int);
00141 int             TvCtrlPointGetContrast(int);
00142 int             TvCtrlPointGetBrightness(int);
00143 
00144 int             TvCtrlPointGetDevice(int, struct TvDeviceNode **);
00145 int             TvCtrlPointPrintList(void);
00146 int             TvCtrlPointPrintDevice(int);
00147 void    TvCtrlPointAddDevice(IXML_Document *, const char *, int); 
00148 void    TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
00149 
00156 void TvStateUpdate(
00158         char *UDN,
00160         int Service,
00162         IXML_Document *ChangedVariables,
00164         char **State);
00165 
00166 void    TvCtrlPointHandleEvent(const char *, int, IXML_Document *); 
00167 void    TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int); 
00168 int             TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
00169 
00178 void TvCtrlPointVerifyTimeouts(
00181         int incr);
00182 
00183 void    TvCtrlPointPrintCommands(void);
00184 void*   TvCtrlPointCommandLoop(void *);
00185 int             TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr, int combo);
00186 int             TvCtrlPointStop(void);
00187 int             TvCtrlPointProcessCommand(char *cmdline);
00188 
00192 void TvCtrlPointPrintShortHelp(void);
00193 
00197 void TvCtrlPointPrintLongHelp(void);
00198 
00202 void TvCtrlPointPrintCommands(void);
00203 
00209 void *TvCtrlPointCommandLoop(void *args);
00210 
00214 int TvCtrlPointProcessCommand(char *cmdline);
00215 
00216 #ifdef __cplusplus
00217 };
00218 #endif
00219 
00220 
00225 #endif /* UPNP_TV_CTRLPT_H */