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);
345 * Gets a cached current program with supplied service_id from tv service.
347 * Note that this function is vaild only when tv service having a cached data
349 * To have a cached data, the channel ever been tuned before calling
352 * @param service_id The channel id to get current program
353 * @param request The structure for return program data which contains
354 * function pointer and additional data for banner
355 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
357 int tv_epg_get_cache_program(int service_id, struct tv_program_request *request)
359 Eina_List *list = NULL;
360 TvServiceEpgEventData epg_data;
361 struct tv_program_info *prog_info;
365 if (!g_tv_info.epg_svc) {
366 _ERR("failed to get epg service");
371 _ERR("failed to get tv_program_request");
375 r = tv_service_epg_get_cache_current_program(
376 g_tv_info.epg_svc, service_id, &epg_data);
377 if (r != TVS_ERROR_OK) {
378 _ERR("failed to get epg get cached current program : %d",
383 prog_info = _tv_get_program_info(&epg_data);
385 list = eina_list_append(list, prog_info);
387 if (request->tv_program_cb)
388 request->tv_program_cb(list, request->user_data);
391 _tv_epg_del_list(list);
399 * Sends a request to tv service to get programs with supplied service_id.
401 * Beware that service_id should be current tuned channel.
402 * If not, calling this function may cause unexpected behavior.
403 * And note that get a EPG program is asynchronous operation.
404 * So tv_program_request should be supplied to get a result from tv service.
406 * @param service_id The channel id to get current program
407 * @param request The structure for return program data which contains function pointer and additional data for banner
408 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
410 int tv_epg_get_program_list(int service_id,
411 struct tv_program_request *request)
415 if (!g_tv_info.epg_svc) {
416 _ERR("failed to get epg service");
421 _ERR("failed to get tv_program_request");
425 r = tv_service_epg_get_program_list(g_tv_info.epg_svc, service_id,
426 TVS_EPG_CURRENT_TIME, EPG_PROGRAM_OFFSET,
427 (TvServiceEpgCallback) _tv_epg_event_cb, request);
428 if (r != TVS_ERROR_OK) {
429 _ERR("failed to get epg get current program");
437 * Frees the TvServiceFilterNode.
439 * @param data TvServiceFilterNode pointer to be freed
441 static void _tv_channel_free_filter(gpointer data)
443 TvServiceFilterNode *filter_node;
448 filter_node = (TvServiceFilterNode *) data;
450 g_value_unset(filter_node->value);
451 g_free(filter_node->value);
456 * Gets a available channel list.
458 * Note that deleted channels and service channels are excluded by default.
460 * @return Available channel list, or NULL if fails
462 Eina_List *tv_channel_get_list()
464 GList *tvs_list = NULL;
465 Eina_List *channel_list = NULL;
466 TvServiceChannel *tvs_data = NULL;
467 const struct tv_channel_info *channel_info;
470 r = tv_service_get_channel_list(
471 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG,
472 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
473 if (r != TVS_ERROR_OK) {
474 _ERR("failed to get channel list");
478 for (i = 0; i < g_list_length(tvs_list); i++) {
479 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
481 channel_info = _tv_channel_get_info(tvs_data);
483 channel_list = eina_list_append(channel_list,
492 TvServiceFilterNode *_tv_channel_get_filter(
493 TvServiceChannelDataAttr attribute, int type, void *data)
495 TvServiceFilterNode *filter;
498 filter = g_malloc0(sizeof(*filter));
502 filter->attribute = attribute;
504 value = g_malloc0(sizeof(GValue));
512 g_value_init(value, G_TYPE_STRING);
513 g_value_set_string(value, data);
515 filter->match_type = CHANNEL_FILTER_MATCH_CONTAIN;
518 g_value_init(value, G_TYPE_INT);
519 g_value_set_int(value, (gint) data);
521 filter->match_type = CHANNEL_FILTER_MATCH_EQUAL;
524 filter->value = value;
530 * Search channels that are starts with supplied major and minor number.
532 * Note that deleted channels and service channels are excluded by default.
534 * @param major Major channel number to search
535 * @param minor Minor channel number to search
536 * @return Found channel list, or NULL if fails
538 Eina_List *tv_channel_search_by_number(long major, long minor)
540 char buf[CHANNEL_FILTER_STRING_MAX_LEN];
541 GList *tvs_list = NULL, *filter = NULL;
542 TvServiceFilterNode *filter_node;
543 TvServiceChannel *tvs_data;
544 Eina_List *channel_list = NULL;
545 const struct tv_channel_info *channel_info;
548 if (major > 0 && major < MAJOR_MAX) {
549 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", major);
551 filter_node = _tv_channel_get_filter(
552 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
555 filter = g_list_append(filter, (gpointer)filter_node);
558 if (minor > 0 && minor < MINOR_MAX) {
559 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", minor);
561 filter_node = _tv_channel_get_filter(
562 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
565 filter = g_list_append(filter, (gpointer)filter_node);
569 _ERR("failed to get filter");
573 r = tv_service_get_channel_list_ex(
574 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
575 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
576 if (r != TVS_ERROR_OK) {
577 _ERR("failed to get channel list");
581 for (i = 0; i < g_list_length(tvs_list); i++) {
582 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
586 channel_info = _tv_channel_get_info(tvs_data);
588 channel_list = eina_list_append(channel_list,
595 g_list_free(tvs_list);
597 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
604 * Frees the tv_channel_info.
606 * @param channel_list channel_list pointer to be freed
608 void tv_channel_del_list(Eina_List *channel_list)
610 struct tv_channel_info *data;
612 EINA_LIST_FREE(channel_list, data)
616 void _tv_channel_add_history(int service_id)
620 snprintf(buf, sizeof(buf), "%d", service_id);
621 app_contents_recent_add(CONTENTS_CHANNEL, buf);
625 * Tunes to specific channel with service id.
627 * @param service_id The channel id
628 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
630 int tv_channel_tune_with_service_id(int service_id)
634 if (!g_tv_info.live_svc) {
635 _ERR("failed to get live service");
639 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
640 if (r != TVS_ERROR_OK) {
641 _ERR("failed to set service");
645 _tv_channel_add_history(service_id);
647 g_tv_info.viewing_locked_channel = -1;
653 * Tunes to last viewed channel.
655 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
657 int tv_channel_tune(void)
662 if (!g_tv_info.live_svc) {
663 _ERR("failed to get live service");
667 r = tv_service_live_get_last_channel(&service_id);
669 _ERR("failed to get current service id");
670 service_id = DEFAULT_SERVICE;
673 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
674 if (r != TVS_ERROR_OK) {
675 _ERR("failed to set service");
679 _tv_channel_add_history(service_id);
681 g_tv_info.viewing_locked_channel = -1;
687 * Tunes to specific channel with major and minor.
689 * @param service_id The channel id
690 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
692 int tv_channel_direct_tune(long major, long minor)
694 GList *tvs_list = NULL, *filter = NULL;
695 TvServiceFilterNode *filter_node;
696 TvServiceChannel *tvs_data;
699 if (major > 0 && major < MAJOR_MAX) {
700 filter_node = _tv_channel_get_filter(
701 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
702 G_TYPE_INT, (void *) major);
704 filter = g_list_append(filter, (gpointer)filter_node);
707 if (minor > 0 && minor < MINOR_MAX) {
708 filter_node = _tv_channel_get_filter(
709 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
710 G_TYPE_INT, (void *) minor);
712 filter = g_list_append(filter, (gpointer)filter_node);
716 _ERR("failed to get filter");
720 r = tv_service_get_channel_list_ex(
721 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
722 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
723 if (r != TVS_ERROR_OK)
726 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, 0);
728 r = tv_channel_tune_with_service_id(tvs_data->service_id);
730 _ERR("failed to get tvs_data");
734 if (r == TVS_ERROR_OK)
735 g_tv_info.viewing_locked_channel = -1;
737 g_list_foreach(tvs_list, (GFunc) g_free, NULL);
738 g_list_free(tvs_list);
741 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
748 * Tunes to locked channel.
750 * @param service_id The channel id
751 * @param password 4 digit password
752 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
754 int tv_channel_tune_locked_channel(int service_id, char *password)
758 if (!g_tv_info.live_svc) {
759 _ERR("failed to get live service");
763 r = tv_service_live_tune_locked_channel(g_tv_info.live_svc,
764 service_id, password);
765 if (r != TVS_ERROR_OK) {
766 _ERR("failed to set service");
770 _tv_channel_add_history(service_id);
772 g_tv_info.viewing_locked_channel = service_id;
778 * Tunes to next channel.
780 * Note that deleted channels and service channels will skipped.
782 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
784 int tv_channel_next(void)
786 TvServiceAntenna antenna_type;
789 if (!g_tv_info.live_svc) {
790 _ERR("failed to get live service");
794 r = tv_service_live_get_antenna_type(g_tv_info.live_svc, &antenna_type);
796 _ERR("failed to get antenna type");
800 r = tv_service_live_tune_up(g_tv_info.live_svc,
801 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG, antenna_type);
803 _ERR("failed to tune up");
807 g_tv_info.viewing_locked_channel = -1;
809 r = tv_service_live_get_service_id(g_tv_info.live_svc, &service_id);
811 _ERR("failed to get service id");
815 _tv_channel_add_history(service_id);
821 * Tunes to previous channel.
823 * Note that deleted channels and service channels will skipped.
825 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
827 int tv_channel_prev(void)
829 TvServiceAntenna antenna_type;
832 if (!g_tv_info.live_svc) {
833 _ERR("failed to get live service");
837 r = tv_service_live_get_antenna_type(g_tv_info.live_svc, &antenna_type);
839 _ERR("failed to get antenna type");
843 r = tv_service_live_tune_down(g_tv_info.live_svc,
844 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG, antenna_type);
846 _ERR("failed to tune down");
850 g_tv_info.viewing_locked_channel = -1;
852 r = tv_service_live_get_service_id(g_tv_info.live_svc, &service_id);
854 _ERR("failed to get service id");
858 _tv_channel_add_history(service_id);
864 * Sets the channel's favorite status.
866 * @param service_id The channel id
867 * @param flag The value to be set
868 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
870 int tv_channel_set_favorite(int service_id, Eina_Bool flag)
875 r = tv_service_add_favorite_channel(service_id);
877 _ERR("failed to add favorite channel");
881 r = tv_service_delete_favorite_channel(service_id);
883 _ERR("failed to delete favorite channel");
894 * If channel is added, the channel will be included at
895 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
897 * @param service_id The channel id
898 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
900 int tv_channel_add_channel(int service_id)
904 r = tv_service_add_channel(service_id);
906 _ERR("failed to add channel");
914 * Deletes the channel.
916 * If channel is deleted, the channel will be omitted at
917 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
919 * @param service_id The channel id
920 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
922 int tv_channel_del_channel(int service_id)
926 r = tv_service_delete_channel(service_id);
928 _ERR("failed to delete channel");
938 * @param service_id The channel id
939 * @param password 4 digits password
940 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
942 int tv_channel_lock_channel(int service_id, char *password)
946 r = tv_service_lock_channel(service_id, password);
948 _ERR("failed to lock channel");
956 * Unlocks the channel.
958 * @param service_id The channel id
959 * @param password 4 digits password
960 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
962 int tv_channel_unlock_channel(int service_id, char *password)
966 r = tv_service_unlock_channel(service_id, password);
968 _ERR("failed to unlock channel");
976 * Callback function for receives tv service events.
978 * @param event Event type
979 * @param user_data Not in use
980 * @param data Event specific detailed data
982 void _tv_service_event_cb(TvServiceLiveEvent event,
983 gpointer user_data, const gpointer data)
985 gboolean *lock_status;
988 case TV_SERVICE_LIVE_EVENT_TUNER_LOCK:
990 _ERR("failed to get data");
994 lock_status = (gboolean *) data;
995 if (g_tv_info.signal_cb)
996 g_tv_info.signal_cb(g_tv_info.signal_cb_data,
999 case TV_SERVICE_LIVE_EVENT_AUTO_DESTROY:
1000 g_tv_info.live_svc = NULL;
1002 case TV_SERVICE_LIVE_EVENT_RESOLUTION:
1003 case TV_SERVICE_LIVE_EVENT_BEGIN:
1004 case TV_SERVICE_LIVE_EVENT_CHANNEL_LOCK:
1005 case TV_SERVICE_LIVE_EVENT_CHANNEL_UNLOCK:
1011 * Sets tv signal callback function.
1013 * @param cb The function pointer to get callback
1014 * @param data An Additional data to passed to callback
1016 void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data)
1018 g_tv_info.signal_cb = cb;
1019 g_tv_info.signal_cb_data = data;
1023 * Sets window id for tv overlay.
1025 * @param window_id The window id to overlay
1026 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1028 int tv_overlay_set(void *window_id)
1032 if (!g_tv_info.live_svc) {
1033 _ERR("failed to get live service");
1037 r = tv_service_live_set_window_overlay(g_tv_info.live_svc, window_id);
1039 _ERR("failed to set overlay");
1047 * Destory the tv service handles.
1049 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1051 int tv_destroy(void)
1055 if (g_tv_info.live_svc) {
1056 r = tv_service_live_destroy(g_tv_info.live_svc);
1057 if (r != TVS_ERROR_OK)
1058 _ERR("failed to destroy live service");
1059 g_tv_info.live_svc = NULL;
1062 r = tv_service_channel_info_destroy();
1064 _ERR("failed to destroy channel info service");
1066 if (g_tv_info.epg_svc) {
1067 r = tv_service_epg_destroy(g_tv_info.epg_svc);
1069 _ERR("failed to destroy epg service");
1070 g_tv_info.epg_svc = NULL;
1077 * Create the tv service handles.
1079 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1085 r = tv_service_live_create(&g_tv_info.live_svc);
1086 if (r != TVS_ERROR_OK) {
1087 _ERR("failed to create live service");
1091 r = tv_service_live_register_callback(g_tv_info.live_svc,
1092 _tv_service_event_cb, NULL);
1093 if (r != TVS_ERROR_OK) {
1094 _ERR("failed to register live callback");
1098 r = tv_service_channel_info_create();
1099 if (r != TVS_ERROR_OK) {
1100 _ERR("failed to create channel info service");
1104 r = tv_service_epg_create(&g_tv_info.epg_svc);
1105 if (r != TVS_ERROR_OK) {
1106 _ERR("failed to create epg service");
1117 * Pause the tv service handles.
1119 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1127 * Resume the tv service handles.
1129 * Live service could be destroyed by tv service while app is pausing.
1130 * If live service is destroyed, then _tv_service_event_cb sets
1131 * g_tv_info.live_svc to NULL.
1132 * So if g_tv_info.live_svc is NULL, then recreates live service and returns 1.
1133 * Therefore, if tv_resume returns 1, then app needs to be set overlay and tune.
1134 * Or returns 0, then app just needs to set overlay.
1136 * @return 0 if successful; 1 if live service was destroyed; otherwise negative value is returned
1142 if (g_tv_info.live_svc)
1145 r = tv_service_live_create(&g_tv_info.live_svc);
1146 if (r != TVS_ERROR_OK) {
1147 _ERR("failed to create live service");
1151 r = tv_service_live_register_callback(g_tv_info.live_svc,
1152 _tv_service_event_cb, NULL);
1153 if (r != TVS_ERROR_OK) {
1154 _ERR("failed to register live callback");