tv_device.h
Go to the documentation of this file.
#ifndef UPNP_TV_DEVICE_H
#define UPNP_TV_DEVICE_H
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#include <signal.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "sample_util.h"
#include "ithread.h"
#include "upnp.h"
#include <stdlib.h>
#include <string.h>
#define MAX_COLOR 10
#define MIN_COLOR 1
#define MAX_BRIGHTNESS 10
#define MIN_BRIGHTNESS 1
#define POWER_ON 1
#define POWER_OFF 0
#define MAX_TINT 10
#define MIN_TINT 1
#define MAX_VOLUME 10
#define MIN_VOLUME 1
#define MAX_CONTRAST 10
#define MIN_CONTRAST 1
#define MAX_CHANNEL 100
#define MIN_CHANNEL 1
#define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0
#define TV_SERVICE_PICTURE 1
#define TV_CONTROL_VARCOUNT 3
#define TV_CONTROL_POWER 0
#define TV_CONTROL_CHANNEL 1
#define TV_CONTROL_VOLUME 2
#define TV_PICTURE_VARCOUNT 4
#define TV_PICTURE_COLOR 0
#define TV_PICTURE_TINT 1
#define TV_PICTURE_CONTRAST 2
#define TV_PICTURE_BRIGHTNESS 3
#define TV_MAX_VAL_LEN 5
#define TV_MAXACTIONS 12
#define TV_MAXVARS TV_PICTURE_VARCOUNT
#define IP_MODE_IPV4 1
#define IP_MODE_IPV6_LLA 2
#define IP_MODE_IPV6_ULA_GUA 3
typedef int (*upnp_action)(
IXML_Document *request,
IXML_Document **out,
const char **errorString);
struct TvService
{
char UDN[NAME_SIZE];
char ServiceId[NAME_SIZE];
char ServiceType[NAME_SIZE];
const char *VariableName[TV_MAXVARS];
char *VariableStrVal[TV_MAXVARS];
const char *ActionNames[TV_MAXACTIONS];
upnp_action actions[TV_MAXACTIONS];
int VariableCount;
};
extern struct TvService tv_service_table[];
extern UpnpDevice_Handle device_handle;
extern ithread_mutex_t TVDevMutex;
int SetActionTable(
int serviceType,
struct TvService *out);
int TvDeviceStateTableInit(
char *DescDocURL);
int TvDeviceHandleSubscriptionRequest(
const UpnpSubscriptionRequest *sr_event);
int TvDeviceHandleGetVarRequest(
UpnpStateVarRequest *cgv_event);
int TvDeviceHandleActionRequest(
UpnpActionRequest *ca_event);
int TvDeviceCallbackEventHandler(
Upnp_EventType,
const void *Event,
void *Cookie);
int TvDeviceSetServiceTableVar(
unsigned int service,
int variable,
char *value);
/* Control Service Actions */
int TvDevicePowerOn(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDevicePowerOff(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceSetChannel(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseChannel(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseChannel(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceSetVolume(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseVolume(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseVolume(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
/*Picture Service Actions */
int TvDeviceSetColor(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseColor(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseColor(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceSetTint(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseTint(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseTint(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceSetContrast(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseContrast(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseContrast(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceSetBrightness(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceIncreaseBrightness(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
int TvDeviceDecreaseBrightness(
IXML_Document *in,
IXML_Document **out,
const char **errorString);
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);
int TvDeviceStop(void);
void *TvDeviceCommandLoop(void *args);
int device_main(int argc, char *argv[]);
#ifdef __cplusplus
}
#endif
#endif /* UPNP_TV_DEVICE_H */
UpnpDevice_Handle
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition upnp.h:439
TvDeviceDecreaseVolume
int TvDeviceDecreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the volume.
Definition tv_device.c:835
TvDeviceSetBrightness
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:1240
TV_MAXACTIONS
#define TV_MAXACTIONS
Definition tv_device.h:130
TvDeviceSetChannel
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:619
TvDeviceDecreaseContrast
int TvDeviceDecreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the contrast.
Definition tv_device.c:1234
TvDeviceDecreaseColor
int TvDeviceDecreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the color.
Definition tv_device.c:946
TvDeviceCallbackEventHandler
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:1359
TvDevicePowerOff
int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power off.
Definition tv_device.c:594
TvDeviceHandleGetVarRequest
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *cgv_event)
Called during a get variable request callback.
Definition tv_device.c:364
TvDevicePowerOn
int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power on.
Definition tv_device.c:568
TV_MAXVARS
#define TV_MAXVARS
Definition tv_device.h:133
SetActionTable
int SetActionTable(int serviceType, struct TvService *out)
Initializes the action table for the specified service.
Definition tv_device.c:171
TvDeviceSetColor
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:841
TvDeviceDecreaseBrightness
int TvDeviceDecreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease brightnesss.
Definition tv_device.c:1353
TvDeviceIncreaseVolume
int TvDeviceIncreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the volume.
Definition tv_device.c:829
device_main
int device_main(int argc, char *argv[])
Main entry point for tv device application.
Definition tv_device.c:1569
upnp_action
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
TvDeviceHandleSubscriptionRequest
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *sr_event)
Called during a subscription request callback.
Definition tv_device.c:308
tv_service_table
struct TvService tv_service_table[]
Definition tv_device.c:75
TvDeviceIncreaseChannel
int TvDeviceIncreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the channel.
Definition tv_device.c:717
TvDeviceIncreaseContrast
int TvDeviceIncreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the contrast.
Definition tv_device.c:1228
TvDeviceSetContrast
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:1121
device_handle
UpnpDevice_Handle device_handle
Definition tv_device.c:78
TvDeviceSetTint
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:958
TVDevMutex
ithread_mutex_t TVDevMutex
Definition tv_device.c:84
TvDeviceStart
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:1397
TvDeviceSetServiceTableVar
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:507
TvDeviceDecreaseTint
int TvDeviceDecreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease tint.
Definition tv_device.c:1100
print_string
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:162
TvDeviceCommandLoop
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:1535
TvDeviceDecreaseChannel
int TvDeviceDecreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the channel.
Definition tv_device.c:711
TvDeviceIncreaseTint
int TvDeviceIncreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase tint.
Definition tv_device.c:1081
TvDeviceIncreaseBrightness
int TvDeviceIncreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase brightnesss.
Definition tv_device.c:1347
TvDeviceStop
int TvDeviceStop(void)
Stops the device. Uninitializes the sdk.
Definition tv_device.c:1525
TvDeviceIncreaseColor
int TvDeviceIncreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the color.
Definition tv_device.c:952
TvDeviceSetVolume
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:723
TvDeviceStateTableInit
int TvDeviceStateTableInit(char *DescDocURL)
Initialize the device state table for this TvDevice, pulling identifier info from the description Doc...
Definition tv_device.c:226
TvDeviceHandleActionRequest
int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event)
Called during an action request callback.
Definition tv_device.c:420
ithread.h
sample_util.h
TvService
Definition tv_device.h:159
TvService::VariableCount
int VariableCount
Definition tv_device.h:175
TvService::UDN
char UDN[NAME_SIZE]
Definition tv_device.h:161
TvService::actions
upnp_action actions[12]
Definition tv_device.h:173
TvService::VariableName
const char * VariableName[4]
Definition tv_device.h:167
TvService::VariableStrVal
char * VariableStrVal[4]
Definition tv_device.h:169
TvService::ServiceType
char ServiceType[NAME_SIZE]
Definition tv_device.h:165
TvService::ActionNames
const char * ActionNames[12]
Definition tv_device.h:171
TvService::ServiceId
char ServiceId[NAME_SIZE]
Definition tv_device.h:163
_IXML_Document
Data structure representing the DOM Document.
Definition ixml.h:160
s_UpnpActionRequest
Definition UpnpActionRequest.c:19
s_UpnpStateVarRequest
Definition UpnpStateVarRequest.c:19
s_UpnpSubscriptionRequest
Definition UpnpSubscriptionRequest.c:19
upnp.h