[Mvpmc-cvs] mvpmc/src gui.c,1.53,1.54 mythtv.c,1.44,1.45 video.c,1.48,1.49
Status: Alpha
Brought to you by:
gettler
From: Jon G. <ge...@us...> - 2005-06-14 03:55:32
|
Update of /cvsroot/mvpmc/mvpmc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7737/src Modified Files: gui.c mythtv.c video.c Log Message: Updates for live tv based off a patch from John Reid: - improve support for multiple tuners - add channel name, time, and description info for shows - add the channel name and times to the OSD - make video go fullscreen when a show is selected Index: mythtv.c =================================================================== RCS file: /cvsroot/mvpmc/mvpmc/src/mythtv.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** mythtv.c 6 Jun 2005 02:37:50 -0000 1.44 --- mythtv.c 14 Jun 2005 03:55:16 -0000 1.45 *************** *** 94,102 **** #define MAX_TUNER 16 struct livetv_prog { ! char *program; int count; ! int rec_id[MAX_TUNER]; ! char *chan[MAX_TUNER]; }; static struct livetv_prog *livetv_list = NULL; --- 94,110 ---- #define MAX_TUNER 16 + struct livetv_proginfo { + int rec_id; + char *chan; + char *channame; + }; struct livetv_prog { ! char *title; ! char *subtitle; ! char *description; ! char *start; ! char *end; int count; ! struct livetv_proginfo pi[MAX_TUNER]; }; static struct livetv_prog *livetv_list = NULL; *************** *** 160,165 **** x = ((const struct livetv_prog*)a); y = ((const struct livetv_prog*)b); ! X = atoi(x->chan[0]); ! Y = atoi(y->chan[0]); if (X < Y) --- 168,173 ---- x = ((const struct livetv_prog*)a); y = ((const struct livetv_prog*)b); ! X = atoi(x->pi[0].chan); ! Y = atoi(y->pi[0].chan); if (X < Y) *************** *** 196,199 **** --- 204,228 ---- } + static void + mythtv_fullscreen(void) + { + mvpw_hide(mythtv_browser); + mvpw_hide(mythtv_logo); + mvpw_hide(mythtv_channel); + mvpw_hide(mythtv_date); + mvpw_hide(mythtv_description); + mvpw_hide(mythtv_record); + mvpw_hide(shows_widget); + mvpw_hide(episodes_widget); + mvpw_hide(freespace_widget); + + av_move(0, 0, 0); + mvpw_show(root); + mvpw_expose(root); + mvpw_focus(root); + + printf("fullscreen video mode\n"); + } + static int mythtv_verify(void) *************** *** 401,420 **** show_select_callback(mvp_widget_t *widget, char *item, void *key) { ! mvpw_hide(mythtv_logo); ! mvpw_hide(mythtv_channel); ! mvpw_hide(mythtv_date); ! mvpw_hide(mythtv_description); ! mvpw_hide(mythtv_record); ! mvpw_hide(shows_widget); ! mvpw_hide(episodes_widget); ! mvpw_hide(freespace_widget); ! ! mvpw_hide(widget); ! av_move(0, 0, 0); ! mvpw_show(root); ! mvpw_expose(root); ! mvpw_focus(root); ! ! printf("fullscreen video mode\n"); if (cmyth_proginfo_compare(hilite_prog, current_prog) != 0) { --- 430,434 ---- show_select_callback(mvp_widget_t *widget, char *item, void *key) { ! mythtv_fullscreen(); if (cmyth_proginfo_compare(hilite_prog, current_prog) != 0) { *************** *** 1230,1242 **** char *description, *program; char *title, *subtitle; ! if (current_prog) { title = (char *) cmyth_proginfo_title(current_prog); subtitle = (char *) cmyth_proginfo_subtitle(current_prog); ! ! program = alloca(strlen(title) + strlen(subtitle) + 16); ! sprintf(program, "%s - %s", title, subtitle); ! ! description = (char *) cmyth_proginfo_description(current_prog); mvpw_set_text_str(mythtv_osd_description, description); --- 1244,1280 ---- char *description, *program; char *title, *subtitle; ! cmyth_timestamp_t ts; ! char start[256], end[256], str[256], *ptr, *chansign; ! if (current_prog) { title = (char *) cmyth_proginfo_title(current_prog); subtitle = (char *) cmyth_proginfo_subtitle(current_prog); ! ! if (mythtv_livetv) { ! chansign = (char*)cmyth_proginfo_chansign(current_prog); ! ! ts = cmyth_proginfo_start(current_prog); ! cmyth_timestamp_to_string(start, ts); ! ts = cmyth_proginfo_end(current_prog); ! cmyth_timestamp_to_string(end, ts); ! ! ptr = strchr(start, 'T'); ! *ptr = '\0'; ! sprintf(str, "%5.5s - ", ptr+1); ! ptr = strchr(end, 'T'); ! *ptr = '\0'; ! strncat(str, ptr+1,5); ! ! program = alloca(strlen(chansign) + strlen(str) + ! strlen(title) + strlen(subtitle) + 16); ! sprintf(program, "[%s] %s %s - %s", ! chansign, str, title, subtitle); ! } else { ! program = alloca(strlen(title) + ! strlen(subtitle) + 16); ! sprintf(program, "%s - %s", title, subtitle); ! } ! ! description = (char *)cmyth_proginfo_description(current_prog); mvpw_set_text_str(mythtv_osd_description, description); *************** *** 1607,1611 **** double rate; char *rb_file; ! char *msg; int c; --- 1645,1649 ---- double rate; char *rb_file; ! char *msg, buf[256]; int c; *************** *** 1653,1656 **** --- 1691,1701 ---- goto err; } + if(cmyth_recorder_is_recording(control, recorder) == 1) { + snprintf(buf, sizeof(buf), + "Failed: tuner %d is busy.", tuner); + msg = buf; + cmyth_recorder_release(recorder); + goto err; + } } else { if ((recorder=cmyth_conn_get_free_recorder(control)) == NULL) { *************** *** 1933,1951 **** int id = -1; int tuner_change = 1, tuner = 0; ! ! printf("%s(): prog %d\n", __FUNCTION__, prog); if (mythtv_livetv) { id = cmyth_recorder_get_recorder_id(recorder); for (i=0; i<livetv_list[prog].count; i++) { ! if (id == livetv_list[prog].rec_id[i]) { tuner_change = 0; ! channame = strdup(livetv_list[prog].chan[i]); break; } } } else { ! channame = strdup(livetv_list[prog].chan[0]); ! tuner = livetv_list[prog].rec_id[0]; tuner_change = 0; printf("enable livetv tuner %d chan '%s'\n", tuner, channame); --- 1978,1996 ---- int id = -1; int tuner_change = 1, tuner = 0; ! struct livetv_proginfo *pi; if (mythtv_livetv) { id = cmyth_recorder_get_recorder_id(recorder); for (i=0; i<livetv_list[prog].count; i++) { ! pi = &livetv_list[prog].pi[i]; ! if (id == pi->rec_id) { tuner_change = 0; ! channame = strdup(pi->chan); break; } } } else { ! channame = strdup(livetv_list[prog].pi[0].chan); ! tuner = livetv_list[prog].pi[0].rec_id; tuner_change = 0; printf("enable livetv tuner %d chan '%s'\n", tuner, channame); *************** *** 1953,1958 **** if (tuner_change && (id != -1)) { ! tuner = livetv_list[prog].rec_id[0]; ! channame = strdup(livetv_list[prog].chan[0]); printf("switch from tuner %d to %d\n", id, tuner); mythtv_livetv_stop(); --- 1998,2003 ---- if (tuner_change && (id != -1)) { ! tuner = livetv_list[prog].pi[0].rec_id; ! channame = strdup(livetv_list[prog].pi[0].chan); printf("switch from tuner %d to %d\n", id, tuner); mythtv_livetv_stop(); *************** *** 1995,1998 **** --- 2040,2045 ---- video_play(root); + mythtv_fullscreen(); + err: pthread_mutex_unlock(&myth_mutex); *************** *** 2004,2007 **** --- 2051,2083 ---- } + static void + livetv_hilite_callback(mvp_widget_t *widget, char *item, void *key, int hilite) + { + int prog = (int)key; + char buf[256]; + + if (hilite) { + snprintf(buf, sizeof(buf), "%s %s", + livetv_list[prog].pi[0].chan, + livetv_list[prog].pi[0].channame); + mvpw_set_text_str(mythtv_channel, buf); + mvpw_expose(mythtv_channel); + snprintf(buf, sizeof(buf), "%s - %s", + livetv_list[prog].start, livetv_list[prog].end); + mvpw_set_text_str(mythtv_date, buf); + mvpw_expose(mythtv_date); + mvpw_set_text_str(mythtv_description, + livetv_list[prog].description); + mvpw_expose(mythtv_description); + } else { + mvpw_set_text_str(mythtv_channel, ""); + mvpw_expose(mythtv_channel); + mvpw_set_text_str(mythtv_date, ""); + mvpw_expose(mythtv_date); + mvpw_set_text_str(mythtv_description, ""); + mvpw_expose(mythtv_description); + } + } + static int get_livetv_programs_rec(int id, struct livetv_prog **list, int *n, int *p) *************** *** 2009,2019 **** cmyth_proginfo_t next_prog, cur; cmyth_recorder_t rec = recorder; ! const char *title, *subtitle, *channame, *start; ! int cur_id, i; int c = 0; ! char buf[256]; ! cur_id = cmyth_recorder_get_recorder_id(recorder); ! printf("Getting program listings for recorder %d [%d]\n", id, cur_id); --- 2085,2099 ---- cmyth_proginfo_t next_prog, cur; cmyth_recorder_t rec = recorder; ! cmyth_timestamp_t ts; ! const char *title, *subtitle, *channame, *start_channame, *chansign; ! const char *description; ! char start[256], end[256], *ptr; ! int cur_id, i; int c = 0; ! struct livetv_proginfo *pi; ! cur_id = cmyth_recorder_get_recorder_id(recorder); ! ! printf("Getting program listings for recorder %d [%d]\n", id, cur_id); *************** *** 2030,2038 **** cur = cmyth_proginfo_create(); cmyth_proginfo_hold(cur); if (cmyth_recorder_get_program_info(control, rec, cur) < 0) { fprintf(stderr, "get program info failed!\n"); return -1; } ! start = (char *) cmyth_proginfo_channame(cur); do { --- 2110,2120 ---- cur = cmyth_proginfo_create(); cmyth_proginfo_hold(cur); + if (cmyth_recorder_get_program_info(control, rec, cur) < 0) { fprintf(stderr, "get program info failed!\n"); return -1; } ! ! start_channame = (char *) cmyth_proginfo_channame(cur); do { *************** *** 2045,2068 **** title = (char *) cmyth_proginfo_title(next_prog); subtitle = (char *) cmyth_proginfo_subtitle(next_prog); channame = (char *) cmyth_proginfo_channame(next_prog); ! ! snprintf(buf, sizeof(buf), "%s - %s", title, subtitle); cur = next_prog; for (i=0; i<*p; i++) { ! if (strcmp((*list)[i].program, buf) == 0) { if ((*list)[*p].count == MAX_TUNER) goto next; ! (*list)[i].chan[(*list)[*p].count] = strdup(channame); ! (*list)[i].rec_id[(*list)[*p].count++] = id; goto next; } } ! (*list)[*p].program = strdup(buf); (*list)[*p].count = 1; ! (*list)[*p].rec_id[0] = id; ! (*list)[*p].chan[0] = strdup(channame); (*p)++; c++; --- 2127,2180 ---- title = (char *) cmyth_proginfo_title(next_prog); subtitle = (char *) cmyth_proginfo_subtitle(next_prog); + description = (char *) cmyth_proginfo_description(next_prog); channame = (char *) cmyth_proginfo_channame(next_prog); ! chansign = (char *) cmyth_proginfo_chansign(next_prog); ! ! ts = cmyth_proginfo_start(next_prog); ! if (ts != NULL ) { ! cmyth_timestamp_to_string(start, ts); ! ts = cmyth_proginfo_end(next_prog); ! cmyth_timestamp_to_string(end, ts); ! ptr = strchr(start, 'T'); ! *ptr = '\0'; ! memmove(start, ptr+1, strlen(ptr+1)+1); ! ptr = strchr(end, 'T'); ! *ptr = '\0'; ! memmove(end, ptr+1, strlen(ptr+1)+1); ! } cur = next_prog; for (i=0; i<*p; i++) { ! if ((strcmp((*list)[i].title, title) == 0) && ! (strcmp((*list)[i].subtitle, subtitle) == 0) && ! (strcmp((*list)[i].description, description) == 0) && ! (strcmp((*list)[i].start, start) == 0) && ! (strcmp((*list)[i].end, end) == 0)) { if ((*list)[*p].count == MAX_TUNER) goto next; ! pi = &((*list)[i].pi[(*list)[*p].count]); ! pi->chan = strdup(channame); ! pi->channame = strdup(chansign); ! pi->rec_id = id; goto next; } } ! (*list)[*p].title = strdup(title); ! (*list)[*p].subtitle = strdup(subtitle); ! (*list)[*p].description = strdup(description); ! if (start) ! (*list)[*p].start = strdup(start); ! else ! (*list)[*p].start = NULL; ! if (end) ! (*list)[*p].end = strdup(end); ! else ! (*list)[*p].end = NULL; (*list)[*p].count = 1; ! (*list)[*p].pi[0].rec_id = id; ! (*list)[*p].pi[0].chan = strdup(channame); ! (*list)[*p].pi[0].channame = strdup(chansign); (*p)++; c++; *************** *** 2073,2085 **** *list = realloc(*list, sizeof(**list)*(*n)); } ! } while (strcmp(start, channame) != 0); ! if (cur_id != id) { - if (cmyth_recorder_done_ringbuf(control, rec) != 0) { - fprintf(stderr, "done ringbuf failed\n"); - } cmyth_recorder_release(rec); } - cmyth_proginfo_release(next_prog); --- 2185,2192 ---- *list = realloc(*list, sizeof(**list)*(*n)); } ! } while (strcmp(start_channame, channame) != 0); if (cur_id != id) { cmyth_recorder_release(rec); } cmyth_proginfo_release(next_prog); *************** *** 2098,2104 **** if (livetv_list) { for (i=0; i<livetv_count; i++) { ! free(livetv_list[i].program); ! for (j=0; j<livetv_list[i].count; j++) ! free(livetv_list[i].chan[j]); } free(livetv_list); --- 2205,2217 ---- if (livetv_list) { for (i=0; i<livetv_count; i++) { ! free(livetv_list[i].title); ! free(livetv_list[i].subtitle); ! free(livetv_list[i].description); ! free(livetv_list[i].start); ! free(livetv_list[i].end); ! for (j=0; j<livetv_list[i].count; j++) { ! free(livetv_list[i].pi[j].chan); ! free(livetv_list[i].pi[j].channame); ! } } free(livetv_list); *************** *** 2121,2125 **** item_attr.select = livetv_select_callback; ! item_attr.hilite = NULL; p = 0; --- 2234,2238 ---- item_attr.select = livetv_select_callback; ! item_attr.hilite = livetv_hilite_callback; p = 0; *************** *** 2142,2154 **** qsort(list, p, sizeof(*list), livetv_compare); for (j=0; j<p; j++) { ! snprintf(buf, sizeof(buf), "%s: %s", ! list[j].chan[0], list[j].program); mvpw_add_menu_item(mythtv_browser, buf, (void*)j, &item_attr); } - livetv_list = list; - livetv_count = p; - return 0; } --- 2255,2267 ---- qsort(list, p, sizeof(*list), livetv_compare); + livetv_list = list; + livetv_count = p; + for (j=0; j<p; j++) { ! snprintf(buf, sizeof(buf), "%s: %s - %s", ! list[j].pi[0].chan, list[j].title, list[j].subtitle); mvpw_add_menu_item(mythtv_browser, buf, (void*)j, &item_attr); } return 0; } *************** *** 2179,2182 **** --- 2292,2299 ---- } + mvpw_show(mythtv_channel); + mvpw_show(mythtv_date); + mvpw_show(mythtv_description); + return failed; } Index: video.c =================================================================== RCS file: /cvsroot/mvpmc/mvpmc/src/video.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** video.c 7 Jun 2005 03:50:21 -0000 1.48 --- video.c 14 Jun 2005 03:55:16 -0000 1.49 *************** *** 548,551 **** --- 548,554 ---- running_mythtv = 0; } else { + mvpw_show(mythtv_channel); + mvpw_show(mythtv_date); + mvpw_show(mythtv_description); mvpw_show(mythtv_logo); mvpw_show(mythtv_browser); Index: gui.c =================================================================== RCS file: /cvsroot/mvpmc/mvpmc/src/gui.c,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** gui.c 7 Jun 2005 03:50:20 -0000 1.53 --- gui.c 14 Jun 2005 03:55:16 -0000 1.54 *************** *** 1087,1090 **** --- 1087,1093 ---- printf("return from livetv to myth main menu!\n"); mvpw_hide(mythtv_browser); + mvpw_hide(mythtv_channel); + mvpw_hide(mythtv_date); + mvpw_hide(mythtv_description); mvpw_show(mythtv_logo); mvpw_show(mythtv_menu); |