+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(live-app CXX)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkg REQUIRED
- dlog
- glib-2.0
- gio-2.0
- appcore-efl
- bundle
- provider
- aul
- ecore-x
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-ADD_DEFINITIONS("-DNDEBUG")
-ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
-ADD_DEFINITIONS("-DPKGNAME=\"org.tizen.${PROJECT_NAME}\"")
-ADD_DEFINITIONS(${pkg_CFLAGS})
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -g")
-
-ADD_EXECUTABLE(${PROJECT_NAME}
- src/CMain.cpp
- src/CWindow.cpp
- src/CController.cpp
- src/CView.cpp
- src/CModel.cpp
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl")
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.${PROJECT_NAME}.xml DESTINATION /opt/share/packages)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.${PROJECT_NAME}.conf DESTINATION /opt/usr/live/org.tizen.${PROJECT_NAME}/etc)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/image/unknown.png DESTINATION /opt/usr/live/org.tizen.${PROJECT_NAME}/res/image)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION
- /opt/usr/apps/org.tizen.${PROJECT_NAME}/bin
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/image/org.tizen.${PROJECT_NAME}.png DESTINATION /opt/share/icons/default/small)
-# End of a file
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CController {
-public:
- static int Initialize(const char *name);
- static int Finalize(void);
-
- static int s_CreateLB(struct event_arg *arg, int *width, int *height, double *priority, void *data);
- static int s_RecreateLB(struct event_arg *arg, void *data);
- static int s_DestroyLB(struct event_arg *arg, void *data);
- static int s_ContentEvent(struct event_arg *arg, void *data);
- static int s_Clicked(struct event_arg *arg, void *data);
- static int s_TextEvent(struct event_arg *arg, void *data);
- static int s_Resize(struct event_arg *arg, void *data);
- static int s_SetPeriod(struct event_arg *arg, void *data);
- static int s_ChangeGroup(struct event_arg *arg, void *data);
- static int s_Pinup(struct event_arg *arg, void *data);
- static int s_UpdateContent(struct event_arg *arg, void *data);
- static int s_Pause(struct event_arg *arg, void *data);
- static int s_Resume(struct event_arg *arg, void *data);
- static int s_Disconnected(struct event_arg *arg, void *data);
- static int s_Connected(struct event_arg *arg, void *data);
- static int s_CreatePD(struct event_arg *arg, void *data);
- static int s_DestroyPD(struct event_arg *arg, void *data);
- static Eina_Bool s_PingHandler(void *data);
-
-private:
- CController(void);
- virtual ~CController(void);
-
- char *m_sName;
-
- static CController *m_pInstance;
- static Ecore_Timer *m_pPing;
-
- static const double m_nPingInterval;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CModel {
-public:
- /*! \TODO: Fill me */
- static CModel *GetInstance();
-
- void *GetTaggedObject(const char *tag);
- int AddTaggedObject(const char *tag, void *object);
- void *DelTaggedObject(const char *tag);
-
-private:
- CModel(void);
- virtual ~CModel(void);
-
- static CModel *m_pInstance;
- Eina_List *m_pList;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CView {
-public:
- /*! \TODO: fill me */
- static CView *Create(CWindow *win);
- int Destroy(void);
-
- void ResetLayout(void);
-
-private:
- CView(void);
- virtual ~CView(void);
-
- int InitLayout(void);
-
- CWindow *m_pWindow;
- Evas_Object *m_pScroller;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CWindow {
-public:
- static CWindow *Find(enum target_type type, const char *id);
- static CWindow *Create(enum target_type type, const char *id, int w, int h);
-
- static void *s_AllocateCanvas(void *data, int size);
- static void s_ReleaseCanvas(void *data, void *canvas);
- static void s_PostRender(void *data, Evas *e, void *event_info);
- static int s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data);
-
- int Destroy(void);
- int Resize(int w, int h);
-
- void SetBuffer(struct livebox_buffer *pBuffer) { m_pBuffer = pBuffer; }
- enum target_type Type(void) { return m_vType; }
- int Width(void) { return m_nWidth; }
- int Height(void) { return m_nHeight; }
- struct livebox_buffer *Buffer(void) { return m_pBuffer; }
- Evas_Object *Object(void) { return m_pObject; }
- const char *Id(void) { return m_sID; }
- Evas *EvasObject(void) { return m_pEvas; }
-
-private:
- CWindow(enum target_type type, int width, int height);
- virtual ~CWindow(void);
-
- enum target_type m_vType;
- int m_nWidth;
- int m_nHeight;
-
- struct livebox_buffer *m_pBuffer;
-
- Ecore_Evas *m_pEcoreEvas;
- Evas *m_pEvas;
- Evas_Object *m_pObject;
-
- char *m_sID;
-
- static Eina_List *s_pList;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-#if !defined(FLOG)
-#define DbgPrint(format, arg...) LOGD("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#else
-extern FILE *__file_log_fp;
-#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-
-#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#endif
-
-/* End of a file */
-
+++ /dev/null
-timeout=60
-period=20.0
-network=1
-auto_launch=0
-size=700x700;700x172;700x348;348x348;348x172;172x172
-group=user,created{default}
-pd_size=720x240
-secured=0
-pinup=1
-buffer_livebox=1
-buffer_pd=1
-abi=app
+++ /dev/null
-<?xml version="1.0" encoding="utf-8" ?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.live-app" version="0.0.1" install-location="auto">
- <label>Live App</label>
- <author email="nicesj.park@samsung.com" href="www.samsung.com">Sung-jae Park</author>
- <description>Sample for an application style livebox</description>
- <ui-application appid="org.tizen.live-app" exec="/opt/usr/apps/org.tizen.live-app/bin/live-app" nodisplay="false" multiple="false" type="capp" taskmanage="false">
- <icon>org.tizen.live-app.png</icon>
- <label>App Livebox</label>
- </ui-application>
-</manifest>
+++ /dev/null
-Name: org.tizen.live-app
-Summary: App style livebox
-Version: 0.0.1
-Release: 1
-Group: main/app
-License: Flora License
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake, gettext-tools
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(provider)
-BuildRequires: pkgconfig(ecore-x)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(mm-player)
-
-%description
-App style livebox content provider
-
-%prep
-%setup -q
-
-%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-#-fpie LDFLAGS="${LDFLAGS} -pie -O3"
-CFLAGS="-Wall -Winline -Werror -p -g" make %{?jobs:-j%jobs}
-#${CFLAGS}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-%post
-mkdir -p /opt/usr/live/org.tizen.live-app/libexec
-touch /opt/usr/live/org.tizen.live-app/libexec/liblive-org.tizen.live-app.so
-
-%files -n org.tizen.live-app
-#%manifest org.tizen.live-app.manifest
-%defattr(-,root,root,-)
-/opt/usr/apps/org.tizen.live-app/bin/live-app
-/opt/share/packages/*.xml
-/opt/usr/live/org.tizen.live-app/etc/*
-/opt/usr/live/org.tizen.live-app/res/image/*
-/opt/share/icons/default/small/*.png
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <Ecore.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
-#include <Ecore_X.h>
-#include <Eina.h>
-
-#include <aul.h>
-#include <dlog.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include "debug.h"
-#include "CWindow.h"
-#include "CController.h"
-#include "CView.h"
-#include "CModel.h"
-
-CController *CController::m_pInstance = NULL;
-Ecore_Timer *CController::m_pPing = NULL;
-const double CController::m_nPingInterval = 120.0f;
-
-int CController::s_CreateLB(struct event_arg *arg, int *width, int *height, double *priority, void *data)
-{
- CWindow *win;
- CView *view;
- int ret;
-
- *width = 348;
- *height = 348;
- arg->info.lb_create.out_content = NULL;
- arg->info.lb_create.out_title = NULL;
-
- win = CWindow::Create(TYPE_LB, arg->id, *width, *height);
- if (!win)
- return -EFAULT;
-
- view = CView::Create(win);
- if (!view) {
- win->Destroy();
- return -EFAULT;
- }
-
- ret = CModel::GetInstance()->AddTaggedObject(arg->id, view);
- if (ret < 0) {
- view->Destroy();
- win->Destroy();
- return ret;
- }
-
- return 0;
-}
-
-int CController::s_RecreateLB(struct event_arg *arg, void *data)
-{
- CWindow *win;
- CView *view;
- int ret;
-
- win = CWindow::Create(TYPE_LB, arg->id, arg->info.lb_recreate.width, arg->info.lb_recreate.height);
- if (!win) {
- ErrPrint("Failed to create a window %s\n", arg->id);
- return -EFAULT;
- }
-
- view = CView::Create(win);
- if (!view) {
- ErrPrint("Failed to create a view %s\n", arg->id);
- win->Destroy();
- return -EFAULT;
- }
-
- ret = CModel::GetInstance()->AddTaggedObject(arg->id, view);
- if (ret < 0) {
- ErrPrint("Failed to add a view %s\n", arg->id);
- view->Destroy();
- win->Destroy();
- return ret;
- }
-
- return 0;
-}
-
-int CController::s_DestroyLB(struct event_arg *arg, void *data)
-{
- CWindow *win;
- CView *view;
-
- view = (CView *)CModel::GetInstance()->DelTaggedObject(arg->id);
- if (view)
- view->Destroy();
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (win)
- win->Destroy();
-
- return 0;
-}
-
-int CController::s_ContentEvent(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Clicked(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_TextEvent(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Resize(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- win->Resize(arg->info.resize.w, arg->info.resize.h);
- return 0;
-}
-
-int CController::s_SetPeriod(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_ChangeGroup(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Pinup(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_UpdateContent(struct event_arg *arg, void *data)
-{
- CWindow *win;
-
- win = CWindow::Find(TYPE_LB, arg->id);
- if (!win)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Pause(struct event_arg *arg, void *data)
-{
- if (m_pPing)
- ecore_timer_freeze(m_pPing);
-
- return 0;
-}
-
-int CController::s_Resume(struct event_arg *arg, void *data)
-{
- if (m_pPing)
- ecore_timer_thaw(m_pPing);
-
- return 0;
-}
-
-int CController::s_Disconnected(struct event_arg *arg, void *data)
-{
- if (m_pPing) {
- ecore_timer_del(m_pPing);
- m_pPing = NULL;
- }
-
- delete m_pInstance;
- aul_terminate_pid(getpid());
- return 0;
-}
-
-Eina_Bool CController::s_PingHandler(void *data)
-{
- DbgPrint("Send ping\n");
- provider_send_ping();
- return ECORE_CALLBACK_RENEW;
-}
-
-int CController::s_Connected(struct event_arg *arg, void *data)
-{
- int ret;
-
- if (m_pPing) {
- DbgPrint("Already connected\n");
- return -EINVAL;
- }
-
- /*!
- * \note
- * Phase 2. Send "hello" signal to master
- * Add "ping" timer (Master will wait 240 seconds)
- */
- ret = provider_send_hello();
- if (ret < 0) {
- ErrPrint("Failed to send a ping(%d)\n", ret);
- return -EFAULT;
- }
-
- m_pPing = ecore_timer_add(m_nPingInterval, s_PingHandler, NULL);
- if (!m_pPing)
- ErrPrint("Failed to add a ping timer\n");
-
- DbgPrint("Connected\n");
- return 0;
-}
-
-int CController::s_CreatePD(struct event_arg *arg, void *data)
-{
- CWindow *win;
- CView *view;
- int ret;
- char *tagname;
-
- win = CWindow::Create(TYPE_PD, arg->id, arg->info.pd_create.w, arg->info.pd_create.h);
- if (!win) {
- ErrPrint("Failed to create a PD\n");
- return -EFAULT;
- }
-
- view = CView::Create(win);
- if (!view) {
- ErrPrint("Failed to create a view\n");
- win->Destroy();
- return -EFAULT;
- }
-
- ret = strlen(arg->id); /* reuse ret */
- tagname = (char *)malloc(ret + strlen(",pd,view") + 1);
- if (!tagname) {
- ErrPrint("Heap: %s\n", strerror(errno));
- win->Destroy();
- return -EFAULT;
- }
-
- strcpy(tagname, arg->id);
- strcpy(tagname + ret, ",pd,view");
- DbgPrint("TAGNAME: %s\n", tagname);
-
- ret = CModel::GetInstance()->AddTaggedObject(tagname, view);
- free(tagname);
- if (ret < 0) {
- DbgPrint("Failed to add a tagged object\n");
- view->Destroy();
- win->Destroy();
- return ret;
- }
-
- DbgPrint("PD is created\n");
- return 0;
-}
-
-int CController::s_DestroyPD(struct event_arg *arg, void *data)
-{
- CWindow *win;
- CView *view;
- int ret;
- char *tagname;
-
- win = CWindow::Find(TYPE_PD, arg->id);
- if (!win) {
- ErrPrint("Failed to find a window (%s)\n", arg->id);
- return -ENOENT;
- }
-
- ret = strlen(arg->id);
- tagname = (char *)malloc(ret + strlen(",pd,view") + 1);
- if (!tagname) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
- }
-
- strcpy(tagname, arg->id);
- strcpy(tagname + ret, ",pd,view");
-
- view = (CView *)CModel::GetInstance()->DelTaggedObject(tagname);
- free(tagname);
- if (view) {
- DbgPrint("Destroy VIEW\n");
- view->Destroy();
- }
-
- DbgPrint("Destroy WIN\n");
- win->Destroy();
- return 0;
-}
-
-CController::CController(void)
-: m_sName(NULL)
-{
-}
-
-CController::~CController(void)
-{
- free(m_sName);
- m_sName = NULL;
-
- m_pInstance = NULL;
-
- if (m_pPing) {
- ecore_timer_del(m_pPing);
- m_pPing = NULL;
- }
-}
-
-int CController::Initialize(const char *name)
-{
- int ret;
- struct event_handler table;
-
- DbgPrint("Initialize %s\n", name);
-
- if (CController::m_pInstance) {
- ErrPrint("Controller is already exists\n");
- return -EALREADY;
- }
-
- try {
- m_pInstance = new CController();
- } catch (...) {
- ErrPrint("Failed to create a controller\n");
- return -ENOMEM;
- }
-
- m_pInstance->m_sName = strdup(name);
- if (!m_pInstance->m_sName) {
- ErrPrint("Heap: %s\n", strerror(errno));
- delete m_pInstance;
- return -ENOMEM;
- }
-
- table.lb_create = CController::s_CreateLB;
- table.lb_recreate = CController::s_RecreateLB;
- table.lb_destroy = CController::s_DestroyLB;
- table.content_event = CController::s_ContentEvent;
- table.clicked = CController::s_Clicked;
- table.text_signal = CController::s_TextEvent;
- table.resize = CController::s_Resize;
- table.set_period = CController::s_SetPeriod;
- table.change_group = CController::s_ChangeGroup;
- table.pinup = CController::s_Pinup;
- table.update_content = CController::s_UpdateContent;
- table.pause = CController::s_Pause;
- table.resume = CController::s_Resume;
- table.disconnected = CController::s_Disconnected;
- table.connected = CController::s_Connected;
- table.pd_create = CController::s_CreatePD;
- table.pd_destroy = CController::s_DestroyPD;
-
- DbgPrint("Slave name is %s\n", m_pInstance->m_sName);
- ret = provider_init(ecore_x_display_get(), m_pInstance->m_sName, &table, NULL);
- if (ret < 0) {
- ErrPrint("Failed to initialize the provider %d\n", ret);
- delete m_pInstance;
- return ret;
- }
-
- return 0;
-}
-
-int CController::Finalize(void)
-{
- if (!m_pInstance)
- return -EINVAL;
-
- provider_fini();
- delete m_pInstance;
- return 0;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <libgen.h>
-
-#include <Ecore.h>
-
-#include <appcore-efl.h>
-#include <dlog.h>
-#include <bundle.h>
-
-#include "debug.h"
-#include "CController.h"
-
-static int app_create(void *data)
-{
- return 0;
-}
-
-static int app_terminate(void *data)
-{
- return CController::Finalize();
-}
-
-static int app_pause(void *data)
-{
- return 0;
-}
-
-static int app_resume(void *data)
-{
- return 0;
-}
-
-static int app_reset(bundle *b, void *data)
-{
- const char *name;
-
- name = bundle_get_val(b, "name");
- if (!name) {
- ErrPrint("Name is not valid\n");
- elm_exit();
- return -EINVAL;
- }
-
- return CController::Initialize(name);
-}
-
-int main(int argc, char *argv[])
-{
- struct appcore_ops ops;
-
- ops.create = app_create;
- ops.terminate = app_terminate;
- ops.pause = app_pause;
- ops.resume = app_resume;
- ops.reset = app_reset;
- ops.data = NULL;
-
- return appcore_efl_main(basename(argv[0]), &argc, &argv, &ops);
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <errno.h>
-
-#include <dlog.h>
-#include <Eina.h>
-
-#include "debug.h"
-#include "CModel.h"
-
-struct TItem {
-/* public: */
- char *tag;
- void *data;
-};
-
-CModel *CModel::m_pInstance = NULL;
-
-CModel::CModel(void)
-: m_pList(NULL)
-{
-}
-
-CModel::~CModel(void)
-{
-}
-
-CModel *CModel::GetInstance()
-{
- if (m_pInstance)
- return m_pInstance;
-
- try {
- m_pInstance = new CModel();
- } catch (...) {
- return NULL;
- }
-
- return m_pInstance;
-}
-
-void *CModel::GetTaggedObject(const char *tag)
-{
- Eina_List *l;
- void *ptr;
- TItem *item;
-
- EINA_LIST_FOREACH(m_pList, l, ptr) {
- item = (TItem *)ptr;
- if (!strcmp(item->tag, tag))
- return item->data;
- }
-
- return NULL;
-}
-
-int CModel::AddTaggedObject(const char *tag, void *object)
-{
- TItem *item;
-
- try {
- item = new TItem();
- } catch (...) {
- return -ENOMEM;
- }
-
- item->tag = strdup(tag);
- if (!item->tag) {
- delete item;
- return -ENOMEM;
- }
-
- item->data = object;
-
- m_pList = eina_list_append(m_pList, item);
- return 0;
-}
-
-void *CModel::DelTaggedObject(const char *tag)
-{
- Eina_List *l;
- Eina_List *n;
- void *ptr;
- TItem *item;
-
- EINA_LIST_FOREACH_SAFE(m_pList, l, n, ptr) {
- item = (TItem *)ptr;
- if (!strcmp(item->tag, tag)) {
- void *ret;
- m_pList = eina_list_remove(m_pList, ptr);
-
- ret = item->data;
- free(item->tag);
- free(item);
-
- return ret;
- }
- }
-
- return NULL;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-
-#include <stdio.h>
-#include <dlog.h>
-#include <errno.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include "debug.h"
-#include "CWindow.h"
-#include "CView.h"
-
-CView::CView(void)
-: m_pWindow(NULL)
-, m_pScroller(NULL)
-{
-}
-
-CView::~CView(void)
-{
-}
-
-static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- CView *view = (CView *)data;
-
- view->ResetLayout();
-}
-
-void CView::ResetLayout(void)
-{
- m_pScroller = NULL;
-}
-
-int CView::InitLayout(void)
-{
- Evas_Object *pScroller;
- Evas_Object *pIcon;
- char sTitle[256];
- int w;
- int h;
- int i;
-
- pScroller = elm_list_add(m_pWindow->Object());
- if (!pScroller)
- return -EFAULT;
-
- evas_object_geometry_get(m_pWindow->Object(), NULL, NULL, &w, &h);
- evas_object_size_hint_weight_set(pScroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_list_multi_select_set(pScroller, EINA_FALSE);
- elm_list_mode_set(pScroller, ELM_LIST_COMPRESS);
- elm_scroller_bounce_set(pScroller, EINA_TRUE, EINA_FALSE);
- evas_object_resize(pScroller, w, h);
- evas_object_move(pScroller, 0, 0);
- evas_object_show(pScroller);
-
- for (i = 0; i < 100; i++) {
- pIcon = elm_icon_add(m_pWindow->Object());
- elm_icon_file_set(pIcon, "/opt/usr/live/org.tizen.live-app/res/image/unknown.png", NULL);
- elm_icon_resizable_set(pIcon, 1, 1);
- snprintf(sTitle, sizeof(sTitle), "%d List item: %d", i, i);
- elm_list_item_append(pScroller, sTitle, pIcon, NULL /* end */, NULL, NULL);
- }
-
- elm_list_go(pScroller);
- m_pScroller = pScroller;
- evas_object_event_callback_add(m_pScroller, EVAS_CALLBACK_DEL, del_cb, this);
- return 0;
-}
-
-CView *CView::Create(CWindow *win)
-{
- CView *pInst;
-
- if (!win)
- return NULL;
-
- try {
- pInst = new CView();
- } catch (...) {
- return NULL;
- }
-
- pInst->m_pWindow = win;
- pInst->InitLayout();
- return pInst;
-}
-
-int CView::Destroy(void)
-{
- if (m_pScroller) {
- evas_object_del(m_pScroller);
- m_pScroller = NULL;
- }
-
- delete this;
- return 0;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-
-#include <Ecore_Evas.h>
-#include <Ecore.h>
-#include <Evas.h>
-
-#include <dlog.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include "debug.h"
-#include "CWindow.h"
-
-Eina_List *CWindow::s_pList = NULL;
-
-void *CWindow::s_AllocateCanvas(void *data, int size)
-{
- CWindow *win = (CWindow *)data;
- struct livebox_buffer *pBuffer;
- void *canvas;
-
- pBuffer = provider_buffer_acquire(win->Type(), PKGNAME, win->Id(),
- win->Width(), win->Height(), sizeof(int),
- CWindow::s_BufferEventHandler, win);
-
- if (!pBuffer)
- return NULL;
-
- win->SetBuffer(pBuffer);
- canvas = provider_buffer_ref(win->Buffer());
- return canvas;
-}
-
-void CWindow::s_ReleaseCanvas(void *data, void *canvas)
-{
- int ret;
- CWindow *win = (CWindow *)data;
-
- ret = provider_buffer_unref(canvas);
- DbgPrint("Unref %d\n", ret);
-
- ret = provider_buffer_release(win->Buffer());
- DbgPrint("release %d\n", ret);
-
- win->SetBuffer(NULL);
-}
-
-void CWindow::s_PostRender(void *data, Evas *e, void *event_info)
-{
- CWindow *win = (CWindow *)data;
-
- if (win->EvasObject() != e)
- return;
-
- switch (win->Type()) {
- case TYPE_PD:
- provider_buffer_sync(win->Buffer());
- provider_send_desc_updated(PKGNAME, win->Id(), NULL);
- break;
- case TYPE_LB:
- provider_buffer_sync(win->Buffer());
- provider_send_updated(PKGNAME, win->Id(), win->Width(), win->Height(), 1.0f, NULL, NULL);
- break;
- default:
- break;
- }
-}
-
-int CWindow::s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
-{
- CWindow *win = (CWindow *)data;
- int ix;
- int iy;
-
- ix = win->Width() * x;
- iy = win->Height() * y;
-
- DbgPrint("POS(%dx%d)\n", ix, iy);
-
- switch (event) {
- case BUFFER_EVENT_ENTER:
- evas_event_feed_mouse_in(win->EvasObject(), timestamp, NULL);
- break;
- case BUFFER_EVENT_LEAVE:
- evas_event_feed_mouse_out(win->EvasObject(), timestamp, NULL);
- break;
- case BUFFER_EVENT_DOWN:
- //evas_event_feed_mouse_in(win->EvasObject(), timestamp, NULL);
- evas_event_feed_mouse_move(win->EvasObject(), ix, iy, timestamp + 0.01f, NULL);
- evas_event_feed_mouse_down(win->EvasObject(), 1, EVAS_BUTTON_NONE, timestamp + 0.02f, NULL);
- break;
- case BUFFER_EVENT_MOVE:
- evas_event_feed_mouse_move(win->EvasObject(), ix, iy, timestamp, NULL);
- break;
- case BUFFER_EVENT_UP:
- evas_event_feed_mouse_up(win->EvasObject(), 1, EVAS_BUTTON_NONE, timestamp, NULL);
- //evas_event_feed_mouse_out(win->EvasObject(), timestamp + 0.01f, NULL);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-CWindow *CWindow::Create(enum target_type type, const char *id, int w, int h)
-{
- CWindow *win;
-
- try {
- win = new CWindow(type, w, h);
- } catch (...) {
- return NULL;
- }
-
- win->m_sID = strdup(id);
- if (!win->m_sID) {
- win->Destroy();
- return NULL;
- }
-
- win->m_pEcoreEvas = ecore_evas_buffer_allocfunc_new(win->m_nWidth, win->m_nHeight, CWindow::s_AllocateCanvas, CWindow::s_ReleaseCanvas, win);
- if (!win->m_pEcoreEvas) {
- ErrPrint("Failed to allocate a new EE\n");
- win->Destroy();
- return NULL;
- }
-
- win->m_pEvas = ecore_evas_get(win->m_pEcoreEvas);
- if (!win->m_pEvas) {
- win->Destroy();
- return NULL;
- }
-
- evas_event_callback_add(win->m_pEvas, EVAS_CALLBACK_RENDER_FLUSH_POST, s_PostRender, win);
-
- ecore_evas_alpha_set(win->m_pEcoreEvas, EINA_TRUE);
- ecore_evas_manual_render_set(win->m_pEcoreEvas, EINA_FALSE);
- ecore_evas_resize(win->m_pEcoreEvas, win->m_nWidth, win->m_nHeight);
- ecore_evas_show(win->m_pEcoreEvas);
- ecore_evas_activate(win->m_pEcoreEvas);
-
- win->m_pObject = evas_object_rectangle_add(win->m_pEvas);
- evas_object_resize(win->m_pObject, win->m_nWidth, win->m_nHeight);
- evas_object_color_set(win->m_pObject, 0, 0, 0, 255);
- evas_object_show(win->m_pObject);
-
- s_pList = eina_list_append(s_pList, win);
- return win;
-}
-
-CWindow *CWindow::Find(enum target_type type, const char *id)
-{
- Eina_List *l;
- void *item;
- CWindow *win;
-
- EINA_LIST_FOREACH(s_pList, l, item) {
- win = (CWindow *)item;
-
- if (win->Type() == type && !strcmp(win->Id(), id))
- return win;
- }
-
- return NULL;
-}
-
-int CWindow::Destroy(void)
-{
- s_pList = eina_list_remove(s_pList, this);
-
- if (m_pObject)
- evas_object_del(m_pObject);
-
- if (m_pEcoreEvas)
- ecore_evas_free(m_pEcoreEvas);
-
- free(m_sID);
- delete this;
- return 0;
-}
-
-int CWindow::Resize(int w, int h)
-{
- m_nWidth = w;
- m_nHeight = h;
-
- if (m_pEcoreEvas)
- ecore_evas_resize(m_pEcoreEvas, w, h);
-
- return 0;
-}
-
-CWindow::CWindow(enum target_type type, int width, int height)
-: m_vType(type)
-, m_nWidth(width)
-, m_nHeight(height)
-, m_pBuffer(NULL)
-, m_pEcoreEvas(NULL)
-, m_pEvas(NULL)
-, m_sID(NULL)
-{
-}
-
-CWindow::~CWindow(void)
-{
-}
-
-/* End of a file */
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(live-video CXX)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkg REQUIRED
- dlog
- glib-2.0
- gio-2.0
- appcore-efl
- bundle
- provider
- aul
- ecore-x
- ecore
- x11
- xdamage
- mm-player
- libdrm
- libtbm
- libdri2
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-ADD_DEFINITIONS("-DNDEBUG")
-ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
-ADD_DEFINITIONS("-DPKGNAME=\"org.tizen.${PROJECT_NAME}\"")
-ADD_DEFINITIONS(${pkg_CFLAGS})
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -g")
-
-ADD_EXECUTABLE(${PROJECT_NAME}
- src/CMain.cpp
- src/CWindow.cpp
- src/CController.cpp
- src/CView.cpp
- src/CModel.cpp
- src/CVideo.cpp
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl")
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.${PROJECT_NAME}.xml DESTINATION /opt/share/packages)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.${PROJECT_NAME}.conf DESTINATION /opt/usr/live/org.tizen.${PROJECT_NAME}/etc)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/image/unknown.png DESTINATION /opt/usr/live/org.tizen.${PROJECT_NAME}/res/image)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/image/org.tizen.live-video.png DESTINATION /opt/share/icons/default/small)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION
- /opt/usr/apps/org.tizen.${PROJECT_NAME}/bin
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE)
-
-# End of a file
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CController {
-public:
- static int Initialize(const char *name);
- static int Finalize(void);
-
- static int s_CreateLB(struct event_arg *arg, int *width, int *height, double *priority, void *data);
- static int s_RecreateLB(struct event_arg *arg, void *data);
- static int s_DestroyLB(struct event_arg *arg, void *data);
- static int s_ContentEvent(struct event_arg *arg, void *data);
- static int s_Clicked(struct event_arg *arg, void *data);
- static int s_TextEvent(struct event_arg *arg, void *data);
- static int s_Resize(struct event_arg *arg, void *data);
- static int s_SetPeriod(struct event_arg *arg, void *data);
- static int s_ChangeGroup(struct event_arg *arg, void *data);
- static int s_Pinup(struct event_arg *arg, void *data);
- static int s_UpdateContent(struct event_arg *arg, void *data);
- static int s_Pause(struct event_arg *arg, void *data);
- static int s_Resume(struct event_arg *arg, void *data);
- static int s_Disconnected(struct event_arg *arg, void *data);
- static int s_Connected(struct event_arg *arg, void *data);
- static int s_CreatePD(struct event_arg *arg, void *data);
- static int s_DestroyPD(struct event_arg *arg, void *data);
- static Eina_Bool s_PingHandler(void *data);
-
-private:
- CController(void);
- virtual ~CController(void);
-
- char *m_sName;
-
- static CController *m_pInstance;
- static Ecore_Timer *m_pPing;
-
- static const double m_nPingInterval;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CModel {
-public:
- static CModel *GetInstance(void);
- const char *VideoFilename(void);
- int SetVideoFilename(const char *filename);
-
- /*! \TODO: Fill me */
-
-private:
- CModel(void);
- virtual ~CModel(void);
-
- static CModel *m_pInstance;
- char *m_sFilename;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CVideo {
-public:
- enum TVideoState {
- STOPPED = 0x00,
- PLAYING = 0x01,
- };
-
- static CVideo *Find(enum target_type type, const char *id);
- static CVideo *Create(enum target_type type, const char *id, int w, int h);
-
- static int s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data);
- static Eina_Bool s_DamageEventHandler(void *data, int type, void *event);
- static int s_MMMessageHandler(int message, void *_param, void *user_param);
-
- int Destroy(void);
- int Resize(int w, int h);
-
- void SetBuffer(struct livebox_buffer *pBuffer);
- enum target_type Type(void) { return m_vType; }
- int Width(void) { return m_nWidth; }
- int Height(void) { return m_nHeight; }
- struct livebox_buffer *Buffer(void) { return m_pBuffer; }
- const char *Id(void) { return m_sId; }
- int PixmapId(void) { return m_nId; }
-
- int Play(const char *file);
- int Stop(void);
- enum TVideoState State(void);
-private:
- CVideo(enum target_type type, int width, int height);
- virtual ~CVideo(void);
-
- int Update(void);
- void Clear(void);
-
- enum TVideoState m_vState;
- enum target_type m_vType;
- int m_nWidth;
- int m_nHeight;
-
- struct livebox_buffer *m_pBuffer;
-
- int m_nId; /*!< Pixmap ID */
- char *m_sId;
- Ecore_X_Damage m_vDamage;
-
- char *m_sError;
- MMHandleType m_vPlayer;
-
- static Eina_List *s_pList;
- Ecore_Event_Handler *m_pDamageHandler;
-};
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CView {
-public:
- /*! \TODO: fill me */
-private:
- CView(void);
- virtual ~CView(void);
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-class CWindow {
-public:
- static CWindow *Find(enum target_type type, const char *id);
- static CWindow *Create(enum target_type type, const char *id, int w, int h);
-
- static void *s_AllocateCanvas(void *data, int size);
- static void s_ReleaseCanvas(void *data, void *canvas);
- static void s_PostRender(void *data, Evas *e, void *event_info);
- static int s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data);
-
- virtual ~CWindow(void);
- int Destroy(void);
- int Resize(int w, int h);
-
- void SetBuffer(struct livebox_buffer *pBuffer) { m_pBuffer = pBuffer; }
- enum target_type Type(void) { return m_vType; }
- int Width(void) { return m_nWidth; }
- int Height(void) { return m_nHeight; }
- struct livebox_buffer *Buffer(void) { return m_pBuffer; }
- Evas_Object *Object(void) { return m_pObject; }
- const char *Id(void) { return m_sID; }
- Evas *EvasObject(void) { return m_pEvas; }
-
-private:
- CWindow(enum target_type type, int width, int height);
-
- enum target_type m_vType;
- int m_nWidth;
- int m_nHeight;
-
- struct livebox_buffer *m_pBuffer;
-
- Ecore_Evas *m_pEcoreEvas;
- Evas *m_pEvas;
- Evas_Object *m_pObject;
-
- char *m_sID;
-
- static Eina_List *s_pList;
-};
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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.
- */
-
-#if !defined(FLOG)
-#define DbgPrint(format, arg...) LOGD("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#else
-extern FILE *__file_log_fp;
-#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-
-#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#endif
-
-/* End of a file */
-
+++ /dev/null
-timeout=60
-period=20.0
-network=1
-auto_launch=0
-size=700x700;700x172;700x348;348x348;348x172;172x172
-group=user,created{default}
-pd_size=720x240
-secured=0
-pinup=1
-buffer_livebox=1
-buffer_pd=1
-abi=app
+++ /dev/null
-<?xml version="1.0" encoding="utf-8" ?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.live-video" version="0.0.1" install-location="auto">
- <label>Live Player</label>
- <author email="nicesj.park@samsung.com" href="www.samsung.com">Sung-jae Park</author>
- <description>Application based livebox media player</description>
- <ui-application appid="org.tizen.live-video" exec="/opt/usr/apps/org.tizen.live-video/bin/live-video" nodisplay="false" multiple="false" type="capp" taskmanage="false">
- <icon>org.tizen.live-video.png</icon>
- <label>Live Player</label>
- </ui-application>
-</manifest>
+++ /dev/null
-Name: org.tizen.live-video
-Summary: Video playing livebox
-Version: 0.0.1
-Release: 1
-Group: main/app
-License: Flora License
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake, gettext-tools
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(provider)
-BuildRequires: pkgconfig(ecore-x)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(mm-player)
-BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(xdamage)
-BuildRequires: pkgconfig(libdrm)
-BuildRequires: pkgconfig(libtbm)
-BuildRequires: pkgconfig(libdri2)
-
-%description
-App style livebox content provider (video)
-
-%prep
-%setup -q
-
-%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-#-fpie LDFLAGS="${LDFLAGS} -pie -O3"
-CFLAGS="-Wall -Winline -Werror -p -g" make %{?jobs:-j%jobs}
-#${CFLAGS}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-%post
-mkdir -p /opt/usr/live/org.tizen.live-video/libexec
-touch /opt/usr/live/org.tizen.live-video/libexec/liblive-org.tizen.live-video.so
-
-%files -n org.tizen.live-video
-#%manifest org.tizen.live-video.manifest
-%defattr(-,root,root,-)
-/opt/usr/apps/org.tizen.live-video/bin/live-video
-/opt/share/packages/*.xml
-/opt/usr/live/org.tizen.live-video/etc/*
-/opt/usr/live/org.tizen.live-video/res/image/*
-/opt/share/icons/default/small/*.png
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <Elementary.h>
-#include <Ecore.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
-#include <Ecore_X.h>
-
-#include <aul.h>
-#include <dlog.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include <mm_message.h>
-#include <mm_player.h>
-
-#include "debug.h"
-#include "CVideo.h"
-#include "CWindow.h"
-#include "CController.h"
-#include "CModel.h"
-
-CController *CController::m_pInstance = NULL;
-Ecore_Timer *CController::m_pPing = NULL;
-const double CController::m_nPingInterval = 120.0f;
-
-struct TWindowData {
- Evas_Object *list;
- char *id;
-};
-
-int CController::s_CreateLB(struct event_arg *arg, int *width, int *height, double *priority, void *data)
-{
- CVideo *video;
-
- *width = 348;
- *height = 348;
- arg->info.lb_create.out_content = NULL;
- arg->info.lb_create.out_title = NULL;
-
- DbgPrint("Content: %s\n", arg->info.lb_create.content);
-
- video = CVideo::Create(TYPE_LB, arg->id, *width, *height);
- if (!video)
- return -EFAULT;
-
- return 0;
-}
-
-int CController::s_RecreateLB(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- DbgPrint("Content: %s\n", arg->info.lb_recreate.content);
-
- video = CVideo::Create(TYPE_LB, arg->id, arg->info.lb_recreate.width, arg->info.lb_recreate.height);
- if (!video)
- return -EFAULT;
-
- return 0;
-}
-
-int CController::s_DestroyLB(struct event_arg *arg, void *data)
-{
- CVideo *video;
- CWindow *win;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (video)
- video->Destroy();
-
- win = CWindow::Find(TYPE_PD, arg->id);
- if (win)
- win->Destroy();
-
- return 0;
-}
-
-int CController::s_ContentEvent(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Clicked(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video) {
- ErrPrint("Instance is not found: %s\n", arg->id);
- return -ENOENT;
- }
-
- switch (video->State()) {
- case CVideo::PLAYING:
- video->Stop();
- break;
- case CVideo::STOPPED:
- video->Play(CModel::GetInstance()->VideoFilename());
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-int CController::s_TextEvent(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Resize(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- video->Resize(arg->info.resize.w, arg->info.resize.h);
- return 0;
-}
-
-int CController::s_SetPeriod(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_ChangeGroup(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Pinup(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_UpdateContent(struct event_arg *arg, void *data)
-{
- CVideo *video;
-
- video = CVideo::Find(TYPE_LB, arg->id);
- if (!video)
- return -ENOENT;
-
- return 0;
-}
-
-int CController::s_Pause(struct event_arg *arg, void *data)
-{
- if (m_pPing)
- ecore_timer_freeze(m_pPing);
-
- return 0;
-}
-
-int CController::s_Resume(struct event_arg *arg, void *data)
-{
- if (m_pPing)
- ecore_timer_thaw(m_pPing);
-
- return 0;
-}
-
-int CController::s_Disconnected(struct event_arg *arg, void *data)
-{
- if (m_pPing) {
- ecore_timer_del(m_pPing);
- m_pPing = NULL;
- }
-
- aul_terminate_pid(getpid());
- return 0;
-}
-
-Eina_Bool CController::s_PingHandler(void *data)
-{
- provider_send_ping();
- return ECORE_CALLBACK_RENEW;
-}
-
-int CController::s_Connected(struct event_arg *arg, void *data)
-{
- if (m_pPing)
- return -EINVAL;
-
- /*!
- * \note
- * Phase 2. Send "hello" signal to master
- * Add "ping" timer (Master will wait 240 seconds)
- */
- if (provider_send_hello() < 0)
- return -EFAULT;
-
- m_pPing = ecore_timer_add(m_nPingInterval, s_PingHandler, NULL);
- if (!m_pPing)
- ErrPrint("Failed to add a ping timer\n");
- return 0;
-}
-
-static void press_cb(void *data, Evas_Object *list, void *event_info)
-{
- CVideo *video;
- Elm_Object_Item *item;
- const char *filename;
- char *path;
- int pathlen;
- TWindowData *win_data = (TWindowData *)data;
-
- video = CVideo::Find(TYPE_LB, win_data->id);
- if (!video) {
- ErrPrint("Video is not exists\n");
- return;
- }
-
- item = elm_list_selected_item_get(list);
- if (!item) {
- ErrPrint("Item is not selected\n");
- return;
- }
-
- filename = elm_object_item_part_text_get(item, NULL);
- if (!filename) {
- ErrPrint("Selected item is not valid\n");
- return;
- }
-
- pathlen = strlen(filename) + strlen("/opt/usr/media/Videos/") + 1;
- path = (char *)malloc(pathlen);
- if (!path) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return;
- }
-
- snprintf(path, pathlen, "/opt/usr/media/Videos/%s", filename);
- CModel::GetInstance()->SetVideoFilename(path);
- DbgPrint("Updated Video file: %s\n", path);
- free(path);
-
- if (video->State() == CVideo::PLAYING)
- video->Stop();
-
- video->Play(CModel::GetInstance()->VideoFilename());
-}
-
-int CController::s_CreatePD(struct event_arg *arg, void *data)
-{
- Evas_Object *list;
- TWindowData *win_data;
- CWindow *win;
- Evas_Object *parent;
- int w;
- int h;
-
- DIR *handle;
-
- win_data = (TWindowData *)malloc(sizeof(*win_data));
- if (!win_data) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
- }
-
- win = CWindow::Create(TYPE_PD, arg->id, arg->info.pd_create.w, arg->info.pd_create.h);
- if (!win) {
- ErrPrint("Window for PID is not able to create\n");
- free(win_data);
- return -EFAULT;
- }
-
- parent = win->Object();
- if (!parent) {
- ErrPrint("Window is not valid\n");
- free(win_data);
- return -EFAULT;
- }
-
- list = elm_list_add(parent);
- evas_object_geometry_get(parent, NULL, NULL, &w, &h);
- evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_list_multi_select_set(list, EINA_FALSE);
- elm_list_mode_set(list, ELM_LIST_COMPRESS);
- elm_scroller_bounce_set(list, EINA_TRUE, EINA_FALSE);
- evas_object_resize(list, w, h);
- evas_object_move(list, 0, 0);
- evas_object_show(list);
-
- handle = opendir("/opt/usr/media/Videos/");
- if (handle) {
- struct dirent *ent;
-
- while ((ent = readdir(handle)))
- elm_list_item_append(list, ent->d_name, NULL, NULL /* end */, press_cb, win_data);
-
- closedir(handle);
- }
-
- elm_list_go(list);
-
- win_data->id = strdup(arg->id);
- if (!win_data->id) {
- evas_object_del(list);
- free(win_data);
- return -ENOMEM;
- }
- win_data->list = list;
-
- evas_object_data_set(parent, "win_data", win_data);
- return 0;
-}
-
-int CController::s_DestroyPD(struct event_arg *arg, void *data)
-{
- CWindow *win;
- TWindowData *win_data;
-
- win = CWindow::Find(TYPE_PD, arg->id);
- if (!win) {
- ErrPrint("PD Window for %s is not exists\n", arg->id);
- return -ENOENT;
- }
-
- win_data = (TWindowData *)evas_object_data_del(win->Object(), "win_data");
- if (win_data) {
- evas_object_del(win_data->list);
- free(win_data->id);
- free(win_data);
- }
-
- win->Destroy();
- return 0;
-}
-
-CController::CController(void)
-: m_sName(NULL)
-{
-}
-
-CController::~CController(void)
-{
- free(m_sName);
- m_sName = NULL;
-
- m_pInstance = NULL;
-
- if (m_pPing) {
- ecore_timer_del(m_pPing);
- m_pPing = NULL;
- }
-}
-
-int CController::Initialize(const char *name)
-{
- int ret;
- struct event_handler table;
-
- if (CController::m_pInstance)
- return -EALREADY;
-
- try {
- m_pInstance = new CController();
- } catch (...) {
- return -ENOMEM;
- }
-
- m_pInstance->m_sName = strdup(name);
- if (!m_pInstance->m_sName) {
- delete m_pInstance;
- return -ENOMEM;
- }
-
- table.lb_create = CController::s_CreateLB;
- table.lb_recreate = CController::s_RecreateLB;
- table.lb_destroy = CController::s_DestroyLB;
- table.content_event = CController::s_ContentEvent;
- table.clicked = CController::s_Clicked;
- table.text_signal = CController::s_TextEvent;
- table.resize = CController::s_Resize;
- table.set_period = CController::s_SetPeriod;
- table.change_group = CController::s_ChangeGroup;
- table.pinup = CController::s_Pinup;
- table.update_content = CController::s_UpdateContent;
- table.pause = CController::s_Pause;
- table.resume = CController::s_Resume;
- table.disconnected = CController::s_Disconnected;
- table.connected = CController::s_Connected;
- table.pd_create = CController::s_CreatePD;
- table.pd_destroy = CController::s_DestroyPD;
-
- ret = provider_init(ecore_x_display_get(), m_pInstance->m_sName, &table, NULL);
- if (ret < 0) {
- delete m_pInstance;
- return ret;
- }
-
- return 0;
-}
-
-int CController::Finalize(void)
-{
- if (!m_pInstance)
- return -EINVAL;
-
- provider_fini();
-
- delete m_pInstance;
- return 0;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <libgen.h>
-
-#include <Elementary.h>
-#include <Ecore.h>
-
-#include <appcore-efl.h>
-#include <dlog.h>
-#include <bundle.h>
-
-#include "debug.h"
-#include "CController.h"
-
-static int app_create(void *data)
-{
- return 0;
-}
-
-static int app_terminate(void *data)
-{
- return CController::Finalize();
-}
-
-static int app_pause(void *data)
-{
- return 0;
-}
-
-static int app_resume(void *data)
-{
- return 0;
-}
-
-static int app_reset(bundle *b, void *data)
-{
- const char *name;
-
- name = bundle_get_val(b, "name");
- if (!name) {
- ErrPrint("Name is not valid\n");
- elm_exit();
- return -EINVAL;
- }
-
- return CController::Initialize(name);
-}
-
-int main(int argc, char *argv[])
-{
- struct appcore_ops ops;
-
- ops.create = app_create;
- ops.terminate = app_terminate;
- ops.pause = app_pause;
- ops.resume = app_resume;
- ops.reset = app_reset;
- ops.data = NULL;
-
- return appcore_efl_main(basename(argv[0]), &argc, &argv, &ops);
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <dlog.h>
-
-#include "debug.h"
-#include "CModel.h"
-
-CModel *CModel::m_pInstance = NULL;
-
-CModel::CModel(void)
-{
- m_sFilename = strdup("/opt/usr/media/Videos/Helicopter.mp4");
- if (!m_sFilename)
- throw -ENOMEM;
-}
-
-CModel::~CModel(void)
-{
- free(m_sFilename);
-}
-
-CModel *CModel::GetInstance(void)
-{
- if (!m_pInstance) {
- try {
- m_pInstance = new CModel();
- } catch (...) {
- return NULL;
- }
- }
-
- return m_pInstance;
-}
-
-const char *CModel::VideoFilename(void)
-{
- return m_sFilename;
-}
-
-int CModel::SetVideoFilename(const char *filename)
-{
- char *tmp;
-
- tmp = strdup(filename);
- if (!tmp) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
- }
-
- free(m_sFilename);
- m_sFilename = tmp;
- return 0;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-
-#include <X11/Xlib.h>
-#include <Ecore.h>
-#include <Ecore_X.h>
-
-#include <dlog.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include <mm_types.h>
-#include <mm_error.h>
-#include <mm_message.h>
-#include <mm_player.h>
-
-#include "debug.h"
-#include "CWindow.h"
-#include "CVideo.h"
-#include "CModel.h"
-
-Eina_List *CVideo::s_pList = NULL;
-
-
-CVideo *CVideo::Find(enum target_type type, const char *id)
-{
- Eina_List *l;
- void *item;
- CVideo *video;
-
- EINA_LIST_FOREACH(s_pList, l, item) {
- video = (CVideo *)item;
-
- if (video->Type() == type && !strcmp(video->Id(), id))
- return video;
- }
-
- return NULL;
-}
-
-CVideo *CVideo::Create(enum target_type type, const char *id, int w, int h)
-{
- CVideo *video;
- struct livebox_buffer *pBuffer;
-
- if (!ecore_x_damage_query()) {
- ErrPrint("Damage event is not supported\n");
- return NULL;
- }
-
- try {
- video = new CVideo(type, w, h);
- } catch (...) {
- ErrPrint("Failed to create a video instance\n");
- return NULL;
- }
-
- video->m_sId = strdup(id);
- if (!video->m_sId) {
- ErrPrint("Heap: %s\n", strerror(errno));
- video->Destroy();
- return NULL;
- }
-
- pBuffer = provider_buffer_acquire(video->Type(), PKGNAME, video->Id(),
- video->Width(), video->Height(), sizeof(int),
- CVideo::s_BufferEventHandler, video);
- if (!pBuffer) {
- ErrPrint("Failed to acquire buffer handle\n");
- video->Destroy();
- return NULL;
- }
-
- /*!
- * \note
- * this function must has to be called before add an item to the s_pList
- */
- video->SetBuffer(pBuffer);
-
- s_pList = eina_list_append(s_pList, video);
- return video;
-}
-
-Eina_Bool CVideo::s_DamageEventHandler(void *data, int type, void *event)
-{
- CVideo *video = (CVideo *)data;
- Ecore_X_Event_Damage *e = (Ecore_X_Event_Damage *)event;
-
- if (e->drawable == video->PixmapId()) {
- switch (video->Type()) {
- case TYPE_LB:
- provider_send_updated(PKGNAME, video->Id(), video->Width(), video->Height(), 1.0f, NULL, NULL);
- break;
- case TYPE_PD:
- provider_send_desc_updated(PKGNAME, video->Id(), NULL);
- break;
- default:
- ErrPrint("Unknown video type\n");
- break;
- }
-
- video->Update();
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-int CVideo::Update(void)
-{
- ecore_x_damage_subtract(m_vDamage, None, None);
- return 0;
-}
-
-void CVideo::SetBuffer(struct livebox_buffer *pBuffer)
-{
- if (!pBuffer) {
- if (m_pDamageHandler)
- ecore_event_handler_del(m_pDamageHandler);
-
- m_pDamageHandler = NULL;
-
- if (m_vDamage)
- ecore_x_damage_free(m_vDamage);
-
- m_vDamage = 0;
- return;
- }
-
- m_pBuffer = pBuffer;
-
- m_nId = provider_buffer_pixmap_id(m_pBuffer);
- if (m_nId == 0) {
- ErrPrint("Failed to get pixmap\n");
- return;
- }
-
- m_pDamageHandler = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, CVideo::s_DamageEventHandler, this);
- if (!m_pDamageHandler) {
- ErrPrint("Failed to add a event handler\n");
- return;
- }
-
- m_vDamage = ecore_x_damage_new(m_nId, ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES);
- if (!m_vDamage) {
- ErrPrint("Failed to create a new damage object\n");
- return;
- }
-
- DbgPrint("Prepare callback\n");
- Clear();
-}
-
-int CVideo::s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
-{
- CVideo *video = (CVideo *)data;
- int ix;
- int iy;
-
- ix = video->Width() * x;
- iy = video->Height() * y;
-
- switch (event) {
- case BUFFER_EVENT_ENTER:
- break;
- case BUFFER_EVENT_LEAVE:
- break;
- case BUFFER_EVENT_DOWN:
- DbgPrint("Down: %dx%d\n", ix, iy);
- break;
- case BUFFER_EVENT_MOVE:
- break;
- case BUFFER_EVENT_UP:
- DbgPrint("Up: %dx%d\n", ix, iy);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-int CVideo::Destroy(void)
-{
- int ret;
- DbgPrint("Destroy a video object\n");
-
- s_pList = eina_list_remove(s_pList, this);
-
- Stop(); /*!< Just try to stop playing */
-
- if (m_nId)
- ecore_x_damage_free(m_vDamage);
-
- if (m_pDamageHandler)
- ecore_event_handler_del(m_pDamageHandler);
-
- free(m_sId);
-
- ret = provider_buffer_release(m_pBuffer);
- DbgPrint("release: %d\n", ret);
- delete this;
- return 0;
-}
-
-int CVideo::Resize(int w, int h)
-{
- struct livebox_buffer *pBuffer;
-
- if (m_nWidth == w && m_nHeight == h) {
- DbgPrint("Size has no changes\n");
- return 0;
- }
-
- m_nWidth = w;
- m_nHeight = h;
-
- if (!m_pBuffer) {
- ErrPrint("Buffer is not available\n");
- return -EINVAL;
- }
-
- SetBuffer(NULL);
-
- provider_buffer_release(m_pBuffer);
- m_pBuffer = NULL;
-
- pBuffer = provider_buffer_acquire(m_vType, PKGNAME,
- m_sId, m_nWidth, m_nHeight, sizeof(int),
- CVideo::s_BufferEventHandler, this);
-
- SetBuffer(pBuffer);
-
- if (m_vState == PLAYING) {
- const char *uri;
- m_sError = NULL;
-
- uri = CModel::GetInstance()->VideoFilename();
- DbgPrint("Update PIXMAP: 0x%X (file: %s)\n", m_nId, uri);
- mm_player_set_attribute(m_vPlayer, &m_sError,
- "display_surface_type", MM_DISPLAY_SURFACE_X,
- "display_width", m_nWidth,
- "display_height", m_nHeight,
- "display_overlay", &m_nId, sizeof(m_nId),
- "profile_uri", uri, strlen(uri),
- "display_rotation", MM_DISPLAY_ROTATION_NONE,
- "profile_play_count", 1,
- NULL);
- if (m_sError)
- ErrPrint("SetAttribute: %s\n", m_sError);
- }
-
- return 0;
-}
-
-int CVideo::s_MMMessageHandler(int message, void *_param, void *user_param)
-{
- CVideo *video = (CVideo *)user_param;
- // MMMessageParamType *param = (MMMessageParamType *)_param;
-
- switch (message) {
- case MM_MESSAGE_END_OF_STREAM:
- video->Stop();
- DbgPrint("End of stream\n");
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-void CVideo::Clear(void)
-{
- static unsigned int s_color = 0x00FF0000;
- GC gc;
-
- gc = XCreateGC((Display *)ecore_x_display_get(), PixmapId(), 0, 0);
-
- XSetForeground((Display *)ecore_x_display_get(), gc, 0xFF000000 | s_color);
- XFillRectangle((Display *)ecore_x_display_get(), PixmapId(), gc, 0, 0, Width(), Height());
-
- XSync((Display *)ecore_x_display_get(), FALSE);
- XFreeGC((Display *)ecore_x_display_get(), gc);
-
- s_color >>= 2;
- if (s_color == 0)
- s_color = 0xFF000000;
-}
-
-int CVideo::Play(const char *uri)
-{
- if (m_vState == PLAYING)
- return -EBUSY;
-
- if (mm_player_create(&m_vPlayer) != MM_ERROR_NONE) {
- ErrPrint("Failed to create a player\n");
- return -EFAULT;
- }
-
- m_sError = NULL;
- mm_player_set_attribute(m_vPlayer, &m_sError,
- "display_surface_type", MM_DISPLAY_SURFACE_X,
- "display_width", m_nWidth,
- "display_height", m_nHeight,
- "display_overlay", &m_nId, sizeof(m_nId),
- "profile_uri", uri, strlen(uri),
- "display_rotation", MM_DISPLAY_ROTATION_NONE,
- "profile_play_count", 1,
- NULL);
- if (m_sError)
- ErrPrint("SetAttribute: %s\n", m_sError);
-
- if (mm_player_realize(m_vPlayer) != MM_ERROR_NONE) {
- ErrPrint("Failed to realize a player\n");
- mm_player_destroy(m_vPlayer);
- m_vPlayer = 0;
- return -EFAULT;
- }
-
- mm_player_set_message_callback(m_vPlayer, CVideo::s_MMMessageHandler, this);
- mm_player_start(m_vPlayer);
- m_vState = PLAYING;
-
- DbgPrint("Play file %s on %d\n", uri, m_nId);
- return 0;
-}
-
-int CVideo::Stop(void)
-{
- if (m_vState == STOPPED)
- return -EALREADY;
-
- m_vState = STOPPED;
-
- if (m_vPlayer) {
- mm_player_unrealize(m_vPlayer);
- mm_player_destroy(m_vPlayer);
- m_vPlayer = 0;
- }
-
- DbgPrint("Stop playing\n");
- return 0;
-}
-
-CVideo::CVideo(enum target_type type, int width, int height)
-: m_vState(STOPPED)
-, m_vType(type)
-, m_nWidth(width)
-, m_nHeight(height)
-, m_pBuffer(NULL)
-, m_nId(0)
-, m_sId(NULL)
-, m_sError(NULL)
-, m_vPlayer(0)
-{
-}
-
-CVideo::~CVideo(void)
-{
-}
-
-CVideo::TVideoState CVideo::State(void)
-{
- return m_vState;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdio.h>
-#include <dlog.h>
-
-#include "debug.h"
-#include "CView.h"
-
-CView::CView(void)
-{
-}
-
-CView::~CView(void)
-{
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-
-#include <Ecore_Evas.h>
-#include <Ecore.h>
-#include <Evas.h>
-
-#include <dlog.h>
-
-#include <provider.h>
-#include <provider_buffer.h>
-
-#include "debug.h"
-#include "CWindow.h"
-
-Eina_List *CWindow::s_pList = NULL;
-
-void *CWindow::s_AllocateCanvas(void *data, int size)
-{
- CWindow *win = (CWindow *)data;
- struct livebox_buffer *pBuffer;
- void *canvas;
-
- pBuffer = provider_buffer_acquire(win->Type(), PKGNAME, win->Id(),
- win->Width(), win->Height(), sizeof(int),
- CWindow::s_BufferEventHandler, win);
-
- if (!pBuffer)
- return NULL;
-
- win->SetBuffer(pBuffer);
- canvas = provider_buffer_ref(win->Buffer());
- return canvas;
-}
-
-void CWindow::s_ReleaseCanvas(void *data, void *canvas)
-{
- int ret;
- CWindow *win = (CWindow *)data;
-
- ret = provider_buffer_unref(canvas);
- DbgPrint("Unref %d\n", ret);
-
- ret = provider_buffer_release(win->Buffer());
- DbgPrint("release %d\n", ret);
-
- win->SetBuffer(NULL);
-}
-
-void CWindow::s_PostRender(void *data, Evas *e, void *event_info)
-{
- CWindow *win = (CWindow *)data;
-
- if (win->EvasObject() != e)
- return;
-
- switch (win->Type()) {
- case TYPE_PD:
- provider_buffer_sync(win->Buffer());
- provider_send_desc_updated(PKGNAME, win->Id(), NULL);
- break;
- case TYPE_LB:
- provider_buffer_sync(win->Buffer());
- provider_send_updated(PKGNAME, win->Id(), win->Width(), win->Height(), 1.0f, NULL, NULL);
- break;
- default:
- break;
- }
-}
-
-int CWindow::s_BufferEventHandler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
-{
- CWindow *win = (CWindow *)data;
- int ix;
- int iy;
-
- ix = win->Width() * x;
- iy = win->Height() * y;
-
- switch (event) {
- case BUFFER_EVENT_ENTER:
- evas_event_feed_mouse_in(win->EvasObject(), timestamp, NULL);
- break;
- case BUFFER_EVENT_LEAVE:
- evas_event_feed_mouse_out(win->EvasObject(), timestamp, NULL);
- break;
- case BUFFER_EVENT_DOWN:
- evas_event_feed_mouse_in(win->EvasObject(), timestamp, NULL);
- evas_event_feed_mouse_move(win->EvasObject(), ix, iy, timestamp + 0.01f, NULL);
- evas_event_feed_mouse_down(win->EvasObject(), 1, EVAS_BUTTON_NONE, timestamp + 0.02f, NULL);
- break;
- case BUFFER_EVENT_MOVE:
- evas_event_feed_mouse_move(win->EvasObject(), ix, iy, timestamp, NULL);
- break;
- case BUFFER_EVENT_UP:
- evas_event_feed_mouse_up(win->EvasObject(), 1, EVAS_BUTTON_NONE, timestamp, NULL);
- evas_event_feed_mouse_out(win->EvasObject(), timestamp + 0.01f, NULL);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-CWindow *CWindow::Create(enum target_type type, const char *id, int w, int h)
-{
- CWindow *win;
-
- try {
- win = new CWindow(type, w, h);
- } catch (...) {
- return NULL;
- }
-
- win->m_sID = strdup(id);
- if (!win->m_sID) {
- win->Destroy();
- return NULL;
- }
-
- win->m_pEcoreEvas = ecore_evas_buffer_allocfunc_new(win->m_nWidth, win->m_nHeight, CWindow::s_AllocateCanvas, CWindow::s_ReleaseCanvas, win);
- if (!win->m_pEcoreEvas) {
- ErrPrint("Failed to allocate a new EE\n");
- win->Destroy();
- return NULL;
- }
-
- win->m_pEvas = ecore_evas_get(win->m_pEcoreEvas);
- if (!win->m_pEvas) {
- win->Destroy();
- return NULL;
- }
-
- evas_event_callback_add(win->m_pEvas, EVAS_CALLBACK_RENDER_FLUSH_POST, s_PostRender, win);
-
- ecore_evas_alpha_set(win->m_pEcoreEvas, EINA_TRUE);
- ecore_evas_manual_render_set(win->m_pEcoreEvas, EINA_FALSE);
- ecore_evas_resize(win->m_pEcoreEvas, win->m_nWidth, win->m_nHeight);
- ecore_evas_show(win->m_pEcoreEvas);
- ecore_evas_activate(win->m_pEcoreEvas);
-
- win->m_pObject = evas_object_rectangle_add(win->m_pEvas);
- evas_object_resize(win->m_pObject, win->m_nWidth, win->m_nHeight);
- evas_object_color_set(win->m_pObject, 0, 0, 0, 255);
- evas_object_show(win->m_pObject);
-
- s_pList = eina_list_append(s_pList, win);
- return win;
-}
-
-CWindow *CWindow::Find(enum target_type type, const char *id)
-{
- Eina_List *l;
- void *item;
- CWindow *win;
-
- EINA_LIST_FOREACH(s_pList, l, item) {
- win = (CWindow *)item;
-
- if (win->Type() == type && !strcmp(win->Id(), id))
- return win;
- }
-
- return NULL;
-}
-
-int CWindow::Destroy(void)
-{
- s_pList = eina_list_remove(s_pList, this);
-
- if (m_pObject)
- evas_object_del(m_pObject);
-
- if (m_pEcoreEvas)
- ecore_evas_free(m_pEcoreEvas);
-
- free(m_sID);
- delete this;
- return 0;
-}
-
-int CWindow::Resize(int w, int h)
-{
- m_nWidth = w;
- m_nHeight = h;
-
- if (m_pEcoreEvas)
- ecore_evas_resize(m_pEcoreEvas, w, h);
-
- return 0;
-}
-
-CWindow::CWindow(enum target_type type, int width, int height)
-: m_vType(type)
-, m_nWidth(width)
-, m_nHeight(height)
-, m_pBuffer(NULL)
-, m_pEcoreEvas(NULL)
-, m_pEvas(NULL)
-, m_sID(NULL)
-{
-}
-
-CWindow::~CWindow(void)
-{
-}
-
-/* End of a file */