2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <app_debug.h>
22 #include <app_contents.h>
25 #include <glib-object.h>
29 #include "tv_service.h"
31 #define DEFAULT_SERVICE 1
34 * The Storage structure to used by tv related functions and events.
37 /**< The handle to use tv service live api. */
38 TvServiceLive live_svc;
39 /**< The handle to use tv service epg api. */
42 /**< Stores service id if tune to locked channel was succeeded. */
43 int viewing_locked_channel;
45 /**< The function pointer to pass tv signal event */
46 void (*signal_cb)(void *data, int is_signal);
47 /**< An Additional data to passed to tv signal event */
51 static struct _tv_info g_tv_info;
54 * Gets the tv_channel_info with supplied TvServiceChannel.
56 * Abstracts tv service data structure.
58 * @param channel The channel data defined by tv service
59 * @return Channel information, or NULL if fails
61 static struct tv_channel_info *_tv_channel_get_info(TvServiceChannel *channel)
63 struct tv_channel_info *channel_info = NULL;
66 _ERR("failed to get channel");
70 channel_info = calloc(1, sizeof(*channel_info));
72 _ERR("failed to calloc channel info");
76 channel_info->service_id = channel->service_id;
77 channel_info->channel_major = channel->major;
78 channel_info->channel_minor = channel->minor;
79 channel_info->channel_type = channel->channel_type;
80 channel_info->locked = channel->locked;
81 channel_info->digital = channel->digital;
82 channel_info->favorite = channel->favorite;
83 channel_info->remembered = channel->remembered;
84 strncpy(channel_info->channel_name, channel->program_name,
87 if (channel->service_id == g_tv_info.viewing_locked_channel)
88 channel_info->tune_locked = EINA_TRUE;
94 * Clones the tv_channel_info.
96 * @param channel_info tv_channel_info pointer to be cloned
97 * @return Channel information, or NULL if fails
99 const struct tv_channel_info *tv_channel_clone_info(
100 const struct tv_channel_info *channel_info)
102 struct tv_channel_info *new_channel_info = NULL;
105 _ERR("failed to get channel info");
109 new_channel_info = calloc(1, sizeof(*channel_info));
110 if (!new_channel_info) {
111 _ERR("failed to calloc channel info");
115 memcpy(new_channel_info, channel_info, sizeof(*new_channel_info));
117 return new_channel_info;
121 * Frees the tv_channel_info.
123 * @param channel_info tv_channel_info pointer to be freed
125 void tv_channel_del_info(const struct tv_channel_info *channel_info)
128 _ERR("failed to get channel info");
132 free((void *)channel_info);
136 * Gets current channel's TvServiceChannel data from tv service.
138 * @param channel The pointer to store TvServiceChannel
139 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
141 static int _tv_get_channel(TvServiceChannel *channel)
146 if (!g_tv_info.live_svc) {
147 _ERR("failed to get live service");
151 r = tv_service_live_get_service_id(g_tv_info.live_svc, &svc_id);
153 _ERR("failed to get service id");
157 r = tv_service_get_channel(svc_id, channel);
159 _ERR("failed to get channel");
167 * Returns current channel's info.
169 * tv_channel_get_info retrieves current channel's information
172 * @return Returns current channel info, or NULL if fails
174 const struct tv_channel_info *tv_channel_get_info(void)
176 const struct tv_channel_info *channel_info;
177 TvServiceChannel channel;
180 r = _tv_get_channel(&channel);
182 _ERR("failed to get channel");
186 channel_info = _tv_channel_get_info(&channel);
192 * Returns tv_program_info with supplied TvServiceEpgEventData.
194 * Abstracts tv service data structure.
196 * @param prog TvServiceEpgEventData passed from tv service
197 * @return Returns tv_program_info, or NULL if fails
199 static struct tv_program_info *_tv_get_program_info(TvServiceEpgEventData *prog)
201 struct tv_program_info *prog_info;
203 prog_info = calloc(1, sizeof(*prog_info));
205 _ERR("failed to calloc program info");
209 prog_info->service_id = prog->service_id;
210 prog_info->start_time = prog->start_time;
211 prog_info->end_time = prog->start_time + prog->length_in_seconds;
212 prog_info->duration = prog->length_in_seconds;
213 prog_info->current_time = prog->current_time;
214 strncpy(prog_info->prog_title, (char *)prog->title_text,
215 sizeof(prog_info->prog_title) - 1);
216 strncpy(prog_info->prog_description, (char *)prog->extended_text,
217 sizeof(prog_info->prog_description) - 1);
223 * Gets current channel's service id from tv service.
225 * @param service_id The pointer to store service id
226 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
228 int tv_get_current_service_id(int *service_id)
232 if (!g_tv_info.live_svc) {
233 _ERR("failed to get live service");
237 r = tv_service_live_get_service_id(g_tv_info.live_svc, service_id);
238 if (r != TVS_ERROR_OK) {
239 _ERR("failed to get current service info");
249 * @param epg_list Eina_List to be freed
251 static void _tv_epg_del_list(Eina_List *epg_list)
253 struct tv_program_info *data;
255 EINA_LIST_FREE(epg_list, data)
260 * Callback function to get EPG program list from tv service.
262 * _tv_epg_event_cb is called from tv service when banner
263 * have requested to get program data.
264 * If this function is called, then derives program list from epg_list
265 * and calls banner's callback function which included in user_data.
267 * @param type Event type
268 * @param epg_list EPG program list
269 * @param user_data tv_program_request to handle request
271 static void _tv_epg_event_cb(tvs_epg_event_e type, GList *epg_list,
275 Eina_List *list = NULL;
276 TvServiceEpgEventData *epg_data;
277 struct tv_program_info *prog_info;
278 struct tv_program_request *request;
281 _ERR("failed to get user_data");
285 for (i = 0; i < g_list_length(epg_list); i++) {
286 epg_data = (TvServiceEpgEventData *)
287 g_list_nth_data(epg_list, i);
292 prog_info = _tv_get_program_info(epg_data);
294 list = eina_list_append(list, prog_info);
297 request = (struct tv_program_request *) user_data;
298 if (request->tv_program_cb)
299 request->tv_program_cb(list, request->user_data);
302 _tv_epg_del_list(list);
308 * Send a request to tv service to get a current program with supplied service_id.
310 * Beware that service_id should be current tuned channel.
311 * If not, calling this function may cause unexpected behavior.
312 * And note that get a EPG program is asynchronous operation.
313 * So tv_program_request should be supplied to get a result from tv service.
315 * @param service_id The channel id to get current program
316 * @param request The structure for return program data which contains function pointer
317 * and additional data for banner
318 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
320 int tv_epg_get_program(int service_id, struct tv_program_request *request)
324 if (!g_tv_info.epg_svc) {
325 _ERR("failed to get epg service");
330 _ERR("failed to get tv_program_request");
334 r = tv_service_epg_get_current_program(g_tv_info.epg_svc, service_id,
335 (TvServiceEpgCallback) _tv_epg_event_cb, request);
336 if (r != TVS_ERROR_OK) {
337 _ERR("failed to get epg get current program : %d", service_id);
346 * Gets a cached current program with supplied service_id from tv service.
348 * Note that this function is vaild only when tv service having a cached data
350 * To have a cached data, the channel ever been tuned before calling
353 * @param service_id The channel id to get current program
354 * @param request The structure for return program data which contains
355 * function pointer and additional data for banner
356 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
358 int tv_epg_get_cache_program(int service_id, struct tv_program_request *request)
360 Eina_List *list = NULL;
361 TvServiceEpgEventData epg_data;
362 struct tv_program_info *prog_info;
366 if (!g_tv_info.epg_svc) {
367 _ERR("failed to get epg service");
372 _ERR("failed to get tv_program_request");
376 r = tv_service_epg_get_cache_current_program(
377 g_tv_info.epg_svc, service_id, &epg_data);
378 if (r != TVS_ERROR_OK) {
379 _ERR("failed to get epg get cached current program : %d",
384 prog_info = _tv_get_program_info(&epg_data);
386 list = eina_list_append(list, prog_info);
388 if (request->tv_program_cb)
389 request->tv_program_cb(list, request->user_data);
392 _tv_epg_del_list(list);
400 * Sends a request to tv service to get programs with supplied service_id.
402 * Beware that service_id should be current tuned channel.
403 * If not, calling this function may cause unexpected behavior.
404 * And note that get a EPG program is asynchronous operation.
405 * So tv_program_request should be supplied to get a result from tv service.
407 * @param service_id The channel id to get current program
408 * @param request The structure for return program data which contains function pointer and additional data for banner
409 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
411 int tv_epg_get_program_list(int service_id,
412 struct tv_program_request *request)
416 if (!g_tv_info.epg_svc) {
417 _ERR("failed to get epg service");
422 _ERR("failed to get tv_program_request");
426 r = tv_service_epg_get_program_list(g_tv_info.epg_svc, service_id,
427 TVS_EPG_CURRENT_TIME, EPG_PROGRAM_OFFSET,
428 (TvServiceEpgCallback) _tv_epg_event_cb, request);
429 if (r != TVS_ERROR_OK) {
430 _ERR("failed to get epg get current program");
438 * Frees the TvServiceFilterNode.
440 * @param data TvServiceFilterNode pointer to be freed
442 static void _tv_channel_free_filter(gpointer data)
444 TvServiceFilterNode *filter_node;
449 filter_node = (TvServiceFilterNode *) data;
451 g_value_unset(filter_node->value);
452 g_free(filter_node->value);
457 * Gets a available channel list.
459 * Note that deleted channels and service channels are excluded by default.
461 * @return Available channel list, or NULL if fails
463 Eina_List *tv_channel_get_list()
465 GList *tvs_list = NULL;
466 Eina_List *channel_list = NULL;
467 TvServiceChannel *tvs_data = NULL;
468 const struct tv_channel_info *channel_info;
471 r = tv_service_get_channel_list(
472 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG,
473 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
474 if (r != TVS_ERROR_OK) {
475 _ERR("failed to get channel list");
479 for (i = 0; i < g_list_length(tvs_list); i++) {
480 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
482 channel_info = _tv_channel_get_info(tvs_data);
484 channel_list = eina_list_append(channel_list,
493 TvServiceFilterNode *_tv_channel_get_filter(
494 TvServiceChannelDataAttr attribute, int type, void *data)
496 TvServiceFilterNode *filter;
499 filter = g_malloc0(sizeof(*filter));
503 filter->attribute = attribute;
505 value = g_malloc0(sizeof(GValue));
513 g_value_init(value, G_TYPE_STRING);
514 g_value_set_string(value, data);
516 filter->match_type = CHANNEL_FILTER_MATCH_CONTAIN;
519 g_value_init(value, G_TYPE_INT);
520 g_value_set_int(value, (gint) data);
522 filter->match_type = CHANNEL_FILTER_MATCH_EQUAL;
525 filter->value = value;
531 * Search channels that are starts with supplied major and minor number.
533 * Note that deleted channels and service channels are excluded by default.
535 * @param major Major channel number to search
536 * @param minor Minor channel number to search
537 * @return Found channel list, or NULL if fails
539 Eina_List *tv_channel_search_by_number(long major, long minor)
541 char buf[CHANNEL_FILTER_STRING_MAX_LEN];
542 GList *tvs_list = NULL, *filter = NULL;
543 TvServiceFilterNode *filter_node;
544 TvServiceChannel *tvs_data;
545 Eina_List *channel_list = NULL;
546 const struct tv_channel_info *channel_info;
549 if (major > 0 && major < MAJOR_MAX) {
550 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", major);
552 filter_node = _tv_channel_get_filter(
553 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
556 filter = g_list_append(filter, (gpointer)filter_node);
559 if (minor > 0 && minor < MINOR_MAX) {
560 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", minor);
562 filter_node = _tv_channel_get_filter(
563 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
566 filter = g_list_append(filter, (gpointer)filter_node);
570 _ERR("failed to get filter");
574 r = tv_service_get_channel_list_ex(
575 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
576 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
577 if (r != TVS_ERROR_OK) {
578 _ERR("failed to get channel list");
582 for (i = 0; i < g_list_length(tvs_list); i++) {
583 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
587 channel_info = _tv_channel_get_info(tvs_data);
589 channel_list = eina_list_append(channel_list,
596 g_list_free(tvs_list);
598 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
605 * Frees the tv_channel_info.
607 * @param channel_list channel_list pointer to be freed
609 void tv_channel_del_list(Eina_List *channel_list)
611 struct tv_channel_info *data;
613 EINA_LIST_FREE(channel_list, data)
617 void _tv_channel_add_history(int service_id)
621 snprintf(buf, sizeof(buf), "%d", service_id);
622 app_contents_recent_add(CONTENTS_CHANNEL, buf);
626 * Tunes to specific channel with service id.
628 * @param service_id The channel id
629 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
631 int tv_channel_tune_with_service_id(int service_id)
635 if (!g_tv_info.live_svc) {
636 _ERR("failed to get live service");
640 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
641 if (r != TVS_ERROR_OK) {
642 _ERR("failed to set service");
646 _tv_channel_add_history(service_id);
648 g_tv_info.viewing_locked_channel = -1;
654 * Tunes to last viewed channel.
656 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
658 int tv_channel_tune(void)
663 if (!g_tv_info.live_svc) {
664 _ERR("failed to get live service");
668 r = tv_service_live_get_last_channel(&service_id);
670 _ERR("failed to get current service id");
671 service_id = DEFAULT_SERVICE;
674 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
675 if (r != TVS_ERROR_OK) {
676 _ERR("failed to set service");
680 _tv_channel_add_history(service_id);
682 g_tv_info.viewing_locked_channel = -1;
688 * Tunes to specific channel with major and minor.
690 * @param service_id The channel id
691 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
693 int tv_channel_direct_tune(long major, long minor)
695 GList *tvs_list = NULL, *filter = NULL;
696 TvServiceFilterNode *filter_node;
697 TvServiceChannel *tvs_data;
700 if (major > 0 && major < MAJOR_MAX) {
701 filter_node = _tv_channel_get_filter(
702 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
703 G_TYPE_INT, (void *) major);
705 filter = g_list_append(filter, (gpointer)filter_node);
708 if (minor > 0 && minor < MINOR_MAX) {
709 filter_node = _tv_channel_get_filter(
710 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
711 G_TYPE_INT, (void *) minor);
713 filter = g_list_append(filter, (gpointer)filter_node);
717 _ERR("failed to get filter");
721 r = tv_service_get_channel_list_ex(
722 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
723 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
724 if (r != TVS_ERROR_OK)
727 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, 0);
729 r = tv_channel_tune_with_service_id(tvs_data->service_id);
731 _ERR("failed to get tvs_data");
735 if (r == TVS_ERROR_OK)
736 g_tv_info.viewing_locked_channel = -1;
738 g_list_foreach(tvs_list, (GFunc) g_free, NULL);
739 g_list_free(tvs_list);
742 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
749 * Tunes to locked channel.
751 * @param service_id The channel id
752 * @param password 4 digit password
753 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
755 int tv_channel_tune_locked_channel(int service_id, char *password)
759 if (!g_tv_info.live_svc) {
760 _ERR("failed to get live service");
764 r = tv_service_live_tune_locked_channel(g_tv_info.live_svc,
765 service_id, password);
766 if (r != TVS_ERROR_OK) {
767 _ERR("failed to set service");
771 _tv_channel_add_history(service_id);
773 g_tv_info.viewing_locked_channel = service_id;
779 * Tunes to next channel.
781 * Note that deleted channels and service channels will skipped.
783 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
785 int tv_channel_next(void)
787 TvServiceAntenna antenna_type;
790 if (!g_tv_info.live_svc) {
791 _ERR("failed to get live service");
795 r = tv_service_live_get_antenna_type(g_tv_info.live_svc, &antenna_type);
797 _ERR("failed to get antenna type");
801 r = tv_service_live_tune_up(g_tv_info.live_svc,
802 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG, antenna_type);
804 _ERR("failed to tune up");
808 g_tv_info.viewing_locked_channel = -1;
810 r = tv_service_live_get_service_id(g_tv_info.live_svc, &service_id);
812 _ERR("failed to get service id");
816 _tv_channel_add_history(service_id);
822 * Tunes to previous channel.
824 * Note that deleted channels and service channels will skipped.
826 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
828 int tv_channel_prev(void)
830 TvServiceAntenna antenna_type;
833 if (!g_tv_info.live_svc) {
834 _ERR("failed to get live service");
838 r = tv_service_live_get_antenna_type(g_tv_info.live_svc, &antenna_type);
840 _ERR("failed to get antenna type");
844 r = tv_service_live_tune_down(g_tv_info.live_svc,
845 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG, antenna_type);
847 _ERR("failed to tune down");
851 g_tv_info.viewing_locked_channel = -1;
853 r = tv_service_live_get_service_id(g_tv_info.live_svc, &service_id);
855 _ERR("failed to get service id");
859 _tv_channel_add_history(service_id);
865 * Sets the channel's favorite status.
867 * @param service_id The channel id
868 * @param flag The value to be set
869 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
871 int tv_channel_set_favorite(int service_id, Eina_Bool flag)
876 r = tv_service_add_favorite_channel(service_id);
878 _ERR("failed to add favorite channel");
882 r = tv_service_delete_favorite_channel(service_id);
884 _ERR("failed to delete favorite channel");
895 * If channel is added, the channel will be included at
896 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
898 * @param service_id The channel id
899 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
901 int tv_channel_add_channel(int service_id)
905 r = tv_service_add_channel(service_id);
907 _ERR("failed to add channel");
915 * Deletes the channel.
917 * If channel is deleted, the channel will be omitted at
918 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
920 * @param service_id The channel id
921 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
923 int tv_channel_del_channel(int service_id)
927 r = tv_service_delete_channel(service_id);
929 _ERR("failed to delete channel");
939 * @param service_id The channel id
940 * @param password 4 digits password
941 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
943 int tv_channel_lock_channel(int service_id, char *password)
947 r = tv_service_lock_channel(service_id, password);
949 _ERR("failed to lock channel");
957 * Unlocks the channel.
959 * @param service_id The channel id
960 * @param password 4 digits password
961 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
963 int tv_channel_unlock_channel(int service_id, char *password)
967 r = tv_service_unlock_channel(service_id, password);
969 _ERR("failed to unlock channel");
977 * Callback function for receives tv service events.
979 * @param event Event type
980 * @param user_data Not in use
981 * @param data Event specific detailed data
983 void _tv_service_event_cb(TvServiceLiveEvent event,
984 gpointer user_data, const gpointer data)
986 gboolean *lock_status;
989 case TV_SERVICE_LIVE_EVENT_TUNER_LOCK:
991 _ERR("failed to get data");
995 lock_status = (gboolean *) data;
996 if (g_tv_info.signal_cb)
997 g_tv_info.signal_cb(g_tv_info.signal_cb_data,
1000 case TV_SERVICE_LIVE_EVENT_AUTO_DESTROY:
1001 g_tv_info.live_svc = NULL;
1003 case TV_SERVICE_LIVE_EVENT_RESOLUTION:
1004 case TV_SERVICE_LIVE_EVENT_BEGIN:
1005 case TV_SERVICE_LIVE_EVENT_CHANNEL_LOCK:
1006 case TV_SERVICE_LIVE_EVENT_CHANNEL_UNLOCK:
1012 * Sets tv signal callback function.
1014 * @param cb The function pointer to get callback
1015 * @param data An Additional data to passed to callback
1017 void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data)
1019 g_tv_info.signal_cb = cb;
1020 g_tv_info.signal_cb_data = data;
1024 * Sets window id for tv overlay.
1026 * @param window_id The window id to overlay
1027 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1029 int tv_overlay_set(void *window_id)
1033 if (!g_tv_info.live_svc) {
1034 _ERR("failed to get live service");
1038 r = tv_service_live_set_window_overlay(g_tv_info.live_svc, window_id);
1040 _ERR("failed to set overlay");
1048 * Destory the tv service handles.
1050 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1052 int tv_destroy(void)
1056 if (g_tv_info.live_svc) {
1057 r = tv_service_live_destroy(g_tv_info.live_svc);
1058 if (r != TVS_ERROR_OK)
1059 _ERR("failed to destroy live service");
1060 g_tv_info.live_svc = NULL;
1063 r = tv_service_channel_info_destroy();
1065 _ERR("failed to destroy channel info service");
1067 if (g_tv_info.epg_svc) {
1068 r = tv_service_epg_destroy(g_tv_info.epg_svc);
1070 _ERR("failed to destroy epg service");
1071 g_tv_info.epg_svc = NULL;
1078 * Create the tv service handles.
1080 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1086 r = tv_service_live_create(&g_tv_info.live_svc);
1087 if (r != TVS_ERROR_OK) {
1088 _ERR("failed to create live service");
1092 r = tv_service_live_register_callback(g_tv_info.live_svc,
1093 _tv_service_event_cb, NULL);
1094 if (r != TVS_ERROR_OK) {
1095 _ERR("failed to register live callback");
1099 r = tv_service_channel_info_create();
1100 if (r != TVS_ERROR_OK) {
1101 _ERR("failed to create channel info service");
1105 r = tv_service_epg_create(&g_tv_info.epg_svc);
1106 if (r != TVS_ERROR_OK) {
1107 _ERR("failed to create epg service");
1118 * Pause the tv service handles.
1120 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1126 if (g_tv_info.live_svc) {
1127 r = tv_service_live_destroy(g_tv_info.live_svc);
1128 if (r != TVS_ERROR_OK)
1129 _ERR("failed to destroy live service");
1130 g_tv_info.live_svc = NULL;
1137 * Resume the tv service handles.
1139 * Live service could be destroyed by tv service while app is pausing.
1140 * If live service is destroyed, then _tv_service_event_cb sets
1141 * g_tv_info.live_svc to NULL.
1142 * So if g_tv_info.live_svc is NULL, then recreates live service and returns 1.
1143 * Therefore, if tv_resume returns 1, then app needs to be set overlay and tune.
1144 * Or returns 0, then app just needs to set overlay.
1146 * @return 0 if successful; 1 if live service was destroyed; otherwise negative value is returned
1152 if (g_tv_info.live_svc)
1155 r = tv_service_live_create(&g_tv_info.live_svc);
1156 if (r != TVS_ERROR_OK) {
1157 _ERR("failed to create live service");
1161 r = tv_service_live_register_callback(g_tv_info.live_svc,
1162 _tv_service_event_cb, NULL);
1163 if (r != TVS_ERROR_OK) {
1164 _ERR("failed to register live callback");