Name: capi-media-controller
Summary: A media controller library in Tizen Native API
-Version: 0.1.86
+Version: 0.1.87
Release: 1
Group: Multimedia/API
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Source1: mediacontroller.service
Source2: mediacontroller.socket
+Source3: mediacontroller2.service
BuildRequires: cmake
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(capi-appfw-app-control)
-%define upgrade_script_path /usr/share/upgrade/scripts
+# socket activation enable(1), disable(0)
+%define on_demand 1
%description
This package provides a media controller library in Tizen Native API
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if %{on_demand}
+ -DON_DEMAND_SOCKET_ACTIVATION=YES
+%else
+ -DON_DEMAND_SOCKET_ACTIVATION=NO
+%endif
%__make %{?jobs:-j%jobs}
# Daemon & socket activation
mkdir -p %{buildroot}%{_unitdir}
+%if %{on_demand}
mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
+%else
+mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
+%endif
+
# change
+%if %{on_demand}
install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/mediacontroller.service
install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/mediacontroller.socket
ln -s ../mediacontroller.socket %{buildroot}%{_unitdir}/sockets.target.wants/mediacontroller.socket
-
+%else
+install -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/mediacontroller.service
+ln -s ../mediacontroller.service %{buildroot}%{_unitdir}/multi-user.target.wants/mediacontroller.service
+%endif
%post
%defattr(-,root,root,-)
%{_bindir}/mediacontroller
%{_unitdir}/mediacontroller.service
+%if %{on_demand}
%{_unitdir}/mediacontroller.socket
%{_unitdir}/sockets.target.wants/mediacontroller.socket
+%else
+%{_unitdir}/multi-user.target.wants/mediacontroller.service
+%endif
%license LICENSE.APLv2.0
%files devel
--- /dev/null
+[Unit]
+Description=Media controller
+Wants=wait-mount@opt-usr.service
+After=wait-mount@opt-usr.service
+
+[Service]
+User=multimedia_fw
+Group=multimedia_fw
+SmackProcessLabel=System
+ExecStart=/usr/bin/mediacontroller
+Type=simple
+
+[Install]
+WantedBy=multi-user.target
int mc_ipc_service_connect(mc_priv_type_e priv_type)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
int sockfd = -1;
struct sockaddr_un serv_addr;
unsigned int retrycount = 0;
+#endif
ret = __make_service_connection(priv_type);
mc_retvm_if(ret == MEDIA_CONTROLLER_ERROR_NONE, ret, "service is already running!");
mc_retvm_if(ret == MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED, ret, "Permission deny!");
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
/* If can't make connection to service, the service activation is needed */
/* Create Socket */
ret = __make_service_connection(priv_type);
mc_retvm_if(ret == MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED, ret, "Permission deny!");
}
+#endif
return ret;
}
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DTIZEN_DEBUG")
ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
+IF(ON_DEMAND_SOCKET_ACTIVATION)
+ADD_DEFINITIONS("-D_ON_DEMAND_SOCKET_ACTIVATION")
+ENDIF(ON_DEMAND_SOCKET_ACTIVATION)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
* limitations under the License.
*/
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
#include <systemd/sd-daemon.h>
+#endif
#include "media_controller_private.h"
#include "media_controller_socket.h"
#include "media_controller_cynara.h"
GMainLoop *g_mc_mainloop = NULL;
+
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
static int g_mc_timer_id = 0;
#define MC_MAIN_TIMEOUT_SEC_60 60
return -1;
}
}
+#endif
int main(int argc, char **argv)
{
GThread *svc_thread = NULL;
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
int fd = -1;
int client_fd = -1;
struct sockaddr_in client_addr;
int client_addr_size = 0;
+#endif
mc_debug_fenter();
return -1;
}
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
fd = __mc_main_create_socket_activation();
if (fd < 0) {
mc_error("Failed to socket creation");
if (client_fd == -1)
mc_error("accept failed");
}
+#endif
/* Create media controller service thread */
svc_thread = g_thread_new("mc_svc_thread", (GThreadFunc)mc_svc_thread, NULL);
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
/* Create Timer */
__mc_main_create_timer(g_mc_timer_id);
+#endif
mc_debug("*** Media Controller Daemon is running ***");
g_thread_join(svc_thread);
g_main_loop_unref(g_mc_mainloop);
+#ifdef _ON_DEMAND_SOCKET_ACTIVATION
__mc_main_destroy_timer(g_mc_timer_id);
+#endif
mc_cynara_finish();
mc_debug("*** Media Controller Daemon is stopped ***");