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>
24 #include <tv_service_proxy.h>
25 #include <tv_service_proxy_epg.h>
28 #include <glib-object.h>
33 #define DEFAULT_SERVICE 1
35 struct _channel_history {
41 * The Storage structure to used by tv related functions and events.
44 /**< The handle to use tv service live api. */
45 TvServiceLive live_svc;
46 /**< The handle to use tv service epg api. */
49 /**< Stores service id if tune to locked channel was succeeded. */
50 int viewing_locked_channel;
51 /**< Stores previous service id. */
52 struct _channel_history history;
54 /**< The function pointer to pass tv signal event */
55 void (*signal_cb)(void *data, int is_signal);
56 /**< An Additional data to passed to tv signal event */
60 static struct _tv_info g_tv_info;
63 * Gets the tv_channel_info with supplied TvServiceChannel.
65 * Abstracts tv service data structure.
67 * @param channel The channel data defined by tv service
68 * @return Channel information, or NULL if fails
70 static struct tv_channel_info *_tv_channel_get_info(TvServiceChannel *channel)
72 struct tv_channel_info *channel_info = NULL;
75 _ERR("failed to get channel");
79 channel_info = calloc(1, sizeof(*channel_info));
81 _ERR("failed to calloc channel info");
85 channel_info->service_id = channel->service_id;
86 channel_info->channel_major = channel->major;
87 channel_info->channel_minor = channel->minor;
88 channel_info->channel_type = channel->channel_type;
89 channel_info->locked = channel->locked;
90 channel_info->digital = channel->digital;
91 channel_info->favorite = channel->favorite;
92 channel_info->remembered = channel->remembered;
93 strncpy(channel_info->channel_name, channel->program_name,
96 if (channel->service_id == g_tv_info.viewing_locked_channel)
97 channel_info->tune_locked = EINA_TRUE;
103 * Clones the tv_channel_info.
105 * @param channel_info tv_channel_info pointer to be cloned
106 * @return Channel information, or NULL if fails
108 const struct tv_channel_info *tv_channel_clone_info(
109 const struct tv_channel_info *channel_info)
111 struct tv_channel_info *new_channel_info = NULL;
114 _ERR("failed to get channel info");
118 new_channel_info = calloc(1, sizeof(*channel_info));
119 if (!new_channel_info) {
120 _ERR("failed to calloc channel info");
124 memcpy(new_channel_info, channel_info, sizeof(*new_channel_info));
126 return new_channel_info;
130 * Frees the tv_channel_info.
132 * @param channel_info tv_channel_info pointer to be freed
134 void tv_channel_del_info(const struct tv_channel_info *channel_info)
137 _ERR("failed to get channel info");
141 free((void *)channel_info);
145 * Gets current channel's TvServiceChannel data from tv service.
147 * @param channel The pointer to store TvServiceChannel
148 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
150 static int _tv_get_channel(TvServiceChannel *channel)
155 if (!g_tv_info.live_svc) {
156 _ERR("failed to get live service");
160 r = tv_service_live_get_service_id(g_tv_info.live_svc, &svc_id);
162 _ERR("failed to get service id");
166 r = tv_service_get_channel(svc_id, channel);
168 _ERR("failed to get channel");
176 * Returns current channel's info.
178 * tv_channel_get_info retrieves current channel's information
181 * @return Returns current channel info, or NULL if fails
183 const struct tv_channel_info *tv_channel_get_info(void)
185 const struct tv_channel_info *channel_info;
186 TvServiceChannel channel;
189 r = _tv_get_channel(&channel);
191 _ERR("failed to get channel");
195 channel_info = _tv_channel_get_info(&channel);
201 * Returns tv_program_info with supplied TvServiceEpgEventData.
203 * Abstracts tv service data structure.
205 * @param prog TvServiceEpgEventData passed from tv service
206 * @return Returns tv_program_info, or NULL if fails
208 static struct tv_program_info *_tv_get_program_info(TvServiceEpgEventData *prog)
210 struct tv_program_info *prog_info;
212 prog_info = calloc(1, sizeof(*prog_info));
214 _ERR("failed to calloc program info");
218 prog_info->service_id = prog->service_id;
219 prog_info->start_time = prog->start_time;
220 prog_info->end_time = prog->start_time + prog->length_in_seconds;
221 prog_info->duration = prog->length_in_seconds;
222 prog_info->current_time = prog->current_time;
223 strncpy(prog_info->prog_title, (char *)prog->title_text,
224 sizeof(prog_info->prog_title) - 1);
225 strncpy(prog_info->prog_description, (char *)prog->extended_text,
226 sizeof(prog_info->prog_description) - 1);
232 * Gets current channel's service id from tv service.
234 * @param service_id The pointer to store service id
235 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
237 int tv_get_current_service_id(int *service_id)
241 if (!g_tv_info.live_svc) {
242 _ERR("failed to get live service");
246 r = tv_service_live_get_service_id(g_tv_info.live_svc, service_id);
247 if (r != TVS_ERROR_OK) {
248 _ERR("failed to get current service info");
258 * @param epg_list Eina_List to be freed
260 static void _tv_epg_del_list(Eina_List *epg_list)
262 struct tv_program_info *data;
264 EINA_LIST_FREE(epg_list, data)
269 * Callback function to get EPG program list from tv service.
271 * _tv_epg_event_cb is called from tv service when banner
272 * have requested to get program data.
273 * If this function is called, then derives program list from epg_list
274 * and calls banner's callback function which included in user_data.
276 * @param type Event type
277 * @param epg_list EPG program list
278 * @param user_data tv_program_request to handle request
280 static void _tv_epg_event_cb(tvs_epg_event_e type, GList *epg_list,
284 Eina_List *list = NULL;
285 TvServiceEpgEventData *epg_data;
286 struct tv_program_info *prog_info;
287 struct tv_program_request *request;
290 _ERR("failed to get user_data");
294 for (i = 0; i < g_list_length(epg_list); i++) {
295 epg_data = (TvServiceEpgEventData *)
296 g_list_nth_data(epg_list, i);
301 prog_info = _tv_get_program_info(epg_data);
303 list = eina_list_append(list, prog_info);
306 request = (struct tv_program_request *) user_data;
307 if (request->tv_program_cb)
308 request->tv_program_cb(list, request->user_data);
311 _tv_epg_del_list(list);
317 * Send a request to tv service to get a current program with supplied service_id.
319 * Beware that service_id should be current tuned channel.
320 * If not, calling this function may cause unexpected behavior.
321 * And note that get a EPG program is asynchronous operation.
322 * So tv_program_request should be supplied to get a result from tv service.
324 * @param service_id The channel id to get current program
325 * @param request The structure for return program data which contains function pointer
326 * and additional data for banner
327 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
329 int tv_epg_get_program(int service_id, struct tv_program_request *request)
333 if (!g_tv_info.epg_svc) {
334 _ERR("failed to get epg service");
339 _ERR("failed to get tv_program_request");
343 r = tv_service_epg_get_current_program(g_tv_info.epg_svc, service_id,
344 (TvServiceEpgCallback) _tv_epg_event_cb, request);
345 if (r != TVS_ERROR_OK) {
346 _ERR("failed to get epg get current program : %d", service_id);
355 * Gets a cached current program with supplied service_id from tv service.
357 * Note that this function is vaild only when tv service having a cached data
359 * To have a cached data, the channel ever been tuned before calling
362 * @param service_id The channel id to get current program
363 * @param request The structure for return program data which contains
364 * function pointer and additional data for banner
365 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
367 int tv_epg_get_cache_program(int service_id, struct tv_program_request *request)
369 Eina_List *list = NULL;
370 TvServiceEpgEventData epg_data;
371 struct tv_program_info *prog_info;
375 if (!g_tv_info.epg_svc) {
376 _ERR("failed to get epg service");
381 _ERR("failed to get tv_program_request");
385 r = tv_service_epg_get_cache_current_program(
386 g_tv_info.epg_svc, service_id, &epg_data);
387 if (r != TVS_ERROR_OK) {
388 _ERR("failed to get epg get cached current program : %d",
393 prog_info = _tv_get_program_info(&epg_data);
395 list = eina_list_append(list, prog_info);
397 if (request->tv_program_cb)
398 request->tv_program_cb(list, request->user_data);
401 _tv_epg_del_list(list);
409 * Sends a request to tv service to get programs with supplied service_id.
411 * Beware that service_id should be current tuned channel.
412 * If not, calling this function may cause unexpected behavior.
413 * And note that get a EPG program is asynchronous operation.
414 * So tv_program_request should be supplied to get a result from tv service.
416 * @param service_id The channel id to get current program
417 * @param request The structure for return program data which contains function pointer and additional data for banner
418 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
420 int tv_epg_get_program_list(int service_id,
421 struct tv_program_request *request)
425 if (!g_tv_info.epg_svc) {
426 _ERR("failed to get epg service");
431 _ERR("failed to get tv_program_request");
435 r = tv_service_epg_get_program_list(g_tv_info.epg_svc, service_id,
436 TVS_EPG_CURRENT_TIME, EPG_PROGRAM_OFFSET,
437 (TvServiceEpgCallback) _tv_epg_event_cb, request);
438 if (r != TVS_ERROR_OK) {
439 _ERR("failed to get epg get current program");
447 * Frees the TvServiceFilterNode.
449 * @param data TvServiceFilterNode pointer to be freed
451 static void _tv_channel_free_filter(gpointer data)
453 TvServiceFilterNode *filter_node;
458 filter_node = (TvServiceFilterNode *) data;
460 g_value_unset(filter_node->value);
461 g_free(filter_node->value);
466 * Gets a available channel list.
468 * Note that deleted channels and service channels are excluded by default.
470 * @return Available channel list, or NULL if fails
472 Eina_List *tv_channel_get_list()
474 GList *tvs_list = NULL;
475 Eina_List *channel_list = NULL;
476 TvServiceChannel *tvs_data = NULL;
477 const struct tv_channel_info *channel_info;
480 r = tv_service_get_channel_list(
481 TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG,
482 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
483 if (r != TVS_ERROR_OK) {
484 _ERR("failed to get channel list");
488 for (i = 0; i < g_list_length(tvs_list); i++) {
489 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
491 channel_info = _tv_channel_get_info(tvs_data);
493 channel_list = eina_list_append(channel_list,
503 * Gets a favorite channel list.
505 * @return Favorite channel list, or NULL if fails
507 Eina_List *tv_channel_get_favorite_list()
509 GList *tvs_list = NULL;
510 Eina_List *channel_list = NULL;
511 TvServiceChannel *tvs_data = NULL;
512 const struct tv_channel_info *channel_info;
515 r = tv_service_get_channel_list(
516 TV_SERVICE_CHANNEL_MODE_FAVORITE,
517 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
518 if (r != TVS_ERROR_OK) {
519 _ERR("failed to get channel list");
523 for (i = 0; i < g_list_length(tvs_list); i++) {
524 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
526 channel_info = _tv_channel_get_info(tvs_data);
528 channel_list = eina_list_append(channel_list,
537 TvServiceFilterNode *_tv_channel_get_filter(
538 TvServiceChannelDataAttr attribute, int type, void *data)
540 TvServiceFilterNode *filter;
543 filter = g_malloc0(sizeof(*filter));
547 filter->attribute = attribute;
549 value = g_malloc0(sizeof(GValue));
557 g_value_init(value, G_TYPE_STRING);
558 g_value_set_string(value, data);
560 filter->match_type = CHANNEL_FILTER_MATCH_CONTAIN;
563 g_value_init(value, G_TYPE_INT);
564 g_value_set_int(value, (gint) data);
566 filter->match_type = CHANNEL_FILTER_MATCH_EQUAL;
569 filter->value = value;
575 * Search channels that are starts with supplied major and minor number.
577 * Note that deleted channels and service channels are excluded by default.
579 * @param major Major channel number to search
580 * @param minor Minor channel number to search
581 * @return Found channel list, or NULL if fails
583 Eina_List *tv_channel_search_by_number(long major, long minor)
585 char buf[CHANNEL_FILTER_STRING_MAX_LEN];
586 GList *tvs_list = NULL, *filter = NULL;
587 TvServiceFilterNode *filter_node;
588 TvServiceChannel *tvs_data;
589 Eina_List *channel_list = NULL;
590 const struct tv_channel_info *channel_info;
593 if (major > 0 && major < MAJOR_MAX) {
594 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", major);
596 filter_node = _tv_channel_get_filter(
597 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
600 filter = g_list_append(filter, (gpointer)filter_node);
603 if (minor > 0 && minor < MINOR_MAX) {
604 snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", minor);
606 filter_node = _tv_channel_get_filter(
607 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
610 filter = g_list_append(filter, (gpointer)filter_node);
614 _ERR("failed to get filter");
618 r = tv_service_get_channel_list_ex(
619 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
620 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
621 if (r != TVS_ERROR_OK) {
622 _ERR("failed to get channel list");
626 for (i = 0; i < g_list_length(tvs_list); i++) {
627 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
631 channel_info = _tv_channel_get_info(tvs_data);
633 channel_list = eina_list_append(channel_list,
640 g_list_free(tvs_list);
642 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
649 * Frees the tv_channel_info.
651 * @param channel_list channel_list pointer to be freed
653 void tv_channel_del_list(Eina_List *channel_list)
655 struct tv_channel_info *data;
657 EINA_LIST_FREE(channel_list, data)
661 static void _tv_channel_add_history(int service_id)
665 g_tv_info.history.service_id[g_tv_info.history.idx++ % 2]
668 snprintf(buf, sizeof(buf), "%d", service_id);
669 app_contents_recent_add(CONTENTS_CHANNEL, buf);
672 static int _tv_channel_get_history(void)
676 service_id = g_tv_info.history.service_id[g_tv_info.history.idx % 2];
682 * Tunes to specific channel with service id.
684 * @param service_id The channel id
685 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
687 int tv_channel_tune_with_service_id(int service_id)
691 if (!g_tv_info.live_svc) {
692 _ERR("failed to get live service");
696 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
697 if (r != TVS_ERROR_OK) {
698 _ERR("failed to set service");
702 _tv_channel_add_history(service_id);
704 g_tv_info.viewing_locked_channel = -1;
710 * Tunes to last viewed channel.
712 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
714 int tv_channel_tune(void)
719 if (!g_tv_info.live_svc) {
720 _ERR("failed to get live service");
724 r = tv_service_live_get_last_channel(&service_id);
725 if (r < 0 || service_id < 1) {
726 _ERR("failed to get current service id");
727 service_id = DEFAULT_SERVICE;
730 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
731 if (r != TVS_ERROR_OK) {
732 _ERR("failed to set service");
736 _tv_channel_add_history(service_id);
738 g_tv_info.viewing_locked_channel = -1;
744 * Tunes to previously viewed channel.
746 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
748 int tv_channel_tune_prev_channel(void)
753 if (!g_tv_info.live_svc) {
754 _ERR("failed to get live service");
758 service_id = _tv_channel_get_history();
759 if (service_id < 1) {
760 _ERR("no previous channel");
764 r = tv_service_live_tune(g_tv_info.live_svc, service_id);
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 = -1;
778 * Tunes to specific channel with major and minor.
780 * @param service_id The channel id
781 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
783 int tv_channel_direct_tune(long major, long minor)
785 GList *tvs_list = NULL, *filter = NULL;
786 TvServiceFilterNode *filter_node;
787 TvServiceChannel *tvs_data;
790 if (!g_tv_info.live_svc) {
791 _ERR("failed to get live service");
795 if (major > 0 && major < MAJOR_MAX) {
796 filter_node = _tv_channel_get_filter(
797 TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
798 G_TYPE_INT, (void *) major);
800 filter = g_list_append(filter, (gpointer)filter_node);
803 if (minor > 0 && minor < MINOR_MAX) {
804 filter_node = _tv_channel_get_filter(
805 TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
806 G_TYPE_INT, (void *) minor);
808 filter = g_list_append(filter, (gpointer)filter_node);
812 _ERR("failed to get filter");
816 r = tv_service_get_channel_list_ex(
817 TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
818 TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
819 if (r != TVS_ERROR_OK)
822 tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, 0);
824 r = tv_channel_tune_with_service_id(tvs_data->service_id);
826 _ERR("failed to get tvs_data");
830 if (r == TVS_ERROR_OK)
831 g_tv_info.viewing_locked_channel = -1;
833 g_list_foreach(tvs_list, (GFunc) g_free, NULL);
834 g_list_free(tvs_list);
837 g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
844 * Tunes to locked channel.
846 * @param service_id The channel id
847 * @param password 4 digit password
848 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
850 int tv_channel_tune_locked_channel(int service_id, char *password)
854 if (!g_tv_info.live_svc) {
855 _ERR("failed to get live service");
859 r = tv_service_live_tune_locked_channel(g_tv_info.live_svc,
860 service_id, password);
861 if (r != TVS_ERROR_OK) {
862 _ERR("failed to set service");
866 _tv_channel_add_history(service_id);
868 g_tv_info.viewing_locked_channel = service_id;
874 * Sets the channel's favorite status.
876 * @param service_id The channel id
877 * @param flag The value to be set
878 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
880 int tv_channel_set_favorite(int service_id, Eina_Bool flag)
885 r = tv_service_add_favorite_channel(service_id);
887 _ERR("failed to add favorite channel");
891 r = tv_service_delete_favorite_channel(service_id);
893 _ERR("failed to delete favorite channel");
904 * If channel is added, the channel will be included at
905 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
907 * @param service_id The channel id
908 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
910 int tv_channel_add_channel(int service_id)
914 r = tv_service_add_channel(service_id);
916 _ERR("failed to add channel");
924 * Deletes the channel.
926 * If channel is deleted, the channel will be omitted at
927 * tv_channel_next, tv_channel_prev and tv_channel_get_list.
929 * @param service_id The channel id
930 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
932 int tv_channel_del_channel(int service_id)
936 r = tv_service_delete_channel(service_id);
938 _ERR("failed to delete channel");
948 * @param service_id The channel id
949 * @param password 4 digits password
950 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
952 int tv_channel_lock_channel(int service_id, char *password)
956 r = tv_service_lock_channel(service_id, password);
958 _ERR("failed to lock channel");
966 * Unlocks the channel.
968 * @param service_id The channel id
969 * @param password 4 digits password
970 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
972 int tv_channel_unlock_channel(int service_id, char *password)
976 r = tv_service_unlock_channel(service_id, password);
978 _ERR("failed to unlock channel");
986 * Callback function for receives tv service events.
988 * @param event Event type
989 * @param user_data Not in use
990 * @param data Event specific detailed data
992 void _tv_service_event_cb(TvServiceLiveEvent event,
993 gpointer user_data, const gpointer data)
995 gboolean *lock_status;
998 case TV_SERVICE_LIVE_EVENT_TUNER_LOCK:
1000 _ERR("failed to get data");
1004 lock_status = (gboolean *) data;
1005 if (g_tv_info.signal_cb)
1006 g_tv_info.signal_cb(g_tv_info.signal_cb_data,
1009 case TV_SERVICE_LIVE_EVENT_AUTO_DESTROY:
1010 g_tv_info.live_svc = NULL;
1012 case TV_SERVICE_LIVE_EVENT_RESOLUTION:
1013 case TV_SERVICE_LIVE_EVENT_BEGIN:
1014 case TV_SERVICE_LIVE_EVENT_CHANNEL_LOCK:
1015 case TV_SERVICE_LIVE_EVENT_CHANNEL_UNLOCK:
1021 * Sets tv signal callback function.
1023 * @param cb The function pointer to get callback
1024 * @param data An Additional data to passed to callback
1026 void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data)
1028 g_tv_info.signal_cb = cb;
1029 g_tv_info.signal_cb_data = data;
1033 * Destory the tv service handles.
1035 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1037 int tv_destroy(void)
1041 if (g_tv_info.live_svc)
1042 g_tv_info.live_svc = NULL;
1044 r = tv_service_channel_info_destroy();
1046 _ERR("failed to destroy channel info service");
1048 if (g_tv_info.epg_svc) {
1049 r = tv_service_epg_destroy(g_tv_info.epg_svc);
1051 _ERR("failed to destroy epg service");
1052 g_tv_info.epg_svc = NULL;
1059 * Create the tv service handles.
1061 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1067 r = tv_service_live_create(&g_tv_info.live_svc);
1068 if (r != TVS_ERROR_OK) {
1069 _ERR("failed to create live service");
1073 r = tv_service_live_register_callback(g_tv_info.live_svc,
1074 _tv_service_event_cb, NULL);
1075 if (r != TVS_ERROR_OK) {
1076 _ERR("failed to register live callback");
1080 r = tv_service_channel_info_create();
1081 if (r != TVS_ERROR_OK) {
1082 _ERR("failed to create channel info service");
1086 r = tv_service_epg_create(&g_tv_info.epg_svc);
1087 if (r != TVS_ERROR_OK) {
1088 _ERR("failed to create epg service");
1092 memset(&g_tv_info.history, 0, sizeof(g_tv_info.history));
1101 * Pause the tv service handles.
1103 * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
1109 if (g_tv_info.live_svc) {
1110 r = tv_service_live_tune_pause(g_tv_info.live_svc);
1111 if (r != TVS_ERROR_OK)
1112 _ERR("failed to pause live service");
1119 * Resume the tv service handles.
1121 * Live service could be destroyed by tv service while app is pausing.
1122 * If live service is destroyed, then _tv_service_event_cb sets
1123 * g_tv_info.live_svc to NULL.
1124 * So if g_tv_info.live_svc is NULL, then recreates live service and returns 1.
1125 * Therefore, if tv_resume returns 1, then app needs to be set overlay and tune.
1126 * Or returns 0, then app just needs to set overlay.
1128 * @return 0 if successful; 1 if live service was destroyed; otherwise negative value is returned
1134 if (!g_tv_info.live_svc) {
1135 r = tv_service_live_create(&g_tv_info.live_svc);
1136 if (r != TVS_ERROR_OK) {
1137 _ERR("failed to create live service");
1141 r = tv_service_live_register_callback(g_tv_info.live_svc,
1142 _tv_service_event_cb, NULL);
1143 if (r != TVS_ERROR_OK) {
1144 _ERR("failed to register live callback");
1151 r = tv_service_live_tune_resume(g_tv_info.live_svc);
1152 if (r != TVS_ERROR_OK) {
1153 _ERR("failed to create live service");
1157 r = tv_service_live_register_callback(g_tv_info.live_svc,
1158 _tv_service_event_cb, NULL);
1159 if (r != TVS_ERROR_OK) {
1160 _ERR("failed to register live callback");