Doxygen and white spaces in samples.
This commit is contained in:
parent
4b0c8d52b8
commit
40e6e4503c
@ -29,6 +29,13 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup UpnpSamples
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
#define SAMPLE_UTIL_C
|
#define SAMPLE_UTIL_C
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
@ -618,3 +625,5 @@ void linux_print(const char *format, ...)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
va_end(argList);
|
va_end(argList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef SAMPLE_UTIL_H
|
||||||
|
#define SAMPLE_UTIL_H
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
@ -29,10 +32,11 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef SAMPLE_UTIL_H
|
|
||||||
#define SAMPLE_UTIL_H
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
* \defgroup UpnpSamples Sample Code
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
* \file
|
* \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -259,5 +263,7 @@ void linux_print(const char *format, ...)
|
|||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
|
||||||
#endif /* SAMPLE_UTIL_H */
|
#endif /* SAMPLE_UTIL_H */
|
||||||
|
|
||||||
|
@ -29,6 +29,18 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup UpnpSamples
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \name Control Point Sample Module
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
#include "tv_ctrlpt.h"
|
#include "tv_ctrlpt.h"
|
||||||
|
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
@ -1568,3 +1580,6 @@ int TvCtrlPointProcessCommand(char *cmdline)
|
|||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! @} Control Point Sample Module */
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
@ -33,6 +33,14 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
* \addtogroup UpnpSamples
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \name Contro Point Sample API
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
* \file
|
* \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -42,17 +50,13 @@ extern "C" {
|
|||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
|
|
||||||
#include "ithread.h"
|
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "UpnpString.h"
|
#include "UpnpString.h"
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
#include "UpnpUniStd.h" /* for close() */
|
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define TV_SERVICE_SERVCOUNT 2
|
#define TV_SERVICE_SERVCOUNT 2
|
||||||
#define TV_SERVICE_CONTROL 0
|
#define TV_SERVICE_CONTROL 0
|
||||||
@ -213,5 +217,9 @@ int TvCtrlPointProcessCommand(char *cmdline);
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* UPNP_TV_CTRLPT_H */
|
|
||||||
|
|
||||||
|
/*! @} Device Sample */
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
|
||||||
|
#endif /* UPNP_TV_CTRLPT_H */
|
||||||
|
@ -29,6 +29,18 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup UpnpSamples
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \name Device Sample Module
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
#include "tv_device.h"
|
#include "tv_device.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -40,12 +52,14 @@
|
|||||||
/*! Global arrays for storing Tv Control Service variable names, values,
|
/*! Global arrays for storing Tv Control Service variable names, values,
|
||||||
* and defaults. */
|
* and defaults. */
|
||||||
const char *tvc_varname[] = { "Power", "Channel", "Volume" };
|
const char *tvc_varname[] = { "Power", "Channel", "Volume" };
|
||||||
|
|
||||||
char tvc_varval[TV_CONTROL_VARCOUNT][TV_MAX_VAL_LEN];
|
char tvc_varval[TV_CONTROL_VARCOUNT][TV_MAX_VAL_LEN];
|
||||||
const char *tvc_varval_def[] = { "1", "1", "5" };
|
const char *tvc_varval_def[] = { "1", "1", "5" };
|
||||||
|
|
||||||
/*! Global arrays for storing Tv Picture Service variable names, values,
|
/*! Global arrays for storing Tv Picture Service variable names, values,
|
||||||
* and defaults. */
|
* and defaults. */
|
||||||
const char *tvp_varname[] = { "Color", "Tint", "Contrast", "Brightness" };
|
const char *tvp_varname[] = { "Color", "Tint", "Contrast", "Brightness" };
|
||||||
|
|
||||||
char tvp_varval[TV_PICTURE_VARCOUNT][TV_MAX_VAL_LEN];
|
char tvp_varval[TV_PICTURE_VARCOUNT][TV_MAX_VAL_LEN];
|
||||||
const char *tvp_varval_def[] = { "5", "5", "5", "5" };
|
const char *tvp_varval_def[] = { "5", "5", "5", "5" };
|
||||||
|
|
||||||
@ -97,15 +111,15 @@ ithread_mutex_t TVDevMutex;
|
|||||||
*/
|
*/
|
||||||
static int SetServiceTable(
|
static int SetServiceTable(
|
||||||
/*! [in] one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. */
|
/*! [in] one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. */
|
||||||
IN int serviceType,
|
int serviceType,
|
||||||
/*! [in] UDN of device containing service. */
|
/*! [in] UDN of device containing service. */
|
||||||
IN const char *UDN,
|
const char *UDN,
|
||||||
/*! [in] serviceId of service. */
|
/*! [in] serviceId of service. */
|
||||||
IN const char *serviceId,
|
const char *serviceId,
|
||||||
/*! [in] service type (as specified in Description Document) . */
|
/*! [in] service type (as specified in Description Document) . */
|
||||||
IN const char *serviceTypeS,
|
const char *serviceTypeS,
|
||||||
/*! [in,out] service containing table to be set. */
|
/*! [in,out] service containing table to be set. */
|
||||||
INOUT struct TvService *out)
|
struct TvService *out)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -126,11 +140,9 @@ static int SetServiceTable(
|
|||||||
strcpy(tv_service_table[TV_SERVICE_CONTROL].
|
strcpy(tv_service_table[TV_SERVICE_CONTROL].
|
||||||
VariableStrVal[i], tvc_varval_def[i]);
|
VariableStrVal[i], tvc_varval_def[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TV_SERVICE_PICTURE:
|
case TV_SERVICE_PICTURE:
|
||||||
out->VariableCount = TV_PICTURE_VARCOUNT;
|
out->VariableCount = TV_PICTURE_VARCOUNT;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
i < tv_service_table[TV_SERVICE_PICTURE].VariableCount;
|
i < tv_service_table[TV_SERVICE_PICTURE].VariableCount;
|
||||||
i++) {
|
i++) {
|
||||||
@ -141,7 +153,6 @@ static int SetServiceTable(
|
|||||||
strcpy(tv_service_table[TV_SERVICE_PICTURE].
|
strcpy(tv_service_table[TV_SERVICE_PICTURE].
|
||||||
VariableStrVal[i], tvp_varval_def[i]);
|
VariableStrVal[i], tvp_varval_def[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -209,12 +220,12 @@ int TvDeviceStateTableInit(char *DescDocURL)
|
|||||||
{
|
{
|
||||||
IXML_Document *DescDoc = NULL;
|
IXML_Document *DescDoc = NULL;
|
||||||
int ret = UPNP_E_SUCCESS;
|
int ret = UPNP_E_SUCCESS;
|
||||||
char *servid_ctrl = NULL,
|
char *servid_ctrl = NULL;
|
||||||
*evnturl_ctrl = NULL,
|
char *evnturl_ctrl = NULL;
|
||||||
*ctrlurl_ctrl = NULL;
|
char *ctrlurl_ctrl = NULL;
|
||||||
char *servid_pict = NULL,
|
char *servid_pict = NULL;
|
||||||
*evnturl_pict = NULL,
|
char *evnturl_pict = NULL;
|
||||||
*ctrlurl_pict = NULL;
|
char *ctrlurl_pict = NULL;
|
||||||
char *udn = NULL;
|
char *udn = NULL;
|
||||||
|
|
||||||
/*Download description document */
|
/*Download description document */
|
||||||
@ -224,40 +235,29 @@ int TvDeviceStateTableInit(char *DescDocURL)
|
|||||||
ret = UPNP_E_INVALID_DESC;
|
ret = UPNP_E_INVALID_DESC;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
udn = SampleUtil_GetFirstDocumentItem(DescDoc, "UDN");
|
udn = SampleUtil_GetFirstDocumentItem(DescDoc, "UDN");
|
||||||
|
/* Find the Tv Control Service identifiers */
|
||||||
/*
|
|
||||||
Find the Tv Control Service identifiers
|
|
||||||
*/
|
|
||||||
if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL,
|
if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL,
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
&servid_ctrl, &evnturl_ctrl,
|
&servid_ctrl, &evnturl_ctrl,
|
||||||
&ctrlurl_ctrl)) {
|
&ctrlurl_ctrl)) {
|
||||||
SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find"
|
SampleUtil_Print("TvDeviceStateTableInit -- Error: Could not find Service: %s\n",
|
||||||
" Service: %s\n",
|
|
||||||
TvServiceType[TV_SERVICE_CONTROL]);
|
TvServiceType[TV_SERVICE_CONTROL]);
|
||||||
|
|
||||||
ret = UPNP_E_INVALID_DESC;
|
ret = UPNP_E_INVALID_DESC;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set control service table */
|
/* set control service table */
|
||||||
SetServiceTable(TV_SERVICE_CONTROL, udn, servid_ctrl,
|
SetServiceTable(TV_SERVICE_CONTROL, udn, servid_ctrl,
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
&tv_service_table[TV_SERVICE_CONTROL]);
|
&tv_service_table[TV_SERVICE_CONTROL]);
|
||||||
|
|
||||||
/*
|
/* Find the Tv Picture Service identifiers */
|
||||||
Find the Tv Picture Service identifiers
|
|
||||||
*/
|
|
||||||
if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL,
|
if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL,
|
||||||
TvServiceType[TV_SERVICE_PICTURE],
|
TvServiceType[TV_SERVICE_PICTURE],
|
||||||
&servid_pict, &evnturl_pict,
|
&servid_pict, &evnturl_pict,
|
||||||
&ctrlurl_pict)) {
|
&ctrlurl_pict)) {
|
||||||
SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find"
|
SampleUtil_Print("TvDeviceStateTableInit -- Error: Could not find Service: %s\n",
|
||||||
" Service: %s\n",
|
|
||||||
TvServiceType[TV_SERVICE_PICTURE]);
|
TvServiceType[TV_SERVICE_PICTURE]);
|
||||||
|
|
||||||
ret = UPNP_E_INVALID_DESC;
|
ret = UPNP_E_INVALID_DESC;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
@ -267,7 +267,6 @@ int TvDeviceStateTableInit(char *DescDocURL)
|
|||||||
&tv_service_table[TV_SERVICE_PICTURE]);
|
&tv_service_table[TV_SERVICE_PICTURE]);
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
if (udn)
|
if (udn)
|
||||||
free(udn);
|
free(udn);
|
||||||
@ -314,32 +313,30 @@ int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *sr_event
|
|||||||
for (j = 0; j < tv_service_table[i].VariableCount; ++j) {
|
for (j = 0; j < tv_service_table[i].VariableCount; ++j) {
|
||||||
/* add each variable to the property set */
|
/* add each variable to the property set */
|
||||||
/* for initial state dump */
|
/* for initial state dump */
|
||||||
UpnpAddToPropertySet(
|
UpnpAddToPropertySet(&PropSet,
|
||||||
&PropSet,
|
tv_service_table[i].
|
||||||
tv_service_table[i].VariableName[j],
|
VariableName[j],
|
||||||
tv_service_table[i].VariableStrVal[j]);
|
tv_service_table[i].
|
||||||
|
VariableStrVal[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dump initial state */
|
/* dump initial state */
|
||||||
UpnpAcceptSubscriptionExt(
|
UpnpAcceptSubscriptionExt(device_handle,
|
||||||
device_handle,
|
|
||||||
l_udn,
|
l_udn,
|
||||||
l_serviceId,
|
l_serviceId, PropSet, l_sid);
|
||||||
PropSet,
|
|
||||||
l_sid);
|
|
||||||
/* free document */
|
/* free document */
|
||||||
Document_free(PropSet);
|
Document_free(PropSet);
|
||||||
#endif
|
#endif
|
||||||
UpnpAcceptSubscription(
|
UpnpAcceptSubscription(device_handle,
|
||||||
device_handle,
|
|
||||||
l_udn,
|
l_udn,
|
||||||
l_serviceId,
|
l_serviceId,
|
||||||
(const char **)tv_service_table[i].
|
(const char **)
|
||||||
VariableName,
|
tv_service_table[i].VariableName,
|
||||||
(const char **)tv_service_table[i].
|
(const char **)
|
||||||
VariableStrVal,
|
tv_service_table
|
||||||
tv_service_table[i].VariableCount,
|
[i].VariableStrVal,
|
||||||
l_sid);
|
tv_service_table[i].
|
||||||
|
VariableCount, l_sid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,10 +357,8 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *cgv_event)
|
|||||||
|
|
||||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
|
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
|
||||||
/* check udn and service id */
|
/* check udn and service id */
|
||||||
const char *devUDN =
|
const char *devUDN = cgv_event->DevUDN;
|
||||||
cgv_event->DevUDN;
|
const char *serviceID = cgv_event->ServiceID;
|
||||||
const char *serviceID =
|
|
||||||
cgv_event->ServiceID;
|
|
||||||
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
|
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
|
||||||
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
|
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
|
||||||
/* check variable name */
|
/* check variable name */
|
||||||
@ -383,8 +378,7 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *cgv_event)
|
|||||||
if (getvar_succeeded) {
|
if (getvar_succeeded) {
|
||||||
cgv_event->ErrCode = UPNP_E_SUCCESS;
|
cgv_event->ErrCode = UPNP_E_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||||
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
|
||||||
" Unknown variable name = %s\n",
|
" Unknown variable name = %s\n",
|
||||||
cgv_event->StateVarName);
|
cgv_event->StateVarName);
|
||||||
cgv_event->ErrCode = 404;
|
cgv_event->ErrCode = 404;
|
||||||
@ -474,42 +468,33 @@ int TvDeviceHandleActionRequest(struct Upnp_Action_Request *ca_event)
|
|||||||
int TvDeviceSetServiceTableVar(unsigned int service, int variable, char *value)
|
int TvDeviceSetServiceTableVar(unsigned int service, int variable, char *value)
|
||||||
{
|
{
|
||||||
/* IXML_Document *PropSet= NULL; */
|
/* IXML_Document *PropSet= NULL; */
|
||||||
|
if (service >= TV_SERVICE_SERVCOUNT ||
|
||||||
if( ( service >= TV_SERVICE_SERVCOUNT )
|
variable >= tv_service_table[service].VariableCount ||
|
||||||
|| ( variable >= tv_service_table[service].VariableCount )
|
strlen(value) >= TV_MAX_VAL_LEN)
|
||||||
|| ( strlen( value ) >= TV_MAX_VAL_LEN ) ) {
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
|
|
||||||
strcpy(tv_service_table[service].VariableStrVal[variable], value);
|
strcpy(tv_service_table[service].VariableStrVal[variable], value);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Using utility api */
|
/* Using utility api */
|
||||||
PropSet= UpnpCreatePropertySet(1,tv_service_table[service].
|
PropSet = UpnpCreatePropertySet(1,
|
||||||
VariableName[variable],
|
tv_service_table[service].VariableName[variable],
|
||||||
tv_service_table[service].
|
tv_service_table[service].VariableStrVal[variable]);
|
||||||
VariableStrVal[variable]);
|
|
||||||
|
|
||||||
UpnpNotifyExt(device_handle, tv_service_table[service].UDN,
|
UpnpNotifyExt(device_handle, tv_service_table[service].UDN,
|
||||||
tv_service_table[service].ServiceId, PropSet);
|
tv_service_table[service].ServiceId, PropSet);
|
||||||
|
|
||||||
/* Free created property set */
|
/* Free created property set */
|
||||||
Document_free(PropSet);
|
Document_free(PropSet);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UpnpNotify(device_handle,
|
UpnpNotify(device_handle,
|
||||||
tv_service_table[service].UDN,
|
tv_service_table[service].UDN,
|
||||||
tv_service_table[service].ServiceId,
|
tv_service_table[service].ServiceId,
|
||||||
( const char ** )&tv_service_table[service].
|
(const char **)&tv_service_table[service].VariableName[variable],
|
||||||
VariableName[variable],
|
(const char **)&tv_service_table[service].VariableStrVal[variable], 1);
|
||||||
( const char ** )&tv_service_table[service].
|
|
||||||
VariableStrVal[variable], 1 );
|
|
||||||
|
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
return ( 1 );
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -538,14 +523,14 @@ static int TvDeviceSetPower(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDevicePowerOn(IXML_Document * in,IXML_Document **out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
|
|
||||||
if (TvDeviceSetPower(POWER_ON)) {
|
if (TvDeviceSetPower(POWER_ON)) {
|
||||||
/* create a response */
|
/* create a response */
|
||||||
|
|
||||||
if (UpnpAddToActionResponse(out, "PowerOn",
|
if (UpnpAddToActionResponse(out, "PowerOn",
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
"Power", "1") != UPNP_E_SUCCESS) {
|
"Power", "1") != UPNP_E_SUCCESS) {
|
||||||
@ -561,7 +546,8 @@ int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorSt
|
|||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDevicePowerOff(IXML_Document *in, IXML_Document **out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
@ -575,41 +561,34 @@ int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorS
|
|||||||
(*errorString) = "Internal Error";
|
(*errorString) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*errorString) = "Internal Error";
|
(*errorString) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceSetChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceSetChannel(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
|
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
|
|
||||||
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Channel"))) {
|
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Channel"))) {
|
||||||
(*errorString) = "Invalid Channel";
|
(*errorString) = "Invalid Channel";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = atoi(value);
|
channel = atoi(value);
|
||||||
|
|
||||||
if (channel < MIN_CHANNEL || channel > MAX_CHANNEL) {
|
if (channel < MIN_CHANNEL || channel > MAX_CHANNEL) {
|
||||||
|
|
||||||
free(value);
|
free(value);
|
||||||
SampleUtil_Print( "error: can't change to channel %d\n", channel );
|
SampleUtil_Print("error: can't change to channel %d\n",
|
||||||
|
channel);
|
||||||
(*errorString) = "Invalid Channel";
|
(*errorString) = "Invalid Channel";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the channel goes here. */
|
/* Vendor-specific code to set the channel goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
||||||
TV_CONTROL_CHANNEL, value)) {
|
TV_CONTROL_CHANNEL, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetChannel",
|
if (UpnpAddToActionResponse(out, "SetChannel",
|
||||||
@ -630,11 +609,11 @@ int TvDeviceSetChannel(IXML_Document *in, IXML_Document **out, const char **erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int IncrementChannel(int incr, IN IXML_Document *in, IXML_Document **out, const char **errorString)
|
int IncrementChannel(int incr, IN IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
int curchannel;
|
int curchannel;
|
||||||
int newchannel;
|
int newchannel;
|
||||||
|
|
||||||
const char *actionName = NULL;
|
const char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@ -645,8 +624,9 @@ int IncrementChannel(int incr, IN IXML_Document *in, IXML_Document **out, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curchannel = atoi( tv_service_table[TV_SERVICE_CONTROL].
|
curchannel =
|
||||||
VariableStrVal[TV_CONTROL_CHANNEL] );
|
atoi(tv_service_table[TV_SERVICE_CONTROL].VariableStrVal
|
||||||
|
[TV_CONTROL_CHANNEL]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newchannel = curchannel + incr;
|
newchannel = curchannel + incr;
|
||||||
@ -657,11 +637,8 @@ int IncrementChannel(int incr, IN IXML_Document *in, IXML_Document **out, const
|
|||||||
(*errorString) = "Invalid Channel";
|
(*errorString) = "Invalid Channel";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the channel goes here. */
|
/* Vendor-specific code to set the channel goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newchannel);
|
sprintf(value, "%d", newchannel);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
||||||
TV_CONTROL_CHANNEL, value)) {
|
TV_CONTROL_CHANNEL, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
@ -680,39 +657,37 @@ int IncrementChannel(int incr, IN IXML_Document *in, IXML_Document **out, const
|
|||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceDecreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceDecreaseChannel(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementChannel(-1, in, out, errorString);
|
return IncrementChannel(-1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceIncreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceIncreaseChannel(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementChannel(1, in, out, errorString);
|
return IncrementChannel(1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceSetVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceSetVolume(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int volume = 0;
|
int volume = 0;
|
||||||
|
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
|
|
||||||
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Volume"))) {
|
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Volume"))) {
|
||||||
(*errorString) = "Invalid Volume";
|
(*errorString) = "Invalid Volume";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
volume = atoi(value);
|
volume = atoi(value);
|
||||||
|
|
||||||
if (volume < MIN_VOLUME || volume > MAX_VOLUME) {
|
if (volume < MIN_VOLUME || volume > MAX_VOLUME) {
|
||||||
SampleUtil_Print("error: can't change to volume %d\n", volume);
|
SampleUtil_Print("error: can't change to volume %d\n", volume);
|
||||||
(*errorString) = "Invalid Volume";
|
(*errorString) = "Invalid Volume";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
||||||
TV_CONTROL_VOLUME, value)) {
|
TV_CONTROL_VOLUME, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetVolume",
|
if (UpnpAddToActionResponse(out, "SetVolume",
|
||||||
@ -759,28 +734,26 @@ static int IncrementVolume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curvolume = atoi( tv_service_table[TV_SERVICE_CONTROL].
|
curvolume =
|
||||||
VariableStrVal[TV_CONTROL_VOLUME] );
|
atoi(tv_service_table[TV_SERVICE_CONTROL].VariableStrVal
|
||||||
|
[TV_CONTROL_VOLUME]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newvolume = curvolume + incr;
|
newvolume = curvolume + incr;
|
||||||
|
|
||||||
if (newvolume < MIN_VOLUME || newvolume > MAX_VOLUME) {
|
if (newvolume < MIN_VOLUME || newvolume > MAX_VOLUME) {
|
||||||
SampleUtil_Print("error: can't change to volume %d\n",
|
SampleUtil_Print("error: can't change to volume %d\n",
|
||||||
newvolume);
|
newvolume);
|
||||||
(*errorString) = "Invalid Volume";
|
(*errorString) = "Invalid Volume";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newvolume);
|
sprintf(value, "%d", newvolume);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL,
|
||||||
TV_CONTROL_VOLUME, value)) {
|
TV_CONTROL_VOLUME, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
"Volume", value ) != UPNP_E_SUCCESS ) {
|
"Volume",
|
||||||
|
value) != UPNP_E_SUCCESS) {
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = "Internal Error";
|
(*errorString) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
@ -793,17 +766,20 @@ static int IncrementVolume(
|
|||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceIncreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceIncreaseVolume(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementVolume(1, in, out, errorString);
|
return IncrementVolume(1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceDecreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceDecreaseVolume(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementVolume(-1, in, out, errorString);
|
return IncrementVolume(-1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceSetColor(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceSetColor(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
@ -814,17 +790,13 @@ int TvDeviceSetColor(IXML_Document *in, IXML_Document **out, const char **errorS
|
|||||||
(*errorString) = "Invalid Color";
|
(*errorString) = "Invalid Color";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
color = atoi(value);
|
color = atoi(value);
|
||||||
|
|
||||||
if (color < MIN_COLOR || color > MAX_COLOR) {
|
if (color < MIN_COLOR || color > MAX_COLOR) {
|
||||||
SampleUtil_Print("error: can't change to color %d\n", color);
|
SampleUtil_Print("error: can't change to color %d\n", color);
|
||||||
(*errorString) = "Invalid Color";
|
(*errorString) = "Invalid Color";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_COLOR, value)) {
|
TV_PICTURE_COLOR, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetColor",
|
if (UpnpAddToActionResponse(out, "SetColor",
|
||||||
@ -871,22 +843,19 @@ static int IncrementColor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curcolor = atoi( tv_service_table[TV_SERVICE_PICTURE].
|
curcolor =
|
||||||
VariableStrVal[TV_PICTURE_COLOR] );
|
atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal
|
||||||
|
[TV_PICTURE_COLOR]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newcolor = curcolor + incr;
|
newcolor = curcolor + incr;
|
||||||
|
|
||||||
if (newcolor < MIN_COLOR || newcolor > MAX_COLOR) {
|
if (newcolor < MIN_COLOR || newcolor > MAX_COLOR) {
|
||||||
SampleUtil_Print("error: can't change to color %d\n", newcolor);
|
SampleUtil_Print("error: can't change to color %d\n", newcolor);
|
||||||
(*errorString) = "Invalid Color";
|
(*errorString) = "Invalid Color";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newcolor);
|
sprintf(value, "%d", newcolor);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_COLOR, value)) {
|
TV_PICTURE_COLOR, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
@ -904,39 +873,37 @@ static int IncrementColor(
|
|||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceDecreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceDecreaseColor(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementColor(-1, in, out, errorString);
|
return IncrementColor(-1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceIncreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceIncreaseColor(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementColor(1, in, out, errorString);
|
return IncrementColor(1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceSetTint(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceSetTint(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int tint = -1;
|
int tint = -1;
|
||||||
|
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
|
|
||||||
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Tint"))) {
|
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Tint"))) {
|
||||||
(*errorString) = "Invalid Tint";
|
(*errorString) = "Invalid Tint";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
tint = atoi(value);
|
tint = atoi(value);
|
||||||
|
|
||||||
if (tint < MIN_TINT || tint > MAX_TINT) {
|
if (tint < MIN_TINT || tint > MAX_TINT) {
|
||||||
SampleUtil_Print("error: can't change to tint %d\n", tint);
|
SampleUtil_Print("error: can't change to tint %d\n", tint);
|
||||||
(*errorString) = "Invalid Tint";
|
(*errorString) = "Invalid Tint";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_TINT, value)) {
|
TV_PICTURE_TINT, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetTint",
|
if (UpnpAddToActionResponse(out, "SetTint",
|
||||||
@ -971,7 +938,8 @@ int TvDeviceSetTint(IXML_Document *in, IXML_Document **out, const char **errorSt
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString)
|
int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out,
|
||||||
|
OUT const char **errorString)
|
||||||
{
|
{
|
||||||
int curtint;
|
int curtint;
|
||||||
int newtint;
|
int newtint;
|
||||||
@ -985,22 +953,19 @@ int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OU
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curtint = atoi( tv_service_table[TV_SERVICE_PICTURE].
|
curtint =
|
||||||
VariableStrVal[TV_PICTURE_TINT] );
|
atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal
|
||||||
|
[TV_PICTURE_TINT]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newtint = curtint + incr;
|
newtint = curtint + incr;
|
||||||
|
|
||||||
if (newtint < MIN_TINT || newtint > MAX_TINT) {
|
if (newtint < MIN_TINT || newtint > MAX_TINT) {
|
||||||
SampleUtil_Print("error: can't change to tint %d\n", newtint);
|
SampleUtil_Print("error: can't change to tint %d\n", newtint);
|
||||||
(*errorString) = "Invalid Tint";
|
(*errorString) = "Invalid Tint";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newtint);
|
sprintf(value, "%d", newtint);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_TINT, value)) {
|
TV_PICTURE_TINT, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
@ -1031,8 +996,8 @@ int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OU
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
||||||
TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString)
|
OUT const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementTint(1, in, out, errorString);
|
return IncrementTint(1, in, out, errorString);
|
||||||
}
|
}
|
||||||
@ -1050,8 +1015,8 @@ TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const c
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
||||||
TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString)
|
OUT const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementTint(-1, in, out, errorString);
|
return IncrementTint(-1, in, out, errorString);
|
||||||
}
|
}
|
||||||
@ -1071,8 +1036,8 @@ TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const c
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
||||||
TvDeviceSetContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString)
|
OUT const char **errorString)
|
||||||
{
|
{
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int contrast = -1;
|
int contrast = -1;
|
||||||
@ -1084,18 +1049,14 @@ TvDeviceSetContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT const ch
|
|||||||
(*errorString) = "Invalid Contrast";
|
(*errorString) = "Invalid Contrast";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
contrast = atoi(value);
|
contrast = atoi(value);
|
||||||
|
|
||||||
if (contrast < MIN_CONTRAST || contrast > MAX_CONTRAST) {
|
if (contrast < MIN_CONTRAST || contrast > MAX_CONTRAST) {
|
||||||
SampleUtil_Print("error: can't change to contrast %d\n",
|
SampleUtil_Print("error: can't change to contrast %d\n",
|
||||||
contrast);
|
contrast);
|
||||||
(*errorString) = "Invalid Contrast";
|
(*errorString) = "Invalid Contrast";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_CONTRAST, value)) {
|
TV_PICTURE_CONTRAST, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetContrast",
|
if (UpnpAddToActionResponse(out, "SetContrast",
|
||||||
@ -1143,23 +1104,20 @@ static int IncrementContrast(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curcontrast = atoi( tv_service_table[TV_SERVICE_PICTURE].
|
curcontrast =
|
||||||
VariableStrVal[TV_PICTURE_CONTRAST] );
|
atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal
|
||||||
|
[TV_PICTURE_CONTRAST]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newcontrast = curcontrast + incr;
|
newcontrast = curcontrast + incr;
|
||||||
|
|
||||||
if (newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST) {
|
if (newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST) {
|
||||||
SampleUtil_Print("error: can't change to contrast %d\n",
|
SampleUtil_Print("error: can't change to contrast %d\n",
|
||||||
newcontrast);
|
newcontrast);
|
||||||
(*errorString) = "Invalid Contrast";
|
(*errorString) = "Invalid Contrast";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the channel goes here. */
|
/* Vendor-specific code to set the channel goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newcontrast);
|
sprintf(value, "%d", newcontrast);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_CONTRAST, value)) {
|
TV_PICTURE_CONTRAST, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
@ -1198,23 +1156,18 @@ int TvDeviceSetBrightness(IXML_Document *in, IXML_Document **out,
|
|||||||
|
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
(*errorString) = NULL;
|
(*errorString) = NULL;
|
||||||
|
|
||||||
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Brightness"))) {
|
if (!(value = SampleUtil_GetFirstDocumentItem(in, "Brightness"))) {
|
||||||
(*errorString) = "Invalid Brightness";
|
(*errorString) = "Invalid Brightness";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
brightness = atoi(value);
|
brightness = atoi(value);
|
||||||
|
|
||||||
if (brightness < MIN_BRIGHTNESS || brightness > MAX_BRIGHTNESS) {
|
if (brightness < MIN_BRIGHTNESS || brightness > MAX_BRIGHTNESS) {
|
||||||
SampleUtil_Print("error: can't change to brightness %d\n",
|
SampleUtil_Print("error: can't change to brightness %d\n",
|
||||||
brightness);
|
brightness);
|
||||||
(*errorString) = "Invalid Brightness";
|
(*errorString) = "Invalid Brightness";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the volume goes here. */
|
/* Vendor-specific code to set the volume goes here. */
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_BRIGHTNESS, value)) {
|
TV_PICTURE_BRIGHTNESS, value)) {
|
||||||
if (UpnpAddToActionResponse(out, "SetBrightness",
|
if (UpnpAddToActionResponse(out, "SetBrightness",
|
||||||
@ -1261,23 +1214,20 @@ static int IncrementBrightness(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock(&TVDevMutex);
|
ithread_mutex_lock(&TVDevMutex);
|
||||||
curbrightness = atoi( tv_service_table[TV_SERVICE_PICTURE].
|
curbrightness =
|
||||||
VariableStrVal[TV_PICTURE_BRIGHTNESS] );
|
atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal
|
||||||
|
[TV_PICTURE_BRIGHTNESS]);
|
||||||
ithread_mutex_unlock(&TVDevMutex);
|
ithread_mutex_unlock(&TVDevMutex);
|
||||||
|
|
||||||
newbrightness = curbrightness + incr;
|
newbrightness = curbrightness + incr;
|
||||||
|
|
||||||
if (newbrightness < MIN_BRIGHTNESS || newbrightness > MAX_BRIGHTNESS) {
|
if (newbrightness < MIN_BRIGHTNESS || newbrightness > MAX_BRIGHTNESS) {
|
||||||
SampleUtil_Print("error: can't change to brightness %d\n",
|
SampleUtil_Print("error: can't change to brightness %d\n",
|
||||||
newbrightness);
|
newbrightness);
|
||||||
(*errorString) = "Invalid Brightness";
|
(*errorString) = "Invalid Brightness";
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vendor-specific code to set the channel goes here. */
|
/* Vendor-specific code to set the channel goes here. */
|
||||||
|
|
||||||
sprintf(value, "%d", newbrightness);
|
sprintf(value, "%d", newbrightness);
|
||||||
|
|
||||||
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE,
|
||||||
TV_PICTURE_BRIGHTNESS, value)) {
|
TV_PICTURE_BRIGHTNESS, value)) {
|
||||||
if (UpnpAddToActionResponse(out, actionName,
|
if (UpnpAddToActionResponse(out, actionName,
|
||||||
@ -1296,27 +1246,34 @@ static int IncrementBrightness(
|
|||||||
in = in;
|
in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceIncreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceIncreaseBrightness(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementBrightness(1, in, out, errorString);
|
return IncrementBrightness(1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceDecreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString)
|
int TvDeviceDecreaseBrightness(IXML_Document * in, IXML_Document ** out,
|
||||||
|
const char **errorString)
|
||||||
{
|
{
|
||||||
return IncrementBrightness(-1, in, out, errorString);
|
return IncrementBrightness(-1, in, out, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event,
|
||||||
|
void *Cookie)
|
||||||
{
|
{
|
||||||
switch (EventType) {
|
switch (EventType) {
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
TvDeviceHandleSubscriptionRequest((struct Upnp_Subscription_Request *)Event);
|
TvDeviceHandleSubscriptionRequest((struct
|
||||||
|
Upnp_Subscription_Request *)
|
||||||
|
Event);
|
||||||
break;
|
break;
|
||||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||||
TvDeviceHandleGetVarRequest((struct Upnp_State_Var_Request *)Event);
|
TvDeviceHandleGetVarRequest((struct Upnp_State_Var_Request *)
|
||||||
|
Event);
|
||||||
break;
|
break;
|
||||||
case UPNP_CONTROL_ACTION_REQUEST:
|
case UPNP_CONTROL_ACTION_REQUEST:
|
||||||
TvDeviceHandleActionRequest((struct Upnp_Action_Request *)Event);
|
TvDeviceHandleActionRequest((struct Upnp_Action_Request *)
|
||||||
|
Event);
|
||||||
break;
|
break;
|
||||||
/* ignore these cases, since this is not a control point */
|
/* ignore these cases, since this is not a control point */
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||||
@ -1331,7 +1288,8 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
|||||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
SampleUtil_Print
|
||||||
|
("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||||
EventType);
|
EventType);
|
||||||
}
|
}
|
||||||
/* Print a summary of the event received */
|
/* Print a summary of the event received */
|
||||||
@ -1351,11 +1309,9 @@ int TvDeviceStart(char *ip_address, unsigned short port,
|
|||||||
ithread_mutex_init(&TVDevMutex, NULL);
|
ithread_mutex_init(&TVDevMutex, NULL);
|
||||||
|
|
||||||
SampleUtil_Initialize(pfun);
|
SampleUtil_Initialize(pfun);
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Initializing UPnP Sdk with\n"
|
||||||
"Initializing UPnP Sdk with\n"
|
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address ? ip_address : "{NULL}",
|
ip_address ? ip_address : "{NULL}", port);
|
||||||
port);
|
|
||||||
ret = UpnpInit(ip_address, port);
|
ret = UpnpInit(ip_address, port);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print("Error with UpnpInit -- %d\n", ret);
|
SampleUtil_Print("Error with UpnpInit -- %d\n", ret);
|
||||||
@ -1365,11 +1321,9 @@ int TvDeviceStart(char *ip_address, unsigned short port,
|
|||||||
}
|
}
|
||||||
ip_address = UpnpGetServerIpAddress();
|
ip_address = UpnpGetServerIpAddress();
|
||||||
port = UpnpGetServerPort();
|
port = UpnpGetServerPort();
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("UPnP Initialized\n"
|
||||||
"UPnP Initialized\n"
|
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address ? ip_address : "{NULL}",
|
ip_address ? ip_address : "{NULL}", port);
|
||||||
port);
|
|
||||||
if (!desc_doc_name) {
|
if (!desc_doc_name) {
|
||||||
if (combo) {
|
if (combo) {
|
||||||
desc_doc_name = "tvcombodesc.xml";
|
desc_doc_name = "tvcombodesc.xml";
|
||||||
@ -1386,33 +1340,32 @@ int TvDeviceStart(char *ip_address, unsigned short port,
|
|||||||
web_dir_path);
|
web_dir_path);
|
||||||
ret = UpnpSetWebServerRootDir(web_dir_path);
|
ret = UpnpSetWebServerRootDir(web_dir_path);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print
|
||||||
"Error specifying webserver root directory -- %s: %d\n",
|
("Error specifying webserver root directory -- %s: %d\n",
|
||||||
web_dir_path, ret);
|
web_dir_path, ret);
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Registering the RootDevice\n"
|
||||||
"Registering the RootDevice\n"
|
"\t with desc_doc_url: %s\n", desc_doc_url);
|
||||||
"\t with desc_doc_url: %s\n",
|
|
||||||
desc_doc_url);
|
|
||||||
ret = UpnpRegisterRootDevice(desc_doc_url, TvDeviceCallbackEventHandler,
|
ret = UpnpRegisterRootDevice(desc_doc_url, TvDeviceCallbackEventHandler,
|
||||||
&device_handle, &device_handle);
|
&device_handle, &device_handle);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print("Error registering the rootdevice : %d\n", ret);
|
SampleUtil_Print("Error registering the rootdevice : %d\n",
|
||||||
|
ret);
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("RootDevice Registered\n"
|
||||||
"RootDevice Registered\n"
|
|
||||||
"Initializing State Table\n");
|
"Initializing State Table\n");
|
||||||
TvDeviceStateTableInit(desc_doc_url);
|
TvDeviceStateTableInit(desc_doc_url);
|
||||||
SampleUtil_Print("State Table Initialized\n");
|
SampleUtil_Print("State Table Initialized\n");
|
||||||
ret = UpnpSendAdvertisement(device_handle, default_advr_expire);
|
ret = UpnpSendAdvertisement(device_handle, default_advr_expire);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print("Error sending advertisements : %d\n", ret);
|
SampleUtil_Print("Error sending advertisements : %d\n",
|
||||||
|
ret);
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1451,10 +1404,8 @@ void *TvDeviceCommandLoop(void *args)
|
|||||||
TvDeviceStop();
|
TvDeviceStop();
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("\n Unknown command: %s\n\n", cmd);
|
||||||
"\n Unknown command: %s\n\n", cmd);
|
SampleUtil_Print(" Valid Commands:\n"
|
||||||
SampleUtil_Print(
|
|
||||||
" Valid Commands:\n"
|
|
||||||
" Exit\n\n");
|
" Exit\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1484,12 +1435,11 @@ int device_main(int argc, char *argv[])
|
|||||||
} else if (strcmp(argv[i], "-webdir") == 0) {
|
} else if (strcmp(argv[i], "-webdir") == 0) {
|
||||||
web_dir_path = argv[++i];
|
web_dir_path = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-help") == 0) {
|
} else if (strcmp(argv[i], "-help") == 0) {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Usage: %s -ip ipaddress -port port"
|
||||||
"Usage: %s -ip ipaddress -port port"
|
|
||||||
" -desc desc_doc_name -webdir web_dir_path"
|
" -desc desc_doc_name -webdir web_dir_path"
|
||||||
" -help (this message)\n", argv[0]);
|
" -help (this message)\n", argv[0]);
|
||||||
SampleUtil_Print(
|
SampleUtil_Print
|
||||||
"\tipaddress: IP address of the device"
|
("\tipaddress: IP address of the device"
|
||||||
" (must match desc. doc)\n"
|
" (must match desc. doc)\n"
|
||||||
"\t\te.g.: 192.168.0.4\n"
|
"\t\te.g.: 192.168.0.4\n"
|
||||||
"\tport: Port number to use for"
|
"\tport: Port number to use for"
|
||||||
@ -1508,3 +1458,6 @@ int device_main(int argc, char *argv[])
|
|||||||
linux_print, 0);
|
linux_print, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! @} Device Sample Module */
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
@ -33,6 +33,14 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
* \addtogroup UpnpSamples
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \name Device Sample API
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
* \file
|
* \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -47,7 +55,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "UpnpUniStd.h" /* for close() */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -557,5 +564,8 @@ int device_main(int argc, char *argv[]);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
/*! @} Control Point Sample API */
|
||||||
|
|
||||||
|
/*! @} UpnpSamples */
|
||||||
|
|
||||||
|
#endif /* UPNP_TV_DEVICE_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user