This is an example of how to use the TV Service's Live APIs.
#include <signal.h>
#include <stdlib.h>
#include <time.h>
#include <glib/gprintf.h>
#include "tv_service_logger.h"
static GMainLoop *loop = NULL;
gint temp_freq = 0;
gint temp_mod = 0;
gint apid = 0;
gint vpid = 0;
gint ppid = 0;
gint change_freq = 0;
gint change_mod = 0;
gint change_apid = 0;
gint change_vpid = 0;
gint change_ppid = 0;
gint pro_num = 0;
gint change_pro_num = 0;
gint audio_mute;
gint video_mute;
gint tune_type = 0;
gboolean
exit_loop (gpointer user_data)
{
printf ("EXIT LOOP!!!!!!!!!!!\n");
if (live_handle) {
}
g_main_loop_quit (loop);
return FALSE;
}
gboolean
change_video_mute (gpointer user_data)
{
gboolean mute = FALSE;
printf ("tv_service_live_get_video_mute before setting = %d\n", mute);
printf ("tv_service_live_get_video_mute after setting = %d\n", mute);
if (video_mute == TRUE) {
video_mute = FALSE;
}
return FALSE;
}
gboolean
change_audio_mute (gpointer user_data)
{
gint res;
printf ("Before tv_service_live_set_audio_mute, mute[%d]\n", audio_mute);
printf ("ERROR !!! tv_service_live_set_audio_mute fail!\n");
return FALSE;
}
gboolean mute_temp = FALSE;
printf ("After tv_service_live_set_audio_mute[%d], tv_service_live_get_audio_mute = [%d]\n", audio_mute, mute_temp);
if (audio_mute == TRUE) {
audio_mute = FALSE;
}
return FALSE;
}
gboolean
change_audio_volume(gpointer user_data)
{
gdouble volume = 0;
gint res;
printf ("ERROR !!! tv_service_live_get_volume fail!\n");
return FALSE;
}
printf ("tv_service_live_get_volume = %lf\n", volume);
printf ("Before tv_service_live_set_volume, volume[%lf]\n", volume);
printf ("ERROR !!! tv_service_live_set_volume fail!\n");
return FALSE;
}
return FALSE;
}
gboolean
change_channel (gpointer user_data)
{
if (tune_type == 0) {
printf ("change_channel, handle:%p, freq:%d, mod:%d, apid:%d, vpid:%d, ppid:%d\n",\
live_handle, change_freq, change_mod, change_apid, change_vpid, change_ppid);
printf ("ERROR !!! In main tv_service_live_tune_full failed!\n");
return FALSE;
}
} else if (tune_type == 1) {
printf ("change_channel, handle:%p, freq:%d, mod:%d, pro_number:%d\n",\
live_handle, change_freq, change_mod, change_pro_num);
printf ("ERROR !!! In main tv_service_live_tune_by_program_number failed!\n");
return FALSE;
}
}
printf ("change_channel finish\n");
return FALSE;
}
gboolean
__tune_pause(gpointer user_data){
}
gboolean
__tune_resume(gpointer user_data){
}
gboolean
live_tune_by_program_number (gpointer user_data)
{
printf ("Before tv_service_live_tune_by_program_number, handle:%p, freq:%d, mod:%d, pro_num:%d\n",\
live_handle, temp_freq, temp_mod, pro_num);
printf ("ERROR !!! tv_service_live_tune_by_program_number failed!\n");
return FALSE;
}
return FALSE;
}
static void
{
switch (event) {
{
gboolean *lock_status = (gboolean *)data;
printf ("tv_service_callback: get tuner locked callback:%d\n", *lock_status);
}
break;
{
printf (
"tv_service_callback: set resolution width:%d,height:%d\n", res_data->
width,res_data->
height);
}
break;
printf ("event channel lock\n");
break;
printf ("event channel unlock\n");
break;
printf ("event auto destroy\n");
live_handle = NULL;
exit_loop (NULL);
break;
default:
printf ("get callback_type: %d\n", event);
}
return;
}
void
signal_handle (int signum)
{
printf ("In signal handle!\n");
if (live_handle) {
}
g_main_loop_quit (loop);
exit (0);
return;
}
int
main (int argc, char ** argv)
{
int isSimpleTest = 0;
int isServiceIDTest = 0;
int service_id = 0;
if (argc == 13) {
temp_freq = atoi (argv[1]);
temp_mod = atoi (argv[2]);
vpid = atoi (argv[3]);
apid = atoi (argv[4]);
ppid = atoi (argv[5]);
change_freq = atoi (argv[6]);
change_mod = atoi (argv[7]);
change_vpid = atoi (argv[8]);
change_apid = atoi (argv[9]);
change_ppid = atoi (argv[10]);
pro_num = atoi (argv[11]);
change_pro_num= atoi (argv[12]);
} else if (argc == 6){
temp_freq = atoi (argv[1]);
temp_mod = atoi (argv[2]);
vpid = atoi (argv[3]);
apid = atoi (argv[4]);
ppid = atoi (argv[5]);
isSimpleTest = 1;
} else if (argc == 3){
isServiceIDTest = 1;
service_id = atoi (argv[2]);
printf("This is tune test by service id \n");
printf("service id is %d\n", service_id);
} else if (argc == 4){
isServiceIDTest = 2;
service_id = atoi (argv[2]);
printf("This is tune pause resume test by service id \n");
printf("service id is %d\n", service_id);
} else if (argc == 2){
int input_value = atoi(argv[1]);
printf("This is vconf test\n");
printf("test value is %d\n",input_value);
if(!tv_service_vconf_set_last_channel(input_value))
printf("Fail to set vconf\n");
int value = 0;
if(!tv_service_vconf_get_last_channel(&value))
printf("Fail to get vconf\n");
else
printf("Vconf value is %d\n", value);
return -1;
} else {
printf("usage : tv-service-live-test 485000000 7 17 20 16 473000000 7 17 20 16 1 2\n");
return -1;
}
loop = g_main_loop_new (NULL, FALSE);
printf ("ERROR !!! tv_service_live_create failed!\n");
return -1;
}
printf ("After tv_service_live_create\n");
printf ("After tv_service_live_register_callback\n");
if(isServiceIDTest == 1){
printf ("ERROR !!! tv_service_live_tune failed!\n");
return -1;
}
}
else if(isServiceIDTest == 2){
printf ("ERROR !!! tv_service_live_tune failed!\n");
return -1;
}
g_timeout_add_seconds (20, __tune_pause, live_handle);
g_timeout_add_seconds (40, __tune_resume, live_handle);
}
else {
printf ("Before tv_service_live_tune_full, handle:%p, freq:%d, mod:%d, vpid:%d, apid:%d, ppid:%d\n",\
live_handle, temp_freq, temp_mod, vpid, apid, ppid);
if(isSimpleTest == 1){
printf ("ERROR !!! tv_service_live_tune_full failed!\n");
return -1;
}
}
else {
printf ("ERROR !!! tv_service_live_tune_full failed!\n");
return -1;
}
g_timeout_add_seconds (3, change_audio_volume, live_handle);
audio_mute = TRUE;
g_timeout_add_seconds (8, change_audio_mute, live_handle);
g_timeout_add_seconds (10, change_audio_mute, live_handle);
video_mute = TRUE;
g_timeout_add_seconds (12, change_video_mute, live_handle);
g_timeout_add_seconds (14, change_video_mute, live_handle);
g_timeout_add_seconds (18, change_channel, live_handle);
g_timeout_add_seconds (28, change_audio_volume, live_handle);
audio_mute = TRUE;
g_timeout_add_seconds (33, change_audio_mute, live_handle);
g_timeout_add_seconds (35, change_audio_mute, live_handle);
video_mute = TRUE;
g_timeout_add_seconds (37, change_video_mute, live_handle);
g_timeout_add_seconds (39, change_video_mute, live_handle);
g_timeout_add_seconds (50, exit_loop, NULL);
}
}
g_main_loop_run (loop);
if (live_handle) {
}
return 0;
}