SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR} media_player)
+INCLUDE_DIRECTORIES(${INC_DIR} media_player device_control)
SET(dependents "dlog glib-2.0 storage capi-system-info libxml-2.0")
SET(pc_dependents "storage capi-system-info libxml-2.0")
aux_source_directory(src SOURCES)
aux_source_directory(media_player SOURCES)
+aux_source_directory(device_control SOURCES)
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
DIRECTORY ${INC_DIR}/ DESTINATION include/media
FILES_MATCHING
PATTERN "${INC_DIR}/rose_tizen.h"
+ PATTERN "${INC_DIR}/rose_tizen_sem_parse.h"
+ PATTERN "${INC_DIR}/rose_tizen_ctlinfo_parse.h"
+ PATTERN "${INC_DIR}/rose_tizen_device_ctl.h"
+ PATTERN "${INC_DIR}/rose_tizen_mplayer.h"
)
SET(PC_NAME ${fw_name})
--- /dev/null
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <dlfcn.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include "rose_tizen_device_ctl_interface.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+
+#define LOG_TAG "ROSE_DEVICE_CTL_INTF"
+
+#define LIB_TIZEN_DEVICE_CTL PATH_LIBDIR"/librose-tizen-device-control.so"
+
+#define DEVOCE_CTL_INTF_CHECK_ARG(x_handle) \
+do { \
+ if (!x_handle) { \
+ LOGE("%s argument is NULL", #x_handle); \
+ return DEVICE_CTL_ERROR_INVALID_PARAMETER; \
+ } \
+} while (0)
+
+int _rose_device_ctl_create(device_ctl_interface **handle)
+{
+ device_ctl_interface *h = NULL;
+ int ret = DEVICE_CTL_ERROR_NONE;
+
+ h = (device_ctl_interface *)g_new0(device_ctl_interface, 1);
+ h->dl_handle = dlopen(LIB_TIZEN_DEVICE_CTL, RTLD_NOW);
+ if (!h->dl_handle) {
+ SECURE_LOGE("Failed to open device control library (%s)",
+ LIB_TIZEN_DEVICE_CTL);
+ g_free(h);
+ return DEVICE_CTL_ERROR_INVALID_OPERATION;
+ }
+
+ h->fp.create = dlsym(h->dl_handle, "device_ctl_create");
+ h->fp.destroy = dlsym(h->dl_handle, "device_ctl_destroy");
+ h->fp.prepare = dlsym(h->dl_handle, "device_ctl_prepare");
+ h->fp.unprepare = dlsym(h->dl_handle, "device_ctl_unprepare");
+ h->fp.set_ctl_info = dlsym(h->dl_handle, "device_ctl_set_ctl_info");
+ h->fp.activate = dlsym(h->dl_handle, "device_ctl_activate");
+
+ if (h->fp.create == NULL || h->fp.destroy == NULL) {
+ LOGE("could not get mandatory funtion");
+ ret = DEVICE_CTL_ERROR_INVALID_OPERATION;
+ goto FAIL;
+ }
+
+ ret = h->fp.create(&h->dc_handle);
+ if (ret != DEVICE_CTL_ERROR_NONE) {
+ LOGE("Failed to create device control handle");
+ goto FAIL;
+ }
+
+ *handle = h;
+ LOGD("device control interface handle = %p", *handle);
+
+ return ret;
+FAIL:
+ if (h) {
+ if (h->dl_handle)
+ dlclose(h->dl_handle);
+ g_free(h);
+ }
+ return ret;
+
+}
+
+int _rose_device_ctl_destroy(device_ctl_interface *handle)
+{
+ int ret = DEVICE_CTL_ERROR_NONE;
+ DEVOCE_CTL_INTF_CHECK_ARG(handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dl_handle);
+
+ ret = handle->fp.destroy(handle->dc_handle);
+ if (ret != DEVICE_CTL_ERROR_NONE)
+ LOGW("Failed to destory device control handle");
+ handle->dc_handle = NULL;
+
+ dlclose(handle->dl_handle);
+ LOGD("close device control interface");
+ handle->dl_handle = NULL;
+
+ g_free(handle);
+ handle = NULL;
+
+ return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_prepare(device_ctl_interface *handle)
+{
+ int ret = DEVICE_CTL_ERROR_NONE;
+ DEVOCE_CTL_INTF_CHECK_ARG(handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+ ret = handle->fp.prepare(handle->dc_handle);
+ if (ret != DEVICE_CTL_ERROR_NONE)
+ LOGW("Failed to prepare device control handle");
+
+ LOGD("prepare device control interface");
+
+ return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_unprepare(device_ctl_interface *handle)
+{
+ int ret = DEVICE_CTL_ERROR_NONE;
+ DEVOCE_CTL_INTF_CHECK_ARG(handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+ ret = handle->fp.unprepare(handle->dc_handle);
+ if (ret != DEVICE_CTL_ERROR_NONE)
+ LOGW("Failed to unprepare device control handle");
+
+ LOGD("unprepare device control interface");
+
+ return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_set_info(device_ctl_interface *handle, rose_control_info *ctl_info)
+{
+ int ret = DEVICE_CTL_ERROR_NONE;
+ DEVOCE_CTL_INTF_CHECK_ARG(handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(ctl_info);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+ ret = handle->fp.set_ctl_info(handle->dc_handle, ctl_info);
+ if (ret != DEVICE_CTL_ERROR_NONE)
+ LOGW("Failed to set device control info");
+
+ LOGD("set device control info");
+
+ return DEVICE_CTL_ERROR_NONE;
+}
+int _rose_device_ctl_activate(device_ctl_interface *handle, rose_sem_effect_elements *effect)
+{
+ int ret = DEVICE_CTL_ERROR_NONE;
+ DEVOCE_CTL_INTF_CHECK_ARG(handle);
+ DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+ if (!handle->fp.activate) {
+ LOGW("Not found activate function");
+ return DEVICE_CTL_ERROR_INVALID_OPERATION;
+ }
+
+ ret = handle->fp.activate(handle->dc_handle, effect);
+ if (ret != DEVICE_CTL_ERROR_NONE)
+ LOGE("Failed to activate");
+
+ return ret;
+}
\ No newline at end of file
--- /dev/null
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rose_tizen_sem_parse.h"
+#include "rose_tizen_ctlinfo_parse.h"
+#include "rose_tizen_device_ctl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* media player interface */
+typedef struct _device_ctl_interface {
+ void *dl_handle;
+ void *dc_handle;
+ device_ctl_fp_t fp;
+} device_ctl_interface;
+
+int _rose_device_ctl_create(device_ctl_interface **handle);
+int _rose_device_ctl_destroy(device_ctl_interface *handle);
+int _rose_device_ctl_prepare(device_ctl_interface *handle);
+int _rose_device_ctl_unprepare(device_ctl_interface *handle);
+int _rose_device_ctl_set_info(device_ctl_interface *handle, rose_control_info *ctl_info);
+int _rose_device_ctl_activate(device_ctl_interface *handle, rose_sem_effect_elements *effect);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__ */
ROSE_DISPLAY_TYPE_NONE = 4,
} rose_display_type_e;
-int rose_create(rose_h * rose);
+int rose_create(rose_h *rose);
int rose_destroy(rose_h rose);
int rose_prepare(rose_h rose);
GList *sdc_elements;
};
-int rose_ctl_info_parse(xmlNode * a_node, rose_control_info ** ctl_info);
-void rose_ctl_info_free(rose_control_info * ctl_info);
+int rose_ctl_info_parse(xmlNode *a_node, rose_control_info **ctl_info);
+void rose_ctl_info_free(rose_control_info *ctl_info);
/* The number of devices and information of the device are needed. */
-guint rose_ctl_get_total_delay_time(rose_control_info * ctl_info, rose_sdc_type_e type);
+guint rose_ctl_get_total_delay_time(rose_control_info *ctl_info, rose_sdc_type_e type);
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+typedef enum device_ctl_error {
+ DEVICE_CTL_ERROR_NONE, //
+ DEVICE_CTL_ERROR_OUT_OF_MEMORY, //
+ DEVICE_CTL_ERROR_INVALID_PARAMETER, //
+ DEVICE_CTL_ERROR_INVALID_OPERATION,
+} device_ctl_error_t;
+
+typedef struct device_ctl_fp {
+ /* create & destroy */
+ device_ctl_error_t (*create)(void **device_ctl_handle);
+ device_ctl_error_t (*destroy)(void *device_ctl_handle);
+ device_ctl_error_t (*prepare)(void *device_ctl_handle);
+ device_ctl_error_t (*unprepare)(void *device_ctl_handle);
+ device_ctl_error_t (*set_ctl_info)(void *device_ctl_handle, void *ctl_info);
+ device_ctl_error_t (*activate)(void *device_ctl_handle, void *effect_element);
+} device_ctl_fp_t;
+
+device_ctl_error_t device_ctl_create(void **device_ctl_handle);
+device_ctl_error_t device_ctl_destroy(void *device_ctl_handle);
+device_ctl_error_t device_ctl_prepare(void *device_ctl_handle);
+device_ctl_error_t device_ctl_unprepare(void *device_ctl_handle);
+device_ctl_error_t device_ctl_set_ctl_info(void *device_ctl_handle, void *ctl_info);
+device_ctl_error_t device_ctl_activate(void *device_ctl_handle, void *effect_element);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__ */
--- /dev/null
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+typedef enum mplayer_error {
+ MPLAYER_ERROR_NONE,
+ MPLAYER_ERROR_OUT_OF_MEMORY,
+ MPLAYER_ERROR_INVALID_PARAMETER,
+ MPLAYER_ERROR_NO_SUCH_FILE,
+ MPLAYER_ERROR_INVALID_OPERATION,
+ MPLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE,
+ MPLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE,
+ MPLAYER_ERROR_SEEK_FAILED,
+ MPLAYER_ERROR_INVALID_STATE,
+ MPLAYER_ERROR_NOT_SUPPORTED_FILE,
+ MPLAYER_ERROR_INVALID_URI,
+ MPLAYER_ERROR_SOUND_POLICY,
+ MPLAYER_ERROR_CONNECTION_FAILED,
+ MPLAYER_ERROR_VIDEO_CAPTURE_FAILED,
+ MPLAYER_ERROR_DRM_EXPIRED,
+ MPLAYER_ERROR_DRM_NO_LICENSE,
+ MPLAYER_ERROR_DRM_FUTURE_USE,
+ MPLAYER_ERROR_DRM_NOT_PERMITTED,
+ MPLAYER_ERROR_RESOURCE_LIMIT,
+ MPLAYER_ERROR_PERMISSION_DENIED,
+ MPLAYER_ERROR_SERVICE_DISCONNECTED,
+ MPLAYER_ERROR_BUFFER_SPACE,
+ MPLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC,
+ MPLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC,
+ MPLAYER_ERROR_NOT_SUPPORTED_SUBTITLE,
+ MPLAYER_ERROR_NOT_SUPPORTED_FORMAT,
+} mplayer_error_t;
+
+typedef enum {
+ MPLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */
+ MPLAYER_DISPLAY_TYPE_EVAS = 3, /**< Evas image object surface display (Since 4.0) */
+ MPLAYER_DISPLAY_TYPE_NONE = 4, /**< This disposes of buffers (Since 4.0) */
+} mplayer_display_type_e;
+
+typedef struct mplayer_fp {
+ /* create & destroy */
+ mplayer_error_t (*create)(void **mplayer_handle);
+ mplayer_error_t (*destroy)(void *mplayer_handle);
+ mplayer_error_t (*set_uri)(void *mplayer_handle, const char *uri);
+ mplayer_error_t (*set_display)(void *mplayer_handle, int type, void *display);
+ mplayer_error_t (*prepare)(void *mplayer_handle);
+ mplayer_error_t (*unprepare)(void *mplayer_handle);
+ mplayer_error_t (*start)(void *mplayer_handle);
+ mplayer_error_t (*stop)(void *mplayer_handle);
+ mplayer_error_t (*pause)(void *mplayer_handle);
+ mplayer_error_t (*set_play_position)(void *mplayer_handle, int msec, bool accurate);
+ mplayer_error_t (*get_play_position)(void *mplayer_handle, int *msec);
+} mplayer_fp_t;
+
+mplayer_error_t mplayer_create(void **mplayer_handle);
+mplayer_error_t mplayer_destroy(void *mplayer_handle);
+mplayer_error_t mplayer_set_uri(void *mplayer_handle, const char *uri);
+mplayer_error_t mplayer_set_display(void *mplayer_handle, int type, void *display);
+mplayer_error_t mplayer_prepare(void *mplayer_handle);
+mplayer_error_t mplayer_unprepare(void *mplayer_handle);
+mplayer_error_t mplayer_start(void *mplayer_handle);
+mplayer_error_t mplayer_stop(void *mplayer_handle);
+mplayer_error_t mplayer_pause(void *mplayer_handle);
+mplayer_error_t mplayer_set_play_position(void *mplayer_handle, int msec, bool accurate);
+mplayer_error_t mplayer_get_play_position(void *mplayer_handle, int *msec);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__ */
#endif
/* Property parsing */
-gboolean _get_xml_prop_string(xmlNode * node, const gchar * prop_name, gchar ** prop_value);
-gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean * prop_value);
-gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, gint * prop_value);
-gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name, guint * prop_value);
-gboolean _get_xml_prop_float(xmlNode * node, const gchar * prop_name, gfloat * prop_value);
+gboolean _get_xml_prop_string(xmlNode *node, const gchar *prop_name, gchar **prop_value);
+gboolean _get_xml_prop_boolean(xmlNode *node, const gchar *prop_name, gboolean *prop_value);
+gboolean _get_xml_prop_signed_integer(xmlNode *node, const gchar *prop_name, gint *prop_value);
+gboolean _get_xml_prop_unsigned_integer(xmlNode *node, const gchar *prop_name, guint *prop_value);
+gboolean _get_xml_prop_float(xmlNode *node, const gchar *prop_name, gfloat *prop_value);
#ifdef __cplusplus
}
#include "rose_tizen_sem_parse.h"
#include "rose_tizen_ctlinfo_parse.h"
#include "rose_tizen_mplayer_interface.h"
+#include "rose_tizen_device_ctl_interface.h"
#ifdef __cplusplus
extern "C" {
rose_sem *sem;
rose_control_info *ctl_info;
mplayer_interface *mplayer_intf;
+ device_ctl_interface *device_ctl_intf;
rose_render *renderer;
} rose_s;
};
-int rose_sem_parse(xmlNode * a_node, rose_sem ** sem);
-void rose_sem_free(rose_sem * sem);
+int rose_sem_parse(xmlNode *a_node, rose_sem **sem);
+void rose_sem_free(rose_sem *sem);
guint _rose_sem_get_pts(rose_sem_effect_elements *effect, guint time_scale);
gint64 _rose_sem_get_render_time(rose_sem_effect_elements *effect, guint time_scale);
+++ /dev/null
-/*
-* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
-#define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-typedef enum mplayer_error {
- MPLAYER_ERROR_NONE,
- MPLAYER_ERROR_OUT_OF_MEMORY,
- MPLAYER_ERROR_INVALID_PARAMETER,
- MPLAYER_ERROR_NO_SUCH_FILE,
- MPLAYER_ERROR_INVALID_OPERATION,
- MPLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE,
- MPLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE,
- MPLAYER_ERROR_SEEK_FAILED,
- MPLAYER_ERROR_INVALID_STATE,
- MPLAYER_ERROR_NOT_SUPPORTED_FILE,
- MPLAYER_ERROR_INVALID_URI,
- MPLAYER_ERROR_SOUND_POLICY,
- MPLAYER_ERROR_CONNECTION_FAILED,
- MPLAYER_ERROR_VIDEO_CAPTURE_FAILED,
- MPLAYER_ERROR_DRM_EXPIRED,
- MPLAYER_ERROR_DRM_NO_LICENSE,
- MPLAYER_ERROR_DRM_FUTURE_USE,
- MPLAYER_ERROR_DRM_NOT_PERMITTED,
- MPLAYER_ERROR_RESOURCE_LIMIT,
- MPLAYER_ERROR_PERMISSION_DENIED,
- MPLAYER_ERROR_SERVICE_DISCONNECTED,
- MPLAYER_ERROR_BUFFER_SPACE,
- MPLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC,
- MPLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC,
- MPLAYER_ERROR_NOT_SUPPORTED_SUBTITLE,
- MPLAYER_ERROR_NOT_SUPPORTED_FORMAT,
-} mplayer_error_t;
-
-typedef enum {
- MPLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */
- MPLAYER_DISPLAY_TYPE_EVAS = 3, /**< Evas image object surface display (Since 4.0) */
- MPLAYER_DISPLAY_TYPE_NONE = 4, /**< This disposes of buffers (Since 4.0) */
-} mplayer_display_type_e;
-
-typedef struct mplayer_fp {
- /* create & destroy */
- mplayer_error_t (*create)(void **mplayer_handle);
- mplayer_error_t (*destroy)(void *mplayer_handle);
- mplayer_error_t (*set_uri)(void *mplayer_handle, const char *uri);
- mplayer_error_t (*set_display)(void *mplayer_handle, int type, void *display);
- mplayer_error_t (*prepare)(void *mplayer_handle);
- mplayer_error_t (*unprepare)(void *mplayer_handle);
- mplayer_error_t (*start)(void *mplayer_handle);
- mplayer_error_t (*stop)(void *mplayer_handle);
- mplayer_error_t (*pause)(void *mplayer_handle);
- mplayer_error_t (*set_play_position)(void *mplayer_handle, int msec, bool accurate);
- mplayer_error_t (*get_play_position)(void *mplayer_handle, int *msec);
-} mplayer_fp_t;
-
-mplayer_error_t mplayer_create(void **mplayer_handle);
-mplayer_error_t mplayer_destroy(void *mplayer_handle);
-mplayer_error_t mplayer_set_uri(void *mplayer_handle, const char *uri);
-mplayer_error_t mplayer_set_display(void *mplayer_handle, int type, void *display);
-mplayer_error_t mplayer_prepare(void *mplayer_handle);
-mplayer_error_t mplayer_unprepare(void *mplayer_handle);
-mplayer_error_t mplayer_start(void *mplayer_handle);
-mplayer_error_t mplayer_stop(void *mplayer_handle);
-mplayer_error_t mplayer_pause(void *mplayer_handle);
-mplayer_error_t mplayer_set_play_position(void *mplayer_handle, int msec, bool accurate);
-mplayer_error_t mplayer_get_play_position(void *mplayer_handle, int *msec);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__ */
\ No newline at end of file
#define LIB_TIZEN_PLAYER PATH_LIBDIR"/librose-tizen-mplayer.so"
-#define MPLAYER_INTF_CHECK_ARG(x_handle) \
-do { \
- if (!x_handle) { \
- LOGE("%s argument is NULL", #x_handle); \
- return MPLAYER_ERROR_INVALID_PARAMETER; \
- } \
+#define MPLAYER_INTF_CHECK_ARG(x_handle) \
+do { \
+ if (!x_handle) { \
+ LOGE("%s argument is NULL", #x_handle); \
+ return MPLAYER_ERROR_INVALID_PARAMETER; \
+ } \
} while (0)
int _rose_mplayer_create(mplayer_interface **handle)
*msec = get_msec;
return ret;
-}
\ No newline at end of file
+}
* limitations under the License.
*/
-
#ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__
#define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__
}
#endif /* __cplusplus */
-#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__ */
\ No newline at end of file
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__ */
Name: capi-media-rose-tizen
Summary: For RoSE(Representation Of Sensory Effect) APIs
-Version: 0.0.6
+Version: 0.0.7
Release: 0
Group: Multimedia/API
License: Apache-2.0
#include <stdlib.h>
#include "rose_tizen_priv.h"
-static gpointer _rose_render_thread (gpointer data);
+static gpointer _rose_render_thread(gpointer data);
static gint _wait_to_render(gpointer data);
static gboolean _create_render_thread(rose_s *handle);
static void _destroy_render_thread(rose_s *handle);
static void _start_mplayer(rose_s *handle);
static guint _calc_wait_time(gint64 next_pts, gint64 cur_pts);
-int rose_create(rose_h * rose)
+int rose_create(rose_h *rose)
{
int ret = ROSE_ERROR_NONE;
rose_s *handle;
return ROSE_ERROR_INVALID_OPERATION;
}
- handle = (rose_s *) g_new0(rose_s, 1);
+ handle = (rose_s *)g_new0(rose_s, 1);
ret = _rose_mplayer_create(&handle->mplayer_intf);
if (ret) {
LOGE("Failed to create mplayer handle %d", ret);
return ROSE_ERROR_INVALID_OPERATION;
}
+ ret = _rose_device_ctl_create(&handle->device_ctl_intf);
+ if (ret) {
+ LOGE("Failed to create device ctl handle %d", ret);
+ goto ERROR;
+ }
+
ROSE_SET_STATE(handle, ROSE_STATE_IDLE);
- *rose = (rose_h) handle;
+ *rose = (rose_h)handle;
return ret;
+
+ERROR:
+ if (handle->mplayer_intf)
+ _rose_mplayer_destroy(handle->mplayer_intf);
+
+ ROSE_G_FREE_IF(handle);
+ return ROSE_ERROR_INVALID_OPERATION;
}
int rose_destroy(rose_h rose)
ROSE_CHECK_INSTANCE(rose);
- handle = (rose_s *) rose;
+ handle = (rose_s *)rose;
if (handle->sem) {
rose_sem_free(handle->sem);
handle->sem = NULL;
handle->ctl_info = NULL;
}
+ ret = _rose_device_ctl_destroy(handle->device_ctl_intf);
+ if (ret)
+ LOGE("Failed to destroy device control handle %d", ret);
+
ret = _rose_mplayer_destroy(handle->mplayer_intf);
- if (ret) // need to check error handling
+ if (ret)
LOGE("Failed to destroy mplayer handle %d", ret);
ROSE_G_FREE_IF(handle->sem_path);
int rose_set_sem_path(rose_h rose, const char *path)
{
int ret = ROSE_ERROR_NONE;
- rose_s *handle = (rose_s *) rose;
+ rose_s *handle = (rose_s *)rose;
xmlDocPtr doc = NULL;
xmlNodePtr root_element = NULL;
}
if (root_element->type != XML_ELEMENT_NODE
- || xmlStrstr(root_element->name, (xmlChar *) "SEM") == NULL) {
+ || xmlStrstr(root_element->name, (xmlChar *)"SEM") == NULL) {
LOGE("can not find the root element SEM, failed to parse the SEM file");
ret = ROSE_ERROR_INVALID_OPERATION;
goto ERROR;
int rose_set_control_info_path(rose_h rose, const char *path)
{
int ret = ROSE_ERROR_NONE;
- rose_s *handle = (rose_s *) rose;
+ rose_s *handle = (rose_s *)rose;
xmlDocPtr doc = NULL;
xmlNodePtr root_element = NULL;
}
if (root_element->type != XML_ELEMENT_NODE
- || xmlStrstr(root_element->name, (xmlChar *) "ControlInfo") == NULL) {
+ || xmlStrstr(root_element->name, (xmlChar *)"ControlInfo") == NULL) {
LOGE("can not find the root element ControlInfo, failed to parse the ControlInfo file");
ret = ROSE_ERROR_INVALID_OPERATION;
goto ERROR;
_rose_apply_delay(handle);
+ if (handle->ctl_info) {
+ ret = _rose_device_ctl_set_info(handle->device_ctl_intf, handle->ctl_info);
+ if (ret) {
+ LOGE("Failed to set device ctl info %d", ret);
+ goto ERROR;
+ }
+ }
+
+ ret = _rose_device_ctl_prepare(handle->device_ctl_intf);
+ if (ret) {
+ LOGE("Failed to prepare device ctl %d", ret);
+ goto ERROR;
+ }
+
ret = _rose_mplayer_prepare(handle->mplayer_intf);
if (ret) {
LOGE("Failed to prepare player %d", ret);
ERROR:
_rose_mplayer_unprepare(handle->mplayer_intf);
+ _rose_device_ctl_unprepare(handle->device_ctl_intf);
_destroy_render_thread(handle);
ROSE_G_FREE_IF(handle->renderer);
return ret;
ROSE_CHECK_INSTANCE(handle->mplayer_intf);
ROSE_CHECK_STATE(handle, ROSE_STATE_READY);
+ ret = _rose_device_ctl_unprepare(handle->device_ctl_intf);
+ if (ret)
+ LOGE("Failed to unprepare device ctl %d", ret);
+
ret = _rose_mplayer_unprepare(handle->mplayer_intf);
if (ret)
LOGE("Failed to unprepare player %d", ret);
ROSE_CHECK_INSTANCE(handle->renderer);
ROSE_CHECK_STATE(handle, ROSE_STATE_PLAYING);
- /* pause render thread*/
+ /* pause render thread */
renderer = ROSE_GET_RENDERER(handle);
renderer->thread_pause = TRUE;
if (renderer->wait_timer != 0) {
ROSE_CHECK_INSTANCE(handle->renderer);
ROSE_CHECK_STATE(handle, ROSE_STATE_PLAYING);
- /* pause render thread*/
+ /* pause render thread */
renderer = ROSE_GET_RENDERER(handle);
renderer->thread_pause = TRUE;
if (renderer->wait_timer != 0) {
if (renderer->base_clock == 0) {
_RENDER_CLOCK_MUTEX_LOCK(renderer);
- renderer->base_clock = g_get_monotonic_time() + renderer->time_offset * G_GINT64_CONSTANT (1000);
+ renderer->base_clock = g_get_monotonic_time() + renderer->time_offset * G_GINT64_CONSTANT(1000);
_RENDER_CLOCK_MUTEX_UNLOCK(renderer);
return;
}
_RENDER_CLOCK_MUTEX_LOCK(renderer);
renderer->base_clock = g_get_monotonic_time()
- + renderer->time_offset * G_GINT64_CONSTANT (1000)
- - (gint64)(get_msec * G_GINT64_CONSTANT (1000));
+ + renderer->time_offset * G_GINT64_CONSTANT(1000)
+ - (gint64)(get_msec * G_GINT64_CONSTANT(1000));
_RENDER_CLOCK_MUTEX_UNLOCK(renderer);
}
-static gpointer _rose_render_thread (gpointer data)
+static gpointer _rose_render_thread(gpointer data)
{
+ int ret = ROSE_ERROR_NONE;
rose_s *handle = (rose_s *)data;
rose_render *renderer = NULL;
rose_sem *sem = NULL;
wait_time = _calc_wait_time(0, cur_pts);
LOGD("Need to mplayer start");
LOGD("add wait timer %u ms", wait_time);
- renderer->wait_timer = g_timeout_add((guint)wait_time,
- (GSourceFunc)_wait_to_render, handle);
+ renderer->wait_timer = g_timeout_add(wait_time, (GSourceFunc)_wait_to_render, handle);
_RENDER_COND_WAIT(renderer);
_start_mplayer(handle);
cur_pts = 0;
wait_time = _calc_wait_time(next_pts, cur_pts);
LOGD("add wait timer %u ms", wait_time);
renderer->cur_sem_list = next_list;
- renderer->wait_timer = g_timeout_add((guint)wait_time,
- (GSourceFunc)_wait_to_render, handle);
+ renderer->wait_timer = g_timeout_add(wait_time, (GSourceFunc)_wait_to_render, handle);
_RENDER_COND_WAIT(renderer);
if (renderer->thread_pause || renderer->thread_exit)
continue;
if (renderer->thread_exit)
break;
+ ret = _rose_device_ctl_activate(handle->device_ctl_intf, cur_list->data);
+ if (ret)
+ LOGW("Error activate device control");
cur_list = cur_list->next;
}
LOGD("Called wait_render timer");
g_usleep(1000);
- //_resync_base_time(handle);
if (!renderer->mplayer_is_started)
render_time = 0;
running_time = _get_running_time(renderer);
if (running_time >= render_time)
break;
- g_usleep((render_time - running_time) * G_GINT64_CONSTANT (1000));
+ g_usleep((render_time - running_time) * G_GINT64_CONSTANT(1000));
}
ERROR:
gint64 running_time = -1;
ROSE_CHECK_CONDITION(renderer, -1, "Renderer is NULL");
_RENDER_CLOCK_MUTEX_LOCK(renderer);
- running_time = (g_get_monotonic_time() - renderer->base_clock ) / G_GINT64_CONSTANT (1000);
+ running_time = (g_get_monotonic_time() - renderer->base_clock) / G_GINT64_CONSTANT(1000);
_RENDER_CLOCK_MUTEX_UNLOCK(renderer);
return running_time;
}
_RENDER_COND_INIT(handle->renderer);
_RENDER_PAUSE_COND_INIT(handle->renderer);
- handle->renderer->thread = g_thread_new ("thread",
- (GThreadFunc)_rose_render_thread, handle);
+ handle->renderer->thread = g_thread_new("Render thread", (GThreadFunc)_rose_render_thread, handle);
if (handle->renderer->thread == NULL) {
LOGE("Failed to create render thread");
return FALSE;
renderer->thread_exit = TRUE;
renderer->thread_pause = FALSE;
- if (renderer->wait_timer > 0) {
+ if (renderer->wait_timer != 0) {
g_source_remove(renderer->wait_timer);
renderer->wait_timer = 0;
}
for (; sem_node; sem_node = sem_node->next) {
sem_element = (rose_sem_effect_elements *)sem_node->data;
- delay = rose_ctl_get_total_delay_time(ctl_info, (int) sem_element->type);
+ delay = rose_ctl_get_total_delay_time(ctl_info, (int)sem_element->type);
if (delay != G_MAXUINT)
sem_element->delay_time = delay;
}
handle->renderer->time_offset = time_offset;
LOGD("Time offset = [%" G_GINT64_FORMAT "]", time_offset);
-
}
static void _start_mplayer(rose_s *handle)
wait_time = next_pts - cur_pts - DEFAULT_CHECK_TIME_MS;
return wait_time;
-}
\ No newline at end of file
+}
#include "rose_tizen_priv.h"
#include "rose_tizen_parse_xml.h"
-static gboolean _parse_namespace(xmlNode * node, rose_control_info *ctl_info);
-static void _free_namespace(rose_sdc_namespace * namespace);
-static gboolean _get_xml_prop_sdc_type(xmlNode * node,
- const gchar * property_name, rose_sdc_type_e * property_value);
-
-static gboolean _parse_sdc_element(xmlNode * node, rose_control_info *ctl_info);
-static gboolean _parse_sdc_list(xmlNode * node, rose_control_info *ctl_info);
-static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light);
-static gboolean _parse_sdc_flash_type(xmlNode * node, rose_sdc_flash **flash);
-static gboolean _parse_sdc_wind_type(xmlNode * node, rose_sdc_wind **wind);
-static gboolean _parse_sdc_vibration_type(xmlNode * node, rose_sdc_vibration **vibration);
-
-static void _free_sdc_element(rose_sdc_element * sdc_element);
+static gboolean _parse_namespace(xmlNode *node, rose_control_info *ctl_info);
+static void _free_namespace(rose_sdc_namespace *namespace);
+static gboolean _get_xml_prop_sdc_type(xmlNode *node,
+ const gchar *property_name, rose_sdc_type_e *property_value);
+
+static gboolean _parse_sdc_element(xmlNode *node, rose_control_info *ctl_info);
+static gboolean _parse_sdc_list(xmlNode *node, rose_control_info *ctl_info);
+static gboolean _parse_sdc_light_type(xmlNode *node, rose_sdc_light **light);
+static gboolean _parse_sdc_flash_type(xmlNode *node, rose_sdc_flash **flash);
+static gboolean _parse_sdc_wind_type(xmlNode *node, rose_sdc_wind **wind);
+static gboolean _parse_sdc_vibration_type(xmlNode *node, rose_sdc_vibration **vibration);
+
+static void _free_sdc_element(rose_sdc_element *sdc_element);
static void _free_sdc_light_type(rose_sdc_light *light);
static void _free_sdc_flash_type(rose_sdc_flash *flash);
static void _free_sdc_wind_type(rose_sdc_wind *wind);
static void _free_sdc_vibration_type(rose_sdc_vibration *vibration);
-static gboolean _parse_namespace(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_namespace(xmlNode *node, rose_control_info *ctl_info)
{
xmlNs *curr_ns;
gboolean exist = FALSE;
return exist;
}
-static void _free_namespace(rose_sdc_namespace * namespace)
+static void _free_namespace(rose_sdc_namespace *namespace)
{
if (!namespace)
return;
g_slice_free(rose_sdc_namespace, namespace);
}
-int rose_ctl_info_parse(xmlNode * node, rose_control_info ** ctl_info)
+int rose_ctl_info_parse(xmlNode *node, rose_control_info **ctl_info)
{
xmlNode *cur_node;
- rose_control_info * new_ctl_info;
+ rose_control_info *new_ctl_info;
int ret = ROSE_ERROR_NONE;
gboolean exist = FALSE;
ROSE_CHECK_INSTANCE(ctl_info);
- rose_ctl_info_free(*ctl_info);
-
new_ctl_info = g_slice_new0(rose_control_info);
LOGD("namespaces of root ControlInfo node:");
ret = ROSE_ERROR_INVALID_OPERATION;
}
+ rose_ctl_info_free(*ctl_info);
*ctl_info = new_ctl_info;
return ret;
}
-static gboolean _parse_sdc_list(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_sdc_list(xmlNode *node, rose_control_info *ctl_info)
{
gboolean exist = FALSE;
xmlNode *cur_node;
return exist;
}
-static gboolean _parse_sdc_element(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_sdc_element(xmlNode *node, rose_control_info *ctl_info)
{
rose_sdc_element *new_sdc_element = NULL;
gboolean exist = FALSE;
ctl_info->sdc_elements = g_list_append(ctl_info->sdc_elements, new_sdc_element);
- return exist;
+ return TRUE;
}
-static gboolean _get_xml_prop_sdc_type(xmlNode * node, const gchar * property_name, rose_sdc_type_e * property_value)
+static gboolean _get_xml_prop_sdc_type(xmlNode *node, const gchar *property_name, rose_sdc_type_e *property_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
return exists;
}
-static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light)
+static gboolean _parse_sdc_light_type(xmlNode *node, rose_sdc_light **light)
{
rose_sdc_light *new_light = NULL;
gboolean exist = FALSE;
- // xmlNode *cur_node;
ROSE_CHECK_NULL_FALSE(light);
exist |= new_light->num_of_light_levels_flag
= _get_xml_prop_unsigned_integer(node, "numOfLightLevels",
&new_light->num_of_light_levels);
-#if 0
-/* need to check color element */
- for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
- if (xmlStrstr(cur_node->name, (xmlChar *) "Color")) {
- gchar *color = NULL;
- }
- }
-#endif
+
if (!exist) {
g_slice_free(rose_sdc_light, new_light);
new_light = NULL;
return TRUE;
}
-static gboolean _parse_sdc_flash_type(xmlNode * node, rose_sdc_flash **flash)
+static gboolean _parse_sdc_flash_type(xmlNode *node, rose_sdc_flash **flash)
{
rose_sdc_flash *new_flash = NULL;
gboolean exist = FALSE;
return TRUE;
}
-static gboolean _parse_sdc_wind_type(xmlNode * node, rose_sdc_wind **wind)
+static gboolean _parse_sdc_wind_type(xmlNode *node, rose_sdc_wind **wind)
{
rose_sdc_wind *new_wind = NULL;
gboolean exist = FALSE;
return TRUE;
}
-static gboolean _parse_sdc_vibration_type(xmlNode * node, rose_sdc_vibration **vibration)
+static gboolean _parse_sdc_vibration_type(xmlNode *node, rose_sdc_vibration **vibration)
{
rose_sdc_vibration *new_vibration = NULL;
gboolean exist = FALSE;
static void _free_sdc_light_type(rose_sdc_light *light)
{
- if (!light)
- return;
+ ROSE_CHECK_NULL_VOID(light);
+
g_list_free_full(light->color, g_free);
- g_free(light->unit);
+ ROSE_G_FREE_IF(light->unit);
g_slice_free(rose_sdc_light, light);
}
static void _free_sdc_flash_type(rose_sdc_flash *flash)
{
- if (!flash)
- return;
+ ROSE_CHECK_NULL_VOID(flash);
+
_free_sdc_light_type(flash->light);
g_slice_free(rose_sdc_flash, flash);
}
static void _free_sdc_wind_type(rose_sdc_wind *wind)
{
- if (!wind)
- return;
- g_free(wind->unit);
+ ROSE_CHECK_NULL_VOID(wind);
+
+ ROSE_G_FREE_IF(wind->unit);
g_slice_free(rose_sdc_wind, wind);
}
static void _free_sdc_vibration_type(rose_sdc_vibration *vibration)
{
- if (!vibration)
- return;
- g_free(vibration->unit);
+ ROSE_CHECK_NULL_VOID(vibration);
+
+ ROSE_G_FREE_IF(vibration->unit);
g_slice_free(rose_sdc_vibration, vibration);
}
-static void _free_sdc_element(rose_sdc_element * sdc_element)
+static void _free_sdc_element(rose_sdc_element *sdc_element)
{
- if (!sdc_element)
- return;
- g_free (sdc_element->id);
+ ROSE_CHECK_NULL_VOID(sdc_element);
+
+ ROSE_G_FREE_IF(sdc_element->id);
_free_sdc_light_type(sdc_element->light);
_free_sdc_flash_type(sdc_element->flash);
_free_sdc_wind_type(sdc_element->wind);
g_slice_free(rose_sdc_element, sdc_element);
}
-void rose_ctl_info_free(rose_control_info * ctl_info)
+void rose_ctl_info_free(rose_control_info *ctl_info)
{
- if (!ctl_info)
- return;
+ ROSE_CHECK_NULL_VOID(ctl_info);
- g_list_free_full(ctl_info->namespace, (GDestroyNotify) _free_namespace);
- g_list_free_full(ctl_info->sdc_elements, (GDestroyNotify) _free_sdc_element);
+ g_list_free_full(ctl_info->namespace, (GDestroyNotify)_free_namespace);
+ g_list_free_full(ctl_info->sdc_elements, (GDestroyNotify)_free_sdc_element);
g_slice_free(rose_control_info, ctl_info);
}
guint delay_time = G_MAXUINT;
ROSE_CHECK_CONDITION(ctl_info, G_MAXUINT, "ctl_info is NULL");
- r_list = g_list_find_custom (ctl_info->sdc_elements, &type, (GCompareFunc) _compare_type);
+ r_list = g_list_find_custom(ctl_info->sdc_elements, &type, (GCompareFunc)_compare_type);
if (!r_list) {
LOGW("[%d] type is not on the list", type);
return delay_time;
sdc_elem = (rose_sdc_element *)r_list->data;
delay_time = sdc_elem->firstorderdelaytime + sdc_elem->zerothorderdelaytime;
- LOGD("[%d type] delay time is [%u]", type, delay_time);
return delay_time;
-}
\ No newline at end of file
+}
#include "rose_tizen_priv.h"
#include "rose_tizen_parse_xml.h"
-gboolean _get_xml_prop_string(xmlNode * node, const gchar * prop_name, gchar ** prop_value)
+gboolean _get_xml_prop_string(xmlNode *node, const gchar *prop_name, gchar **prop_value)
{
xmlChar *prop_string;
if (!prop_string)
return FALSE;
- *prop_value = (gchar *) prop_string;
+ *prop_value = (gchar *)prop_string;
LOGD(" - %s: %s", prop_name, prop_string);
return TRUE;
}
-gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean * prop_value)
+gboolean _get_xml_prop_boolean(xmlNode *node, const gchar *prop_name, gboolean *prop_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (xmlStrstr(prop_string, (xmlChar *) "false")) {
+ if (xmlStrstr(prop_string, (xmlChar *)"false")) {
*prop_value = FALSE;
LOGD(" - %s: false", prop_name);
- } else if (xmlStrstr(prop_string, (xmlChar *) "true")) {
+ } else if (xmlStrstr(prop_string, (xmlChar *)"true")) {
*prop_value = TRUE;
LOGD(" - %s: true", prop_name);
} else {
return exists;
}
-gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, gint * prop_value)
+gboolean _get_xml_prop_signed_integer(xmlNode *node, const gchar *prop_name, gint *prop_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (sscanf((gchar *) prop_string, "%d", prop_value) == 1 && strstr((gchar *) prop_string, "-") == NULL) {
+ if (sscanf((gchar *)prop_string, "%d", prop_value) == 1 && strstr((gchar *)prop_string, "-") == NULL) {
LOGD(" - %s: %u", prop_name, *prop_value);
} else {
exists = FALSE;
LOGW("failed to parse signed integer property %s from xml string %s", prop_name, prop_string);
- /* sscanf might have written to *prop_value. Restore to default */
}
xmlFree(prop_string);
return exists;
}
-gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name, guint * prop_value)
+gboolean _get_xml_prop_unsigned_integer(xmlNode *node, const gchar *prop_name, guint *prop_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (sscanf((gchar *) prop_string, "%u", prop_value) == 1 && strstr((gchar *) prop_string, "-") == NULL) {
+ if (sscanf((gchar *)prop_string, "%u", prop_value) == 1 && strstr((gchar *)prop_string, "-") == NULL) {
LOGD(" - %s: %u", prop_name, *prop_value);
} else {
exists = FALSE;
LOGW("failed to parse unsigned integer property %s from xml string %s", prop_name, prop_string);
- /* sscanf might have written to *prop_value. Restore to default */
}
xmlFree(prop_string);
return exists;
}
-gboolean _get_xml_prop_float(xmlNode * node, const gchar * prop_name, gfloat * prop_value)
+gboolean _get_xml_prop_float(xmlNode *node, const gchar *prop_name, gfloat *prop_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (sscanf((gchar *) prop_string, "%f", prop_value) == 1) {
+ if (sscanf((gchar *)prop_string, "%f", prop_value) == 1) {
LOGD(" - %s: %f", prop_name, *prop_value);
} else {
exists = FALSE;
#include "rose_tizen_parse_xml.h"
/* node parsing */
-static gboolean _parse_namespace(xmlNode * node, rose_sem * sem);
-static gboolean _parse_declarations(xmlNode * node, rose_sem * sem);
-static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem);
-static gboolean _parse_effect(xmlNode * node, rose_sem * sem, rose_sem_base_attr *base_attr, rose_sem_si_attr *si_attr);
+static gboolean _parse_namespace(xmlNode *node, rose_sem *sem);
+static gboolean _parse_declarations(xmlNode *node, rose_sem *sem);
+static gboolean _parse_group_effect(xmlNode *node, rose_sem *sem);
+static gboolean _parse_effect(xmlNode *node, rose_sem *sem, rose_sem_base_attr *base_attr, rose_sem_si_attr *si_attr);
-static gboolean _parse_si_attr(xmlNode * node, rose_sem_si_attr ** si_attr);
-static gboolean _parse_effect_base_attr(xmlNode * node, rose_sem_base_attr ** attr);
+static gboolean _parse_si_attr(xmlNode *node, rose_sem_si_attr **si_attr);
+static gboolean _parse_effect_base_attr(xmlNode *node, rose_sem_base_attr **attr);
-static void _free_namespace(rose_sem_namespace * namespace);
+static void _free_namespace(rose_sem_namespace *namespace);
static void _free_effect_elements(rose_sem_effect_elements *elements);
-static void _free_si_attr(rose_sem_si_attr * si_attr);
-static void _free_effect_base_attr(rose_sem_base_attr * attr);
+static void _free_si_attr(rose_sem_si_attr *si_attr);
+static void _free_effect_base_attr(rose_sem_base_attr *attr);
-static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr * attr);
-static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr * attr);
+static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr *attr);
+static void _save_si_attr(rose_sem_effect_elements *effect, rose_sem_si_attr *attr);
-static gboolean _get_xml_prop_effect_type(xmlNode * node, const gchar * property_name, rose_sem_effect_type_e * property_value)
+static gboolean _get_xml_prop_effect_type(xmlNode *node, const gchar *property_name, rose_sem_effect_type_e *property_value)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (xmlStrstr(prop_string, (xmlChar *) "LightType")) {
+ if (xmlStrstr(prop_string, (xmlChar *)"LightType")) {
*property_value = SEM_EFFECT_LIGHT;
LOGD(" - %s: LightType", property_name);
- } else if (xmlStrstr(prop_string, (xmlChar *) "FlashType")) {
+ } else if (xmlStrstr(prop_string, (xmlChar *)"FlashType")) {
*property_value = SEM_EFFECT_FLASH;
LOGD(" - %s: FlashType", property_name);
- } else if (xmlStrstr(prop_string, (xmlChar *) "TemperatureType")) {
+ } else if (xmlStrstr(prop_string, (xmlChar *)"TemperatureType")) {
*property_value = SEM_EFFECT_TEMPERATURE;
LOGD(" - %s: TemperatureType", property_name);
- } else if (xmlStrstr(prop_string, (xmlChar *) "WindType")) {
+ } else if (xmlStrstr(prop_string, (xmlChar *)"WindType")) {
*property_value = SEM_EFFECT_WIND;
LOGD(" - %s: WindType", property_name);
- } else if (xmlStrstr(prop_string, (xmlChar *) "VibrationType")) {
+ } else if (xmlStrstr(prop_string, (xmlChar *)"VibrationType")) {
*property_value = SEM_EFFECT_VIBRATION;
LOGD(" - %s: VibrationType", property_name);
} else {
return exists;
}
-static gboolean _get_xml_prop_intensity_range(xmlNode * node, const gchar * property_name, gfloat * min_intensity, gfloat * max_intensity)
+static gboolean _get_xml_prop_intensity_range(xmlNode *node, const gchar *property_name, gfloat *min_intensity, gfloat *max_intensity)
{
xmlChar *prop_string;
gboolean exists = TRUE;
if (!prop_string)
return FALSE;
- if (sscanf((gchar *) prop_string, "%f %f", min_intensity, max_intensity) == 2) {
+ if (sscanf((gchar *)prop_string, "%f %f", min_intensity, max_intensity) == 2) {
LOGD(" - %s: %f %f", property_name, *min_intensity, *max_intensity);
} else {
exists = FALSE;
return exists;
}
-int rose_sem_parse(xmlNode * node, rose_sem ** sem)
+int rose_sem_parse(xmlNode *node, rose_sem **sem)
{
xmlNode *cur_node;
rose_sem *new_sem;
int ret = ROSE_ERROR_NONE;
gboolean exist = FALSE;
- rose_sem_free(*sem);
- *sem = NULL;
new_sem = g_slice_new0(rose_sem);
for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
if (cur_node->type != XML_ELEMENT_NODE)
continue;
- if (xmlStrstr(cur_node->name, (xmlChar *) "Declarations")) {
+ if (xmlStrstr(cur_node->name, (xmlChar *)"Declarations")) {
LOGD("Parsing Declaration");
_parse_declarations(cur_node, new_sem);
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "GroupOfEffects")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"GroupOfEffects")) {
_parse_group_effect(cur_node, new_sem);
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
_parse_effect(cur_node, new_sem, NULL, NULL);
LOGD("Parsing Effect");
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "ReferenceEffect")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"ReferenceEffect")) {
LOGD("Parsing ReferenceEffect");
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "Parameter")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"Parameter")) {
LOGD("Parsing Parameter");
} else {
LOGW("there is no node in SEM");
ret = ROSE_ERROR_INVALID_OPERATION;
}
+ rose_sem_free(*sem);
*sem = new_sem;
LOGD("complete parsing sem = %p", *sem);
return ret;
}
-void rose_sem_free(rose_sem * sem)
+void rose_sem_free(rose_sem *sem)
{
- if (!sem)
- return;
+ ROSE_CHECK_NULL_VOID(sem);
- g_list_free_full(sem->namespace, (GDestroyNotify) _free_namespace);
- g_list_free_full(sem->effect_elements, (GDestroyNotify) _free_effect_elements);
+ g_list_free_full(sem->namespace, (GDestroyNotify)_free_namespace);
+ g_list_free_full(sem->effect_elements, (GDestroyNotify)_free_effect_elements);
_free_si_attr(sem->si_attr);
g_slice_free(rose_sem, sem);
}
-static gboolean _parse_namespace(xmlNode * node, rose_sem * sem)
+static gboolean _parse_namespace(xmlNode *node, rose_sem *sem)
{
xmlNs *curr_ns;
gboolean exist = FALSE;
- if (!sem || !node)
- return FALSE;
+ ROSE_CHECK_NULL_FALSE(node);
+ ROSE_CHECK_NULL_FALSE(sem);
g_list_free_full(sem->namespace, (GDestroyNotify) _free_namespace);
return exist;
}
-static void _free_namespace(rose_sem_namespace * namespace)
+static void _free_namespace(rose_sem_namespace *namespace)
{
- if (!namespace)
- return;
+ ROSE_CHECK_NULL_VOID(namespace);
if (namespace->prefix)
xmlFree(namespace->prefix);
g_slice_free(rose_sem_namespace, namespace);
}
-static gboolean _parse_declarations(xmlNode * node, rose_sem * sem)
+static gboolean _parse_declarations(xmlNode *node, rose_sem *sem)
{
gboolean exist = FALSE;
xmlNode *cur_node;
for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
- if (xmlStrstr(cur_node->name, (xmlChar *) "GroupOfEffects")) {
+ if (xmlStrstr(cur_node->name, (xmlChar *)"GroupOfEffects")) {
LOGD("Parsing ReferenceEffect");
exist |= _parse_group_effect(cur_node, sem);
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
LOGD("Parsing Effect");
exist |= _parse_effect(cur_node, sem, NULL, NULL);
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "Parameter")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"Parameter")) {
LOGD("Parsing Parameter");
} else {
LOGW("there is no node in SEM");
return exist;
}
-static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem)
+static gboolean _parse_group_effect(xmlNode *node, rose_sem *sem)
{
gboolean exist = FALSE;
xmlNode *cur_node;
for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
if (cur_node->type == XML_ELEMENT_NODE) {
- if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+ if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
LOGD("Parsing Effect");
exist |= _parse_effect(cur_node, sem, base_attr, si_attr);
- } else if (xmlStrstr(cur_node->name, (xmlChar *) "ReferenceEffect")) {
+ } else if (xmlStrstr(cur_node->name, (xmlChar *)"ReferenceEffect")) {
LOGD("Parsing ReferenceEffect");
} else {
LOGW("there is no children node in GroupEffects");
return exist;
}
-static gboolean _parse_effect(xmlNode * node, rose_sem * sem,
+static gboolean _parse_effect(xmlNode *node, rose_sem *sem,
rose_sem_base_attr *base_attr,
rose_sem_si_attr *si_attr)
{
if (new_effect->type > SEM_EFFECT_NONE) {
switch (new_effect->type) {
- case SEM_EFFECT_FLASH:
+ case SEM_EFFECT_FLASH: // falls through
exist |= new_effect->frequency_flag = _get_xml_prop_unsigned_integer(node, "frequency", &new_effect->frequency);
case SEM_EFFECT_LIGHT:
exist |= new_effect->color_type_flag = _get_xml_prop_string(node, "color", &new_effect->color_type);
sem->effect_elements = g_list_append(sem->effect_elements, new_effect);
- return exist;
+ return TRUE;
}
-static void _free_si_attr(rose_sem_si_attr * si_attr)
+static void _free_si_attr(rose_sem_si_attr *si_attr)
{
- if (si_attr) {
- if (si_attr->abs_time_scheme_flag)
- xmlFree(si_attr->abs_time_scheme);
- if (si_attr->abs_time_flag)
- xmlFree(si_attr->abs_time);
- g_slice_free(rose_sem_si_attr, si_attr);
- }
+ ROSE_CHECK_NULL_VOID(si_attr);
+
+ if (si_attr->abs_time_scheme_flag)
+ xmlFree(si_attr->abs_time_scheme);
+ if (si_attr->abs_time_flag)
+ xmlFree(si_attr->abs_time);
+ g_slice_free(rose_sem_si_attr, si_attr);
}
-static gboolean _parse_si_attr(xmlNode * node, rose_sem_si_attr ** si_attr)
+static gboolean _parse_si_attr(xmlNode *node, rose_sem_si_attr **si_attr)
{
rose_sem_si_attr *new_si_attr;
gboolean exist = FALSE;
- _free_si_attr(*si_attr);
- *si_attr = NULL;
-
new_si_attr = g_slice_new0(rose_sem_si_attr);
exist |= new_si_attr->anchor_element_flag = _get_xml_prop_boolean(node, "anchorElement", &new_si_attr->anchor_element);
if (!exist) {
g_slice_free(rose_sem_si_attr, new_si_attr);
new_si_attr = NULL;
+ return FALSE;
}
+ _free_si_attr(*si_attr);
*si_attr = new_si_attr;
- return exist;
+ return TRUE;
}
-static void _free_effect_base_attr(rose_sem_base_attr * attr)
+static void _free_effect_base_attr(rose_sem_base_attr *attr)
{
- if (attr) {
- xmlFree(attr->alt);
- xmlFree(attr->location);
- g_slice_free(rose_sem_base_attr, attr);
- }
+ ROSE_CHECK_NULL_VOID(attr);
+
+ xmlFree(attr->alt);
+ xmlFree(attr->location);
+ g_slice_free(rose_sem_base_attr, attr);
}
-static gboolean _parse_effect_base_attr(xmlNode * node, rose_sem_base_attr ** attr)
+static gboolean _parse_effect_base_attr(xmlNode *node, rose_sem_base_attr **attr)
{
rose_sem_base_attr *new_attr;
gboolean exist = FALSE;
- _free_effect_base_attr(*attr);
- *attr = NULL;
-
new_attr = g_slice_new0(rose_sem_base_attr);
exist |= new_attr->activate_flag = _get_xml_prop_boolean(node, "activate", &new_attr->activate);
if (!exist) {
g_slice_free(rose_sem_base_attr, new_attr);
new_attr = NULL;
+ return FALSE;
}
+ _free_effect_base_attr(*attr);
*attr = new_attr;
- return exist;
+ return TRUE;
}
-static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr * attr)
+static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr *attr)
{
- if (!effect || !attr)
- return;
+ ROSE_CHECK_NULL_VOID(effect && attr);
if (!effect->base_attr) {
LOGD("copy parent base attr");
if (!effect->base_attr->location_flag && attr->location_flag) {
effect->base_attr->location_flag = attr->location_flag;
- strncpy(effect->base_attr->location, attr->location, strlen(attr->location));
+ strncpy(effect->base_attr->location, attr->location, strlen(attr->location) + 1);
}
}
-static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr * attr)
+static void _save_si_attr(rose_sem_effect_elements *effect, rose_sem_si_attr *attr)
{
- if (!effect || !attr)
- return;
+ ROSE_CHECK_NULL_VOID(effect && attr);
if (!effect->si_attr) {
LOGD("copy parent si attr");
if (!effect->si_attr->abs_time_flag && attr->abs_time_flag) {
effect->si_attr->abs_time_flag = attr->abs_time_flag;
- strncpy(effect->si_attr->abs_time, attr->abs_time, strlen(attr->abs_time));
+ strncpy(effect->si_attr->abs_time, attr->abs_time, strlen(attr->abs_time) + 1);
}
if (!effect->si_attr->pts_flag && attr->pts_flag) {
}
}
-static void _free_effect_elements(rose_sem_effect_elements * elements)
+static void _free_effect_elements(rose_sem_effect_elements *elements)
{
- if (!elements)
- return;
+ ROSE_CHECK_NULL_VOID(elements);
- g_free(elements->id) ;
+ g_free(elements->id);
g_free(elements->color_type);
_free_effect_base_attr(elements->base_attr);
_free_si_attr(elements->si_attr);
return time_with_delay;
}
-gint _sort_element_pts (rose_sem_effect_elements *e1, rose_sem_effect_elements *e2, rose_sem *sem)
+gint _sort_element_pts(rose_sem_effect_elements *e1, rose_sem_effect_elements *e2, rose_sem *sem)
{
gint64 time1 = 0;
gint64 time2 = 0;
}
#ifdef __FOR_DEBUG
-const char * _convert_type_to_str(rose_sem_effect_type_e type)
+const char *_convert_type_to_str(rose_sem_effect_type_e type)
{
const char *msg;
switch (type) {
- case SEM_EFFECT_LIGHT:
- msg = "SEM_EFFECT_LIGHT";
- break;
- case SEM_EFFECT_FLASH:
- msg = "SEM_EFFECT_FLASH";
- break;
- case SEM_EFFECT_TEMPERATURE:
- msg = "SEM_EFFECT_TEMPERATURE";
- break;
- case SEM_EFFECT_WIND:
- msg = "SEM_EFFECT_WIND";
- break;
- case SEM_EFFECT_VIBRATION:
- msg = "SEM_EFFECT_VIBRATION";
- break;
- default:
- msg = "SEM_EFFECT_UNKNOWN";
- break;
+ case SEM_EFFECT_LIGHT:
+ msg = "SEM_EFFECT_LIGHT";
+ break;
+ case SEM_EFFECT_FLASH:
+ msg = "SEM_EFFECT_FLASH";
+ break;
+ case SEM_EFFECT_TEMPERATURE:
+ msg = "SEM_EFFECT_TEMPERATURE";
+ break;
+ case SEM_EFFECT_WIND:
+ msg = "SEM_EFFECT_WIND";
+ break;
+ case SEM_EFFECT_VIBRATION:
+ msg = "SEM_EFFECT_VIBRATION";
+ break;
+ default:
+ msg = "SEM_EFFECT_UNKNOWN";
+ break;
}
return msg;
}
-void _print_sem_data (rose_sem_effect_elements *effect, guint time_scale)
+void _print_sem_data(rose_sem_effect_elements *effect, guint time_scale)
{
ROSE_CHECK_NULL_VOID(effect);
- // GString *string = g_string_new(NULL);
LOGI("-----------------------------------------------------------------------");
LOGD("%s", _convert_type_to_str(effect->type));
}
}
}
-#endif
\ No newline at end of file
+#endif
}
if (surface_type == ROSE_DISPLAY_TYPE_OVERLAY) {
-
if (!g_win_id) {
g_win_id = create_win(PACKAGE);
if (g_win_id == NULL)
* @remark
* @see
*/
-gboolean input(GIOChannel * channel)
+gboolean input(GIOChannel *channel)
{
gchar buf[MAX_STRING_LEN];
gsize read;