1///////////////////////////////////////////////////////////////////////////
2//
3// Copyright (c) 2000-2003 Intel Corporation
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright notice,
12// this list of conditions and the following disclaimer in the documentation
13// and/or other materials provided with the distribution.
14// * Neither name of Intel Corporation nor the names of its contributors
15// may be used to endorse or promote products derived from this software
16// without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30///////////////////////////////////////////////////////////////////////////
31
32#ifndef UPNP_TV_CTRLPT_H
33#define UPNP_TV_CTRLPT_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include <stdio.h>
40
41#include "ithread.h"
42#include <unistd.h>
43#include <stdarg.h>
44#include <stdlib.h>
45#include <signal.h>
46#include <string.h>
47
48#include "upnp.h"
49#include "upnptools.h"
50#include "sample_util.h"
51
52#define TV_SERVICE_SERVCOUNT	2
53#define TV_SERVICE_CONTROL		0
54#define TV_SERVICE_PICTURE		1
55
56#define TV_CONTROL_VARCOUNT		3
57#define TV_CONTROL_POWER		0
58#define TV_CONTROL_CHANNEL		1
59#define TV_CONTROL_VOLUME		2
60
61#define TV_PICTURE_VARCOUNT		4
62#define TV_PICTURE_COLOR		0
63#define TV_PICTURE_TINT			1
64#define TV_PICTURE_CONTRAST		2
65#define TV_PICTURE_BRIGHTNESS	3
66
67#define TV_MAX_VAL_LEN			5
68
69#define TV_SUCCESS				0
70#define TV_ERROR				(-1)
71#define TV_WARNING				1
72
73/* This should be the maximum VARCOUNT from above */
74#define TV_MAXVARS				TV_PICTURE_VARCOUNT
75
76extern char TvDeviceType[];
77extern char *TvServiceType[];
78extern char *TvServiceName[];
79extern char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS];
80extern char TvVarCount[];
81
82struct tv_service {
83    char ServiceId[NAME_SIZE];
84    char ServiceType[NAME_SIZE];
85    char *VariableStrVal[TV_MAXVARS];
86    char EventURL[NAME_SIZE];
87    char ControlURL[NAME_SIZE];
88    char SID[NAME_SIZE];
89};
90
91extern struct TvDeviceNode *GlobalDeviceList;
92
93struct TvDevice {
94    char UDN[250];
95    char DescDocURL[250];
96    char FriendlyName[250];
97    char PresURL[250];
98    int  AdvrTimeOut;
99    struct tv_service TvService[TV_SERVICE_SERVCOUNT];
100};
101
102struct TvDeviceNode {
103    struct TvDevice device;
104    struct TvDeviceNode *next;
105};
106
107extern ithread_mutex_t DeviceListMutex;
108
109extern UpnpClient_Handle ctrlpt_handle;
110
111void	TvCtrlPointPrintHelp( void );
112int		TvCtrlPointDeleteNode(struct TvDeviceNode*);
113int		TvCtrlPointRemoveDevice(char*);
114int		TvCtrlPointRemoveAll( void );
115int		TvCtrlPointRefresh( void );
116
117
118int		TvCtrlPointSendAction(int, int, char *, char **, char **, int);
119int		TvCtrlPointSendActionNumericArg(int devnum, int service, char *actionName, char *paramName, int paramValue);
120int		TvCtrlPointSendPowerOn(int devnum);
121int		TvCtrlPointSendPowerOff(int devnum);
122int		TvCtrlPointSendSetChannel(int, int);
123int		TvCtrlPointSendSetVolume(int, int);
124int		TvCtrlPointSendSetColor(int, int);
125int		TvCtrlPointSendSetTint(int, int);
126int		TvCtrlPointSendSetContrast(int, int);
127int		TvCtrlPointSendSetBrightness(int, int);
128
129int		TvCtrlPointGetVar(int, int, char*);
130int		TvCtrlPointGetPower(int devnum);
131int		TvCtrlPointGetChannel(int);
132int		TvCtrlPointGetVolume(int);
133int		TvCtrlPointGetColor(int);
134int		TvCtrlPointGetTint(int);
135int		TvCtrlPointGetContrast(int);
136int		TvCtrlPointGetBrightness(int);
137
138int		TvCtrlPointGetDevice(int, struct TvDeviceNode **);
139int		TvCtrlPointPrintList( void );
140int		TvCtrlPointPrintDevice(int);
141void	TvCtrlPointAddDevice (IXML_Document *, char *, int);
142void    TvCtrlPointHandleGetVar(char *,char *,DOMString);
143void	TvStateUpdate(char*,int, IXML_Document * , char **);
144void	TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
145void	TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
146int		TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
147void	TvCtrlPointVerifyTimeouts(int);
148void	TvCtrlPointPrintCommands( void );
149void*	TvCtrlPointCommandLoop( void* );
150int		TvCtrlPointStart( print_string printFunctionPtr, state_update updateFunctionPtr );
151int		TvCtrlPointStop( void );
152int		TvCtrlPointProcessCommand( char *cmdline );
153
154#ifdef __cplusplus
155};
156#endif
157
158#endif //UPNP_TV_CTRLPT_H
159