samples: One more code reorganization.
This commit is contained in:
parent
2e96edcbc5
commit
6bee05a517
@ -42,31 +42,28 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
tv_device_SOURCES = \
|
tv_device_SOURCES = \
|
||||||
common/common_data.h \
|
|
||||||
common/sample_util.c \
|
common/sample_util.c \
|
||||||
common/sample_util.h \
|
common/sample_util.h \
|
||||||
common/tv_device.c \
|
common/tv_device.c \
|
||||||
common/tv_device.h \
|
common/tv_device.h \
|
||||||
tvdevice/linux/tv_device_main.c
|
linux/tv_device_main.c
|
||||||
|
|
||||||
|
|
||||||
tv_ctrlpt_SOURCES = \
|
tv_ctrlpt_SOURCES = \
|
||||||
common/common_data.h \
|
|
||||||
common/sample_util.c \
|
common/sample_util.c \
|
||||||
common/sample_util.h \
|
common/sample_util.h \
|
||||||
common/tv_ctrlpt.c \
|
common/tv_ctrlpt.c \
|
||||||
common/tv_ctrlpt.h \
|
common/tv_ctrlpt.h \
|
||||||
tvctrlpt/linux/tv_ctrlpt_main.c
|
linux/tv_ctrlpt_main.c
|
||||||
|
|
||||||
tv_combo_SOURCES = \
|
tv_combo_SOURCES = \
|
||||||
common/common_data.h \
|
|
||||||
common/sample_util.c \
|
common/sample_util.c \
|
||||||
common/sample_util.h \
|
common/sample_util.h \
|
||||||
common/tv_ctrlpt.c \
|
common/tv_ctrlpt.c \
|
||||||
common/tv_ctrlpt.h \
|
common/tv_ctrlpt.h \
|
||||||
common/tv_device.c \
|
common/tv_device.c \
|
||||||
common/tv_device.h \
|
common/tv_device.h \
|
||||||
tvcombo/linux/tv_combo_main.c
|
linux/tv_combo_main.c
|
||||||
|
|
||||||
|
|
||||||
if WITH_DOCUMENTATION
|
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"
|
#include "sample_util.h"
|
||||||
|
|
||||||
#define ALLOC_COMMON_DATA
|
|
||||||
#include "common_data.h"
|
|
||||||
#include "tv_ctrlpt.h"
|
#include "tv_ctrlpt.h"
|
||||||
#include "tv_device.h"
|
#include "tv_device.h"
|
||||||
|
|
||||||
|
@ -48,6 +48,16 @@ extern "C" {
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.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 */
|
/* mutex to control displaying of events */
|
||||||
extern ithread_mutex_t display_mutex;
|
extern ithread_mutex_t display_mutex;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "tv_ctrlpt.h"
|
#include "tv_ctrlpt.h"
|
||||||
|
|
||||||
#include "common_data.h"
|
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
#include "tv_device.h"
|
#include "tv_device.h"
|
||||||
|
|
||||||
#include "common_data.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define DEFAULT_WEB_DIR "./web"
|
#define DEFAULT_WEB_DIR "./web"
|
||||||
@ -1343,16 +1341,6 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
|||||||
Cookie = Cookie;
|
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,
|
int TvDeviceStart(char *ip_address, unsigned short port,
|
||||||
const char *desc_doc_name, const char *web_dir_path,
|
const char *desc_doc_name, const char *web_dir_path,
|
||||||
print_string pfun, int combo)
|
print_string pfun, int combo)
|
||||||
@ -1435,6 +1423,46 @@ int TvDeviceStart(char *ip_address, unsigned short port,
|
|||||||
return UPNP_E_SUCCESS;
|
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[])
|
int device_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned int portTemp = 0;
|
unsigned int portTemp = 0;
|
||||||
|
@ -529,6 +529,19 @@ int TvDeviceStart(
|
|||||||
/*! [in] Non-zero if called from the combo application. */
|
/*! [in] Non-zero if called from the combo application. */
|
||||||
int combo);
|
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.
|
* \brief Main entry point for tv device application.
|
||||||
*
|
*
|
||||||
@ -540,16 +553,11 @@ int TvDeviceStart(
|
|||||||
* \li \c -ip ipaddress
|
* \li \c -ip ipaddress
|
||||||
* \li \c -port port
|
* \li \c -port port
|
||||||
* \li \c -desc desc_doc_name
|
* \li \c -desc desc_doc_name
|
||||||
* \li \c -webdir web_dir_path"
|
* \li \c -webdir web_dir_path
|
||||||
* \li \c -help
|
* \li \c -help
|
||||||
*/
|
*/
|
||||||
int device_main(int argc, char *argv[]);
|
int device_main(int argc, char *argv[]);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Stops the device. Uninitializes the sdk.
|
|
||||||
*/
|
|
||||||
int TvDeviceStop(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "common_data.h"
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
#include "tv_ctrlpt.h"
|
#include "tv_ctrlpt.h"
|
||||||
#include "tv_device.h"
|
#include "tv_device.h"
|
@ -29,7 +29,6 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "common_data.h"
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
#include "tv_ctrlpt.h"
|
#include "tv_ctrlpt.h"
|
||||||
|
|
@ -29,49 +29,12 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "common_data.h"
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
#include "tv_device.h"
|
#include "tv_device.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.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 main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
Loading…
x
Reference in New Issue
Block a user