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 <stdio.h>
#include <signal.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
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 *ip_address,
unsigned short port,
const char *desc_doc_name,
const char *web_dir_path,
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 */
TvDeviceIncreaseChannel
int TvDeviceIncreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the channel.
Definition: tv_device.c:670
SetActionTable
int SetActionTable(int serviceType, struct TvService *out)
Initializes the action table for the specified service.
Definition: tv_device.c:164
TvDeviceHandleGetVarRequest
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *cgv_event)
Called during a get variable request callback.
Definition: tv_device.c:348
TvService::VariableName
const char * VariableName[4]
Definition: tv_device.h:162
upnp.h
TvDevicePowerOff
int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power off.
Definition: tv_device.c:553
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...
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:676
device_handle
UpnpDevice_Handle device_handle
Definition: tv_device.c:73
TvDevicePowerOn
int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorString)
Turn the power on.
Definition: tv_device.c:530
ithread.h
TvDeviceDecreaseContrast
int TvDeviceDecreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the contrast.
Definition: tv_device.c:1149
TvDeviceHandleActionRequest
int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event)
Called during an action request callback.
Definition: tv_device.c:395
TvDeviceIncreaseVolume
int TvDeviceIncreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the volume.
Definition: tv_device.c:773
TvService::UDN
char UDN[NAME_SIZE]
Definition: tv_device.h:156
TvDeviceStateTableInit
int TvDeviceStateTableInit(char *DescDocURL)
Initialize the device state table for this TvDevice, pulling identifier info from the description Doc...
Definition: tv_device.c:219
tv_service_table
struct TvService tv_service_table[]
Definition: tv_device.c:70
TvDeviceIncreaseContrast
int TvDeviceIncreaseContrast(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the contrast.
Definition: tv_device.c:1143
TvDeviceDecreaseTint
int TvDeviceDecreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease tint.
TV_MAXVARS
#define TV_MAXVARS
Definition: tv_device.h:133
TvService::ServiceId
char ServiceId[NAME_SIZE]
Definition: tv_device.h:158
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:575
sample_util.h
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
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:1155
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:1265
TvDeviceIncreaseTint
int TvDeviceIncreaseTint(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase tint.
device_main
int device_main(int argc, char *argv[])
Main entry point for tv device application.
Definition: tv_device.c:1418
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:892
TV_MAXACTIONS
#define TV_MAXACTIONS
Definition: tv_device.h:130
TvDeviceHandleSubscriptionRequest
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *sr_event)
Called during a subscription request callback.
Definition: tv_device.c:291
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:145
TvDeviceDecreaseBrightness
int TvDeviceDecreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease brightnesss.
Definition: tv_device.c:1259
UpnpDevice_Handle
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:436
TvDeviceDecreaseVolume
int TvDeviceDecreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the volume.
Definition: tv_device.c:779
TvDeviceIncreaseColor
int TvDeviceIncreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase the color.
Definition: tv_device.c:886
TvService::ActionNames
const char * ActionNames[12]
Definition: tv_device.h:166
TvDeviceDecreaseChannel
int TvDeviceDecreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the channel.
Definition: tv_device.c:664
TvDeviceDecreaseColor
int TvDeviceDecreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
Decrease the color.
Definition: tv_device.c:880
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:1388
TvService
Definition: tv_device.h:154
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:472
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:785
TvService::VariableStrVal
char * VariableStrVal[4]
Definition: tv_device.h:164
_IXML_Document
Data structure representing the DOM Document.
Definition: ixml.h:197
TvDeviceIncreaseBrightness
int TvDeviceIncreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
Increase brightnesss.
Definition: tv_device.c:1253
TvService::actions
upnp_action actions[12]
Definition: tv_device.h:168
TvService::VariableCount
int VariableCount
Definition: tv_device.h:170
TvDeviceStop
int TvDeviceStop(void)
Stops the device. Uninitializes the sdk.
Definition: tv_device.c:1378
TvService::ServiceType
char ServiceType[NAME_SIZE]
Definition: tv_device.h:160
TvDeviceStart
int TvDeviceStart(char *ip_address, unsigned short port, const char *desc_doc_name, const char *web_dir_path, print_string pfun, int combo)
Initializes the UPnP Sdk, registers the device, and sends out advertisements.
Definition: tv_device.c:1301
TVDevMutex
ithread_mutex_t TVDevMutex
Definition: tv_device.c:79