extern "C" {
#endif
+struct livebox_buffer; /* Defined by provider */
+
/*!
* \brief
* Return values of livebox programming interfaces.
*/
extern char *livebox_util_nl2br(const char *str);
+
+/*!
+ * Interfaces for direct buffer management (Available only for the PD area)
+ */
+
+
+#ifndef __PROVIDER_BUFFER_H
+/*!
+ * \NOTE
+ * This enumeration value should be sync'd with provider
+ */
+enum buffer_event {
+ BUFFER_EVENT_ENTER, /*!< */
+ BUFFER_EVENT_LEAVE, /*!< */
+ BUFFER_EVENT_DOWN, /*!< */
+ BUFFER_EVENT_MOVE, /*!< */
+ BUFFER_EVENT_UP, /*!< */
+};
+#endif
+
/*!
- * \brief Get the root path of given application package.
- * \param[in] pkgname application package name
- * \param[out] char* Allocated string, root path of given package.
+ * \brief
+ * \param[in] filename
+ * \param[in] width
+ * \param[in] height
+ * \param[in] handler
+ * \param[in] data
+ * \return handler
*/
-extern char *livebox_root_path(const char *pkgname);
+extern struct livebox_buffer *livebox_acquire_buffer(const char *filename, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data);
+
+/*!
+ * \brief
+ * \param[in] handle
+ * \return int
+ */
+extern int livebox_release_buffer(struct livebox_buffer *handle);
+
+/*!
+ * \brief
+ * \param[in] handle
+ * \return void* buffer
+ */
+extern void *livebox_ref_buffer(struct livebox_buffer *handle);
+
+/*!
+ * \brief
+ * \param[in] buffer
+ * \return int
+ */
+extern int livebox_unref_buffer(void *buffer);
+
+/*!
+ * \brief
+ * \param[in] handler
+ * \return int
+ */
+extern int livebox_sync_buffer(struct livebox_buffer *handle);
+
#ifdef __cplusplus
}
#endif
#include <dlog.h>
#include <livebox-service.h>
+#include <provider_buffer.h>
#include "debug.h"
#include "livebox.h"
#define EAPI __attribute__((visibility("default")))
+/*!
+ * \brief This function is defined by the data-provider-slave
+ */
+extern const char *livebox_find_pkgname(const char *filename);
+
struct block {
unsigned int idx;
return -ENOENT;
}
-EAPI char *livebox_root_path(const char *pkgname)
+EAPI struct livebox_buffer *livebox_acquire_buffer(const char *filename, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data)
{
- char *ret;
- char *appid;
- int len;
+ const char *pkgname;
+ struct livebox_buffer *handle;
+ char *uri;
+ int uri_len;
- appid = livebox_service_appid(pkgname);
- if (!appid)
+ if (!filename || !width || !height) {
+ ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
return NULL;
+ }
- len = strlen("/opt/apps//") + strlen(appid) + 1;
- ret = malloc(len);
- if (!ret) {
- DbgPrint("Heap: %s\n", strerror(errno));
+ uri_len = strlen(filename) + strlen("file://") + 1;
+ uri = malloc(uri_len);
+ if (!uri) {
+ ErrPrint("Heap: %s\n", strerror(errno));
return NULL;
}
- snprintf(ret, len, "/opt/apps/%s/", appid);
- return ret;
+ snprintf(uri, uri_len, "file://%s", filename);
+ DbgPrint("Before call the livebox_find_pkgname\n");
+ pkgname = livebox_find_pkgname(uri);
+ DbgPrint("After call the livebox_find_pkgname\n");
+ if (!pkgname) {
+ ErrPrint("Invalid Request\n");
+ free(uri);
+ return NULL;
+ }
+
+ DbgPrint("URI: %s\n", uri);
+ handle = provider_buffer_acquire(TYPE_PD, pkgname, uri, width, height, sizeof(int), handler, data);
+ DbgPrint("Acquire buffer for PD(%s), %s, %p\n", pkgname, uri, handle);
+ free(uri);
+ return handle;
+}
+
+EAPI int livebox_release_buffer(struct livebox_buffer *handle)
+{
+ if (!handle)
+ return -EINVAL;
+
+ DbgPrint("Release buffer\n");
+ return provider_buffer_release(handle);
+}
+
+EAPI void *livebox_ref_buffer(struct livebox_buffer *handle)
+{
+ if (!handle)
+ return -EINVAL;
+
+ DbgPrint("Ref buffer\n");
+ return provider_buffer_ref(handle);
+}
+
+EAPI int livebox_unref_buffer(void *buffer)
+{
+ if (!buffer)
+ return -EINVAL;
+
+ DbgPrint("Unref buffer\n");
+ return provider_buffer_unref(buffer);
+}
+
+EAPI int livebox_sync_buffer(struct livebox_buffer *handle)
+{
+ const char *pkgname;
+ const char *id;
+
+ if (!handle)
+ return -EINVAL;
+
+ pkgname = provider_buffer_pkgname(handle);
+ id = provider_buffer_id(handle);
+ if (!pkgname || !id) {
+ ErrPrint("Invalid buffer handler\n");
+ return -EINVAL;
+ }
+
+ DbgPrint("Sync buffer\n");
+ provider_buffer_sync(handle);
+ provider_send_desc_updated(pkgname, id, NULL);
+ return 0;
}
/* End of a file */