summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Min <jiyong.min@samsung.com>2017-05-17 15:29:57 +0900
committerJiyong Min <jiyong.min@samsung.com>2017-06-09 11:16:28 +0900
commit104651c33732f688b11829024aac45d82085b046 (patch)
tree75451aa5a8abdff818f23bed5ee9e7ab85fdb8b8
parent49660a218a4c3f8990aa0794405e6090c8a22854 (diff)
downloadmedia-controller-accepted/tizen_3.0_common.tar.gz
media-controller-accepted/tizen_3.0_common.tar.bz2
media-controller-accepted/tizen_3.0_common.zip
and change the location of header files Change-Id: I2e1095e7548ec70002b4733fdae939f7fc3dd086 Signed-off-by: jiyong min <jiyong.min@samsung.com>
-rw-r--r--CMakeLists.txt2
-rwxr-xr-xpackaging/capi-media-controller.spec2
-rw-r--r--svc/daemon/media_controller_main.c4
-rw-r--r--svc/include/media_controller_cynara.h (renamed from svc/media_controller_cynara.h)0
-rwxr-xr-xsvc/include/media_controller_db_util.h (renamed from svc/media_controller_db_util.h)5
-rw-r--r--svc/include/media_controller_socket.h (renamed from svc/media_controller_socket.h)0
-rwxr-xr-xsvc/include/media_controller_svc.h (renamed from svc/media_controller_svc.h)0
-rwxr-xr-x[-rw-r--r--]svc/media_controller_db_util.c57
-rwxr-xr-xsvc/media_controller_svc.c5
9 files changed, 70 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d52595..78c61d2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(VERSION ${version})
SET(INC_DIR include)
-SET(SVC_DIR svc)
+SET(SVC_DIR svc/include)
INCLUDE_DIRECTORIES(${INC_DIR} ${SVC_DIR})
diff --git a/packaging/capi-media-controller.spec b/packaging/capi-media-controller.spec
index f3ced4b..d0a2966 100755
--- a/packaging/capi-media-controller.spec
+++ b/packaging/capi-media-controller.spec
@@ -1,6 +1,6 @@
Name: capi-media-controller
Summary: A media controller library in Tizen Native API
-Version: 0.1.33
+Version: 0.1.34
Release: 1
Group: Multimedia/API
License: Apache-2.0
diff --git a/svc/daemon/media_controller_main.c b/svc/daemon/media_controller_main.c
index f71cf8c..4bca35a 100644
--- a/svc/daemon/media_controller_main.c
+++ b/svc/daemon/media_controller_main.c
@@ -15,8 +15,8 @@
*/
#include "media_controller_private.h"
-#include "../media_controller_socket.h"
-#include "../media_controller_svc.h"
+#include "media_controller_socket.h"
+#include "media_controller_svc.h"
#include "media_controller_cynara.h"
GMainLoop *g_mc_mainloop = NULL;
diff --git a/svc/media_controller_cynara.h b/svc/include/media_controller_cynara.h
index 743ae82..743ae82 100644
--- a/svc/media_controller_cynara.h
+++ b/svc/include/media_controller_cynara.h
diff --git a/svc/media_controller_db_util.h b/svc/include/media_controller_db_util.h
index 78386ff..1ec5ec5 100755
--- a/svc/media_controller_db_util.h
+++ b/svc/include/media_controller_db_util.h
@@ -26,7 +26,9 @@
#define MC_DB_TABLE_SERVER_LIST "server_list"
#define MC_DB_TABLE_LATEST_SERVER "latest_server"
-#define DB_SELECT_ALL_SERVER_LIST_EXCEPT_LATEST "SELECT name FROM SQLITE_MASTER WHERE type='table' AND (name != '%q') AND (name NOT IN (SELECT server_name FROM "MC_DB_TABLE_LATEST_SERVER"))"
+#define DB_SELECT_ALL_SERVER_LIST_EXCEPT_LATEST "SELECT name FROM SQLITE_MASTER WHERE type='table' AND (name != '%q') AND (name NOT IN (SELECT server_name FROM "MC_DB_TABLE_LATEST_SERVER"));"
+#define DB_SELECT_LATEST_SERVER "SELECT server_name FROM "MC_DB_TABLE_LATEST_SERVER";"
+#define DB_UPDATE_STATES "UPDATE '%q' SET server_state=%d, playback_state=%d;"
#define SQLITE3_SAFE_FREE(sql_string) {if (sql_string) {sqlite3_free(sql_string); sql_string = NULL; } }
#define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
@@ -36,5 +38,6 @@ int mc_db_util_disconnect(void *handle);
int mc_db_util_create_tables(void *handle);
int mc_db_util_update_db(void *handle, const char *sql_str);
int mc_db_util_delete_whole_server_tables(void *handle);
+int mc_db_util_init_latest_server_table(void *handle);
#endif /*__TIZEN_MEDIA_CONTROLLER_DB_UTIL_H__*/
diff --git a/svc/media_controller_socket.h b/svc/include/media_controller_socket.h
index 2a5bba1..2a5bba1 100644
--- a/svc/media_controller_socket.h
+++ b/svc/include/media_controller_socket.h
diff --git a/svc/media_controller_svc.h b/svc/include/media_controller_svc.h
index 709c206..709c206 100755
--- a/svc/media_controller_svc.h
+++ b/svc/include/media_controller_svc.h
diff --git a/svc/media_controller_db_util.c b/svc/media_controller_db_util.c
index 763e021..16bcf51 100644..100755
--- a/svc/media_controller_db_util.c
+++ b/svc/media_controller_db_util.c
@@ -312,3 +312,60 @@ int mc_db_util_delete_whole_server_tables(void *handle)
return ret;
}
+
+int mc_db_util_init_latest_server_table(void *handle)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ sqlite3 *db_handle = (sqlite3 *)handle;
+ char *sql_str = NULL;
+ sqlite3_stmt *stmt = NULL;
+ char *latest_server_name = NULL;
+
+ mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+ /* Get latest server name */
+ sql_str = sqlite3_mprintf(DB_SELECT_LATEST_SERVER);
+ mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
+
+ ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
+ if (SQLITE_OK != ret) {
+ mc_error("prepare error [%s]\n", sqlite3_errmsg(db_handle));
+ SQLITE3_SAFE_FREE(sql_str);
+ return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
+ }
+
+ ret = sqlite3_step(stmt);
+ while (SQLITE_ROW == ret) {
+ if (sqlite3_column_int(stmt, 0) == 0) {
+ mc_debug("latest_server table does not exist");
+ SQLITE3_FINALIZE(stmt);
+ SQLITE3_SAFE_FREE(sql_str);
+ return MEDIA_CONTROLLER_ERROR_NONE;
+ }
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) {
+ latest_server_name = strdup((const char *)sqlite3_column_text(stmt, 1));
+ mc_debug("latest_server_name: %s", latest_server_name);
+ }
+ ret = sqlite3_step(stmt);
+ }
+
+ SQLITE3_FINALIZE(stmt);
+ SQLITE3_SAFE_FREE(sql_str);
+
+ mc_retvm_if(latest_server_name == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "latest_server is not exist");
+
+ /* Update server_state and playbakc_state to 0 */
+ sql_str = sqlite3_mprintf(DB_UPDATE_STATES, latest_server_name, MC_SERVER_STATE_NONE, MC_PLAYBACK_STATE_NONE);
+ mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
+
+ ret = mc_db_util_update_db(handle, sql_str);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("Error mc_db_util_update_db %d", ret);
+ SQLITE3_SAFE_FREE(sql_str);
+ return ret;
+ }
+
+ SQLITE3_SAFE_FREE(sql_str);
+
+ return ret;
+}
diff --git a/svc/media_controller_svc.c b/svc/media_controller_svc.c
index 52f4393..8df46e0 100755
--- a/svc/media_controller_svc.c
+++ b/svc/media_controller_svc.c
@@ -284,6 +284,11 @@ gboolean mc_svc_thread(void *data)
return FALSE;
}
+ /* Initialize latest server table */
+ if (mc_db_util_init_latest_server_table(mc_svc_data->db_handle) != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_util_init_latest_server_table failed");
+ }
+
/* Create TCP Socket*/
ret = mc_ipc_create_server_socket(MC_DB_UPDATE_PORT, &sockfd);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {