This is an example of how to get notification when channel information change.
#include <glib-object.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <string.h>
#include <glib/gprintf.h>
#include "tv_service_logger.h"
static GMainLoop *loop = NULL;
gboolean
exit_loop(gpointer user_data)
{
g_main_loop_quit(loop);
return FALSE;
}
void
signal_handle(int signum)
{
g_printf ("In signal handle!\n");
if (g_scan_handle) {
g_scan_handle = NULL;
}
g_main_loop_quit(loop);
exit(0);
return;
}
static void
{
switch(type) {
g_printf ("scan event type: TVS_SCAN_EVENT_SEARCH_BEGIN\n");
g_printf (
"total air number: [%ld]\n",data ->data.
l[0]);
g_printf (
"total cable number: [%ld]\n", data->
data.
l[1]);
break;
g_printf ("scan event type: TVS_SCAN_EVENT_SEARCH_CHANNEL\n");
g_printf (
"channel number(PTC): [%ld]\n", data->
data.
l[0]);
g_printf (
"frequency: [%ld]\n", data->
data.
l[1]);
break;
g_printf ("scan event type: TVS_SCAN_EVENT_CHANNEL_FOUND\n");
g_printf (
"antenna type: [%d], digital type: [%d]\n", data->
data.
s[0], data->
data.
s[1]);
g_printf (
"atv channels: [%d], dtv channels: [%d]\n", data->
data.
s[2], data->
data.
s[3]);
break;
g_printf ("scan event type: TVS_SCAN_EVENT_SEARCH_FINISH\n");
g_printf (
"scan search finish type: [%ld]\n", data->
data.
l[0]);
g_scan_handle = NULL;
break;
}
}
static gboolean
channel_scan(gpointer user_data)
{
g_printf ("tv_service_scan_create fail !\n");
g_main_loop_quit(loop);
return FALSE;
}
g_printf ("tv_service_scan_start fail !\n");
g_main_loop_quit(loop);
return FALSE;
}
return FALSE;
}
void
{
printf (
"%ld""|", tvs_data->
major);
printf (
"%ld""|", tvs_data->
minor);
printf (
"%ld""|", tvs_data->
vpid);
printf (
"%ld""|", tvs_data->
apid);
printf (
"%d""|", tvs_data->
locked);
printf ("\n");
}
void
{
switch(event) {
{
GList *tvs_list = NULL;
gint index;
g_printf ("tv_service_callback: get channel callback, event:%d \n", event);
printf("tv_service_get_channel_list fail \n");
return;
} else {
printf("get channels, number[%d] \n", g_list_length(tvs_list));
printf("Serv ID|Fre|Ser Type|Cha Type|Sou ID|Pro Num|Str ID|Maj|Min|Vid Pid|Aud Pid|Loc|Rem|fav|Pro Name|Mod Type|Ant Mode|Vid Type|Aud Type\n");
for(index = 0; index < g_list_length(tvs_list); index++) {
if(p_tvs_data == NULL) {
TVS_LOGE("p_tvs_data is NULL\n");
return;
} else {
print_service(p_tvs_data);
}
}
}
}
break;
default:
g_printf ("get unknown callback_type: %d \n", event);
}
return;
}
int
main(int argc, char ** argv)
{
loop = g_main_loop_new (NULL, FALSE);
signal(SIGINT,signal_handle);
NULL);
g_timeout_add_seconds (1, channel_scan, NULL);
g_timeout_add_seconds (60, exit_loop, NULL);
g_main_loop_run (loop);
g_printf ("exit loop ###################################\n");
return 0;
}