option('version', type: 'string', value: '0.0.0', description: 'ESPP service version')
option('sock-path', type: 'string', value: '/tmp/espp_service.socket', description: 'ESPP service socket path')
-option('dlog', type: 'boolean', value: true, description: 'Use dlog')
\ No newline at end of file
+option('dlog', type: 'boolean', value: true, description: 'Use dlog')
+option('service-app', type: 'boolean', value: false, description: 'Daemon is launched as Tizen service app')
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(json-glib-1.0)
BuildRequires: pkgconfig(esplusplayer)
+%if "%{use_service_app}" == "1"
+BuildRequires: pkgconfig(capi-appfw-service-application)
+%endif
%description
ESPP service package contains daemon binary which uses esplusplayer to render audio/video buffers and it's client library
--datadir=%{_datadir} \
-Dversion=%{version} \
-Dsock-path=/run/espp_service.sock \
+%if "%{use_service_app}" == "1"
+ -Dservice-app=true \
+%endif
build
ninja -C build
#include <stdio.h>
#include <getopt.h>
#include <sys/stat.h>
-
+#ifdef USE_SERVICE_APP
+#include <service_app.h>
+#else
static struct sigaction g_int_old_action;
static struct sigaction g_abrt_old_action;
static struct sigaction g_segv_old_action;
static struct sigaction g_xcpu_old_action;
espp_service_s *g_svc;
+#endif
static void print_usage()
{
return 0;
}
+#ifndef USE_SERVICE_APP
static void __sa_handler(int signal)
{
LOG_ERROR("-------------------- signal[%d] --------------------", signal);
LOG_DEBUG_LEAVE();
}
+#else
+static bool svc_app_create_cb(void *user_data)
+{
+ espp_service_s *svc = (espp_service_s *)user_data;
+
+ ASSERT(svc);
+ LOG_INFO("svc[%p]", svc);
+
+ if (espp_service_init_socket(svc) != 0)
+ return false;
+
+ svc->fd_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, espp_service_handle_destroy_cb);
+
+ return true;
+}
+
+static void svc_app_terminate_cb(void *user_data)
+{
+ espp_service_s *svc = (espp_service_s *)user_data;
+
+ ASSERT(svc);
+ LOG_INFO("svc[%p]", svc);
+
+ g_hash_table_destroy(svc->fd_table);
+ espp_service_deinit_socket(svc);
+
+ LOG_WARNING("exit");
+}
+
+static void svc_app_control_cb(app_control_h app_control, void *user_data)
+{
+ char *app_id = NULL;
+ char *operation = NULL;
+ espp_service_s *svc = (espp_service_s *)user_data;
+
+ ASSERT(svc);
+ LOG_INFO("app_control[%p], svc[%p]", app_control, svc);
+
+ if (app_control_get_app_id(app_control, &app_id) != APP_CONTROL_ERROR_NONE) {
+ LOG_ERROR("failed to app_control_get_app_id()");
+ goto exit;
+ }
+
+ if (app_control_get_operation(app_control, &operation) != APP_CONTROL_ERROR_NONE) {
+ LOG_ERROR("failed to app_control_get_operation()");
+ goto exit;
+ }
+
+ LOG_INFO("app_id[%s] operation[%s]", app_id, operation);
+
+exit:
+ if (app_id)
+ free(app_id);
+ if (operation)
+ free(operation);
+}
+#endif
int main(int argc, char *argv[])
{
goto exit;
}
+#ifndef USE_SERVICE_APP
g_svc = &svc;
initialize_signals();
g_hash_table_destroy(svc.fd_table);
espp_service_deinit_socket(&svc);
deinitialize_signals();
+#else
+ service_app_lifecycle_callback_s event_cb = {0, };
+ event_cb.create = svc_app_create_cb;
+ event_cb.terminate = svc_app_terminate_cb;
+ event_cb.app_control = svc_app_control_cb;
+
+ LOG_WARNING("Use service_app_main()");
+ return service_app_main(argc, argv, &event_cb, &svc);
+#endif
exit:
LOG_WARNING("exit");
'espp_service_msg.c',
]
+daemon_deps = common_deps
+
+message('================ daemon options ================')
+
+if get_option('service-app')
+ message('service-app option is enabled, set USE_SERVICE_APP')
+ conf_data.set('USE_SERVICE_APP', true)
+ service_app_dep = dependency('capi-appfw-service-application', required: true)
+ daemon_deps += [service_app_dep]
+endif
+
+message('================================================')
+
thread_dep = dependency('threads', required: true)
espp_dep = dependency('esplusplayer', required: true)
+daemon_deps += [thread_dep, espp_dep]
executable('espp-service',
espp_service_sources,
include_directories : [configinc],
- dependencies : [common_deps, thread_dep, espp_dep],
+ dependencies : daemon_deps,
install: true,
install_rpath : libdir_path,
pie : true,