Merge of similar files.
This commit is contained in:
parent
4f5d0e1d70
commit
6d8aa815ea
@ -29,9 +29,14 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "upnp_tv_ctrlpt.h"
|
||||
|
||||
/*
|
||||
|
||||
#include "upnp.h"
|
||||
|
||||
|
||||
/*!
|
||||
Mutex for protecting the global device list
|
||||
in a multi-threaded, asynchronous environment.
|
||||
All functions should lock this mutex before reading
|
||||
@ -48,7 +53,7 @@ char *TvServiceType[] = {
|
||||
};
|
||||
char *TvServiceName[] = { "Control", "Picture" };
|
||||
|
||||
/*
|
||||
/*!
|
||||
Global arrays for storing variable names and counts for
|
||||
TvControl and TvPicture services
|
||||
*/
|
||||
@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
|
||||
char TvVarCount[TV_SERVICE_SERVCOUNT] =
|
||||
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
|
||||
|
||||
/*
|
||||
/*!
|
||||
Timeout to request during subscriptions
|
||||
*/
|
||||
int default_timeout = 1801;
|
||||
|
||||
/*
|
||||
/*!
|
||||
The first node in the global device list, or NULL if empty
|
||||
*/
|
||||
struct TvDeviceNode *GlobalDeviceList = NULL;
|
||||
@ -1071,6 +1076,7 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
SampleUtil_Print(
|
||||
"Error in Discovery Callback -- %d", errCode);
|
||||
}
|
||||
|
||||
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
|
||||
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
|
||||
if (errCode != UPNP_E_SUCCESS) {
|
||||
@ -1335,8 +1341,9 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
|
||||
|
||||
SampleUtil_Print(
|
||||
"UPnP Initialized\n"
|
||||
"\tipaddress= %s port = %u\n",
|
||||
ip_address, port);
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
|
||||
SampleUtil_Print("Registering Control Point");
|
||||
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
|
||||
|
@ -38,8 +38,10 @@
|
||||
|
||||
#define DEFAULT_WEB_DIR "./web"
|
||||
|
||||
|
||||
#define DESC_URL_SIZE 200
|
||||
|
||||
|
||||
/*
|
||||
Device type for tv device
|
||||
*/
|
||||
@ -372,20 +374,18 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
||||
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
//unsigned int j = 0;
|
||||
int cmp1 = 0;
|
||||
int cmp2 = 0;
|
||||
const char *l_serviceId = NULL;
|
||||
const char *l_udn = NULL;
|
||||
const char *l_sid = NULL;
|
||||
// IXML_Document *PropSet = NULL;
|
||||
|
||||
// lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
ithread_mutex_lock(&TVDevMutex);
|
||||
|
||||
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||
l_udn = UpnpSubscriptionRequest_get_UDN_cstr(sr_event);
|
||||
l_sid = UpnpSubscriptionRequest_get_SID_cstr(sr_event);
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||
@ -425,7 +425,7 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
|
||||
}
|
||||
}
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
ithread_mutex_unlock(&TVDevMutex);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -443,53 +443,52 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
|
||||
* cgv_event -- The control get variable request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||
int TvDeviceHandleGetVarRequest(INOUT UpnpStateVarRequest *cgv_event)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
int getvar_succeeded = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
int getvar_succeeded = 0;
|
||||
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
ithread_mutex_lock(&TVDevMutex);
|
||||
|
||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||
// check udn and service id
|
||||
const char *devUDN =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||
const char *serviceID =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
|
||||
// check variable name
|
||||
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
||||
const char *stateVarName =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
|
||||
getvar_succeeded = 1;
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||
tv_service_table[i].VariableStrVal[j] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
|
||||
// check udn and service id
|
||||
const char *devUDN =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||
const char *serviceID =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
|
||||
// check variable name
|
||||
for (j = 0; j < tv_service_table[i].VariableCount; j++) {
|
||||
const char *stateVarName = UpnpString_get_String(
|
||||
UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||
if (strcmp(stateVarName,
|
||||
tv_service_table[i].VariableName[j]) == 0) {
|
||||
getvar_succeeded = 1;
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getvar_succeeded) {
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||
" Unknown variable name = %s\n",
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)));
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable");
|
||||
}
|
||||
|
||||
if( getvar_succeeded ) {
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||
" Unknown variable name = %s\n",
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
|
||||
}
|
||||
ithread_mutex_unlock(&TVDevMutex);
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -504,86 +503,81 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||
* ca_event -- The control action request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
|
||||
int TvDeviceHandleActionRequest(INOUT UpnpActionRequest *ca_event)
|
||||
{
|
||||
/*
|
||||
Defaults if action not found
|
||||
*/
|
||||
int action_found = 0;
|
||||
int i = 0;
|
||||
int service = -1;
|
||||
int retCode = 0;
|
||||
char *errorString = NULL;
|
||||
const char *devUDN = NULL;
|
||||
const char *serviceID = NULL;
|
||||
const char *actionName = NULL;
|
||||
IXML_Document *actionResult = NULL;
|
||||
/* Defaults if action not found. */
|
||||
int action_found = 0;
|
||||
int i = 0;
|
||||
int service = -1;
|
||||
int retCode = 0;
|
||||
char *errorString = NULL;
|
||||
const char *devUDN = NULL;
|
||||
const char *serviceID = NULL;
|
||||
const char *actionName = NULL;
|
||||
IXML_Document *actionResult = NULL;
|
||||
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
|
||||
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||
if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
||||
/* Request for action in the TvDevice Control Service */
|
||||
service = TV_SERVICE_CONTROL;
|
||||
} else if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == 0 ) ) {
|
||||
/* Request for action in the TvDevice Picture Service */
|
||||
service = TV_SERVICE_PICTURE;
|
||||
}
|
||||
/* Find and call appropriate procedure based on action name
|
||||
* Each action name has an associated procedure stored in the
|
||||
* service table. These are set at initialization. */
|
||||
for( i = 0; i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL; i++ ) {
|
||||
if( !strcmp( actionName, tv_service_table[service].ActionNames[i] ) ) {
|
||||
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[TV_CONTROL_POWER], "1" ) ) ||
|
||||
( !strcmp( actionName, "PowerOn" ) ) ) {
|
||||
retCode = tv_service_table[service].actions[i](
|
||||
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||
&actionResult,
|
||||
&errorString );
|
||||
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||
} else {
|
||||
errorString = "Power is Off";
|
||||
retCode = UPNP_E_INTERNAL_ERROR;
|
||||
}
|
||||
action_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||
if (strcmp(devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) {
|
||||
/* Request for action in the TvDevice Control Service. */
|
||||
service = TV_SERVICE_CONTROL;
|
||||
} else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) {
|
||||
/* Request for action in the TvDevice Picture Service. */
|
||||
service = TV_SERVICE_PICTURE;
|
||||
}
|
||||
/* Find and call appropriate procedure based on action name.
|
||||
* Each action name has an associated procedure stored in the
|
||||
* service table. These are set at initialization. */
|
||||
for (i = 0;
|
||||
i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL;
|
||||
i++) {
|
||||
if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) {
|
||||
if (!strcmp(tv_service_table[TV_SERVICE_CONTROL].
|
||||
VariableStrVal[TV_CONTROL_POWER], "1") ||
|
||||
!strcmp(actionName, "PowerOn")) {
|
||||
retCode = tv_service_table[service].actions[i](
|
||||
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||
&actionResult,
|
||||
&errorString);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||
} else {
|
||||
errorString = "Power is Off";
|
||||
retCode = UPNP_E_INTERNAL_ERROR;
|
||||
}
|
||||
action_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !action_found ) {
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||
} else {
|
||||
if( retCode == UPNP_E_SUCCESS ) {
|
||||
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
// copy the error string
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
|
||||
switch ( retCode ) {
|
||||
case UPNP_E_INVALID_PARAM:
|
||||
{
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||
break;
|
||||
}
|
||||
case UPNP_E_INTERNAL_ERROR:
|
||||
default:
|
||||
{
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||
break;
|
||||
}
|
||||
if (!action_found) {
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action");
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||
} else {
|
||||
if (retCode == UPNP_E_SUCCESS) {
|
||||
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
// copy the error string
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString);
|
||||
switch (retCode) {
|
||||
case UPNP_E_INVALID_PARAM:
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||
break;
|
||||
case UPNP_E_INTERNAL_ERROR:
|
||||
default:
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -1759,43 +1753,43 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
|
||||
*****************************************************************************/
|
||||
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||
{
|
||||
switch ( EventType ) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
switch (EventType) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
|
||||
break;
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
TvDeviceHandleGetVarRequest((UpnpStateVarRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_ACTION_REQUEST:
|
||||
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
|
||||
break;
|
||||
case UPNP_CONTROL_ACTION_REQUEST:
|
||||
TvDeviceHandleActionRequest((UpnpActionRequest *)Event);
|
||||
break;
|
||||
|
||||
/*
|
||||
ignore these cases, since this is not a control point
|
||||
*/
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
||||
case UPNP_CONTROL_ACTION_COMPLETE:
|
||||
case UPNP_CONTROL_GET_VAR_COMPLETE:
|
||||
case UPNP_EVENT_RECEIVED:
|
||||
case UPNP_EVENT_RENEWAL_COMPLETE:
|
||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||
break;
|
||||
/*
|
||||
ignore these cases, since this is not a control point
|
||||
*/
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
||||
case UPNP_CONTROL_ACTION_COMPLETE:
|
||||
case UPNP_CONTROL_GET_VAR_COMPLETE:
|
||||
case UPNP_EVENT_RECEIVED:
|
||||
case UPNP_EVENT_RENEWAL_COMPLETE:
|
||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||
EventType );
|
||||
}
|
||||
default:
|
||||
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||
EventType);
|
||||
}
|
||||
|
||||
/* Print a summary of the event received */
|
||||
SampleUtil_PrintEvent( EventType, Event );
|
||||
/* Print a summary of the event received */
|
||||
SampleUtil_PrintEvent(EventType, Event);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -1807,8 +1801,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
||||
* Parameters:
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceStop()
|
||||
int TvDeviceStop(void)
|
||||
{
|
||||
UpnpUnRegisterRootDevice( device_handle );
|
||||
UpnpFinish();
|
||||
|
@ -623,7 +623,7 @@ int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OU
|
||||
|
||||
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
||||
char *web_dir_path, print_string pfun);
|
||||
int TvDeviceStop();
|
||||
int TvDeviceStop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -143,8 +143,7 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
|
||||
* UDN -- The Unique Device Name for the device to remove
|
||||
*
|
||||
********************************************************************************/
|
||||
int
|
||||
TvCtrlPointRemoveDevice(const char *UDN)
|
||||
int TvCtrlPointRemoveDevice(const char *UDN)
|
||||
{
|
||||
struct TvDeviceNode *curdevnode;
|
||||
struct TvDeviceNode *prevdevnode;
|
||||
@ -1019,10 +1018,10 @@ void TvCtrlPointHandleSubscribeUpdate(
|
||||
ithread_mutex_unlock( &DeviceListMutex );
|
||||
}
|
||||
|
||||
void
|
||||
TvCtrlPointHandleGetVar( const char *controlURL,
|
||||
const char *varName,
|
||||
const DOMString varValue )
|
||||
void TvCtrlPointHandleGetVar(
|
||||
const char *controlURL,
|
||||
const char *varName,
|
||||
const DOMString varValue)
|
||||
{
|
||||
|
||||
struct TvDeviceNode *tmpdevnode;
|
||||
@ -1033,9 +1032,9 @@ TvCtrlPointHandleGetVar( const char *controlURL,
|
||||
tmpdevnode = GlobalDeviceList;
|
||||
while (tmpdevnode) {
|
||||
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
|
||||
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL ) == 0 ) {
|
||||
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
|
||||
SampleUtil_StateUpdate(
|
||||
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE );
|
||||
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1072,6 +1071,7 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
IXML_Document *DescDoc = NULL;
|
||||
const char *location = NULL;
|
||||
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||
|
||||
if (errCode != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print(
|
||||
"Error in Discovery Callback -- %d", errCode);
|
||||
@ -1087,19 +1087,15 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
TvCtrlPointAddDevice(
|
||||
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
|
||||
}
|
||||
|
||||
if( DescDoc ) {
|
||||
if (DescDoc) {
|
||||
ixmlDocument_free(DescDoc);
|
||||
}
|
||||
|
||||
TvCtrlPointPrintList();
|
||||
break;
|
||||
}
|
||||
|
||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||
/* Nothing to do here... */
|
||||
break;
|
||||
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
|
||||
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
|
||||
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||
@ -1110,16 +1106,12 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
SampleUtil_Print(
|
||||
"Error in Discovery ByeBye Callback -- %d", errCode);
|
||||
}
|
||||
|
||||
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
|
||||
TvCtrlPointRemoveDevice(deviceId);
|
||||
|
||||
SampleUtil_Print("After byebye:");
|
||||
TvCtrlPointPrintList();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* SOAP Stuff */
|
||||
case UPNP_CONTROL_ACTION_COMPLETE: {
|
||||
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
|
||||
@ -1129,29 +1121,24 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
"Error in Action Complete Callback -- %d",
|
||||
errCode);
|
||||
}
|
||||
|
||||
/* No need for any processing here, just print out results.
|
||||
* Service state table updates are handled by events. */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case UPNP_CONTROL_GET_VAR_COMPLETE: {
|
||||
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
|
||||
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
|
||||
if (errCode != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print(
|
||||
"Error in Get Var Complete Callback -- %d",
|
||||
errCode );
|
||||
"Error in Get Var Complete Callback -- %d", errCode);
|
||||
} else {
|
||||
TvCtrlPointHandleGetVar(
|
||||
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
|
||||
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
|
||||
UpnpStateVarComplete_get_CurrentVal(sv_event) );
|
||||
UpnpStateVarComplete_get_CurrentVal(sv_event));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* GENA Stuff */
|
||||
case UPNP_EVENT_RECEIVED: {
|
||||
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||
@ -1161,26 +1148,23 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
UpnpEvent_get_ChangedVariables(e_event));
|
||||
break;
|
||||
}
|
||||
|
||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_RENEWAL_COMPLETE: {
|
||||
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||
|
||||
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
|
||||
if (errCode != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print(
|
||||
"Error in Event Subscribe Callback -- %d",
|
||||
errCode);
|
||||
"Error in Event Subscribe Callback -- %d", errCode);
|
||||
} else {
|
||||
TvCtrlPointHandleSubscribeUpdate(
|
||||
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
|
||||
UpnpEventSubscribe_get_TimeOut(es_event));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case UPNP_EVENT_AUTORENEWAL_FAILED:
|
||||
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
|
||||
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||
@ -1192,7 +1176,6 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||
&TimeOut,
|
||||
newSID);
|
||||
|
||||
if (errCode == UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
|
||||
TvCtrlPointHandleSubscribeUpdate(
|
||||
@ -1204,7 +1187,6 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* ignore these cases, since this is not a device */
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
|
@ -376,20 +376,18 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
||||
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
//unsigned int j = 0;
|
||||
int cmp1 = 0;
|
||||
int cmp2 = 0;
|
||||
const char *l_serviceId = NULL;
|
||||
const char *l_udn = NULL;
|
||||
const char *l_sid = NULL;
|
||||
// IXML_Document *PropSet = NULL;
|
||||
|
||||
// lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
ithread_mutex_lock(&TVDevMutex);
|
||||
|
||||
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||
l_udn = UpnpSubscriptionRequest_get_UDN_cstr(sr_event);
|
||||
l_sid = UpnpSubscriptionRequest_get_SID_cstr(sr_event);
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||
@ -429,7 +427,7 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
|
||||
}
|
||||
}
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
ithread_mutex_unlock(&TVDevMutex);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -447,53 +445,52 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
|
||||
* cgv_event -- The control get variable request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||
int TvDeviceHandleGetVarRequest(INOUT UpnpStateVarRequest *cgv_event)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
int getvar_succeeded = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
int getvar_succeeded = 0;
|
||||
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
ithread_mutex_lock(&TVDevMutex);
|
||||
|
||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||
// check udn and service id
|
||||
const char *devUDN =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||
const char *serviceID =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
|
||||
// check variable name
|
||||
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
||||
const char *stateVarName =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
|
||||
getvar_succeeded = 1;
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||
tv_service_table[i].VariableStrVal[j] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
|
||||
// check udn and service id
|
||||
const char *devUDN =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||
const char *serviceID =
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
|
||||
// check variable name
|
||||
for (j = 0; j < tv_service_table[i].VariableCount; j++) {
|
||||
const char *stateVarName = UpnpString_get_String(
|
||||
UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||
if (strcmp(stateVarName,
|
||||
tv_service_table[i].VariableName[j]) == 0) {
|
||||
getvar_succeeded = 1;
|
||||
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getvar_succeeded) {
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||
" Unknown variable name = %s\n",
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)));
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable");
|
||||
}
|
||||
|
||||
if( getvar_succeeded ) {
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||
" Unknown variable name = %s\n",
|
||||
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
|
||||
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
|
||||
}
|
||||
ithread_mutex_unlock(&TVDevMutex);
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -508,86 +505,81 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||
* ca_event -- The control action request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
|
||||
int TvDeviceHandleActionRequest(INOUT UpnpActionRequest *ca_event)
|
||||
{
|
||||
/*
|
||||
Defaults if action not found
|
||||
*/
|
||||
int action_found = 0;
|
||||
int i = 0;
|
||||
int service = -1;
|
||||
int retCode = 0;
|
||||
char *errorString = NULL;
|
||||
const char *devUDN = NULL;
|
||||
const char *serviceID = NULL;
|
||||
const char *actionName = NULL;
|
||||
IXML_Document *actionResult = NULL;
|
||||
/* Defaults if action not found. */
|
||||
int action_found = 0;
|
||||
int i = 0;
|
||||
int service = -1;
|
||||
int retCode = 0;
|
||||
char *errorString = NULL;
|
||||
const char *devUDN = NULL;
|
||||
const char *serviceID = NULL;
|
||||
const char *actionName = NULL;
|
||||
IXML_Document *actionResult = NULL;
|
||||
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
|
||||
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||
if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
||||
/* Request for action in the TvDevice Control Service */
|
||||
service = TV_SERVICE_CONTROL;
|
||||
} else if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) &&
|
||||
( strcmp( serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == 0 ) ) {
|
||||
/* Request for action in the TvDevice Picture Service */
|
||||
service = TV_SERVICE_PICTURE;
|
||||
}
|
||||
/* Find and call appropriate procedure based on action name
|
||||
* Each action name has an associated procedure stored in the
|
||||
* service table. These are set at initialization. */
|
||||
for( i = 0; i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL; i++ ) {
|
||||
if( !strcmp( actionName, tv_service_table[service].ActionNames[i] ) ) {
|
||||
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[TV_CONTROL_POWER], "1" ) ) ||
|
||||
( !strcmp( actionName, "PowerOn" ) ) ) {
|
||||
retCode = tv_service_table[service].actions[i](
|
||||
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||
&actionResult,
|
||||
&errorString );
|
||||
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||
} else {
|
||||
errorString = "Power is Off";
|
||||
retCode = UPNP_E_INTERNAL_ERROR;
|
||||
}
|
||||
action_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||
if (strcmp(devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) {
|
||||
/* Request for action in the TvDevice Control Service. */
|
||||
service = TV_SERVICE_CONTROL;
|
||||
} else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 &&
|
||||
strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) {
|
||||
/* Request for action in the TvDevice Picture Service. */
|
||||
service = TV_SERVICE_PICTURE;
|
||||
}
|
||||
/* Find and call appropriate procedure based on action name.
|
||||
* Each action name has an associated procedure stored in the
|
||||
* service table. These are set at initialization. */
|
||||
for (i = 0;
|
||||
i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL;
|
||||
i++) {
|
||||
if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) {
|
||||
if (!strcmp(tv_service_table[TV_SERVICE_CONTROL].
|
||||
VariableStrVal[TV_CONTROL_POWER], "1") ||
|
||||
!strcmp(actionName, "PowerOn")) {
|
||||
retCode = tv_service_table[service].actions[i](
|
||||
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||
&actionResult,
|
||||
&errorString);
|
||||
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||
} else {
|
||||
errorString = "Power is Off";
|
||||
retCode = UPNP_E_INTERNAL_ERROR;
|
||||
}
|
||||
action_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !action_found ) {
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||
} else {
|
||||
if( retCode == UPNP_E_SUCCESS ) {
|
||||
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
// copy the error string
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
|
||||
switch ( retCode ) {
|
||||
case UPNP_E_INVALID_PARAM:
|
||||
{
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||
break;
|
||||
}
|
||||
case UPNP_E_INTERNAL_ERROR:
|
||||
default:
|
||||
{
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||
break;
|
||||
}
|
||||
if (!action_found) {
|
||||
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action");
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||
} else {
|
||||
if (retCode == UPNP_E_SUCCESS) {
|
||||
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||
} else {
|
||||
// copy the error string
|
||||
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString);
|
||||
switch (retCode) {
|
||||
case UPNP_E_INVALID_PARAM:
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||
break;
|
||||
case UPNP_E_INTERNAL_ERROR:
|
||||
default:
|
||||
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -1763,43 +1755,43 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
|
||||
*****************************************************************************/
|
||||
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||
{
|
||||
switch ( EventType ) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
switch (EventType) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
|
||||
break;
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
TvDeviceHandleGetVarRequest((UpnpStateVarRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_ACTION_REQUEST:
|
||||
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
|
||||
break;
|
||||
case UPNP_CONTROL_ACTION_REQUEST:
|
||||
TvDeviceHandleActionRequest((UpnpActionRequest *)Event);
|
||||
break;
|
||||
|
||||
/*
|
||||
ignore these cases, since this is not a control point
|
||||
*/
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
||||
case UPNP_CONTROL_ACTION_COMPLETE:
|
||||
case UPNP_CONTROL_GET_VAR_COMPLETE:
|
||||
case UPNP_EVENT_RECEIVED:
|
||||
case UPNP_EVENT_RENEWAL_COMPLETE:
|
||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||
break;
|
||||
/*
|
||||
ignore these cases, since this is not a control point
|
||||
*/
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
||||
case UPNP_CONTROL_ACTION_COMPLETE:
|
||||
case UPNP_CONTROL_GET_VAR_COMPLETE:
|
||||
case UPNP_EVENT_RECEIVED:
|
||||
case UPNP_EVENT_RENEWAL_COMPLETE:
|
||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||
EventType );
|
||||
}
|
||||
default:
|
||||
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||
EventType);
|
||||
}
|
||||
|
||||
/* Print a summary of the event received */
|
||||
SampleUtil_PrintEvent( EventType, Event );
|
||||
/* Print a summary of the event received */
|
||||
SampleUtil_PrintEvent(EventType, Event);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -1811,8 +1803,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
||||
* Parameters:
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceStop(void)
|
||||
int TvDeviceStop(void)
|
||||
{
|
||||
UpnpUnRegisterRootDevice( device_handle );
|
||||
UpnpFinish();
|
||||
@ -1860,7 +1851,8 @@ TvDeviceStart( char *ip_address,
|
||||
SampleUtil_Print(
|
||||
"Initializing UPnP Sdk with\n"
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address, port );
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
|
||||
ret = UpnpInit( ip_address, port );
|
||||
if( ret != UPNP_E_SUCCESS ) {
|
||||
@ -1874,8 +1866,9 @@ TvDeviceStart( char *ip_address,
|
||||
|
||||
SampleUtil_Print(
|
||||
"UPnP Initialized\n"
|
||||
"\tipaddress= %s port = %u\n",
|
||||
ip_address, port );
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
|
||||
if( desc_doc_name == NULL ) {
|
||||
desc_doc_name = "tvdevicedesc.xml";
|
||||
|
Loading…
x
Reference in New Issue
Block a user