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