samples: One more code reorganization.
(cherry picked from commit 6bee05a517cffa610ad4a08db3eea8ceb73ad5eb)
This commit is contained in:
parent
838a8fea28
commit
4c2aa70a3a
@ -42,31 +42,28 @@ endif
|
||||
|
||||
|
||||
tv_device_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
common/tv_device.c \
|
||||
common/tv_device.h \
|
||||
tvdevice/linux/tv_device_main.c
|
||||
linux/tv_device_main.c
|
||||
|
||||
|
||||
tv_ctrlpt_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
common/tv_ctrlpt.c \
|
||||
common/tv_ctrlpt.h \
|
||||
tvctrlpt/linux/tv_ctrlpt_main.c
|
||||
linux/tv_ctrlpt_main.c
|
||||
|
||||
tv_combo_SOURCES = \
|
||||
common/common_data.h \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
common/tv_ctrlpt.c \
|
||||
common/tv_ctrlpt.h \
|
||||
common/tv_device.c \
|
||||
common/tv_device.h \
|
||||
tvcombo/linux/tv_combo_main.c
|
||||
linux/tv_combo_main.c
|
||||
|
||||
|
||||
if WITH_DOCUMENTATION
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef COMMON_DATA
|
||||
#define COMMON_DATA
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
@ -30,10 +30,9 @@
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#define SAMPLE_UTIL_C
|
||||
#include "sample_util.h"
|
||||
|
||||
#define ALLOC_COMMON_DATA
|
||||
#include "common_data.h"
|
||||
#include "tv_ctrlpt.h"
|
||||
#include "tv_device.h"
|
||||
|
||||
|
@ -48,6 +48,16 @@ extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef SAMPLE_UTIL_C
|
||||
/*! Service types for tv services. */
|
||||
const char *TvServiceType[] = {
|
||||
"urn:schemas-upnp-org:service:tvcontrol:1",
|
||||
"urn:schemas-upnp-org:service:tvpicture:1"
|
||||
};
|
||||
#else /* SAMPLE_UTIL_C */
|
||||
extern const char *TvServiceType[];
|
||||
#endif /* SAMPLE_UTIL_C */
|
||||
|
||||
/* mutex to control displaying of events */
|
||||
extern ithread_mutex_t display_mutex;
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include "tv_ctrlpt.h"
|
||||
|
||||
#include "common_data.h"
|
||||
#include "upnp.h"
|
||||
|
||||
/*!
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
#include "tv_device.h"
|
||||
|
||||
#include "common_data.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define DEFAULT_WEB_DIR "./web"
|
||||
@ -1345,16 +1343,6 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
||||
Cookie = Cookie;
|
||||
}
|
||||
|
||||
int TvDeviceStop(void)
|
||||
{
|
||||
UpnpUnRegisterRootDevice( device_handle );
|
||||
UpnpFinish();
|
||||
SampleUtil_Finish();
|
||||
ithread_mutex_destroy( &TVDevMutex );
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
int TvDeviceStart(char *ip_address, unsigned short port,
|
||||
const char *desc_doc_name, const char *web_dir_path,
|
||||
print_string pfun, int combo)
|
||||
@ -1437,6 +1425,46 @@ int TvDeviceStart(char *ip_address, unsigned short port,
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
int TvDeviceStop(void)
|
||||
{
|
||||
UpnpUnRegisterRootDevice(device_handle);
|
||||
UpnpFinish();
|
||||
SampleUtil_Finish();
|
||||
ithread_mutex_destroy(&TVDevMutex);
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
void *TvDeviceCommandLoop(void *args)
|
||||
{
|
||||
int stoploop = 0;
|
||||
char cmdline[100];
|
||||
char cmd[100];
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
args = args;
|
||||
}
|
||||
|
||||
int device_main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int portTemp = 0;
|
||||
|
@ -529,6 +529,19 @@ int TvDeviceStart(
|
||||
/*! [in] Non-zero if called from the combo application. */
|
||||
int combo);
|
||||
|
||||
/*!
|
||||
* \brief Stops the device. Uninitializes the sdk.
|
||||
*/
|
||||
int TvDeviceStop(void);
|
||||
|
||||
/*!
|
||||
* \brief Function that receives commands from the user at the command prompt
|
||||
* during the lifetime of the device, and calls the appropriate
|
||||
* functions for those commands. Only one command, exit, is currently
|
||||
* defined.
|
||||
*/
|
||||
void *TvDeviceCommandLoop(void *args);
|
||||
|
||||
/*!
|
||||
* \brief Main entry point for tv device application.
|
||||
*
|
||||
@ -540,16 +553,11 @@ int TvDeviceStart(
|
||||
* \li \c -ip ipaddress
|
||||
* \li \c -port port
|
||||
* \li \c -desc desc_doc_name
|
||||
* \li \c -webdir web_dir_path"
|
||||
* \li \c -webdir web_dir_path
|
||||
* \li \c -help
|
||||
*/
|
||||
int device_main(int argc, char *argv[]);
|
||||
|
||||
/*!
|
||||
* \brief Stops the device. Uninitializes the sdk.
|
||||
*/
|
||||
int TvDeviceStop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_ctrlpt.h"
|
||||
#include "tv_device.h"
|
@ -29,7 +29,6 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_ctrlpt.h"
|
||||
|
@ -29,49 +29,12 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common_data.h"
|
||||
#include "sample_util.h"
|
||||
#include "tv_device.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*!
|
||||
* \brief Function that receives commands from the user at the command prompt
|
||||
* during the lifetime of the device, and calls the appropriate
|
||||
* functions for those commands. Only one command, exit, is currently
|
||||
* defined.
|
||||
*/
|
||||
void *TvDeviceCommandLoop(void *args)
|
||||
{
|
||||
int stoploop = 0;
|
||||
char cmdline[100];
|
||||
char cmd[100];
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
args = args;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc;
|
Loading…
x
Reference in New Issue
Block a user