libUPnP
1.6.17
|
Data Structures | |
struct | cmdloop_commands |
struct | tv_service |
struct | TvDevice |
struct | TvDeviceNode |
struct | TvService |
Files | |
file | sample_util.c |
file | sample_util.h |
file | tv_ctrlpt.c |
file | tv_ctrlpt.h |
file | tv_device.c |
file | tv_device.h |
Typedefs | |
typedef void(* | print_string )(const char *string,...) |
Prototype for displaying strings. All printing done by the device, control point, and sample util, ultimately use this to display strings to the user. | |
typedef void(* | state_update )(const char *varName, const char *varValue, const char *UDN, eventType type) |
Prototype for passing back state changes. | |
Enumerations | |
enum | eventType { STATE_UPDATE = 0, DEVICE_ADDED = 1, DEVICE_REMOVED = 2, GET_VAR_COMPLETE = 3 } |
Functions | |
int | SampleUtil_Initialize (print_string print_function) |
Initializes the sample util. Must be called before any sample util functions. May be called multiple times. | |
int | SampleUtil_RegisterUpdateFunction (state_update update_function) |
int | SampleUtil_Finish () |
Releases Resources held by sample util. | |
char * | SampleUtil_GetElementValue (IXML_Element *element) |
Given a DOM node such as <Channel>11</Channel>, this routine extracts the value (e.g., 11) from the node and returns it as a string. The string must be freed by the caller using free. | |
IXML_NodeList * | SampleUtil_GetFirstServiceList (IXML_Document *doc) |
Given a DOM node representing a UPnP Device Description Document, this routine parses the document and finds the first service list (i.e., the service list for the root device). The service list is returned as a DOM node list. The NodeList must be freed using NodeList_free. | |
char * | SampleUtil_GetFirstDocumentItem (IXML_Document *doc,const char *item) |
Given a document node, this routine searches for the first element named by the input string item, and returns its value as a string. String must be freed by caller using free. | |
char * | SampleUtil_GetFirstElementItem (IXML_Element *element,const char *item) |
Given a DOM element, this routine searches for the first element named by the input string item, and returns its value as a string. The string must be freed using free. | |
void | SampleUtil_PrintEventType (Upnp_EventType S) |
Prints a callback event type as a string. | |
int | SampleUtil_PrintEvent (Upnp_EventType EventType,void *Event) |
Prints callback event structure details. | |
int | SampleUtil_FindAndParseService (IXML_Document *DescDoc,const char *location,const char *serviceType,char **serviceId,char **eventURL,char **controlURL) |
This routine finds the first occurance of a service in a DOM representation of a description document and parses it. Note that this function currently assumes that the eventURL and controlURL values in the service definitions are full URLs. Relative URLs are not handled here. | |
int | SampleUtil_Print (const char *fmt,...) |
Function emulating printf that ultimately calls the registered print function with the formatted string. | |
void | SampleUtil_StateUpdate (const char *varName,const char *varValue,const char *UDN,eventType type) |
void | linux_print (const char *format,...) |
Prints a string to standard out. | |
Variables | |
static int | initialize_init = 1 |
static int | initialize_register = 1 |
print_string | gPrintFun = NULL |
state_update | gStateUpdateFun = NULL |
ithread_mutex_t | display_mutex |
const char * | TvServiceType [] |
ithread_mutex_t | display_mutex |
print_string | gPrintFun |
state_update | gStateUpdateFun |
Control Point Sample Module | |
enum | cmdloop_tvcmds { PRTHELP = 0, PRTFULLHELP, POWON, POWOFF, SETCHAN, SETVOL, SETCOL, SETTINT, SETCONT, SETBRT, CTRLACTION, PICTACTION, CTRLGETVAR, PICTGETVAR, PRTDEV, LSTDEV, REFRESH, EXITCMD } |
ithread_mutex_t | DeviceListMutex |
UpnpClient_Handle | ctrlpt_handle = -1 |
const char | TvDeviceType [] = "urn:schemas-upnp-org:device:tvdevice:1" |
const char * | TvServiceName [] = { "Control", "Picture" } |
const char * | TvVarName [2][4] |
char | TvVarCount [2] |
int | default_timeout = 1801 |
struct TvDeviceNode * | GlobalDeviceList = NULL |
static int | TvCtrlPointTimerLoopRun = 1 |
Function that runs in its own thread and monitors advertisement and subscription timeouts for devices in the global device list. | |
struct cmdloop_commands | cmdloop_commands |
static struct cmdloop_commands | cmdloop_cmdlist [] |
int | TvCtrlPointDeleteNode (struct TvDeviceNode *node) |
int | TvCtrlPointRemoveDevice (const char *UDN) |
int | TvCtrlPointRemoveAll (void) |
int | TvCtrlPointRefresh (void) |
int | TvCtrlPointGetVar (int service, int devnum, const char *varname) |
int | TvCtrlPointGetPower (int devnum) |
int | TvCtrlPointGetChannel (int devnum) |
int | TvCtrlPointGetVolume (int devnum) |
int | TvCtrlPointGetColor (int devnum) |
int | TvCtrlPointGetTint (int devnum) |
int | TvCtrlPointGetContrast (int devnum) |
int | TvCtrlPointGetBrightness (int devnum) |
int | TvCtrlPointSendAction (int service, int devnum, const char *actionname, const char **param_name, char **param_val, int param_count) |
int | TvCtrlPointSendActionNumericArg (int devnum, int service, const char *actionName, const char *paramName, int paramValue) |
int | TvCtrlPointSendPowerOn (int devnum) |
int | TvCtrlPointSendPowerOff (int devnum) |
int | TvCtrlPointSendSetChannel (int devnum, int channel) |
int | TvCtrlPointSendSetVolume (int devnum, int volume) |
int | TvCtrlPointSendSetColor (int devnum, int color) |
int | TvCtrlPointSendSetTint (int devnum, int tint) |
int | TvCtrlPointSendSetContrast (int devnum, int contrast) |
int | TvCtrlPointSendSetBrightness (int devnum, int brightness) |
int | TvCtrlPointGetDevice (int devnum, struct TvDeviceNode **devnode) |
int | TvCtrlPointPrintList () |
int | TvCtrlPointPrintDevice (int devnum) |
void | TvCtrlPointAddDevice (IXML_Document *DescDoc, const char *location, int expires) |
void | TvStateUpdate (char *UDN,int Service,IXML_Document *ChangedVariables,char **State) |
Update a Tv state table. Called when an event is received. | |
void | TvCtrlPointHandleEvent (const char *sid, int evntkey, IXML_Document *changes) |
void | TvCtrlPointHandleSubscribeUpdate (const char *eventURL, const Upnp_SID sid, int timeout) |
void | TvCtrlPointHandleGetVar (const char *controlURL, const char *varName, const DOMString varValue) |
int | TvCtrlPointCallbackEventHandler (Upnp_EventType EventType, void *Event, void *Cookie) |
void | TvCtrlPointVerifyTimeouts (int incr) |
Checks the advertisement each device in the global device list. | |
void * | TvCtrlPointTimerLoop (void *args) |
int | TvCtrlPointStart (print_string printFunctionPtr, state_update updateFunctionPtr, int combo) |
Call this function to initialize the UPnP library and start the TV Control Point. This function creates a timer thread and provides a callback handler to process any UPnP events that are received. | |
int | TvCtrlPointStop (void) |
void | TvCtrlPointPrintShortHelp (void) |
Print help info for this application. | |
void | TvCtrlPointPrintLongHelp (void) |
Print long help info for this application. | |
void | TvCtrlPointPrintCommands (void) |
void * | TvCtrlPointCommandLoop (void *args) |
Function that receives commands from the user at the command prompt during the lifetime of the device, and calls the appropriate functions for those commands. | |
int | TvCtrlPointProcessCommand (char *cmdline) |
Contro Point Sample API | |
const char * | TvServiceName [] |
const char * | TvVarName [2][4] |
char | TvVarCount [] |
struct TvDeviceNode * | GlobalDeviceList |
ithread_mutex_t | DeviceListMutex |
UpnpClient_Handle | ctrlpt_handle |
void | TvCtrlPointPrintHelp (void) |
#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_SUCCESS 0 |
#define | TV_ERROR (-1) |
#define | TV_WARNING 1 |
#define | TV_MAXVARS TV_PICTURE_VARCOUNT |
Device Sample Module | |
const char * | tvc_varname [] = { "Power", "Channel", "Volume" } |
char | tvc_varval [3][5] |
const char * | tvc_varval_def [] = { "1", "1", "5" } |
const char * | tvp_varname [] = { "Color", "Tint", "Contrast", "Brightness" } |
char | tvp_varval [4][5] |
const char * | tvp_varval_def [] = { "5", "5", "5", "5" } |
int | default_advr_expire = 100 |
struct TvService | tv_service_table [2] |
UpnpDevice_Handle | device_handle = -1 |
ithread_mutex_t | TVDevMutex |
static int | SetServiceTable (int serviceType, const char *UDN, const char *serviceId, const char *serviceTypeS, struct TvService *out) |
Initializes the service table for the specified service. | |
int | SetActionTable (int serviceType,struct TvService *out) |
Initializes the action table for the specified service. | |
int | TvDeviceStateTableInit (char *DescDocURL) |
Initialize the device state table for this TvDevice, pulling identifier info from the description Document. | |
int | TvDeviceHandleSubscriptionRequest (struct Upnp_Subscription_Request *sr_event) |
Called during a subscription request callback. | |
int | TvDeviceHandleGetVarRequest (struct Upnp_State_Var_Request *cgv_event) |
Called during a get variable request callback. | |
int | TvDeviceHandleActionRequest (struct Upnp_Action_Request *ca_event) |
Called during an action request callback. | |
int | TvDeviceSetServiceTableVar (unsigned int service,int variable,char *value) |
Update the TvDevice service state table, and notify all subscribed control points of the updated state. | |
static int | TvDeviceSetPower (int on) |
Turn the power on/off, update the TvDevice control service state table, and notify all subscribed control points of the updated state. | |
int | TvDevicePowerOn (IXML_Document *in,IXML_Document **out,const char **errorString) |
Turn the power on. | |
int | TvDevicePowerOff (IXML_Document *in,IXML_Document **out,const char **errorString) |
Turn the power off. | |
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 control points of the updated state. | |
int | IncrementChannel (int incr, IN IXML_Document *in, IXML_Document **out, const char **errorString) |
int | TvDeviceDecreaseChannel (IXML_Document *in,IXML_Document **out,const char **errorString) |
Decrease the channel. | |
int | TvDeviceIncreaseChannel (IXML_Document *in,IXML_Document **out,const char **errorString) |
Increase the channel. | |
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 points of the updated state. | |
static int | IncrementVolume (int incr, IXML_Document *in, IXML_Document **out, const char **errorString) |
Increment the volume. Read the current volume from the state table, add the increment, and then change the volume. | |
int | TvDeviceIncreaseVolume (IXML_Document *in,IXML_Document **out,const char **errorString) |
Increase the volume. | |
int | TvDeviceDecreaseVolume (IXML_Document *in,IXML_Document **out,const char **errorString) |
Decrease the volume. | |
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 points of the updated state. | |
static int | IncrementColor (int incr, IXML_Document *in, IXML_Document **out, const char **errorString) |
Increment the color. Read the current color from the state table, add the increment, and then change the color. | |
int | TvDeviceDecreaseColor (IXML_Document *in,IXML_Document **out,const char **errorString) |
Decrease the color. | |
int | TvDeviceIncreaseColor (IXML_Document *in,IXML_Document **out,const char **errorString) |
Increase the color. | |
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 points of the updated state. | |
int | IncrementTint (IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) |
int | TvDeviceIncreaseTint (IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) |
int | TvDeviceDecreaseTint (IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) |
int | TvDeviceSetContrast (IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) |
static int | IncrementContrast (int incr, IXML_Document *in, IXML_Document **out, const char **errorString) |
Increment the contrast. Read the current contrast from the state table, add the increment, and then change the contrast. | |
int | TvDeviceIncreaseContrast (IXML_Document *in,IXML_Document **out,const char **errorString) |
Increase the contrast. | |
int | TvDeviceDecreaseContrast (IXML_Document *in,IXML_Document **out,const char **errorString) |
Decrease the contrast. | |
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 control points of the updated state. | |
static int | IncrementBrightness (int incr, IXML_Document *in, IXML_Document **out, const char **errorString) |
Increment the brightness. Read the current brightness from the state table, add the increment, and then change the brightness. | |
int | TvDeviceIncreaseBrightness (IXML_Document *in,IXML_Document **out,const char **errorString) |
Increase brightnesss. | |
int | TvDeviceDecreaseBrightness (IXML_Document *in,IXML_Document **out,const char **errorString) |
Decrease brightnesss. | |
int | TvDeviceCallbackEventHandler (Upnp_EventType,void *Event,void *Cookie) |
The callback handler registered with the SDK while registering root device. | |
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. | |
int | TvDeviceStop (void) |
Stops the device. Uninitializes the sdk. | |
void * | TvDeviceCommandLoop (void *args) |
Function that receives commands from the user at the command prompt during the lifetime of the device, and calls the appropriate functions for those commands. Only one command, exit, is currently defined. | |
int | device_main (int argc, char *argv[]) |
Main entry point for tv device application. | |
#define | DEFAULT_WEB_DIR "./web" |
#define | DESC_URL_SIZE 200 |
#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 |
Device Sample API | |
typedef 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 function with this prototype. | |
struct TvService | tv_service_table [] |
UpnpDevice_Handle | device_handle |
ithread_mutex_t | TVDevMutex |
int | TvDeviceIncreaseTint (IXML_Document *in, IXML_Document **out, const char **errorString) |
Increase tint. | |
int | TvDeviceDecreaseTint (IXML_Document *in, IXML_Document **out, const char **errorString) |
Decrease tint. | |
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 control points of the updated state. | |
#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 MAX_BRIGHTNESS 10 |
Brightness constants
#define MAX_BRIGHTNESS 10 |
Brightness constants
Referenced by IncrementBrightness(), and TvDeviceSetBrightness().
#define MAX_CHANNEL 100 |
Channel constants
#define MAX_CHANNEL 100 |
Channel constants
Referenced by TvDeviceSetChannel().
#define MAX_COLOR 10 |
Color constants
#define MAX_COLOR 10 |
Color constants
Referenced by IncrementColor(), and TvDeviceSetColor().
#define MAX_CONTRAST 10 |
Contrast constants
#define MAX_CONTRAST 10 |
Contrast constants
#define MAX_TINT 10 |
Tint constants
#define MAX_TINT 10 |
Tint constants
Referenced by TvDeviceSetTint().
#define MAX_VOLUME 10 |
Volume constants
#define MAX_VOLUME 10 |
Volume constants
Referenced by IncrementVolume(), and TvDeviceSetVolume().
#define POWER_ON 1 |
Power constants
#define POWER_ON 1 |
Power constants
Referenced by TvDevicePowerOn(), and TvDeviceSetPower().
#define TV_CONTROL_CHANNEL 1 |
Index of channel variable
Referenced by TvDeviceSetChannel().
#define TV_CONTROL_POWER 0 |
Index of power variable
Referenced by TvDeviceHandleActionRequest(), and TvDeviceSetPower().
#define TV_CONTROL_VARCOUNT 3 |
Number of control variables
Referenced by SetServiceTable().
#define TV_CONTROL_VOLUME 2 |
Index of volume variable
Referenced by IncrementVolume(), and TvDeviceSetVolume().
#define TV_MAX_VAL_LEN 5 |
Max value length
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), TvDeviceSetPower(), and TvDeviceSetServiceTableVar().
#define TV_MAXACTIONS 12 |
Max actions
Referenced by TvDeviceHandleActionRequest().
#define TV_MAXVARS TV_PICTURE_VARCOUNT |
This should be the maximum VARCOUNT from above
#define TV_PICTURE_BRIGHTNESS 3 |
Index of brightness variable
Referenced by IncrementBrightness(), and TvDeviceSetBrightness().
#define TV_PICTURE_COLOR 0 |
Index of color variable
Referenced by IncrementColor(), and TvDeviceSetColor().
#define TV_PICTURE_CONTRAST 2 |
Index of contrast variable
Referenced by IncrementContrast().
#define TV_PICTURE_TINT 1 |
Index of tint variable
Referenced by TvDeviceSetTint().
#define TV_PICTURE_VARCOUNT 4 |
Number of picture variables
Referenced by SetServiceTable().
#define TV_SERVICE_CONTROL 0 |
Index of control service
Referenced by IncrementVolume(), SetActionTable(), SetServiceTable(), TvDeviceHandleActionRequest(), TvDevicePowerOff(), TvDevicePowerOn(), TvDeviceSetChannel(), TvDeviceSetPower(), TvDeviceSetVolume(), and TvDeviceStateTableInit().
#define TV_SERVICE_PICTURE 1 |
Index of picture service
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), SetActionTable(), SetServiceTable(), TvDeviceHandleActionRequest(), TvDeviceSetBrightness(), TvDeviceSetColor(), TvDeviceSetTint(), and TvDeviceStateTableInit().
#define TV_SERVICE_SERVCOUNT 2 |
Number of services.
Referenced by TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), and TvDeviceSetServiceTableVar().
typedef void(* print_string)(const char *string,...) |
Prototype for displaying strings. All printing done by the device, control point, and sample util, ultimately use this to display strings to the user.
typedef void(* state_update)(const char *varName,const char *varValue,const char *UDN,eventType type) |
Prototype for passing back state changes.
typedef 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 function with this prototype.
Pointers to these functions, along with action names, are stored in the service table. When an action request comes in the action name is matched, and the appropriate function is called. Each function returns UPNP_E_SUCCESS, on success, and a nonzero error code on failure.
enum cmdloop_tvcmds |
Tags for valid commands issued at the command prompt.
int device_main | ( | int | argc, |
char * | argv[] | ||
) |
Main entry point for tv device application.
Initializes and registers with the sdk. Initializes the state stables of the service. Starts the command loop.
Accepts the following optional arguments:
-ip
ipaddress -port
port -desc
desc_doc_name -webdir
web_dir_path -help
References linux_print(), SampleUtil_Initialize(), SampleUtil_Print(), and TvDeviceStart().
static int IncrementBrightness | ( | int | incr, |
IXML_Document * | in, | ||
IXML_Document ** | out, | ||
const char ** | errorString | ||
) | [static] |
Increment the brightness. Read the current brightness from the state table, add the increment, and then change the brightness.
[in] | incr | The increment by which to change the brightness. |
[in] | in | action request document. |
[out] | out | action result document. |
[out] | errorString | errorString (in case action was unsuccessful). |
References MAX_BRIGHTNESS, SampleUtil_Print(), TV_MAX_VAL_LEN, TV_PICTURE_BRIGHTNESS, TV_SERVICE_PICTURE, tv_service_table, TvDeviceSetServiceTableVar(), TVDevMutex, UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, UpnpAddToActionResponse(), and TvService::VariableStrVal.
Referenced by TvDeviceDecreaseBrightness(), and TvDeviceIncreaseBrightness().
static int IncrementColor | ( | int | incr, |
IXML_Document * | in, | ||
IXML_Document ** | out, | ||
const char ** | errorString | ||
) | [static] |
Increment the color. Read the current color from the state table, add the increment, and then change the color.
[in] | incr | The increment by which to change the volume. |
[in] | in | Action request document. |
[out] | out | Action result document. |
[out] | errorString | Error string in case action was unsuccessful. |
References MAX_COLOR, SampleUtil_Print(), TV_MAX_VAL_LEN, TV_PICTURE_COLOR, TV_SERVICE_PICTURE, tv_service_table, TvDeviceSetServiceTableVar(), TVDevMutex, UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, UpnpAddToActionResponse(), and TvService::VariableStrVal.
Referenced by TvDeviceDecreaseColor(), and TvDeviceIncreaseColor().
static int IncrementContrast | ( | int | incr, |
IXML_Document * | in, | ||
IXML_Document ** | out, | ||
const char ** | errorString | ||
) | [static] |
Increment the contrast. Read the current contrast from the state table, add the increment, and then change the contrast.
[in] | incr | The increment by which to change the volume. |
[in] | in | Action request document. |
[out] | out | Action result document. |
[out] | errorString | Error string in case action was unsuccessful. |
References SampleUtil_Print(), TV_MAX_VAL_LEN, TV_PICTURE_CONTRAST, TV_SERVICE_PICTURE, tv_service_table, TvDeviceSetServiceTableVar(), TVDevMutex, UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, UpnpAddToActionResponse(), and TvService::VariableStrVal.
Referenced by TvDeviceDecreaseContrast(), and TvDeviceIncreaseContrast().
static int IncrementVolume | ( | int | incr, |
IXML_Document * | in, | ||
IXML_Document ** | out, | ||
const char ** | errorString | ||
) | [static] |
Increment the volume. Read the current volume from the state table, add the increment, and then change the volume.
[in] | incr | The increment by which to change the volume. |
[in] | in | Action request document. |
[out] | out | Action result document. |
[out] | errorString | Error string in case action was unsuccessful. |
References MAX_VOLUME, SampleUtil_Print(), TV_CONTROL_VOLUME, TV_MAX_VAL_LEN, TV_SERVICE_CONTROL, tv_service_table, TvDeviceSetServiceTableVar(), TVDevMutex, UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, UpnpAddToActionResponse(), and TvService::VariableStrVal.
Referenced by TvDeviceDecreaseVolume(), and TvDeviceIncreaseVolume().
void linux_print | ( | const char * | format, |
... | |||
) |
Prints a string to standard out.
Referenced by device_main().
int SampleUtil_FindAndParseService | ( | IXML_Document * | DescDoc, |
const char * | location, | ||
const char * | serviceType, | ||
char ** | serviceId, | ||
char ** | eventURL, | ||
char ** | controlURL | ||
) |
This routine finds the first occurance of a service in a DOM representation of a description document and parses it. Note that this function currently assumes that the eventURL and controlURL values in the service definitions are full URLs. Relative URLs are not handled here.
[in] | DescDoc | The DOM description document. |
[in] | location | The location of the description document. |
[in] | serviceType | The type of service to search for. |
[out] | serviceId | The service ID. |
[out] | eventURL | The event URL for the service. |
[out] | controlURL | The control URL for the service. |
References ixmlNodeList_free(), ixmlNodeList_item(), ixmlNodeList_length(), SampleUtil_GetFirstDocumentItem(), SampleUtil_GetFirstElementItem(), SampleUtil_GetFirstServiceList(), SampleUtil_Print(), UPNP_E_SUCCESS, and UpnpResolveURL().
Referenced by TvDeviceStateTableInit().
int SampleUtil_Finish | ( | ) |
Releases Resources held by sample util.
References display_mutex, gPrintFun, gStateUpdateFun, and UPNP_E_SUCCESS.
Referenced by TvDeviceStop().
char * SampleUtil_GetElementValue | ( | IXML_Element * | element | ) |
Given a DOM node such as <Channel>11</Channel>, this routine extracts the value (e.g., 11) from the node and returns it as a string. The string must be freed by the caller using free.
[in] | element | The DOM node from which to extract the value. |
References ixmlNode_getFirstChild(), ixmlNode_getNodeType(), and ixmlNode_getNodeValue().
Referenced by TvStateUpdate().
char * SampleUtil_GetFirstDocumentItem | ( | IXML_Document * | doc, |
const char * | item | ||
) |
Given a document node, this routine searches for the first element named by the input string item, and returns its value as a string. String must be freed by caller using free.
[in] | doc | The DOM document from which to extract the value. |
[in] | item | The item to search for. |
References ixmlDocument_getElementsByTagName(), ixmlNode_getFirstChild(), ixmlNode_getNodeValue(), ixmlNodeList_free(), ixmlNodeList_item(), and SampleUtil_Print().
Referenced by SampleUtil_FindAndParseService(), TvDeviceSetBrightness(), TvDeviceSetChannel(), TvDeviceSetColor(), TvDeviceSetTint(), TvDeviceSetVolume(), and TvDeviceStateTableInit().
char * SampleUtil_GetFirstElementItem | ( | IXML_Element * | element, |
const char * | item | ||
) |
Given a DOM element, this routine searches for the first element named by the input string item, and returns its value as a string. The string must be freed using free.
[in] | element | The DOM element from which to extract the value. |
[in] | item | The item to search for. |
References ixmlElement_getElementsByTagName(), ixmlNode_getFirstChild(), ixmlNode_getNodeValue(), ixmlNodeList_free(), ixmlNodeList_item(), and SampleUtil_Print().
Referenced by SampleUtil_FindAndParseService().
Given a DOM node representing a UPnP Device Description Document, this routine parses the document and finds the first service list (i.e., the service list for the root device). The service list is returned as a DOM node list. The NodeList must be freed using NodeList_free.
[in] | doc | The DOM node from which to extract the service list. |
References ixmlDocument_getElementsByTagName(), ixmlElement_getElementsByTagName(), ixmlNodeList_free(), ixmlNodeList_item(), and ixmlNodeList_length().
Referenced by SampleUtil_FindAndParseService().
int SampleUtil_Initialize | ( | print_string | print_function | ) |
Initializes the sample util. Must be called before any sample util functions. May be called multiple times.
[in] | print_function | Print function to use in SampleUtil_Print. |
References display_mutex, gPrintFun, and UPNP_E_SUCCESS.
Referenced by device_main(), TvCtrlPointStart(), and TvDeviceStart().
int SampleUtil_Print | ( | const char * | fmt, |
... | |||
) |
Function emulating printf that ultimately calls the registered print function with the formatted string.
Provides platform-specific print functionality. This function should be called when you want to print content suitable for console output (i.e., in a large text box or on a screen). If your device/operating system is not supported here, you should add a port.
[in] | fmt | Format (see printf). |
References display_mutex, and gPrintFun.
Referenced by device_main(), IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), SampleUtil_FindAndParseService(), SampleUtil_GetFirstDocumentItem(), SampleUtil_GetFirstElementItem(), SampleUtil_PrintEvent(), SampleUtil_PrintEventType(), TvCtrlPointCommandLoop(), TvCtrlPointPrintCommands(), TvCtrlPointPrintLongHelp(), TvCtrlPointPrintShortHelp(), TvCtrlPointStart(), TvCtrlPointVerifyTimeouts(), TvDeviceCallbackEventHandler(), TvDeviceCommandLoop(), TvDeviceHandleGetVarRequest(), TvDeviceSetBrightness(), TvDeviceSetChannel(), TvDeviceSetColor(), TvDeviceSetPower(), TvDeviceSetTint(), TvDeviceSetVolume(), TvDeviceStart(), TvDeviceStateTableInit(), and TvStateUpdate().
int SampleUtil_PrintEvent | ( | Upnp_EventType | EventType, |
void * | Event | ||
) |
Prints callback event structure details.
[in] | EventType | The type of callback event. |
[in] | Event | The callback event structure. |
References Upnp_Action_Request::ActionName, Upnp_Action_Request::ActionRequest, Upnp_Action_Complete::ActionRequest, Upnp_Action_Request::ActionResult, Upnp_Action_Complete::ActionResult, Upnp_Event::ChangedVariables, Upnp_Action_Complete::CtrlUrl, Upnp_State_Var_Complete::CtrlUrl, Upnp_State_Var_Request::CurrentVal, Upnp_State_Var_Complete::CurrentVal, Upnp_Discovery::DeviceId, Upnp_Discovery::DeviceType, Upnp_Action_Request::DevUDN, Upnp_State_Var_Request::DevUDN, display_mutex, Upnp_Action_Request::ErrCode, Upnp_Action_Complete::ErrCode, Upnp_State_Var_Request::ErrCode, Upnp_State_Var_Complete::ErrCode, Upnp_Discovery::ErrCode, Upnp_Event_Subscribe::ErrCode, Upnp_Action_Request::ErrStr, Upnp_State_Var_Request::ErrStr, Upnp_Event::EventKey, Upnp_Discovery::Expires, Upnp_Discovery::Ext, ixmlFreeDOMString(), ixmlPrintNode(), Upnp_Discovery::Location, Upnp_Discovery::Os, Upnp_Event_Subscribe::PublisherUrl, SampleUtil_Print(), SampleUtil_PrintEventType(), Upnp_Action_Request::ServiceID, Upnp_State_Var_Request::ServiceID, Upnp_Subscription_Request::ServiceId, Upnp_Discovery::ServiceType, Upnp_Discovery::ServiceVer, Upnp_Event::Sid, Upnp_Event_Subscribe::Sid, Upnp_Subscription_Request::Sid, Upnp_State_Var_Request::StateVarName, Upnp_State_Var_Complete::StateVarName, Upnp_Event_Subscribe::TimeOut, Upnp_Subscription_Request::UDN, UPNP_CONTROL_ACTION_COMPLETE, UPNP_CONTROL_ACTION_REQUEST, UPNP_CONTROL_GET_VAR_COMPLETE, UPNP_CONTROL_GET_VAR_REQUEST, UPNP_DISCOVERY_ADVERTISEMENT_ALIVE, UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE, UPNP_DISCOVERY_SEARCH_RESULT, UPNP_DISCOVERY_SEARCH_TIMEOUT, UPNP_EVENT_AUTORENEWAL_FAILED, UPNP_EVENT_RECEIVED, UPNP_EVENT_RENEWAL_COMPLETE, UPNP_EVENT_SUBSCRIBE_COMPLETE, UPNP_EVENT_SUBSCRIPTION_EXPIRED, UPNP_EVENT_SUBSCRIPTION_REQUEST, UPNP_EVENT_UNSUBSCRIBE_COMPLETE, and UpnpGetErrorMessage().
Referenced by TvDeviceCallbackEventHandler().
void SampleUtil_PrintEventType | ( | Upnp_EventType | S | ) |
Prints a callback event type as a string.
[in] | S | The callback event. |
References SampleUtil_Print(), UPNP_CONTROL_ACTION_COMPLETE, UPNP_CONTROL_ACTION_REQUEST, UPNP_CONTROL_GET_VAR_COMPLETE, UPNP_CONTROL_GET_VAR_REQUEST, UPNP_DISCOVERY_ADVERTISEMENT_ALIVE, UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE, UPNP_DISCOVERY_SEARCH_RESULT, UPNP_DISCOVERY_SEARCH_TIMEOUT, UPNP_EVENT_AUTORENEWAL_FAILED, UPNP_EVENT_RECEIVED, UPNP_EVENT_RENEWAL_COMPLETE, UPNP_EVENT_SUBSCRIBE_COMPLETE, UPNP_EVENT_SUBSCRIPTION_EXPIRED, UPNP_EVENT_SUBSCRIPTION_REQUEST, and UPNP_EVENT_UNSUBSCRIBE_COMPLETE.
Referenced by SampleUtil_PrintEvent().
int SampleUtil_RegisterUpdateFunction | ( | state_update | update_function | ) |
[in] | update_function | . |
References gStateUpdateFun, and UPNP_E_SUCCESS.
Referenced by TvCtrlPointStart().
void SampleUtil_StateUpdate | ( | const char * | varName, |
const char * | varValue, | ||
const char * | UDN, | ||
eventType | type | ||
) |
[in] | varName | . |
[in] | varValue | . |
[in] | UDN | . |
[in] | type | . |
References gStateUpdateFun.
int SetActionTable | ( | int | serviceType, |
struct TvService * | out | ||
) |
Initializes the action table for the specified service.
Note that knowledge of the service description is assumed. Action names are hardcoded.
[in] | serviceType | one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. |
[in,out] | out | service containing action table to set. |
References TvService::ActionNames, TvService::actions, TV_SERVICE_CONTROL, TV_SERVICE_PICTURE, TvDeviceDecreaseBrightness(), TvDeviceDecreaseChannel(), TvDeviceDecreaseColor(), TvDeviceDecreaseContrast(), TvDeviceDecreaseTint(), TvDeviceDecreaseVolume(), TvDeviceIncreaseBrightness(), TvDeviceIncreaseChannel(), TvDeviceIncreaseColor(), TvDeviceIncreaseContrast(), TvDeviceIncreaseTint(), TvDeviceIncreaseVolume(), TvDevicePowerOff(), TvDevicePowerOn(), TvDeviceSetBrightness(), TvDeviceSetChannel(), TvDeviceSetColor(), TvDeviceSetContrast(), TvDeviceSetTint(), and TvDeviceSetVolume().
Referenced by SetServiceTable().
static int SetServiceTable | ( | int | serviceType, |
const char * | UDN, | ||
const char * | serviceId, | ||
const char * | serviceTypeS, | ||
struct TvService * | out | ||
) | [static] |
Initializes the service table for the specified service.
[in] | serviceType | one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. |
[in] | UDN | UDN of device containing service. |
[in] | serviceId | serviceId of service. |
[in] | serviceTypeS | service type (as specified in Description Document) . |
[in,out] | out | service containing table to be set. |
References TvService::ServiceId, TvService::ServiceType, SetActionTable(), TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT, TV_SERVICE_CONTROL, TV_SERVICE_PICTURE, tv_service_table, tvc_varname, tvp_varname, TvService::UDN, TvService::VariableCount, TvService::VariableName, and TvService::VariableStrVal.
Referenced by TvDeviceStateTableInit().
void * TvCtrlPointCommandLoop | ( | void * | args | ) |
Function that receives commands from the user at the command prompt during the lifetime of the device, and calls the appropriate functions for those commands.
References SampleUtil_Print().
void TvCtrlPointPrintCommands | ( | void | ) |
the list of valid command line commands to the user
References cmdloop_cmdlist, and SampleUtil_Print().
void TvCtrlPointPrintLongHelp | ( | void | ) |
Print long help info for this application.
References SampleUtil_Print().
void TvCtrlPointPrintShortHelp | ( | void | ) |
Print help info for this application.
References SampleUtil_Print().
int TvCtrlPointStart | ( | print_string | printFunctionPtr, |
state_update | updateFunctionPtr, | ||
int | combo | ||
) |
Call this function to initialize the UPnP library and start the TV Control Point. This function creates a timer thread and provides a callback handler to process any UPnP events that are received.
References DeviceListMutex, SampleUtil_Initialize(), SampleUtil_Print(), SampleUtil_RegisterUpdateFunction(), UPNP_E_SUCCESS, UpnpFinish(), UpnpGetServerIpAddress(), UpnpGetServerPort(), UpnpInit(), and UpnpRegisterClient().
void TvCtrlPointVerifyTimeouts | ( | int | incr | ) |
Checks the advertisement each device in the global device list.
If an advertisement expires, the device is removed from the list.
If an advertisement is about to expire, a search request is sent for that device.
[in] | incr | The increment to subtract from the timeouts each time the function is called. |
References DeviceListMutex, GlobalDeviceList, SampleUtil_Print(), UPNP_E_SUCCESS, and UpnpSearchAsync().
int TvDeviceCallbackEventHandler | ( | Upnp_EventType | , |
void * | Event, | ||
void * | Cookie | ||
) |
The callback handler registered with the SDK while registering root device.
Dispatches the request to the appropriate procedure based on the value of EventType. The four requests handled by the device are:
[in] | EventType | The type of callback event. |
[in] | Event | Data structure containing event data. |
[in] | Cookie | Optional data specified during callback registration. |
References SampleUtil_Print(), SampleUtil_PrintEvent(), TvDeviceHandleActionRequest(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), UPNP_CONTROL_ACTION_COMPLETE, UPNP_CONTROL_ACTION_REQUEST, UPNP_CONTROL_GET_VAR_COMPLETE, UPNP_CONTROL_GET_VAR_REQUEST, UPNP_DISCOVERY_ADVERTISEMENT_ALIVE, UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE, UPNP_DISCOVERY_SEARCH_RESULT, UPNP_DISCOVERY_SEARCH_TIMEOUT, UPNP_EVENT_RECEIVED, UPNP_EVENT_RENEWAL_COMPLETE, UPNP_EVENT_SUBSCRIBE_COMPLETE, UPNP_EVENT_SUBSCRIPTION_REQUEST, and UPNP_EVENT_UNSUBSCRIBE_COMPLETE.
Referenced by TvDeviceStart().
void * TvDeviceCommandLoop | ( | void * | args | ) |
Function that receives commands from the user at the command prompt during the lifetime of the device, and calls the appropriate functions for those commands. Only one command, exit, is currently defined.
References SampleUtil_Print(), and TvDeviceStop().
int TvDeviceDecreaseBrightness | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease brightnesss.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementBrightness().
Referenced by SetActionTable().
int TvDeviceDecreaseChannel | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease the channel.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
Referenced by SetActionTable().
int TvDeviceDecreaseColor | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease the color.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementColor().
Referenced by SetActionTable().
int TvDeviceDecreaseContrast | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease the contrast.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementContrast().
Referenced by SetActionTable().
int TvDeviceDecreaseTint | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease tint.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
Referenced by SetActionTable().
int TvDeviceDecreaseVolume | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Decrease the volume.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementVolume().
Referenced by SetActionTable().
int TvDeviceHandleActionRequest | ( | struct Upnp_Action_Request * | ca_event | ) |
Called during an action request callback.
If the request is for this device and either its control service or picture service, then perform the action and respond.
[in,out] | ca_event | The control action request event structure. |
References Upnp_Action_Request::ActionName, TvService::ActionNames, Upnp_Action_Request::ActionRequest, Upnp_Action_Request::ActionResult, TvService::actions, Upnp_Action_Request::DevUDN, Upnp_Action_Request::ErrCode, Upnp_Action_Request::ErrStr, TvService::ServiceId, Upnp_Action_Request::ServiceID, TV_CONTROL_POWER, TV_MAXACTIONS, TV_SERVICE_CONTROL, TV_SERVICE_PICTURE, tv_service_table, TvService::UDN, UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and TvService::VariableStrVal.
Referenced by TvDeviceCallbackEventHandler().
int TvDeviceHandleGetVarRequest | ( | struct Upnp_State_Var_Request * | cgv_event | ) |
Called during a get variable request callback.
If the request is for this device and either its control service or picture service, then respond with the variable value.
[in,out] | cgv_event | The control get variable request event structure. |
References Upnp_State_Var_Request::CurrentVal, Upnp_State_Var_Request::DevUDN, Upnp_State_Var_Request::ErrCode, Upnp_State_Var_Request::ErrStr, ixmlCloneDOMString(), SampleUtil_Print(), TvService::ServiceId, Upnp_State_Var_Request::ServiceID, Upnp_State_Var_Request::StateVarName, TV_SERVICE_SERVCOUNT, tv_service_table, TVDevMutex, TvService::UDN, UPNP_E_SUCCESS, TvService::VariableCount, TvService::VariableName, and TvService::VariableStrVal.
Referenced by TvDeviceCallbackEventHandler().
int TvDeviceHandleSubscriptionRequest | ( | struct Upnp_Subscription_Request * | sr_event | ) |
Called during a subscription request callback.
If the subscription request is for this device and either its control service or picture service, then accept it.
[in] | sr_event | The subscription request event structure. |
References device_handle, TvService::ServiceId, Upnp_Subscription_Request::ServiceId, Upnp_Subscription_Request::Sid, TV_SERVICE_SERVCOUNT, tv_service_table, TVDevMutex, TvService::UDN, Upnp_Subscription_Request::UDN, UpnpAcceptSubscription(), UpnpAcceptSubscriptionExt(), UpnpAddToPropertySet(), TvService::VariableCount, TvService::VariableName, and TvService::VariableStrVal.
Referenced by TvDeviceCallbackEventHandler().
int TvDeviceIncreaseBrightness | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase brightnesss.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementBrightness().
Referenced by SetActionTable().
int TvDeviceIncreaseChannel | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase the channel.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
Referenced by SetActionTable().
int TvDeviceIncreaseColor | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase the color.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementColor().
Referenced by SetActionTable().
int TvDeviceIncreaseContrast | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase the contrast.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementContrast().
Referenced by SetActionTable().
int TvDeviceIncreaseTint | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase tint.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
Referenced by SetActionTable().
int TvDeviceIncreaseVolume | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Increase the volume.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References IncrementVolume().
Referenced by SetActionTable().
int TvDevicePowerOff | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Turn the power off.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References TV_SERVICE_CONTROL, TvDeviceSetPower(), UPNP_E_INTERNAL_ERROR, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
int TvDevicePowerOn | ( | IXML_Document * | in, |
IXML_Document ** | out, | ||
const char ** | errorString | ||
) |
Turn the power on.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References POWER_ON, TV_SERVICE_CONTROL, TvDeviceSetPower(), UPNP_E_INTERNAL_ERROR, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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 control points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References MAX_BRIGHTNESS, SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), TV_PICTURE_BRIGHTNESS, TV_SERVICE_PICTURE, TvDeviceSetServiceTableVar(), UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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 control points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References MAX_CHANNEL, SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), TV_CONTROL_CHANNEL, TV_SERVICE_CONTROL, TvDeviceSetServiceTableVar(), UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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 points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References MAX_COLOR, SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), TV_PICTURE_COLOR, TV_SERVICE_PICTURE, TvDeviceSetServiceTableVar(), UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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 control points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
Referenced by SetActionTable().
static int TvDeviceSetPower | ( | int | on | ) | [static] |
Turn the power on/off, update the TvDevice control service state table, and notify all subscribed control points of the updated state.
[in] | on | If 1, turn power on. If 0, turn power off. |
References POWER_ON, SampleUtil_Print(), TV_CONTROL_POWER, TV_MAX_VAL_LEN, TV_SERVICE_CONTROL, and TvDeviceSetServiceTableVar().
Referenced by TvDevicePowerOff(), and TvDevicePowerOn().
int TvDeviceSetServiceTableVar | ( | unsigned int | service, |
int | variable, | ||
char * | value | ||
) |
Update the TvDevice service state table, and notify all subscribed control points of the updated state.
Note that since this function blocks on the mutex TVDevMutex, to avoid a hang this function should not be called within any other function that currently has this mutex locked.
[in] | service | The service number (TV_SERVICE_CONTROL or TV_SERVICE_PICTURE). |
[in] | variable | The variable number (TV_CONTROL_POWER, TV_CONTROL_CHANNEL, TV_CONTROL_VOLUME, TV_PICTURE_COLOR, TV_PICTURE_TINT, TV_PICTURE_CONTRAST, or TV_PICTURE_BRIGHTNESS). |
[in] | value | The string representation of the new value. |
References device_handle, TvService::ServiceId, TV_MAX_VAL_LEN, TV_SERVICE_SERVCOUNT, tv_service_table, TVDevMutex, TvService::UDN, UpnpCreatePropertySet(), UpnpNotify(), UpnpNotifyExt(), TvService::VariableCount, TvService::VariableName, and TvService::VariableStrVal.
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), TvDeviceSetBrightness(), TvDeviceSetChannel(), TvDeviceSetColor(), TvDeviceSetPower(), TvDeviceSetTint(), and TvDeviceSetVolume().
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 points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References MAX_TINT, SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), TV_PICTURE_TINT, TV_SERVICE_PICTURE, TvDeviceSetServiceTableVar(), UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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 points of the updated state.
[in] | in | Document of action request. |
[in] | out | Action result. |
[out] | errorString | ErrorString in case action was unsuccessful. |
References MAX_VOLUME, SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), TV_CONTROL_VOLUME, TV_SERVICE_CONTROL, TvDeviceSetServiceTableVar(), UPNP_E_INTERNAL_ERROR, UPNP_E_INVALID_PARAM, UPNP_E_SUCCESS, and UpnpAddToActionResponse().
Referenced by SetActionTable().
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.
[in] | ip_address | ip address to initialize the sdk (may be NULL) if null, then the first non null loopback address is used. |
[in] | port | port number to initialize the sdk (may be 0) if zero, then a random number is used. |
[in] | desc_doc_name | name of description document. may be NULL. Default is tvdevicedesc.xml. |
[in] | web_dir_path | path of web directory. may be NULL. Default is ./web (for Linux) or ../tvdevice/web. |
[in] | pfun | print function to use. |
[in] | combo | Non-zero if called from the combo application. |
References default_advr_expire, device_handle, SampleUtil_Initialize(), SampleUtil_Print(), TvDeviceCallbackEventHandler(), TvDeviceStateTableInit(), TVDevMutex, UPNP_E_SUCCESS, UpnpFinish(), UpnpGetServerIpAddress(), UpnpGetServerPort(), UpnpInit(), UpnpRegisterRootDevice(), UpnpSendAdvertisement(), and UpnpSetWebServerRootDir().
Referenced by device_main().
int TvDeviceStateTableInit | ( | char * | DescDocURL | ) |
Initialize the device state table for this TvDevice, pulling identifier info from the description Document.
Note that knowledge of the service description is assumed. State table variables and default values are currently hardcoded in this file rather than being read from service description documents.
[in] | DescDocURL | The description document URL. |
References ixmlDocument_free(), SampleUtil_FindAndParseService(), SampleUtil_GetFirstDocumentItem(), SampleUtil_Print(), SetServiceTable(), TV_SERVICE_CONTROL, TV_SERVICE_PICTURE, tv_service_table, UPNP_E_INVALID_DESC, UPNP_E_SUCCESS, and UpnpDownloadXmlDoc().
Referenced by TvDeviceStart().
int TvDeviceStop | ( | void | ) |
Stops the device. Uninitializes the sdk.
References device_handle, SampleUtil_Finish(), TVDevMutex, UPNP_E_SUCCESS, UpnpFinish(), and UpnpUnRegisterRootDevice().
Referenced by TvDeviceCommandLoop().
void TvStateUpdate | ( | char * | UDN, |
int | Service, | ||
IXML_Document * | ChangedVariables, | ||
char ** | State | ||
) |
Update a Tv state table. Called when an event is received.
Note: this function is NOT thread save. It must be called from another function that has locked the global device list.
[in] | UDN | The UDN of the parent device. |
[in] | Service | The service state table to update. |
[out] | ChangedVariables | DOM document representing the XML received with the event. |
[out] | State | pointer to the state table for the Tv service to update. |
References ixmlDocument_getElementsByTagName(), ixmlElement_getElementsByTagName(), ixmlNodeList_free(), ixmlNodeList_item(), ixmlNodeList_length(), SampleUtil_GetElementValue(), SampleUtil_Print(), and TvVarName.
struct cmdloop_commands cmdloop_cmdlist[] [static] |
{ {"Help", PRTHELP, 1, ""}, {"HelpFull", PRTFULLHELP, 1, ""}, {"ListDev", LSTDEV, 1, ""}, {"Refresh", REFRESH, 1, ""}, {"PrintDev", PRTDEV, 2, "<devnum>"}, {"PowerOn", POWON, 2, "<devnum>"}, {"PowerOff", POWOFF, 2, "<devnum>"}, {"SetChannel", SETCHAN, 3, "<devnum> <channel (int)>"}, {"SetVolume", SETVOL, 3, "<devnum> <volume (int)>"}, {"SetColor", SETCOL, 3, "<devnum> <color (int)>"}, {"SetTint", SETTINT, 3, "<devnum> <tint (int)>"}, {"SetContrast", SETCONT, 3, "<devnum> <contrast (int)>"}, {"SetBrightness", SETBRT, 3, "<devnum> <brightness (int)>"}, {"CtrlAction", CTRLACTION, 2, "<devnum> <action (string)>"}, {"PictAction", PICTACTION, 2, "<devnum> <action (string)>"}, {"CtrlGetVar", CTRLGETVAR, 2, "<devnum> <varname (string)>"}, {"PictGetVar", PICTGETVAR, 2, "<devnum> <varname (string)>"}, {"Exit", EXITCMD, 1, ""} }
Mappings between command text names, command tag, and required command arguments for command line commands
Referenced by TvCtrlPointPrintCommands().
int default_advr_expire = 100 |
The amount of time (in seconds) before advertisements will expire.
Referenced by TvDeviceStart().
int default_timeout = 1801 |
Timeout to request during subscriptions
Device handle supplied by UPnP SDK.
Referenced by gena_process_subscription_renewal_request(), gena_process_subscription_request(), gena_process_unsubscribe_request(), genaInitNotify(), genaInitNotifyExt(), genaNotifyAll(), genaNotifyAllExt(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), TvDeviceStart(), TvDeviceStop(), and UpnpFinish().
Device handle returned from sdk
Device handle supplied by UPnP SDK.
Referenced by gena_process_subscription_renewal_request(), gena_process_subscription_request(), gena_process_unsubscribe_request(), genaInitNotify(), genaInitNotifyExt(), genaNotifyAll(), genaNotifyAllExt(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), TvDeviceStart(), TvDeviceStop(), and UpnpFinish().
ithread_mutex_t DeviceListMutex |
Mutex for protecting the global device list in a multi-threaded, asynchronous environment. All functions should lock this mutex before reading or writing the device list.
Referenced by TvCtrlPointStart(), and TvCtrlPointVerifyTimeouts().
ithread_mutex_t DeviceListMutex |
Mutex for protecting the global device list in a multi-threaded, asynchronous environment. All functions should lock this mutex before reading or writing the device list.
Referenced by TvCtrlPointStart(), and TvCtrlPointVerifyTimeouts().
ithread_mutex_t display_mutex |
mutex to control displaying of events
Referenced by SampleUtil_Finish(), SampleUtil_Initialize(), SampleUtil_Print(), and SampleUtil_PrintEvent().
ithread_mutex_t display_mutex |
mutex to control displaying of events
Referenced by SampleUtil_Finish(), SampleUtil_Initialize(), SampleUtil_Print(), and SampleUtil_PrintEvent().
struct TvDeviceNode* GlobalDeviceList = NULL |
The first node in the global device list, or NULL if empty
Referenced by TvCtrlPointVerifyTimeouts().
struct TvDeviceNode* GlobalDeviceList |
The first node in the global device list, or NULL if empty
Referenced by TvCtrlPointVerifyTimeouts().
print_string gPrintFun = NULL |
Function pointers to use for displaying formatted strings. Set on Initialization of device.
Referenced by SampleUtil_Finish(), SampleUtil_Initialize(), and SampleUtil_Print().
global print function used by sample util
Function pointers to use for displaying formatted strings. Set on Initialization of device.
Referenced by SampleUtil_Finish(), SampleUtil_Initialize(), and SampleUtil_Print().
state_update gStateUpdateFun = NULL |
global state update function used by smaple util
Referenced by SampleUtil_Finish(), SampleUtil_RegisterUpdateFunction(), and SampleUtil_StateUpdate().
global state update function used by smaple util
Referenced by SampleUtil_Finish(), SampleUtil_RegisterUpdateFunction(), and SampleUtil_StateUpdate().
struct TvService tv_service_table[2] |
Global structure for storing the state table for this device.
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), SetServiceTable(), TvDeviceHandleActionRequest(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), and TvDeviceStateTableInit().
struct TvService tv_service_table[] |
Array of service structures
Global structure for storing the state table for this device.
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), SetServiceTable(), TvDeviceHandleActionRequest(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), and TvDeviceStateTableInit().
const char* tvc_varname[] = { "Power", "Channel", "Volume" } |
Global arrays for storing Tv Control Service variable names, values, and defaults.
Referenced by SetServiceTable().
int TvCtrlPointTimerLoopRun = 1 [static] |
Function that runs in its own thread and monitors advertisement and subscription timeouts for devices in the global device list.
const char TvDeviceType[] = "urn:schemas-upnp-org:device:tvdevice:1" |
Device type for tv device.
ithread_mutex_t TVDevMutex |
Mutex for protecting the global state table data in a multi-threaded, asynchronous environment. All functions should lock this mutex before reading or writing the state table data.
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), TvDeviceStart(), and TvDeviceStop().
ithread_mutex_t TVDevMutex |
Mutex for protecting the global state table data in a multi-threaded, asynchronous environment. All functions should lock this mutex before reading or writing the state table data.
Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), TvDeviceSetServiceTableVar(), TvDeviceStart(), and TvDeviceStop().
const char* tvp_varname[] = { "Color", "Tint", "Contrast", "Brightness" } |
Global arrays for storing Tv Picture Service variable names, values, and defaults.
Referenced by SetServiceTable().
const char* TvServiceName[] = { "Control", "Picture" } |
Service names.
const char* TvServiceName[] |
Service names.
char TvVarCount[2] |
{ 3 , 4 }
const char* TvVarName[2][4] |
{ {"Power", "Channel", "Volume", ""}, {"Color", "Tint", "Contrast", "Brightness"} }
Global arrays for storing variable names and counts for TvControl and TvPicture services
Referenced by TvStateUpdate().
const char* TvVarName[2][4] |
Global arrays for storing variable names and counts for TvControl and TvPicture services
Referenced by TvStateUpdate().