This is an example of how to tune channel by TV Service's Live APIs.
#include <signal.h>
#include <stdlib.h>
#include <time.h>
#include <glib/gprintf.h>
#include "tv_service_logger.h"
typedef struct _Params {
gint service_id;
gint antenna_type;
gint channel_mode;
char password[20];
} Params;
static GMainLoop *loop = NULL;
Params p;
void
print_usage ()
{
g_printf ("test_type: -s set service id and set tune.\n");
g_printf ("i.e) tv-service-live-tune-test {service_id} {antenna_type} {channel_mode} {password}\n");
return;
}
gboolean
exit_loop (gpointer user_data)
{
g_main_loop_quit (loop);
return FALSE;
}
static void
{
switch (event) {
{
gboolean *lock_status = (gboolean*) data;
g_printf ("tv_service_callback: get tuner locked callback:%d\n", *lock_status);
}
break;
g_printf ("event channel lock\n");
break;
g_printf ("event channel unlock\n");
break;
g_printf ("event auto destroy\n");
live_handle = NULL;
exit_loop (NULL);
break;
default:
g_printf ("get callback_type: %d\n", event);
}
return;
}
gboolean
init ()
{
g_printf ("tv_service_live_create failed!\n");
return FALSE;
}
g_printf ("tv_service_live_register_callback failed\n");
return FALSE;
}
return TRUE;
}
void
live_tune_locked_channel (gpointer user_data)
{
if (!init()) {
g_printf ("init failed\n");
return;
}
g_printf("tv_service_live_tune_locked_channel failed!\n");
return;
}
}
gboolean
live_tune (gpointer user_data)
{
if (!init()) {
g_printf ("init failed\n");
return FALSE;
}
g_printf("tv_service_live_tune failed!\n");
return FALSE;
}
return FALSE;
}
gboolean
live_set_antenna_type (gpointer user_data)
{
if (!init()) {
g_printf ("init failed\n");
return FALSE;
}
g_printf("tv_service_live_set_antenna_type failed!\n");
return FALSE;
}
return FALSE;
}
gboolean
live_tune_up (gpointer user_data)
{
g_printf("tv_service_live_tune_up failed!\n");
return FALSE;
}
return FALSE;
}
gboolean
live_tune_down (gpointer user_data)
{
g_printf("tv_service_live_tune_down failed!\n");
return FALSE;
}
return FALSE;
}
gboolean
live_destroy (gpointer user_data)
{
g_printf("tv_service_live_destroy failed!\n");
return FALSE;
}
return FALSE;
}
void
signal_handle (int signum)
{
g_printf ("In signal handle!\n");
if (live_handle)
g_main_loop_quit (loop);
exit (0);
return;
}
int
main (int argc, char ** argv)
{
loop = g_main_loop_new (NULL, FALSE);
if (argc == 5) {
p.service_id = atoi (argv[1]);
p.antenna_type = atoi (argv[2]);
p.channel_mode = atoi (argv[3]);
memcpy (p.password, argv[4], strlen(argv[4]));
g_printf ("password = %s\n", p.password);
} else {
print_usage ();
return -1;
}
live_tune_locked_channel(NULL);
g_timeout_add_seconds (5, live_destroy, NULL);
g_timeout_add_seconds (7, live_set_antenna_type, NULL);
g_timeout_add_seconds (12, live_destroy, NULL);
g_timeout_add_seconds (14, live_tune, NULL);
g_timeout_add_seconds (19, live_tune_up, NULL);
g_timeout_add_seconds (24, live_tune_down, NULL);
g_timeout_add_seconds (29, live_destroy, NULL);
g_timeout_add_seconds (30, exit_loop, NULL);
g_main_loop_run (loop);
g_printf ("exit loop ###################################");
return 0;
}