libUPnP  1.14.5
tv_device.h
Go to the documentation of this file.
1 #ifndef UPNP_TV_DEVICE_H
2 #define UPNP_TV_DEVICE_H
3 
4 /**************************************************************************
5  *
6  * Copyright (c) 2000-2003 Intel Corporation
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * - Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  * - Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  * - Neither name of Intel Corporation nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
29  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  **************************************************************************/
34 
47 #include <stdio.h>
48 #include <signal.h>
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #include "sample_util.h"
55 
56 #include "ithread.h"
57 #include "upnp.h"
58 
59 #include <stdlib.h>
60 #include <string.h>
61 
63 #define MAX_COLOR 10
64 #define MIN_COLOR 1
65 
67 #define MAX_BRIGHTNESS 10
68 #define MIN_BRIGHTNESS 1
69 
71 #define POWER_ON 1
72 #define POWER_OFF 0
73 
75 #define MAX_TINT 10
76 #define MIN_TINT 1
77 
79 #define MAX_VOLUME 10
80 #define MIN_VOLUME 1
81 
83 #define MAX_CONTRAST 10
84 #define MIN_CONTRAST 1
85 
87 #define MAX_CHANNEL 100
88 #define MIN_CHANNEL 1
89 
91 #define TV_SERVICE_SERVCOUNT 2
92 
94 #define TV_SERVICE_CONTROL 0
95 
97 #define TV_SERVICE_PICTURE 1
98 
100 #define TV_CONTROL_VARCOUNT 3
101 
103 #define TV_CONTROL_POWER 0
104 
106 #define TV_CONTROL_CHANNEL 1
107 
109 #define TV_CONTROL_VOLUME 2
110 
112 #define TV_PICTURE_VARCOUNT 4
113 
115 #define TV_PICTURE_COLOR 0
116 
118 #define TV_PICTURE_TINT 1
119 
121 #define TV_PICTURE_CONTRAST 2
122 
124 #define TV_PICTURE_BRIGHTNESS 3
125 
127 #define TV_MAX_VAL_LEN 5
128 
130 #define TV_MAXACTIONS 12
131 
133 #define TV_MAXVARS TV_PICTURE_VARCOUNT
134 
135 #define IP_MODE_IPV4 1
136 #define IP_MODE_IPV6_LLA 2
137 #define IP_MODE_IPV6_ULA_GUA 3
138 
149 typedef int (*upnp_action)(
151  IXML_Document *request,
153  IXML_Document **out,
155  const char **errorString);
156 
158 struct TvService {
160  char UDN[NAME_SIZE];
162  char ServiceId[NAME_SIZE];
164  char ServiceType[NAME_SIZE];
166  const char *VariableName[TV_MAXVARS];
175 };
176 
178 extern struct TvService tv_service_table[];
179 
182 
187 extern ithread_mutex_t TVDevMutex;
188 
195 int SetActionTable(
197  int serviceType,
199  struct TvService *out);
200 
211  char *DescDocURL);
212 
221  const UpnpSubscriptionRequest *sr_event);
222 
231  UpnpStateVarRequest *cgv_event);
232 
241  UpnpActionRequest *ca_event);
242 
256  Upnp_EventType,
258  const void *Event,
260  void *Cookie);
261 
272  unsigned int service,
276  int variable,
278  char *value);
279 
280 /* Control Service Actions */
281 
285 int TvDevicePowerOn(
287  IXML_Document *in,
289  IXML_Document **out,
291  const char **errorString);
292 
296 int TvDevicePowerOff(
298  IXML_Document *in,
300  IXML_Document **out,
302  const char **errorString);
303 
311  IXML_Document *in,
313  IXML_Document **out,
315  const char **errorString);
316 
322  IXML_Document *in,
324  IXML_Document **out,
326  const char **errorString);
327 
333  IXML_Document *in,
335  IXML_Document **out,
337  const char **errorString);
338 
346  IXML_Document *in,
348  IXML_Document **out,
350  const char **errorString);
351 
357  IXML_Document *in,
359  IXML_Document **out,
361  const char **errorString);
362 
368  IXML_Document *in,
370  IXML_Document **out,
372  const char **errorString);
373 
374 /*Picture Service Actions */
375 
381 int TvDeviceSetColor(
383  IXML_Document *in,
385  IXML_Document **out,
387  const char **errorString);
388 
394  IXML_Document *in,
396  IXML_Document **out,
398  const char **errorString);
399 
405  IXML_Document *in,
407  IXML_Document **out,
409  const char **errorString);
410 
416 int TvDeviceSetTint(
418  IXML_Document *in,
420  IXML_Document **out,
422  const char **errorString);
423 
429  IXML_Document *in,
431  IXML_Document **out,
433  const char **errorString);
434 
440  IXML_Document *in,
442  IXML_Document **out,
444  const char **errorString);
445 
453  IXML_Document *in,
455  IXML_Document **out,
457  const char **errorString);
458 
464  IXML_Document *in,
466  IXML_Document **out,
468  const char **errorString);
469 
475  IXML_Document *in,
477  IXML_Document **out,
479  const char **errorString);
480 
488  IXML_Document *in,
490  IXML_Document **out,
492  const char **errorString);
493 
499  IXML_Document *in,
501  IXML_Document **out,
503  const char **errorString);
504 
510  IXML_Document *in,
512  IXML_Document **out,
514  const char **errorString);
515 
520 int TvDeviceStart(
523  char *iface,
526  unsigned short port,
529  const char *desc_doc_name,
532  const char *web_dir_path,
535  int ip_mode,
537  print_string pfun,
539  int combo);
540 
544 int TvDeviceStop(void);
545 
552 void *TvDeviceCommandLoop(void *args);
553 
568 int device_main(int argc, char *argv[]);
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 
578 #endif /* UPNP_TV_DEVICE_H */
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnp.h:439
int TvDeviceDecreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the volume.
Definition: tv_device.c:822
int TvDeviceSetBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the brightness, update the TvDevice picture service state table, and notify all subscribed con...
Definition: tv_device.c:1204
#define TV_MAXACTIONS
Definition: tv_device.h:130
int TvDeviceSetChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the channel, update the TvDevice control service state table, and notify all subscribed contro...
Definition: tv_device.c:614
int TvDeviceDecreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the contrast.
Definition: tv_device.c:1198
int TvDeviceDecreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the color.
Definition: tv_device.c:925
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, const void *Event, void *Cookie)
The callback handler registered with the SDK while registering root device.
Definition: tv_device.c:1315
int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power off.
Definition: tv_device.c:589
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *cgv_event)
Called during a get variable request callback.
Definition: tv_device.c:359
int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power on.
Definition: tv_device.c:563
#define TV_MAXVARS
Definition: tv_device.h:133
int SetActionTable(int serviceType, struct TvService *out)
Initializes the action table for the specified service.
Definition: tv_device.c:166
int TvDeviceSetColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the color, update the TvDevice picture service state table, and notify all subscribed control ...
Definition: tv_device.c:828
int TvDeviceDecreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease brightnesss.
Definition: tv_device.c:1309
int TvDeviceIncreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the volume.
Definition: tv_device.c:816
int device_main(int argc, char *argv[])
Main entry point for tv device application.
Definition: tv_device.c:1520
int(* upnp_action)(IXML_Document *request, IXML_Document **out, const char **errorString)
Prototype for all actions. For each action that a service implements, there is a corresponding functi...
Definition: tv_device.h:149
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *sr_event)
Called during a subscription request callback.
Definition: tv_device.c:303
struct TvService tv_service_table[]
Definition: tv_device.c:70
int TvDeviceIncreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the channel.
Definition: tv_device.c:712
int TvDeviceIncreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the contrast.
Definition: tv_device.c:1192
int TvDeviceSetContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the contrast, update the TvDevice picture service state table, and notify all subscribed contr...
Definition: tv_device.c:1092
UpnpDevice_Handle device_handle
Definition: tv_device.c:73
int TvDeviceSetTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the tint, update the TvDevice picture service state table, and notify all subscribed control p...
Definition: tv_device.c:937
ithread_mutex_t TVDevMutex
Definition: tv_device.c:79
int TvDeviceStart(char *iface, unsigned short port, const char *desc_doc_name, const char *web_dir_path, int ip_mode, print_string pfun, int combo)
Initializes the UPnP Sdk, registers the device, and sends out advertisements.
Definition: tv_device.c:1353
int TvDeviceSetServiceTableVar(unsigned int service, int variable, char *value)
Update the TvDevice service state table, and notify all subscribed control points of the updated stat...
Definition: tv_device.c:502
int TvDeviceDecreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease tint.
Definition: tv_device.c:1071
void(* print_string)(const char *string,...)
Prototype for displaying strings. All printing done by the device, control point, and sample util,...
Definition: sample_util.h:163
void * TvDeviceCommandLoop(void *args)
Function that receives commands from the user at the command prompt during the lifetime of the device...
Definition: tv_device.c:1489
int TvDeviceDecreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the channel.
Definition: tv_device.c:706
int TvDeviceIncreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase tint.
Definition: tv_device.c:1052
int TvDeviceIncreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase brightnesss.
Definition: tv_device.c:1303
int TvDeviceStop(void)
Stops the device. Uninitializes the sdk.
Definition: tv_device.c:1479
int TvDeviceIncreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the color.
Definition: tv_device.c:931
int TvDeviceSetVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Change the volume, update the TvDevice control service state table, and notify all subscribed control...
Definition: tv_device.c:718
int TvDeviceStateTableInit(char *DescDocURL)
Initialize the device state table for this TvDevice, pulling identifier info from the description Doc...
Definition: tv_device.c:221
int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event)
Called during an action request callback.
Definition: tv_device.c:415
Definition: tv_device.h:158
int VariableCount
Definition: tv_device.h:174
char UDN[NAME_SIZE]
Definition: tv_device.h:160
upnp_action actions[12]
Definition: tv_device.h:172
const char * VariableName[4]
Definition: tv_device.h:166
char * VariableStrVal[4]
Definition: tv_device.h:168
char ServiceType[NAME_SIZE]
Definition: tv_device.h:164
const char * ActionNames[12]
Definition: tv_device.h:170
char ServiceId[NAME_SIZE]
Definition: tv_device.h:162
Data structure representing the DOM Document.
Definition: ixml.h:160
Definition: UpnpActionRequest.c:19
Definition: UpnpStateVarRequest.c:19
Definition: UpnpSubscriptionRequest.c:19