libUPnP
1.6.17
|
00001 #ifndef UPNP_TV_DEVICE_H 00002 #define UPNP_TV_DEVICE_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 #include <stdio.h> 00048 #include <signal.h> 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 #include "sample_util.h" 00055 00056 #include "ithread.h" 00057 #include "upnp.h" 00058 00059 #include <stdlib.h> 00060 #include <string.h> 00061 00063 #define MAX_COLOR 10 00064 #define MIN_COLOR 1 00065 00067 #define MAX_BRIGHTNESS 10 00068 #define MIN_BRIGHTNESS 1 00069 00071 #define POWER_ON 1 00072 #define POWER_OFF 0 00073 00075 #define MAX_TINT 10 00076 #define MIN_TINT 1 00077 00079 #define MAX_VOLUME 10 00080 #define MIN_VOLUME 1 00081 00083 #define MAX_CONTRAST 10 00084 #define MIN_CONTRAST 1 00085 00087 #define MAX_CHANNEL 100 00088 #define MIN_CHANNEL 1 00089 00091 #define TV_SERVICE_SERVCOUNT 2 00092 00094 #define TV_SERVICE_CONTROL 0 00095 00097 #define TV_SERVICE_PICTURE 1 00098 00100 #define TV_CONTROL_VARCOUNT 3 00101 00103 #define TV_CONTROL_POWER 0 00104 00106 #define TV_CONTROL_CHANNEL 1 00107 00109 #define TV_CONTROL_VOLUME 2 00110 00112 #define TV_PICTURE_VARCOUNT 4 00113 00115 #define TV_PICTURE_COLOR 0 00116 00118 #define TV_PICTURE_TINT 1 00119 00121 #define TV_PICTURE_CONTRAST 2 00122 00124 #define TV_PICTURE_BRIGHTNESS 3 00125 00127 #define TV_MAX_VAL_LEN 5 00128 00130 #define TV_MAXACTIONS 12 00131 00133 #define TV_MAXVARS TV_PICTURE_VARCOUNT 00134 00145 typedef int (*upnp_action)( 00147 IXML_Document *request, 00149 IXML_Document **out, 00151 const char **errorString); 00152 00154 struct TvService { 00156 char UDN[NAME_SIZE]; 00158 char ServiceId[NAME_SIZE]; 00160 char ServiceType[NAME_SIZE]; 00162 const char *VariableName[TV_MAXVARS]; 00164 char *VariableStrVal[TV_MAXVARS]; 00166 const char *ActionNames[TV_MAXACTIONS]; 00168 upnp_action actions[TV_MAXACTIONS]; 00170 int VariableCount; 00171 }; 00172 00174 extern struct TvService tv_service_table[]; 00175 00177 extern UpnpDevice_Handle device_handle; 00178 00183 extern ithread_mutex_t TVDevMutex; 00184 00191 int SetActionTable( 00193 int serviceType, 00195 struct TvService *out); 00196 00205 int TvDeviceStateTableInit( 00207 char *DescDocURL); 00208 00215 int TvDeviceHandleSubscriptionRequest( 00217 struct Upnp_Subscription_Request *sr_event); 00218 00225 int TvDeviceHandleGetVarRequest( 00227 struct Upnp_State_Var_Request *cgv_event); 00228 00235 int TvDeviceHandleActionRequest( 00237 struct Upnp_Action_Request *ca_event); 00238 00250 int TvDeviceCallbackEventHandler( 00252 Upnp_EventType, 00254 void *Event, 00256 void *Cookie); 00257 00266 int TvDeviceSetServiceTableVar( 00268 unsigned int service, 00272 int variable, 00274 char *value); 00275 00276 /* Control Service Actions */ 00277 00281 int TvDevicePowerOn( 00283 IXML_Document *in, 00285 IXML_Document **out, 00287 const char **errorString); 00288 00292 int TvDevicePowerOff( 00294 IXML_Document *in, 00296 IXML_Document **out, 00298 const char **errorString); 00299 00305 int TvDeviceSetChannel( 00307 IXML_Document *in, 00309 IXML_Document **out, 00311 const char **errorString); 00312 00316 int TvDeviceIncreaseChannel( 00318 IXML_Document *in, 00320 IXML_Document **out, 00322 const char **errorString); 00323 00327 int TvDeviceDecreaseChannel( 00329 IXML_Document *in, 00331 IXML_Document **out, 00333 const char **errorString); 00334 00340 int TvDeviceSetVolume( 00342 IXML_Document *in, 00344 IXML_Document **out, 00346 const char **errorString); 00347 00351 int TvDeviceIncreaseVolume( 00353 IXML_Document *in, 00355 IXML_Document **out, 00357 const char **errorString); 00358 00362 int TvDeviceDecreaseVolume( 00364 IXML_Document *in, 00366 IXML_Document **out, 00368 const char **errorString); 00369 00370 /*Picture Service Actions */ 00371 00377 int TvDeviceSetColor( 00379 IXML_Document *in, 00381 IXML_Document **out, 00383 const char **errorString); 00384 00388 int TvDeviceIncreaseColor( 00390 IXML_Document *in, 00392 IXML_Document **out, 00394 const char **errorString); 00395 00399 int TvDeviceDecreaseColor( 00401 IXML_Document *in, 00403 IXML_Document **out, 00405 const char **errorString); 00406 00412 int TvDeviceSetTint( 00414 IXML_Document *in, 00416 IXML_Document **out, 00418 const char **errorString); 00419 00423 int TvDeviceIncreaseTint( 00425 IXML_Document *in, 00427 IXML_Document **out, 00429 const char **errorString); 00430 00434 int TvDeviceDecreaseTint( 00436 IXML_Document *in, 00438 IXML_Document **out, 00440 const char **errorString); 00441 00447 int TvDeviceSetContrast( 00449 IXML_Document *in, 00451 IXML_Document **out, 00453 const char **errorString); 00454 00458 int TvDeviceIncreaseContrast( 00460 IXML_Document *in, 00462 IXML_Document **out, 00464 const char **errorString); 00465 00469 int TvDeviceDecreaseContrast( 00471 IXML_Document *in, 00473 IXML_Document **out, 00475 const char **errorString); 00476 00482 int TvDeviceSetBrightness( 00484 IXML_Document *in, 00486 IXML_Document **out, 00488 const char **errorString); 00489 00493 int TvDeviceIncreaseBrightness( 00495 IXML_Document *in, 00497 IXML_Document **out, 00499 const char **errorString); 00500 00504 int TvDeviceDecreaseBrightness( 00506 IXML_Document *in, 00508 IXML_Document **out, 00510 const char **errorString); 00511 00516 int TvDeviceStart( 00519 char *ip_address, 00522 unsigned short port, 00525 const char *desc_doc_name, 00528 const char *web_dir_path, 00530 print_string pfun, 00532 int combo); 00533 00537 int TvDeviceStop(void); 00538 00545 void *TvDeviceCommandLoop(void *args); 00546 00561 int device_main(int argc, char *argv[]); 00562 00563 #ifdef __cplusplus 00564 } 00565 #endif 00566 00571 #endif /* UPNP_TV_DEVICE_H */