samples: Unified sample code.
This patch removes duplicated code in samples.
This commit is contained in:
parent
8434e1e936
commit
bd8d6cfc8b
@ -42,27 +42,30 @@ endif
|
||||
|
||||
|
||||
tv_device_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvdevice/tv_device.c \
|
||||
tvdevice/tv_device.h \
|
||||
common/tv_device.c \
|
||||
common/tv_device.h \
|
||||
tvdevice/linux/tv_device_main.c
|
||||
|
||||
|
||||
tv_ctrlpt_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvctrlpt/tv_ctrlpt.c \
|
||||
tvctrlpt/tv_ctrlpt.h \
|
||||
common/tv_ctrlpt.c \
|
||||
common/tv_ctrlpt.h \
|
||||
tvctrlpt/linux/tv_ctrlpt_main.c
|
||||
|
||||
tv_combo_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvcombo/tv_ctrlpt.c \
|
||||
tvcombo/tv_ctrlpt.h \
|
||||
tvcombo/tv_device.c \
|
||||
tvcombo/tv_device.h \
|
||||
common/tv_ctrlpt.c \
|
||||
common/tv_ctrlpt.h \
|
||||
common/tv_device.c \
|
||||
common/tv_device.h \
|
||||
tvcombo/linux/tv_combo_main.c
|
||||
|
||||
|
||||
|
20
upnp/sample/common/common_data.h
Normal file
20
upnp/sample/common/common_data.h
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef COMMON_DATA
|
||||
#define COMMON_DATA
|
||||
|
||||
#ifdef ALLOC_COMMON_DATA
|
||||
|
||||
/*! Service types for tv services. */
|
||||
const char *TvServiceType[] = {
|
||||
"urn:schemas-upnp-org:service:tvcontrol:1",
|
||||
"urn:schemas-upnp-org:service:tvpicture:1"
|
||||
};
|
||||
|
||||
#else /* ALLOC_COMMON_DATA */
|
||||
|
||||
extern const char *TvServiceType[];
|
||||
|
||||
#endif /* ALLOC_COMMON_DATA */
|
||||
|
||||
#endif /* COMMON_DATA */
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "tv_ctrlpt.h"
|
||||
|
||||
#include "common_data.h"
|
||||
#include "upnp.h"
|
||||
|
||||
/*!
|
||||
@ -43,11 +44,10 @@ ithread_mutex_t DeviceListMutex;
|
||||
|
||||
UpnpClient_Handle ctrlpt_handle = -1;
|
||||
|
||||
/*! Device type for tv device. */
|
||||
const char TvDeviceType[] = "urn:schemas-upnp-org:device:tvdevice:1";
|
||||
const char *TvServiceType[] = {
|
||||
"urn:schemas-upnp-org:service:tvcontrol:1",
|
||||
"urn:schemas-upnp-org:service:tvpicture:1"
|
||||
};
|
||||
|
||||
/*! Service names.*/
|
||||
const char *TvServiceName[] = { "Control", "Picture" };
|
||||
|
||||
/*!
|
||||
@ -1220,7 +1220,7 @@ void *TvCtrlPointTimerLoop(void *args)
|
||||
* TV_SUCCESS if everything went well, else TV_ERROR
|
||||
*
|
||||
********************************************************************************/
|
||||
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
|
||||
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr, int combo)
|
||||
{
|
||||
ithread_t timer_thread;
|
||||
int rc;
|
||||
@ -1241,8 +1241,11 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
|
||||
rc = UpnpInit(ip_address, port);
|
||||
if (rc != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d\n", rc);
|
||||
UpnpFinish();
|
||||
return TV_ERROR;
|
||||
if (!combo) {
|
||||
UpnpFinish();
|
||||
|
||||
return TV_ERROR;
|
||||
}
|
||||
}
|
||||
if (!ip_address) {
|
||||
ip_address = UpnpGetServerIpAddress();
|
@ -29,65 +29,56 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef UPNP_TV_CTRLPT_H
|
||||
#define UPNP_TV_CTRLPT_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "sample_util.h"
|
||||
|
||||
|
||||
#include "ithread.h"
|
||||
#include "upnp.h"
|
||||
#include "UpnpString.h"
|
||||
#include "upnptools.h"
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
/* Do not #include <unistd.h> */
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define TV_SERVICE_SERVCOUNT 2
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
#define TV_CONTROL_POWER 0
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
#define TV_CONTROL_POWER 0
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
#define TV_PICTURE_COLOR 0
|
||||
#define TV_PICTURE_TINT 1
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
#define TV_PICTURE_COLOR 0
|
||||
#define TV_PICTURE_TINT 1
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
#define TV_PICTURE_BRIGHTNESS 3
|
||||
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
|
||||
#define TV_SUCCESS 0
|
||||
#define TV_ERROR (-1)
|
||||
#define TV_WARNING 1
|
||||
#define TV_SUCCESS 0
|
||||
#define TV_ERROR (-1)
|
||||
#define TV_WARNING 1
|
||||
|
||||
/* This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
extern const char TvDeviceType[];
|
||||
extern const char *TvServiceType[];
|
||||
extern const char *TvServiceName[];
|
||||
extern const char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS];
|
||||
extern char TvVarCount[];
|
||||
@ -127,7 +118,6 @@ int TvCtrlPointRemoveDevice(const char *);
|
||||
int TvCtrlPointRemoveAll(void);
|
||||
int TvCtrlPointRefresh(void);
|
||||
|
||||
|
||||
int TvCtrlPointSendAction(int, int, const char *, const char **, char **, int);
|
||||
int TvCtrlPointSendActionNumericArg(int devnum, int service, const char *actionName, const char *paramName, int paramValue);
|
||||
int TvCtrlPointSendPowerOn(int devnum);
|
||||
@ -160,7 +150,7 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||
void TvCtrlPointVerifyTimeouts(int);
|
||||
void TvCtrlPointPrintCommands(void);
|
||||
void* TvCtrlPointCommandLoop(void *);
|
||||
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
|
||||
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr, int combo);
|
||||
int TvCtrlPointStop(void);
|
||||
int TvCtrlPointProcessCommand(char *cmdline);
|
||||
|
@ -31,18 +31,14 @@
|
||||
|
||||
#include "tv_device.h"
|
||||
|
||||
#include "common_data.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define DEFAULT_WEB_DIR "./web"
|
||||
|
||||
#define DESC_URL_SIZE 200
|
||||
|
||||
/*! Device type for tv device. */
|
||||
extern const char TvDeviceType[];
|
||||
|
||||
/*! Service types for tv services. */
|
||||
extern const char *TvServiceType[];
|
||||
|
||||
/*! Global arrays for storing Tv Control Service variable names, values,
|
||||
* and defaults. */
|
||||
const char *tvc_varname[] = { "Power", "Channel", "Volume" };
|
||||
@ -1359,88 +1355,83 @@ int TvDeviceStop(void)
|
||||
|
||||
int TvDeviceStart(char *ip_address, unsigned short port,
|
||||
const char *desc_doc_name, const char *web_dir_path,
|
||||
print_string pfun)
|
||||
print_string pfun, int combo)
|
||||
{
|
||||
int ret = UPNP_E_SUCCESS;
|
||||
char desc_doc_url[DESC_URL_SIZE];
|
||||
int ret = UPNP_E_SUCCESS;
|
||||
char desc_doc_url[DESC_URL_SIZE];
|
||||
|
||||
ithread_mutex_init( &TVDevMutex, NULL );
|
||||
ithread_mutex_init(&TVDevMutex, NULL);
|
||||
|
||||
SampleUtil_Initialize( pfun );
|
||||
SampleUtil_Initialize(pfun);
|
||||
SampleUtil_Print(
|
||||
"Initializing UPnP Sdk with\n"
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
ret = UpnpInit(ip_address, port);
|
||||
if (ret != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print("Error with UpnpInit -- %d\n", ret);
|
||||
UpnpFinish();
|
||||
|
||||
SampleUtil_Print(
|
||||
"Initializing UPnP Sdk with\n"
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
return ret;
|
||||
}
|
||||
ip_address = UpnpGetServerIpAddress();
|
||||
port = UpnpGetServerPort();
|
||||
SampleUtil_Print(
|
||||
"UPnP Initialized\n"
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
if (!desc_doc_name) {
|
||||
if (combo) {
|
||||
desc_doc_name = "tvcombodesc.xml";
|
||||
} else {
|
||||
desc_doc_name = "tvdevicedesc.xml";
|
||||
}
|
||||
}
|
||||
if (!web_dir_path) {
|
||||
web_dir_path = DEFAULT_WEB_DIR;
|
||||
}
|
||||
snprintf(desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address,
|
||||
port, desc_doc_name);
|
||||
SampleUtil_Print("Specifying the webserver root directory -- %s\n",
|
||||
web_dir_path );
|
||||
ret = UpnpSetWebServerRootDir(web_dir_path);
|
||||
if (ret != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print(
|
||||
"Error specifying webserver root directory -- %s: %d\n",
|
||||
web_dir_path, ret);
|
||||
UpnpFinish();
|
||||
|
||||
ret = UpnpInit( ip_address, port );
|
||||
if( ret != UPNP_E_SUCCESS ) {
|
||||
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
|
||||
UpnpFinish();
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
SampleUtil_Print(
|
||||
"Registering the RootDevice\n"
|
||||
"\t with desc_doc_url: %s\n",
|
||||
desc_doc_url);
|
||||
ret = UpnpRegisterRootDevice(desc_doc_url, TvDeviceCallbackEventHandler,
|
||||
&device_handle, &device_handle);
|
||||
if (ret != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print("Error registering the rootdevice : %d\n", ret);
|
||||
UpnpFinish();
|
||||
|
||||
ip_address = UpnpGetServerIpAddress();
|
||||
port = UpnpGetServerPort();
|
||||
return ret;
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"RootDevice Registered\n"
|
||||
"Initializing State Table\n");
|
||||
TvDeviceStateTableInit(desc_doc_url);
|
||||
SampleUtil_Print("State Table Initialized\n");
|
||||
ret = UpnpSendAdvertisement(device_handle, default_advr_expire);
|
||||
if (ret != UPNP_E_SUCCESS) {
|
||||
SampleUtil_Print("Error sending advertisements : %d\n", ret);
|
||||
UpnpFinish();
|
||||
|
||||
SampleUtil_Print(
|
||||
"UPnP Initialized\n"
|
||||
"\tipaddress = %s port = %u\n",
|
||||
ip_address ? ip_address : "{NULL}",
|
||||
port);
|
||||
return ret;
|
||||
}
|
||||
SampleUtil_Print("Advertisements Sent\n");
|
||||
}
|
||||
|
||||
if (!desc_doc_name) {
|
||||
desc_doc_name = "tvcombodesc.xml";
|
||||
}
|
||||
|
||||
if (!web_dir_path) {
|
||||
web_dir_path = DEFAULT_WEB_DIR;
|
||||
}
|
||||
|
||||
snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address,
|
||||
port, desc_doc_name );
|
||||
|
||||
SampleUtil_Print( "Specifying the webserver root directory -- %s\n",
|
||||
web_dir_path );
|
||||
ret = UpnpSetWebServerRootDir( web_dir_path );
|
||||
if( ret != UPNP_E_SUCCESS ) {
|
||||
SampleUtil_Print( "Error specifying webserver root directory -- %s: %d\n",
|
||||
web_dir_path, ret );
|
||||
UpnpFinish();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SampleUtil_Print(
|
||||
"Registering the RootDevice\n"
|
||||
"\t with desc_doc_url: %s\n",
|
||||
desc_doc_url );
|
||||
|
||||
ret = UpnpRegisterRootDevice( desc_doc_url, TvDeviceCallbackEventHandler,
|
||||
&device_handle, &device_handle );
|
||||
if( ret != UPNP_E_SUCCESS ) {
|
||||
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
|
||||
UpnpFinish();
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"RootDevice Registered\n"
|
||||
"Initializing State Table\n");
|
||||
TvDeviceStateTableInit( desc_doc_url );
|
||||
SampleUtil_Print("State Table Initialized\n");
|
||||
ret = UpnpSendAdvertisement( device_handle, default_advr_expire );
|
||||
if( ret != UPNP_E_SUCCESS ) {
|
||||
SampleUtil_Print( "Error sending advertisements : %d\n", ret );
|
||||
UpnpFinish();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SampleUtil_Print("Advertisements Sent\n");
|
||||
}
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
@ -130,10 +130,6 @@ extern "C" {
|
||||
/*! This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
extern const char TvDeviceType[];
|
||||
|
||||
extern const char *TvServiceType[];
|
||||
|
||||
/*!
|
||||
* \brief Prototype for all actions. For each action that a service
|
||||
* implements, there is a corresponding function with this prototype.
|
||||
@ -529,7 +525,9 @@ int TvDeviceStart(
|
||||
* may be NULL. Default is ./web (for Linux) or ../tvdevice/web. */
|
||||
const char *web_dir_path,
|
||||
/*! [in] print function to use. */
|
||||
print_string pfun);
|
||||
print_string pfun,
|
||||
/*! [in] Non-zero if called from the combo application. */
|
||||
int combo);
|
||||
|
||||
/*!
|
||||
* \brief Stops the device. Uninitializes the sdk.
|
@ -29,6 +29,8 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define ALLOC_COMMON_DATA
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_ctrlpt.h"
|
||||
#include "tv_device.h"
|
||||
@ -394,7 +396,7 @@ int device_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
port = (unsigned short)portTemp;
|
||||
return TvDeviceStart(ip_address, port, desc_doc_name, web_dir_path, linux_print);
|
||||
return TvDeviceStart(ip_address, port, desc_doc_name, web_dir_path, linux_print, 1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@ -409,7 +411,7 @@ int main(int argc, char **argv)
|
||||
int code;
|
||||
|
||||
device_main(argc, argv);
|
||||
rc = TvCtrlPointStart(linux_print, NULL);
|
||||
rc = TvCtrlPointStart(linux_print, NULL, 1);
|
||||
if (rc != TV_SUCCESS) {
|
||||
SampleUtil_Print("Error starting UPnP TV Control Point\n");
|
||||
return rc;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,172 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef UPNP_TV_CTRLPT_H
|
||||
#define UPNP_TV_CTRLPT_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "sample_util.h"
|
||||
|
||||
|
||||
#include "ithread.h"
|
||||
#include "upnp.h"
|
||||
#include "UpnpString.h"
|
||||
#include "upnptools.h"
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
/* Do not #include <unistd.h> */
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define TV_SERVICE_SERVCOUNT 2
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
#define TV_CONTROL_POWER 0
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
#define TV_PICTURE_COLOR 0
|
||||
#define TV_PICTURE_TINT 1
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
#define TV_PICTURE_BRIGHTNESS 3
|
||||
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
|
||||
#define TV_SUCCESS 0
|
||||
#define TV_ERROR (-1)
|
||||
#define TV_WARNING 1
|
||||
|
||||
/* This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
extern const char TvDeviceType[];
|
||||
extern const char *TvServiceType[];
|
||||
extern const char *TvServiceName[];
|
||||
extern const char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS];
|
||||
extern char TvVarCount[];
|
||||
|
||||
struct tv_service {
|
||||
char ServiceId[NAME_SIZE];
|
||||
char ServiceType[NAME_SIZE];
|
||||
char *VariableStrVal[TV_MAXVARS];
|
||||
char EventURL[NAME_SIZE];
|
||||
char ControlURL[NAME_SIZE];
|
||||
char SID[NAME_SIZE];
|
||||
};
|
||||
|
||||
extern struct TvDeviceNode *GlobalDeviceList;
|
||||
|
||||
struct TvDevice {
|
||||
char UDN[250];
|
||||
char DescDocURL[250];
|
||||
char FriendlyName[250];
|
||||
char PresURL[250];
|
||||
int AdvrTimeOut;
|
||||
struct tv_service TvService[TV_SERVICE_SERVCOUNT];
|
||||
};
|
||||
|
||||
struct TvDeviceNode {
|
||||
struct TvDevice device;
|
||||
struct TvDeviceNode *next;
|
||||
};
|
||||
|
||||
extern ithread_mutex_t DeviceListMutex;
|
||||
|
||||
extern UpnpClient_Handle ctrlpt_handle;
|
||||
|
||||
void TvCtrlPointPrintHelp(void);
|
||||
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
|
||||
int TvCtrlPointRemoveDevice(const char *);
|
||||
int TvCtrlPointRemoveAll(void);
|
||||
int TvCtrlPointRefresh(void);
|
||||
|
||||
|
||||
int TvCtrlPointSendAction(int, int, const char *, const char **, char **, int);
|
||||
int TvCtrlPointSendActionNumericArg(int devnum, int service, const char *actionName, const char *paramName, int paramValue);
|
||||
int TvCtrlPointSendPowerOn(int devnum);
|
||||
int TvCtrlPointSendPowerOff(int devnum);
|
||||
int TvCtrlPointSendSetChannel(int, int);
|
||||
int TvCtrlPointSendSetVolume(int, int);
|
||||
int TvCtrlPointSendSetColor(int, int);
|
||||
int TvCtrlPointSendSetTint(int, int);
|
||||
int TvCtrlPointSendSetContrast(int, int);
|
||||
int TvCtrlPointSendSetBrightness(int, int);
|
||||
|
||||
int TvCtrlPointGetVar(int, int, const char *);
|
||||
int TvCtrlPointGetPower(int devnum);
|
||||
int TvCtrlPointGetChannel(int);
|
||||
int TvCtrlPointGetVolume(int);
|
||||
int TvCtrlPointGetColor(int);
|
||||
int TvCtrlPointGetTint(int);
|
||||
int TvCtrlPointGetContrast(int);
|
||||
int TvCtrlPointGetBrightness(int);
|
||||
|
||||
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
||||
int TvCtrlPointPrintList(void);
|
||||
int TvCtrlPointPrintDevice(int);
|
||||
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
||||
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||
void TvCtrlPointHandleEvent(const char *, int, IXML_Document *);
|
||||
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||
void TvCtrlPointVerifyTimeouts(int);
|
||||
void TvCtrlPointPrintCommands(void);
|
||||
void* TvCtrlPointCommandLoop(void *);
|
||||
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
|
||||
int TvCtrlPointStop(void);
|
||||
int TvCtrlPointProcessCommand(char *cmdline);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* UPNP_TV_CTRLPT_H */
|
||||
|
@ -1,544 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef UPNP_TV_DEVICE_H
|
||||
#define UPNP_TV_DEVICE_H
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sample_util.h"
|
||||
|
||||
#include "ithread.h"
|
||||
#include "upnp.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WIN32
|
||||
/* Do not #include <unistd.h> */
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*! Color constants */
|
||||
#define MAX_COLOR 10
|
||||
#define MIN_COLOR 1
|
||||
|
||||
/*! Brightness constants */
|
||||
#define MAX_BRIGHTNESS 10
|
||||
#define MIN_BRIGHTNESS 1
|
||||
|
||||
/*! Power constants */
|
||||
#define POWER_ON 1
|
||||
#define POWER_OFF 0
|
||||
|
||||
/*! Tint constants */
|
||||
#define MAX_TINT 10
|
||||
#define MIN_TINT 1
|
||||
|
||||
/*! Volume constants */
|
||||
#define MAX_VOLUME 10
|
||||
#define MIN_VOLUME 1
|
||||
|
||||
/*! Contrast constants */
|
||||
#define MAX_CONTRAST 10
|
||||
#define MIN_CONTRAST 1
|
||||
|
||||
/*! Channel constants */
|
||||
#define MAX_CHANNEL 100
|
||||
#define MIN_CHANNEL 1
|
||||
|
||||
/*! Number of services. */
|
||||
#define TV_SERVICE_SERVCOUNT 2
|
||||
|
||||
/*! Index of control service */
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
|
||||
/*! Index of picture service */
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
|
||||
/*! Number of control variables */
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
|
||||
/*! Index of power variable */
|
||||
#define TV_CONTROL_POWER 0
|
||||
|
||||
/*! Index of channel variable */
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
|
||||
/*! Index of volume variable */
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
|
||||
/*! Number of picture variables */
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
|
||||
/*! Index of color variable */
|
||||
#define TV_PICTURE_COLOR 0
|
||||
|
||||
/*! Index of tint variable */
|
||||
#define TV_PICTURE_TINT 1
|
||||
|
||||
/*! Index of contrast variable */
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
|
||||
/*! Index of brightness variable */
|
||||
#define TV_PICTURE_BRIGHTNESS 3
|
||||
|
||||
/*! Max value length */
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
|
||||
/*! Max actions */
|
||||
#define TV_MAXACTIONS 12
|
||||
|
||||
/*! This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
extern const char TvDeviceType[];
|
||||
|
||||
extern const char *TvServiceType[];
|
||||
|
||||
/*!
|
||||
* \brief Prototype for all actions. For each action that a service
|
||||
* implements, there is a corresponding function with this prototype.
|
||||
*
|
||||
* Pointers to these functions, along with action names, are stored
|
||||
* in the service table. When an action request comes in the action
|
||||
* name is matched, and the appropriate function is called.
|
||||
* Each function returns UPNP_E_SUCCESS, on success, and a nonzero
|
||||
* error code on failure.
|
||||
*/
|
||||
typedef int (*upnp_action)(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *request,
|
||||
/*! [out] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] Error string in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*! Structure for storing Tv Service identifiers and state table. */
|
||||
struct TvService {
|
||||
/*! Universally Unique Device Name. */
|
||||
char UDN[NAME_SIZE];
|
||||
/*! . */
|
||||
char ServiceId[NAME_SIZE];
|
||||
/*! . */
|
||||
char ServiceType[NAME_SIZE];
|
||||
/*! . */
|
||||
const char *VariableName[TV_MAXVARS];
|
||||
/*! . */
|
||||
char *VariableStrVal[TV_MAXVARS];
|
||||
/*! . */
|
||||
const char *ActionNames[TV_MAXACTIONS];
|
||||
/*! . */
|
||||
upnp_action actions[TV_MAXACTIONS];
|
||||
/*! . */
|
||||
int VariableCount;
|
||||
};
|
||||
|
||||
/*! Array of service structures */
|
||||
extern struct TvService tv_service_table[];
|
||||
|
||||
/*! Device handle returned from sdk */
|
||||
extern UpnpDevice_Handle device_handle;
|
||||
|
||||
/*! Mutex for protecting the global state table data
|
||||
* in a multi-threaded, asynchronous environment.
|
||||
* All functions should lock this mutex before reading
|
||||
* or writing the state table data. */
|
||||
extern ithread_mutex_t TVDevMutex;
|
||||
|
||||
/*!
|
||||
* \brief Initializes the action table for the specified service.
|
||||
*
|
||||
* Note that knowledge of the service description is assumed.
|
||||
* Action names are hardcoded.
|
||||
*/
|
||||
int SetActionTable(
|
||||
/*! [in] one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. */
|
||||
int serviceType,
|
||||
/*! [out] service containing action table to set. */
|
||||
struct TvService *out);
|
||||
|
||||
/*!
|
||||
* \brief Initialize the device state table for this TvDevice, pulling
|
||||
* identifier info from the description Document.
|
||||
*
|
||||
* Note that knowledge of the service description is assumed.
|
||||
* State table variables and default values are currently hardcoded in
|
||||
* this file rather than being read from service description documents.
|
||||
*/
|
||||
int TvDeviceStateTableInit(
|
||||
/*! [in] The description document URL. */
|
||||
char *DescDocURL);
|
||||
|
||||
/*!
|
||||
* \brief Called during a subscription request callback.
|
||||
*
|
||||
* If the subscription request is for this device and either its
|
||||
* control service or picture service, then accept it.
|
||||
*/
|
||||
int TvDeviceHandleSubscriptionRequest(
|
||||
/*! [in] The subscription request event structure. */
|
||||
struct Upnp_Subscription_Request *sr_event);
|
||||
|
||||
/*!
|
||||
* \brief Called during a get variable request callback.
|
||||
*
|
||||
* If the request is for this device and either its control service or
|
||||
* picture service, then respond with the variable value.
|
||||
*/
|
||||
int TvDeviceHandleGetVarRequest(
|
||||
/*! [in] The control get variable request event structure. */
|
||||
struct Upnp_State_Var_Request *cgv_event);
|
||||
|
||||
/*!
|
||||
* \brief Called during an action request callback.
|
||||
*
|
||||
* If the request is for this device and either its control service
|
||||
* or picture service, then perform the action and respond.
|
||||
*/
|
||||
int TvDeviceHandleActionRequest(
|
||||
/*! [in] The control action request event structure. */
|
||||
struct Upnp_Action_Request *ca_event);
|
||||
|
||||
/*!
|
||||
* \brief The callback handler registered with the SDK while registering
|
||||
* root device.
|
||||
*
|
||||
* Dispatches the request to the appropriate procedure
|
||||
* based on the value of EventType. The four requests handled by the
|
||||
* device are:
|
||||
* \li 1) Event Subscription requests.
|
||||
* \li 2) Get Variable requests.
|
||||
* \li 3) Action requests.
|
||||
*/
|
||||
int TvDeviceCallbackEventHandler(
|
||||
/*! [in] The type of callback event. */
|
||||
Upnp_EventType,
|
||||
/*! [in] Data structure containing event data. */
|
||||
void *Event,
|
||||
/*! [in] Optional data specified during callback registration. */
|
||||
void *Cookie);
|
||||
|
||||
/*!
|
||||
* \brief Update the TvDevice service state table, and notify all subscribed
|
||||
* control points of the updated state.
|
||||
*
|
||||
* Note that since this function blocks on the mutex TVDevMutex,
|
||||
* to avoid a hang this function should not be called within any other
|
||||
* function that currently has this mutex locked.
|
||||
*/
|
||||
int TvDeviceSetServiceTableVar(
|
||||
/*! [in] The service number (TV_SERVICE_CONTROL or TV_SERVICE_PICTURE). */
|
||||
unsigned int service,
|
||||
/*! [in] The variable number (TV_CONTROL_POWER, TV_CONTROL_CHANNEL,
|
||||
* TV_CONTROL_VOLUME, TV_PICTURE_COLOR, TV_PICTURE_TINT,
|
||||
* TV_PICTURE_CONTRAST, or TV_PICTURE_BRIGHTNESS). */
|
||||
int variable,
|
||||
/*! [in] The string representation of the new value. */
|
||||
char *value);
|
||||
|
||||
/* Control Service Actions */
|
||||
|
||||
/*!
|
||||
* \brief Turn the power on.
|
||||
*/
|
||||
int TvDevicePowerOn(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Turn the power off.
|
||||
*/
|
||||
int TvDevicePowerOff(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Change the channel, update the TvDevice control service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetChannel(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase the channel.
|
||||
*/
|
||||
int TvDeviceIncreaseChannel(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease the channel.
|
||||
*/
|
||||
int TvDeviceDecreaseChannel(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Change the volume, update the TvDevice control service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetVolume(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase the volume.
|
||||
*/
|
||||
int TvDeviceIncreaseVolume(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease the volume.
|
||||
*/
|
||||
int TvDeviceDecreaseVolume(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*Picture Service Actions */
|
||||
|
||||
/*!
|
||||
* \brief Change the color, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetColor(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase the color.
|
||||
*/
|
||||
int TvDeviceIncreaseColor(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease the color.
|
||||
*/
|
||||
int TvDeviceDecreaseColor(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Change the tint, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetTint(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase tint.
|
||||
*/
|
||||
int TvDeviceIncreaseTint(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease tint.
|
||||
*/
|
||||
int TvDeviceDecreaseTint(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Change the contrast, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetContrast(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase the contrast.
|
||||
*/
|
||||
int TvDeviceIncreaseContrast(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease the contrast.
|
||||
*/
|
||||
int TvDeviceDecreaseContrast(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Change the brightness, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*/
|
||||
int TvDeviceSetBrightness(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Increase brightnesss.
|
||||
*/
|
||||
int TvDeviceIncreaseBrightness(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Decrease brightnesss.
|
||||
*/
|
||||
int TvDeviceDecreaseBrightness(
|
||||
/*! [in] Document of action request. */
|
||||
IXML_Document *in,
|
||||
/*! [in] Action result. */
|
||||
IXML_Document **out,
|
||||
/*! [out] ErrorString in case action was unsuccessful. */
|
||||
const char **errorString);
|
||||
|
||||
/*!
|
||||
* \brief Initializes the UPnP Sdk, registers the device, and sends out
|
||||
* advertisements.
|
||||
*/
|
||||
int TvDeviceStart(
|
||||
/*! [in] ip address to initialize the sdk (may be NULL)
|
||||
* if null, then the first non null loopback address is used. */
|
||||
char *ip_address,
|
||||
/*! [in] port number to initialize the sdk (may be 0)
|
||||
* if zero, then a random number is used. */
|
||||
unsigned short port,
|
||||
/*! [in] name of description document.
|
||||
* may be NULL. Default is tvdevicedesc.xml. */
|
||||
const char *desc_doc_name,
|
||||
/*! [in] path of web directory.
|
||||
* may be NULL. Default is ./web (for Linux) or ../tvdevice/web. */
|
||||
const char *web_dir_path,
|
||||
/*! [in] print function to use. */
|
||||
print_string pfun);
|
||||
|
||||
/*!
|
||||
* \brief Stops the device. Uninitializes the sdk.
|
||||
*/
|
||||
int TvDeviceStop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,8 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define ALLOC_COMMON_DATA
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_ctrlpt.h"
|
||||
|
||||
@ -366,7 +368,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
int code;
|
||||
|
||||
rc = TvCtrlPointStart(linux_print, NULL);
|
||||
rc = TvCtrlPointStart(linux_print, NULL, 0);
|
||||
if (rc != TV_SUCCESS) {
|
||||
SampleUtil_Print("Error starting UPnP TV Control Point\n");
|
||||
return rc;
|
||||
|
@ -29,15 +29,14 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#define ALLOC_COMMON_DATA
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_device.h"
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Prints a string to standard out.
|
||||
*/
|
||||
@ -58,122 +57,112 @@ void linux_print(const char *format, ...)
|
||||
*/
|
||||
void *TvDeviceCommandLoop(void *args)
|
||||
{
|
||||
int stoploop = 0;
|
||||
char cmdline[100];
|
||||
char cmd[100];
|
||||
int stoploop = 0;
|
||||
char cmdline[100];
|
||||
char cmd[100];
|
||||
|
||||
while (!stoploop) {
|
||||
sprintf( cmdline, " " );
|
||||
sprintf( cmd, " " );
|
||||
while (!stoploop) {
|
||||
sprintf(cmdline, " ");
|
||||
sprintf(cmd, " ");
|
||||
SampleUtil_Print("\n>> ");
|
||||
/* Get a command line */
|
||||
fgets(cmdline, 100, stdin);
|
||||
sscanf(cmdline, "%s", cmd);
|
||||
if( strcasecmp(cmd, "exit") == 0) {
|
||||
SampleUtil_Print("Shutting down...\n");
|
||||
TvDeviceStop();
|
||||
exit(0);
|
||||
} else {
|
||||
SampleUtil_Print(
|
||||
"\n Unknown command: %s\n\n", cmd);
|
||||
SampleUtil_Print(
|
||||
" Valid Commands:\n"
|
||||
" Exit\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
SampleUtil_Print("\n>> ");
|
||||
/* Get a command line */
|
||||
fgets(cmdline, 100, stdin);
|
||||
sscanf(cmdline, "%s", cmd);
|
||||
if( strcasecmp(cmd, "exit") == 0) {
|
||||
SampleUtil_Print("Shutting down...\n");
|
||||
TvDeviceStop();
|
||||
exit(0);
|
||||
} else {
|
||||
SampleUtil_Print("\n Unknown command: %s\n\n", cmd);
|
||||
SampleUtil_Print(" Valid Commands:\n");
|
||||
SampleUtil_Print(" Exit\n\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
args = args;
|
||||
return NULL;
|
||||
args = args;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* main
|
||||
/*!
|
||||
* \brief Main entry point for tv device application.
|
||||
*
|
||||
* Description:
|
||||
* Main entry point for tv device application.
|
||||
* Initializes and registers with the sdk.
|
||||
* Initializes the state stables of the service.
|
||||
* Starts the command loop.
|
||||
* Initializes and registers with the sdk.
|
||||
* Initializes the state stables of the service.
|
||||
* Starts the command loop.
|
||||
*
|
||||
* Parameters:
|
||||
* int argc - count of arguments
|
||||
* char ** argv -arguments. The application
|
||||
* accepts the following optional arguments:
|
||||
*
|
||||
* -ip ipaddress
|
||||
* -port port
|
||||
* -desc desc_doc_name
|
||||
* -webdir web_dir_path"
|
||||
* -help
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(int argc, char **argv)
|
||||
* Accepts the following optional arguments:
|
||||
* \li \c -ip ipaddress
|
||||
* \li \c -port port
|
||||
* \li \c -desc desc_doc_name
|
||||
* \li \c -webdir web_dir_path"
|
||||
* \li \c -help
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int portTemp = 0;
|
||||
char *ip_address = NULL,
|
||||
*desc_doc_name = NULL,
|
||||
*web_dir_path = NULL;
|
||||
int rc;
|
||||
ithread_t cmdloop_thread;
|
||||
unsigned int portTemp = 0;
|
||||
char *ip_address = NULL;
|
||||
char *desc_doc_name = NULL;
|
||||
char *web_dir_path = NULL;
|
||||
int rc;
|
||||
ithread_t cmdloop_thread;
|
||||
#ifdef WIN32
|
||||
#else
|
||||
int sig;
|
||||
sigset_t sigs_to_catch;
|
||||
int sig;
|
||||
sigset_t sigs_to_catch;
|
||||
#endif
|
||||
int code;
|
||||
unsigned short port = 0;
|
||||
int i = 0;
|
||||
|
||||
SampleUtil_Initialize(linux_print);
|
||||
/* Parse options */
|
||||
for( i = 1; i < argc; i++ ) {
|
||||
if( strcmp( argv[i], "-ip" ) == 0 ) {
|
||||
ip_address = argv[++i];
|
||||
} else if( strcmp( argv[i], "-port" ) == 0 ) {
|
||||
sscanf( argv[++i], "%u", &portTemp );
|
||||
} else if( strcmp( argv[i], "-desc" ) == 0 ) {
|
||||
desc_doc_name = argv[++i];
|
||||
} else if( strcmp( argv[i], "-webdir" ) == 0 ) {
|
||||
web_dir_path = argv[++i];
|
||||
} else if( strcmp( argv[i], "-help" ) == 0 ) {
|
||||
SampleUtil_Print( "Usage: %s -ip ipaddress -port port"
|
||||
" -desc desc_doc_name -webdir web_dir_path"
|
||||
" -help (this message)\n", argv[0] );
|
||||
SampleUtil_Print( "\tipaddress: IP address of the device"
|
||||
" (must match desc. doc)\n" );
|
||||
SampleUtil_Print( "\t\te.g.: 192.168.0.4\n" );
|
||||
SampleUtil_Print( "\tport: Port number to use for "
|
||||
"receiving UPnP messages (must match desc. doc)\n" );
|
||||
SampleUtil_Print( "\t\te.g.: 5431\n" );
|
||||
SampleUtil_Print
|
||||
( "\tdesc_doc_name: name of device description document\n" );
|
||||
SampleUtil_Print( "\t\te.g.: tvdevicedesc.xml\n" );
|
||||
SampleUtil_Print
|
||||
( "\tweb_dir_path: Filesystem path where web files "
|
||||
"related to the device are stored\n" );
|
||||
SampleUtil_Print( "\t\te.g.: /upnp/sample/tvdevice/web\n" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
port = (unsigned short)portTemp;
|
||||
TvDeviceStart(ip_address, port, desc_doc_name, web_dir_path, linux_print);
|
||||
|
||||
/* start a command loop thread */
|
||||
code = ithread_create(&cmdloop_thread, NULL, TvDeviceCommandLoop, NULL);
|
||||
int code;
|
||||
unsigned short port = 0;
|
||||
int i = 0;
|
||||
|
||||
SampleUtil_Initialize(linux_print);
|
||||
/* Parse options */
|
||||
for(i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-ip") == 0) {
|
||||
ip_address = argv[++i];
|
||||
} else if(strcmp(argv[i], "-port") == 0) {
|
||||
sscanf(argv[++i], "%u", &portTemp);
|
||||
} else if(strcmp(argv[i], "-desc") == 0) {
|
||||
desc_doc_name = argv[++i];
|
||||
} else if(strcmp(argv[i], "-webdir") == 0) {
|
||||
web_dir_path = argv[++i];
|
||||
} else if(strcmp(argv[i], "-help") == 0) {
|
||||
SampleUtil_Print(
|
||||
"Usage: %s -ip ipaddress -port port"
|
||||
" -desc desc_doc_name -webdir web_dir_path"
|
||||
" -help (this message)\n", argv[0]);
|
||||
SampleUtil_Print(
|
||||
"\tipaddress: IP address of the device"
|
||||
" (must match desc. doc)\n"
|
||||
"\t\te.g.: 192.168.0.4\n"
|
||||
"\tport: Port number to use for"
|
||||
" receiving UPnP messages (must match desc. doc)\n"
|
||||
"\t\te.g.: 5431\n"
|
||||
"\tdesc_doc_name: name of device description document\n"
|
||||
"\t\te.g.: tvdevicedesc.xml\n"
|
||||
"\tweb_dir_path: Filesystem path where web files"
|
||||
" related to the device are stored\n"
|
||||
"\t\te.g.: /upnp/sample/tvdevice/web\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
port = (unsigned short)portTemp;
|
||||
TvDeviceStart(ip_address, port, desc_doc_name, web_dir_path,
|
||||
linux_print, 0);
|
||||
/* start a command loop thread */
|
||||
code = ithread_create(&cmdloop_thread, NULL, TvDeviceCommandLoop, NULL);
|
||||
#ifdef WIN32
|
||||
ithread_join(cmdloop_thread, NULL);
|
||||
ithread_join(cmdloop_thread, NULL);
|
||||
#else
|
||||
/* Catch Ctrl-C and properly shutdown */
|
||||
sigemptyset( &sigs_to_catch );
|
||||
sigaddset( &sigs_to_catch, SIGINT );
|
||||
sigwait( &sigs_to_catch, &sig );
|
||||
|
||||
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
||||
/* Catch Ctrl-C and properly shutdown */
|
||||
sigemptyset(&sigs_to_catch);
|
||||
sigaddset(&sigs_to_catch, SIGINT);
|
||||
sigwait(&sigs_to_catch, &sig);
|
||||
SampleUtil_Print("Shutting down on signal %d...\n", sig);
|
||||
#endif
|
||||
rc = TvDeviceStop();
|
||||
|
||||
return rc;
|
||||
rc = TvDeviceStop();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user