From: jinwoo.shin Date: Wed, 5 Aug 2015 02:27:36 +0000 (+0900) Subject: Add tv overlay control code X-Git-Tag: accepted/tizen/tv/20150806.065642^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F45324%2F3;p=profile%2Ftv%2Fapps%2Fnative%2Fair_livetv.git Add tv overlay control code Change-Id: I75822764cce2c24baf127eb88a462142c00bb2a2 Signed-off-by: jinwoo.shin --- diff --git a/CMakeLists.txt b/CMakeLists.txt index de9e819..7f570a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,9 +66,9 @@ pkg_check_modules(PKGS REQUIRED capi-appfw-application app-utils vconf - glib-2.0 gobject-2.0 - tv-service) + tv-service + tzsh-tvsrv) FOREACH(flag ${PKGS_CFLAGS}) SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}") diff --git a/packaging/org.tizen.live-tv.spec b/packaging/org.tizen.live-tv.spec index 3d06fc2..56819b1 100644 --- a/packaging/org.tizen.live-tv.spec +++ b/packaging/org.tizen.live-tv.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(tv-service) +BuildRequires: pkgconfig(tzsh-tvsrv) BuildRequires: gettext-devel BuildRequires: edje-bin diff --git a/src/main.c b/src/main.c index 0b97768..0ea7cda 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "define.h" #include "tv.h" @@ -34,6 +35,8 @@ struct _appdata { Evas_Object *win; Ecore_Event_Handler *key_down; Ecore_Event_Handler *key_up; + tzsh_h tzsh; + tzsh_tvsrv_h ta; int is_signal; int is_channel; @@ -144,7 +147,7 @@ static Evas_Object *_add_win(const char *name) _ERR("elm_win_add failed"); return NULL; } - elm_win_alpha_set(win, EINA_FALSE); + elm_win_alpha_set(win, EINA_TRUE); elm_win_focus_highlight_enabled_set(win, EINA_FALSE); elm_win_focus_highlight_style_set(win, "invisible"); @@ -153,6 +156,27 @@ static Evas_Object *_add_win(const char *name) return win; } +static tzsh_tvsrv_h _bind_win(Evas_Object *win, tzsh_h tzsh) +{ + tzsh_window tz_win; + tzsh_tvsrv_h ta; + + tz_win = elm_win_window_id_get(win); + if (!tz_win) { + _ERR("failed to get window ID"); + return NULL; + } + + ta = tzsh_tvsrv_create(tzsh, tz_win); + if (!ta) { + _ERR("failed to create tvsrv"); + return NULL; + } + tzsh_tvsrv_bind(ta); + + return ta; +} + static void _tv_signal_cb(void *data, int is_signal) { struct _appdata *ad; @@ -179,10 +203,16 @@ static void _tv_signal_cb(void *data, int is_signal) static void _pause(void *data) { + int r; + + r = tv_pause(); + if (r < 0) + _ERR("Pause tv service failed"); } static void _resume(void *data) { + struct _appdata *ad; int r; if (!data) { @@ -190,6 +220,8 @@ static void _resume(void *data) return; } + ad = data; + r = tv_resume(); if (r < 0) { _ERR("Resume tv service failed"); @@ -201,6 +233,9 @@ static void _resume(void *data) return; } } + + if (ad->win) + elm_win_activate(ad->win); } static bool _create(void *data) @@ -218,12 +253,25 @@ static bool _create(void *data) elm_theme_overlay_add(NULL, THEMEFILE); + ad->tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); + if (!ad->tzsh) { + _ERR("failed to create tzsh"); + return false; + } + win = _add_win(ad->name); if (!win) { _ERR("failed to create win object"); return false; } + ad->ta = _bind_win(win, ad->tzsh); + if (!ad->ta) { + _ERR("failed to bind win object"); + evas_object_del(win); + return false; + } + if (!viewmgr_create(win)) { _ERR("failed to initialize viewmgr"); evas_object_del(win); @@ -280,6 +328,12 @@ static void _terminate(void *data) evas_object_del(ad->win); ad->win = NULL; + + if (ad->ta) + tzsh_tvsrv_destroy(ad->ta); + + if (ad->tzsh) + tzsh_destroy(ad->tzsh); } } diff --git a/src/tv.c b/src/tv.c index 9685aa2..10b9bef 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1121,6 +1121,15 @@ err: */ int tv_pause(void) { + int r; + + if (g_tv_info.live_svc) { + r = tv_service_live_destroy(g_tv_info.live_svc); + if (r != TVS_ERROR_OK) + _ERR("failed to destroy live service"); + g_tv_info.live_svc = NULL; + } + return 0; } diff --git a/src/tv_service.c b/src/tv_service.c deleted file mode 100644 index ee44fac..0000000 --- a/src/tv_service.c +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * 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 -#include -#include -#include - -#include "tv.h" -#include "tv_service.h" - -#define DEFAULT_TIMER_INTERVAL 1.0 -#define TVS_VOLUME_MIN 0.0 -#define TVS_VOLUME_MAX 10.0 -#define TVS_PASSWORD "0000" - -#define VCONF_CHANNEL "db/menu/broadcasting/last_channel" - -struct dummy_tv_service_struct -{ - guint service_id; - TvServiceEpgCallback callback_func; - gpointer user_data; -}; - -struct _tv_service_info -{ - gdouble volume; - gboolean is_mute; -}; - -struct _tv_service_info tv_service_info; -GList *channel_list = NULL, *program_list = NULL; - -static void init_constant_channel_data(TvServiceChannel *channel) -{ - memset(channel, 0, sizeof(TvServiceChannel)); - - channel->frequency = 567000000; - channel->service_type = 2; - channel->channel_type = 0; - - channel->program_number = 1; - channel->source_id = 1; - // channel->stream_id = - channel->pcr_id = 17; - channel->minor = 1; - channel->vpid = 17; - // channel->apid = - channel->pmt_pid =16; - - channel->hide_guide = FALSE; - channel->hidden = FALSE; - channel->locked = FALSE; - channel->remembered = TRUE; - channel->save_by_psi = TRUE; - channel->digital = TRUE; - - channel->modulation_type = TVS_MODULATION_TYPE_8VSB; - channel->antenna_type = TV_SERVICE_ANTENNA_TYPE_CABLE; - channel->video_type = TVS_VIDEO_TYPE_MPEG2; - channel->audio_type = TVS_AUDIO_TYPE_AAC; -} - -/* Creates 3 programs for each channel (service_id) - * with one hour duration each. -*/ -static void init_program_data(int service_id, struct timeval tv) -{ - GList *epg_program_glist = NULL; - int i; - for (i = 0; i < 15; i++) - { - TvServiceEpgEventData *epg_data = NULL; - epg_data = (TvServiceEpgEventData *)g_malloc0 (sizeof(TvServiceEpgEventData)); - memset(epg_data, 0, sizeof(TvServiceEpgEventData)); - - epg_data->service_id = service_id; - // epg_data->event_id = - if (i == 0 && service_id % 2 == 0) - { - // Start first programs of some channels 30 minutes earlier than current time - // and substitute the difference with length - epg_data->start_time = tv.tv_sec - 30 * 60; - epg_data->length_in_seconds = 90 * 60; - } else { - epg_data->start_time = tv.tv_sec + i * 60 * 60; - epg_data->length_in_seconds = 60 * 60; - } - epg_data->etm_location= 1; - snprintf(epg_data->title_text, 255, "Awesome Program %d", i + 1); - snprintf(epg_data->extended_text, 255, "Description of Awesome Program %d", i + 1); - epg_data->current_time = tv.tv_sec; - epg_program_glist = g_list_append (epg_program_glist, epg_data); - } - program_list = g_list_append(program_list, (gpointer)epg_program_glist); -} - -static void init_data() -{ - struct timeval tv; - gettimeofday(&tv, NULL); - int i; - for (i = 1; i < 6; i++) - { - TvServiceChannel *channel = NULL; - channel = (TvServiceChannel *)g_malloc0(sizeof(TvServiceChannel)); - init_constant_channel_data(channel); - channel->service_id = i; - channel->major = (10 + i); - channel->favorite = i % 2 == 0 ? TRUE : FALSE; - snprintf(channel->program_name, PROGRAM_NAME_MAX_LEN - 1, "Super Channel %d", i); - channel_list = g_list_append(channel_list, (gpointer)channel); - init_program_data(i, tv); - } - - tv_service_info.volume = TVS_VOLUME_MAX / 2; - tv_service_info.is_mute = FALSE; -} - -/* 9 */ -gint tv_service_live_get_service_id(TvServiceLive live, gint *service_id) -{ - TvServiceLiveData *live_proxy; - - if (!live || !service_id) - return TVS_ERROR_NOT_AVAILABLE; - - live_proxy = (TvServiceLiveData *)live; - *service_id = live_proxy->service_id; - - _DBG("service_id = %d", *service_id); - - return TVS_ERROR_OK; -} - -/* 10 */ -gint tv_service_get_channel(gint service_id, TvServiceChannel *channel) -{ - _DBG("service_id = %d", service_id); - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - TvServiceChannel *local_channel = NULL; - local_channel = (TvServiceChannel *)g_list_nth_data(channel_list, service_id - 1); - memcpy(channel, local_channel, sizeof(TvServiceChannel)); - - return TVS_ERROR_OK; -} - -/* We intentionally make a new copy of the channel_list, - * because live-tv frees the list internally - */ -TvServiceChannel *first_match_channel = NULL; -static gint _get_channel_list(TvServiceChannelMode channel_mode, TvServiceAntenna antenna_type, GList **channels, - GList *filter, TvServiceChannelSortType sort_type) -{ - GList *tmp_list = NULL; - TvServiceChannel *from, *to; - int i, size = g_list_length(channel_list); - if (filter == NULL) - { - // return the whole list - for (i = 0; i < size; i++) - { - from = g_list_nth_data(channel_list, i); - to = (TvServiceChannel *)malloc(sizeof(TvServiceChannel)); - memcpy(to, from, sizeof(TvServiceChannel)); - tmp_list = g_list_append(tmp_list, to); - } - *channels = tmp_list; - return TVS_ERROR_OK; - } - - TvServiceFilterNode *filter_node; - // FIXME: g_list_length(filter) is always 1, why? - filter_node = g_list_nth_data(filter, 0); - switch (filter_node->attribute) - { - case TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER: - case TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER: - if (filter_node->match_type == CHANNEL_FILTER_MATCH_CONTAIN) - { - _DBG("CHANNEL_FILTER_MATCH_CONTAIN"); - gchar *str_value; - str_value = (gchar *)g_value_get_string((const GValue *)filter_node->value); - gulong gul_major_minor; - int length; - for (i = 0; i < size; i++) - { - from = g_list_nth_data(channel_list, i); - gul_major_minor = filter_node->attribute == TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER - ? from->major : from->minor; - length = snprintf(NULL, 0, "%lu", gul_major_minor); - char char_major_minor[length + 1]; - snprintf(char_major_minor, length + 1, "%lu", gul_major_minor); - if (strstr(char_major_minor, str_value)) - { - if (first_match_channel == NULL) - { - // reserve a copy for CHANNEL_FILTER_MATCH_EQUAL - first_match_channel = (TvServiceChannel *)malloc(sizeof(TvServiceChannel)); - memcpy(first_match_channel, from, sizeof(TvServiceChannel)); - } - to = (TvServiceChannel *)malloc(sizeof(TvServiceChannel)); - memcpy(to, from, sizeof(TvServiceChannel)); - tmp_list = g_list_append(tmp_list, to); - } - } - } - else - { - // FIXME: filter_node->value is always NULL at this point, why? - // gint *int_value; - // int_value = g_value_get_int(filter_node->value); - if (filter_node->match_type == CHANNEL_FILTER_MATCH_EQUAL) - { - _DBG("CHANNEL_FILTER_MATCH_EQUAL"); - if (first_match_channel) - { - tmp_list = g_list_append(tmp_list, first_match_channel); - first_match_channel = NULL; - } - } - else if (filter_node->match_type == CHANNEL_FILTER_MATCH_MORE) - { - _DBG("[NOT IMPLEMENTED YET] channel_filter_match_more"); - } - else if (filter_node->match_type == CHANNEL_FILTER_MATCH_LESS) - { - _DBG("[NOT IMPLEMENTED YET] channel_filter_match_less"); - } - else if (filter_node->match_type == CHANNEL_FILTER_MATCH_UNEQUAL) - { - _DBG("[NOT IMPLEMENTED YET] channel_filter_match_unequal"); - } - else - { - _ERR("match_type[%d] is out of range", filter_node->match_type); - return TVS_ERROR_PROCESS_FAIL; - } - } - break; - case TV_SERVICE_CHANNEL_DATA_SERVICE_ID: - case TV_SERVICE_CHANNEL_DATA_FREQUENCY: - case TV_SERVICE_CHANNEL_DATA_REMEMBERED: - case TV_SERVICE_CHANNEL_DATA_PROGRAM_NAME: - _DBG("case %d is not implemented yet", filter_node->attribute); - break; - default: - _ERR("attribute[%d] is out of range", filter_node->attribute); - return TVS_ERROR_PROCESS_FAIL; - } - - if (g_list_length(tmp_list) < 1) { - first_match_channel = NULL; - *channels = NULL; - return TVS_ERROR_PROCESS_FAIL; - } - *channels = tmp_list; - return TVS_ERROR_OK; -} - -gint tv_service_get_channel_list(TvServiceChannelMode mode, TvServiceAntenna antenna_type, GList **channels) -{ - _DBG(""); - return _get_channel_list(mode, antenna_type, channels, NULL, 0); -} - -gint tv_service_get_channel_list_ex(TvServiceChannelMode mode, TvServiceAntenna antenna_type, GList **channels, - GList *filter, TvServiceChannelSortType sort_type) -{ - _DBG(""); - return _get_channel_list(mode, antenna_type, channels, filter, sort_type); -} - -static Eina_Bool _tv_service_epg_get_current_program_cb(void *data) -{ - struct dummy_tv_service_struct *tvs_epg; - tvs_epg = data; - TvServiceEpgCallback callback_func = tvs_epg->callback_func; - callback_func(TVS_EPG_GET_CURRENT_PROGRAM, - g_list_nth_data(program_list, tvs_epg->service_id - 1), - tvs_epg->user_data); - free(tvs_epg); - - return ECORE_CALLBACK_CANCEL; -} - -/* 11 */ -gint tv_service_epg_get_current_program(TvServiceEpg epg, guint service_id, - TvServiceEpgCallback callback_func, gpointer user_data) -{ - _DBG("service_id = %d", service_id); - if (service_id < 1 || g_list_length(channel_list) < service_id) - { - return TVS_ERROR_NOT_AVAILABLE; - } - - struct dummy_tv_service_struct *tvs_epg; - tvs_epg = calloc(1, sizeof(*tvs_epg)); - tvs_epg->service_id = service_id; - tvs_epg->callback_func = callback_func; - tvs_epg->user_data = user_data; - ecore_timer_add(DEFAULT_TIMER_INTERVAL, _tv_service_epg_get_current_program_cb, tvs_epg); - - return TVS_ERROR_OK; -} - -gint tv_service_epg_get_cache_current_program(TvServiceEpg epg, guint service_id, - TvServiceEpgEventData *app_data) -{ - _DBG("service_id = %d", service_id); - if (service_id < 1 || g_list_length(channel_list) < service_id) - { - return TVS_ERROR_NOT_AVAILABLE; - } - struct timeval tv; - gettimeofday(&tv, NULL); - GList *prog_list = NULL; - prog_list = g_list_nth_data(program_list, service_id - 1); - TvServiceEpgEventData *epg_data = NULL; - gint result = TVS_ERROR_NOT_AVAILABLE; - int i; - for (i = 0; i < g_list_length(prog_list); i++) - { - epg_data = (TvServiceEpgEventData *)g_list_nth_data(prog_list, i); - if (epg_data == NULL) - { - continue; - } - if (epg_data->start_time <= tv.tv_sec && - epg_data->start_time + epg_data->length_in_seconds > tv.tv_sec) - { - app_data->service_id = epg_data->service_id; - app_data->event_id = epg_data->event_id; - app_data->start_time = epg_data->start_time; - app_data->etm_location = epg_data->etm_location; - app_data->length_in_seconds = epg_data->length_in_seconds; - g_stpcpy ((gchar *)app_data->title_text, (gchar *)epg_data->title_text); - g_stpcpy ((gchar *)app_data->extended_text, (gchar *)epg_data->extended_text); - app_data->current_time = tv.tv_sec; - result = TVS_ERROR_OK; - break; - } - } - - return result; -} - -gint tv_service_epg_get_program_list(TvServiceEpg epg, guint service_id, - guint start_time, guint duration, - TvServiceEpgCallback callback_func, gpointer user_data) -{ - _DBG("service_id = %d", service_id); - if (service_id < 1 || g_list_length(channel_list) < service_id) - { - return TVS_ERROR_NOT_AVAILABLE; - } - - struct dummy_tv_service_struct *tvs_epg; - tvs_epg = calloc(1, sizeof(*tvs_epg)); - tvs_epg->service_id = service_id; - tvs_epg->callback_func = callback_func; - tvs_epg->user_data = user_data; - ecore_timer_add(DEFAULT_TIMER_INTERVAL, _tv_service_epg_get_current_program_cb, tvs_epg); - - return TVS_ERROR_OK; -} - -/* 7 */ -gint tv_service_live_tune(TvServiceLive live, gint service_id) -{ - TvServiceLiveData *live_proxy; - - if (!live) - return TVS_ERROR_NOT_AVAILABLE; - - _DBG("service_id = %d", service_id); - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - live_proxy = (TvServiceLiveData *)live; - live_proxy->service_id = service_id; - - vconf_set_int(VCONF_CHANNEL, service_id); - - return TVS_ERROR_OK; -} - -static gboolean _check_lock_unlock_password(gchar *password) -{ - if (g_strcmp0(TVS_PASSWORD, password)) - { - return FALSE; - } - return TRUE; -} - -gint tv_service_live_tune_locked_channel(TvServiceLive live, gint service_id, gchar * password) -{ - if (!live) - return TVS_ERROR_HANDLE_UNINITIALIZED; - - if (!password) { - _ERR("Password is NULL"); - return TVS_ERROR_INVALID_PARAMETER; - } - - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - TvServiceChannel *channel = NULL; - channel = (TvServiceChannel *)g_list_nth_data(channel_list, service_id - 1); - if (!channel) - return TVS_ERROR_NOT_AVAILABLE; - - if (_check_lock_unlock_password(password)) - return TVS_ERROR_OK; - else - return TVS_ERROR_AUTHENTICATE_FAIL; -} - -gint tv_service_live_tune_up(TvServiceLive live, gint channel_mode, TvServiceAntenna antenna_type) -{ - TvServiceLiveData *live_proxy; - gint service_id; - - if (!live) - return TVS_ERROR_NOT_AVAILABLE; - - live_proxy = (TvServiceLiveData *)live; - service_id = (live_proxy->service_id) % g_list_length(channel_list) + 1; - - return tv_service_live_tune(live, service_id); -} - -gint tv_service_live_get_antenna_type(TvServiceLive live, TvServiceAntenna *type) -{ - _DBG(""); - TvServiceLiveData *live_proxy; - live_proxy = (TvServiceLiveData *)live; - *type = live_proxy->antenna_type; - - return TVS_ERROR_OK; -} - -/* 6 */ -gint tv_service_live_get_last_channel(gint *service_id) -{ - gint r = -1; - - r = vconf_get_int(VCONF_CHANNEL, service_id); - if (r < 0) - return TVS_ERROR_NOT_AVAILABLE; - - if ((*service_id) < 1) - return TVS_ERROR_NOT_AVAILABLE; - - return TVS_ERROR_OK; -} - -gint tv_service_live_tune_down(TvServiceLive live, gint channel_mode, - TvServiceAntenna antenna_type) -{ - TvServiceLiveData *live_proxy; - gint service_id; - - if (!live) - return TVS_ERROR_NOT_AVAILABLE; - - live_proxy = (TvServiceLiveData *)live; - service_id = live_proxy->service_id - 1; - if (service_id == 0) - service_id = g_list_length(channel_list); - - return tv_service_live_tune(live, service_id); -} - -gint tv_service_add_favorite_channel(gint service_id) -{ - TvServiceChannel *channel = NULL; - - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - channel = (TvServiceChannel *) g_list_nth_data(channel_list, service_id - 1); - if (!channel) - return TVS_ERROR_NOT_AVAILABLE; - - channel->favorite = TRUE; - - return TVS_ERROR_OK; -} - -gint tv_service_delete_favorite_channel(gint service_id) -{ - TvServiceChannel *channel = NULL; - - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - channel = (TvServiceChannel *) g_list_nth_data(channel_list, service_id - 1); - if (!channel) - return TVS_ERROR_NOT_AVAILABLE; - - channel->favorite = FALSE; - - return TVS_ERROR_OK; -} - -gint tv_service_add_channel(gint service_id) -{ - TvServiceChannel *channel = NULL; - - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - channel = (TvServiceChannel *) g_list_nth_data(channel_list, service_id - 1); - if (!channel) - return TVS_ERROR_NOT_AVAILABLE; - - channel->remembered = TRUE; - - return TVS_ERROR_OK; -} - -gint tv_service_delete_channel(gint service_id) -{ - TvServiceChannel *channel = NULL; - - if (service_id < 1 || g_list_length(channel_list) < service_id) - return TVS_ERROR_NOT_AVAILABLE; - - channel = (TvServiceChannel *) g_list_nth_data(channel_list, service_id - 1); - if (!channel) - return TVS_ERROR_NOT_AVAILABLE; - - channel->remembered = FALSE; - - return TVS_ERROR_OK; -} - -gint tv_service_lock_channel(gint service_id, gchar *password) -{ - if (!password) - { - _ERR("Password is NULL"); - return TVS_ERROR_INVALID_PARAMETER; - } - if (service_id < 1 || g_list_length(channel_list) < service_id) - { - return TVS_ERROR_NOT_AVAILABLE; - } - TvServiceChannel *channel = NULL; - channel = (TvServiceChannel *)g_list_nth_data(channel_list, service_id - 1); - if (!channel) - { - return TVS_ERROR_NOT_AVAILABLE; - } - if (channel->locked) - { - // if channel is already locked, simply return success code - return TVS_ERROR_OK; - } - - if (_check_lock_unlock_password(password)) - { - channel->locked = TRUE; - return TVS_ERROR_OK; - } - - return TVS_ERROR_AUTHENTICATE_FAIL; -} - -gint tv_service_unlock_channel(gint service_id, gchar *password) -{ - if (!password) - { - _ERR("Password is NULL"); - return TVS_ERROR_INVALID_PARAMETER; - } - if (service_id < 1 || g_list_length(channel_list) < service_id) - { - return TVS_ERROR_NOT_AVAILABLE; - } - TvServiceChannel *channel = NULL; - channel = (TvServiceChannel *)g_list_nth_data(channel_list, service_id - 1); - if (!channel) - { - return TVS_ERROR_NOT_AVAILABLE; - } - if (!channel->locked) - { - // if channel is already unlocked, simply return success code - return TVS_ERROR_OK; - } - - if (_check_lock_unlock_password(password)) - { - channel->locked = FALSE; - return TVS_ERROR_OK; - } - - return TVS_ERROR_AUTHENTICATE_FAIL; -} - -gint tv_service_live_get_audio_mute(TvServiceLive live_svc, gboolean *mute) -{ - if (!live_svc) - return TVS_ERROR_HANDLE_UNINITIALIZED; - - if (!mute) - return TVS_ERROR_INVALID_PARAMETER; - - *mute = tv_service_info.is_mute; - - return TVS_ERROR_OK; -} - -gint tv_service_live_set_audio_mute(TvServiceLive live_svc, gboolean mute) -{ - if (!live_svc) - return TVS_ERROR_HANDLE_UNINITIALIZED; - - if (mute != TRUE && mute != FALSE) - return TVS_ERROR_INVALID_VALUE; - - tv_service_info.is_mute = mute; - - return TVS_ERROR_OK; -} - -gint tv_service_live_get_volume(TvServiceLive live_svc, gdouble *vol) -{ - if (!live_svc) - return TVS_ERROR_HANDLE_UNINITIALIZED; - - if (!vol) - return TVS_ERROR_INVALID_PARAMETER; - - *vol = tv_service_info.volume; - - return TVS_ERROR_OK; -} - -gint tv_service_live_set_volume(TvServiceLive live_svc, gdouble vol) -{ - if (!live_svc) - return TVS_ERROR_HANDLE_UNINITIALIZED; - - if (vol < TVS_VOLUME_MIN || vol > TVS_VOLUME_MAX) - return TVS_ERROR_INVALID_VALUE; - - tv_service_info.is_mute = FALSE; - tv_service_info.volume = vol; - - return TVS_ERROR_OK; -} - -/* 5 */ -/* 8 */ -gint tv_service_live_set_window_overlay(TvServiceLive live_svc, void *window_id) -{ - _DBG(""); - return 0; -} - -/* 1 */ -gint tv_service_live_create(TvServiceLive *live) -{ - _DBG(""); - init_data(); - TvServiceLiveData *local = NULL; - local = (TvServiceLiveData*)g_malloc0 (sizeof (TvServiceLiveData)); - // local->service_handle = - local->antenna_type = TV_SERVICE_ANTENNA_TYPE_CABLE; - local->service_id = -1; - // local->unique = - - local->tune_info.freq = 567000000; - local->tune_info.mod = 7; - // local->tune_info.apid = - local->tune_info.vpid = 17; - local->tune_info.ppid = 17; - local->tune_info.pro_num = 1; - - // local->call_back = - // local->user_data = - // local->window_id = - - *live = (TvServiceLive)local; - - return TVS_ERROR_OK; -} - -void _free_program_data(gpointer data) -{ - GList *epg_program_glist; - epg_program_glist = (GList *) data; - if (epg_program_glist) - g_list_free_full(epg_program_glist, (GDestroyNotify)g_free); -} - -gint tv_service_live_destroy(TvServiceLive live) -{ - _DBG(""); - g_list_free_full(program_list, (GDestroyNotify) _free_program_data); - g_list_free_full(channel_list, (GDestroyNotify)g_free); - - TvServiceLiveData *live_proxy; - live_proxy = (TvServiceLiveData *)live; - g_free (live_proxy); - live_proxy = NULL; - - return TVS_ERROR_OK; -} - -/* 2 */ -gint tv_service_live_register_callback(TvServiceLive live_svc, - void *_tv_service_event_cb, void *some_other_variable) -{ - _DBG(""); - return 0; -} - -/* 3 */ -gint tv_service_channel_info_create() -{ - _DBG(""); - return 0; -} - -gint tv_service_channel_info_destroy() -{ - _DBG(""); - return 0; -} - -/* 4 */ -gint tv_service_epg_create(TvServiceEpg * epg) -{ - _DBG(""); - EpgProxyData *proxy_data = NULL; - proxy_data = (EpgProxyData *)g_malloc0 (sizeof (EpgProxyData)); - // proxy_data->identity = identity; - proxy_data->event_list = NULL; - proxy_data->cb_flag = FALSE; - *epg = proxy_data; - - return TVS_ERROR_OK; -} - -gint tv_service_epg_destroy(TvServiceEpg epg) -{ - _DBG(""); - EpgProxyData *proxy_data = (EpgProxyData *)epg; - // g_object_unref (proxy_data->proxy); - g_list_free_full (proxy_data->event_list, (GDestroyNotify)g_free); - g_free (proxy_data); - - return TVS_ERROR_OK; -} diff --git a/src/view_channelinfo.c b/src/view_channelinfo.c index 14e2960..818e06d 100644 --- a/src/view_channelinfo.c +++ b/src/view_channelinfo.c @@ -203,7 +203,7 @@ static void _load_program_info(Evas_Object *obj, char buf[BUF_MAX]; int r, service_id; - service_id = evas_object_data_get(obj, KEY_SVCID); + service_id = (int) evas_object_data_get(obj, KEY_SVCID); if (service_id != prog->service_id) return; @@ -265,7 +265,7 @@ void draw_channel_info(Evas_Object *obj, _load_channel_text(obj, channel_info); _set_icon_box(obj, channel_info); - evas_object_data_set(obj, KEY_SVCID, channel_info->service_id); + evas_object_data_set(obj, KEY_SVCID, (void *)channel_info->service_id); prog_req = calloc(1, sizeof(*prog_req)); prog_req->tv_program_cb = _tv_program_cb;