void osd_callback(mvp_widget_t *widget) { struct stat64 sb; long long offset = 0; int off, Mb; char buf[32]; av_stc_t stc; demux_attr_t *attr; fstat64(fd, &sb); if (video_functions->seek) offset = video_functions->seek(0, SEEK_CUR); off = (int)((double)(offset/1000) / (double)(sb.st_size/1000) * 100.0); snprintf(buf, sizeof(buf), "%d", off); mvpw_set_text_str(offset_widget, buf); mvpw_set_graph_current(offset_bar, off); attr = demux_get_attr(handle); av_current_stc(&stc); Mb = (attr->Bps * 8) / (1024 * 1024); snprintf(buf, sizeof(buf), "Mbps: %d.%.2d Time: %.2d:%.2d:%.2d", Mb, (attr->Bps * 8) / (1024 * 1024 / 100) - (Mb * 100), stc.hour, stc.minute, stc.second); mvpw_set_text_str(bps_widget, buf); }
static void fb_osd_update(mvp_widget_t *widget) { av_stc_t stc; char buf[256]; struct stat64 sb; long long offset; int percent; if (fstat64(fd, &sb) < 0) return; av_current_stc(&stc); snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d", stc.hour, stc.minute, stc.second); mvpw_set_text_str(fb_time, buf); snprintf(buf, sizeof(buf), "Bytes: %lld", (long long)sb.st_size); mvpw_set_text_str(fb_size, buf); offset = lseek(fd, 0, SEEK_CUR); percent = (int)((double)(offset/1000) / (double)(sb.st_size/1000) * 100.0); snprintf(buf, sizeof(buf), "%d%%", percent); mvpw_set_text_str(fb_offset_widget, buf); mvpw_set_graph_current(fb_offset_bar, percent); mvpw_expose(fb_offset_bar); }
void fb_shuffle(int shuffle) { char **item, *tmp; int i, j, k, n; if (shuffle) mvpw_set_menu_title(playlist_widget, "Shuffle Play"); else mvpw_set_menu_title(playlist_widget, "Play All"); item = alloca(sizeof(char*) * MAX_PLAYLIST_ENTRIES); // Recurse from the current directory and find all // audio files n = 0; recurse_find_audio(cwd, item, &n); if (n == 0) { gui_error("No audio files exist in this directory or its subdirectories"); return; } if (shuffle && (n > 1)) { for (i=0; i < MAX_PLAYLIST_ENTRIES; i++) { j = rand() % n; k = rand() % n; tmp = item[k]; item[k] = item[j]; item[j] = tmp; } } printf("created playlist of %d songs\n", n); switch_hw_state(MVPMC_STATE_FILEBROWSER); video_functions = &file_functions; playlist_clear(); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); playlist_create(item, n); // Release the list of items for (i = 0; i < n; i++) free(item[i]); if (shuffle) mvpw_set_text_str(fb_name, "Shuffle Play"); else mvpw_set_text_str(fb_name, "Play All"); mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); playlist_play(NULL); }
void goto_bookmark_status(mvp_widget_t *widget) { char buf[32]; char data[16]="Bookmark Status"; display_on=0; snprintf(buf, sizeof(buf),"Jumping to bookmark"); mvpw_set_text_str(mythtv_osd_description, buf); mvpw_set_text_str(mythtv_osd_program, data); mvpw_expose(mythtv_osd_description); }
void set_commbreak_status(mvp_widget_t *widget) { char buf[55]; char data[16]="Commercial Skip"; display_on=0; snprintf(buf, sizeof(buf),"MythTV Commercial Skip\n"); mvpw_set_text_str(mythtv_osd_description, buf); mvpw_set_text_str(mythtv_osd_program, data); mvpw_expose(mythtv_osd_description); }
void set_bookmark_status_fail(mvp_widget_t *widget) { char buf[32]; char data[16]="Bookmark Status"; //display_on=!display_on; display_on=0; snprintf(buf, sizeof(buf),"Bookmark Failed"); mvpw_set_text_str(mythtv_osd_program, data); mvpw_set_text_str(mythtv_osd_description, buf); mvpw_expose(mythtv_osd_description); }
void set_seek_status(mvp_widget_t *widget) { char buf[42]; char data[16]="Skip"; display_on=0; if (mythtv_commskip) snprintf(buf, sizeof(buf),"MythTV Seek\nNot in Commercial Break"); else snprintf(buf, sizeof(buf),"MythTV Seek\nCommercial Skip Disabled"); mvpw_set_text_str(mythtv_osd_description, buf); mvpw_set_text_str(mythtv_osd_program, data); mvpw_expose(mythtv_osd_description); }
static void hilite_callback(mvp_widget_t *widget, char *item, void *key, bool hilite) { char path[1024], str[1024], date[64]; struct stat64 sb; if (hilite) { sprintf(path, "%s/%s", cwd, item); stat64(path, &sb); ctime_r(&sb.st_mtime, date); snprintf(str, sizeof(str), "File: %s\nSize: %lld\nDate: %s", item, (long long)sb.st_size, date); mvpw_set_text_str(fb_program_widget, str); if (current_hilite) free(current_hilite); current_hilite = strdup(item); /* * Send the currently hilighted text to the display. */ snprintf(display_message, sizeof(display_message), "File:%s\n", current_hilite); display_send(display_message); } }
void video_progress(mvp_widget_t *widget) { long long offset = 0, size; int off; char buf[32]; if ((size=video_functions->size()) < 0) { disable_osd(); mvpw_hide(osd_widget); mvpw_hide(mute_widget); mvpw_hide(pause_widget); mvpw_hide(ffwd_widget); mvpw_hide(zoom_widget); display_on = 0; zoomed = 0; return; } if (video_functions->seek) offset = video_functions->seek(0, SEEK_CUR); off = (int)((double)(offset/1000) / (double)(size/1000) * 100.0); snprintf(buf, sizeof(buf), "%d%%", off); mvpw_set_text_str(offset_widget, buf); mvpw_set_graph_current(offset_bar, off); mvpw_expose(offset_widget); }
void video_timecode(mvp_widget_t *widget) { demux_attr_t *attr; char buf[32]; av_stc_t stc; attr = demux_get_attr(handle); av_current_stc(&stc); snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d", stc.hour, stc.minute, stc.second); if (running_mythtv && !mythtv_livetv) { int seconds = 0, minutes = 0, hours = 0; seconds = mythtv_program_runtime(); if (seconds > 0) { hours = seconds / (60 * 60); minutes = (seconds / 60) % 60; seconds = seconds % 60; snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d / %.2d:%.2d:%.2d", stc.hour, stc.minute, stc.second, hours, minutes, seconds); } } if (using_vlc) { vlc_timecode(buf); } mvpw_set_text_str(time_widget, buf); }
void video_bitrate(mvp_widget_t *widget) { demux_attr_t *attr; av_stc_t stc; char buf[32]; int Mb; attr = demux_get_attr(handle); av_current_stc(&stc); Mb = (attr->Bps * 8) / (1024 * 1024); snprintf(buf, sizeof(buf), "%d.%.2d Mbps", Mb, (attr->Bps * 8) / (1024 * 1024 / 100) - (Mb * 100)); mvpw_set_text_str(bps_widget, buf); }
void start_thruput_test(void) { switch_hw_state(MVPMC_STATE_NONE); DEMUX_WRITE_VIDEO = demux_write_video_nop; DEMUX_WRITE_AUDIO = demux_write_audio_nop; DEMUX_JIT_WRITE_AUDIO = demux_jit_write_audio_nop; thruput = 1; gettimeofday(&thruput_start, NULL); mvpw_set_text_str(thruput_widget, "Press STOP to end test."); mvpw_show(thruput_widget); mvpw_focus(thruput_widget); }
void mvpw_set_array_col(mvp_widget_t *widget, int which, char * string, mvpw_text_attr_t * attr) { if(which>widget->data.array.cols) { PRINTF("** SSDEBUG: ERROR %s index out of range (%d).\n", __FUNCTION__, which); return; } if(widget->data.array.col_labels[which]) { if(string) mvpw_set_text_str(widget->data.array.col_labels[which], string); if(attr) mvpw_set_text_attr(widget->data.array.col_labels[which], attr); } widget->data.array.dirty = 1; }
void mvpw_set_array_cell(mvp_widget_t *widget, int x, int y, char * string, mvpw_text_attr_t * attr) { int i; if(x>widget->data.array.cols || y>widget->data.array.rows) { PRINTF("** SSDEBUG: ERROR %s indexes out of range (%d,%d).\n", __FUNCTION__, x, y); return; } i = widget->data.array.cols * y + x; if(widget->data.array.cells[i]) { if(string) mvpw_set_text_str(widget->data.array.cells[i], string); if(attr) mvpw_set_text_attr(widget->data.array.cells[i], attr); } widget->data.array.dirty = 1; }
void video_clock(mvp_widget_t *widget) { time_t t; struct tm *tm; char buf[64]; char format[12]; if (mythtv_use_12hour_clock) strcpy(format, "%I:%M:%S %p"); else strcpy(format, "%H:%M:%S"); t = time(NULL); tm = localtime(&t); strftime(buf, 64, format, tm); mvpw_set_text_str(widget, buf); }
void end_thruput_test(void) { struct timeval thruput_end, delta; char buf[256]; float rate, sec; if (thruput == 0) return; gettimeofday(&thruput_end, NULL); if ( video_functions->halt_stream != NULL ) { video_functions->halt_stream(); } timersub(&thruput_end, &thruput_start, &delta); sec = ((float)delta.tv_sec + (delta.tv_usec / 1000000.0)); rate = (float)thruput_count / sec; rate = (rate * 8) / (1024 * 1024); snprintf(buf, sizeof(buf), "Bytes: %d\nSeconds: %5.2f\nThroughput: %5.2f mb/s", thruput_count, sec, rate); printf("thruput test:\n%s\n", buf); switch_hw_state(MVPMC_STATE_NONE); DEMUX_WRITE_VIDEO = demux_write_video; DEMUX_WRITE_AUDIO = demux_write_audio; DEMUX_JIT_WRITE_AUDIO = demux_jit_write_audio; thruput = 0; thruput_count = 0; mvpw_set_text_str(thruput_widget, buf); }
static void select_callback(mvp_widget_t *widget, char *item, void *key) { char path[1024], *ptr; struct stat64 sb; sprintf(path, "%s/%s", cwd, item); if (stat64(path, &sb)!=0) { printf("Could not stat %s error %d\n",item,errno); if (strcmp(item,"../")==0 ) { // probably lost network put you back in root strcpy(cwd,"/"); strcpy(path,"/"); stat64(path, &sb); } } if (current_pl && !is_playlist(item)) { free(current_pl); current_pl = NULL; } if (current_pl && (playlist == NULL)) { free(current_pl); current_pl = NULL; } printf("%s(): path '%s'\n", __FUNCTION__, path); if (current && (strcmp(path, current) == 0)) { printf("selected current item\n"); if (is_video(item) || (is_streaming(item) > 100)) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); screensaver_disable(); return; } } if (current_pl && (strcmp(path, current_pl) == 0)) { if (is_playlist(item)) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); return; } } if (S_ISDIR(sb.st_mode)) { if (strcmp(item, "../") == 0) { strcpy(path, cwd); if (path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; if (path[0] == '\0') sprintf(path, "/"); } else { if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; } if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){ mount_djmount(path); } else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { unmount_djmount(); } strncpy(cwd, path, sizeof(cwd)); while ((cwd[0] == '/') && (cwd[1] == '/')) memmove(cwd, cwd+1, strlen(cwd)); mvpw_clear_menu(widget); mvpw_set_menu_title(widget, cwd); busy_start(); add_dirs(widget); add_files(widget); busy_end(); mvpw_expose(widget); } else { switch_hw_state(MVPMC_STATE_FILEBROWSER); if (current) free(current); current = NULL; audio_stop = 1; pthread_kill(audio_thread, SIGURG); while (audio_playing) usleep(1000); current = strdup(path); if (is_streaming(item) > 100) { // Use VLC callbacks for streaming items video_functions = &vlc_functions; // Allow broadcast messages to be sent so // we can tell VLC to start the stream vlc_broadcast_enabled = 1; } else { video_functions = &file_functions; } add_osd_widget(fb_program_widget, OSD_PROGRAM, osd_settings.program, NULL); mvpw_set_text_str(fb_name, item); /* * This code sends the currently playing file name to the display. */ snprintf(display_message, sizeof(display_message), "File:%s\n", item); display_send(display_message); audio_clear(); video_clear(); playlist_clear(); if (is_video(item)) { if (key != NULL) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); } else { mvpw_show(fb_progress); } mvpw_set_timer(fb_progress, fb_osd_update, 500); video_play(NULL); mvpw_show(root); mvpw_expose(root); mvpw_focus(root); } else if (is_audio(item) || is_streaming(item)>=0 ) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); audio_play(NULL); } else if (is_image(item)) { mvpw_hide(widget); printf("Displaying image '%s'\n", path); if (mvpw_load_image_jpeg(iw, path) == 0) { mvpw_show_image_jpeg(iw); av_wss_update_aspect(WSS_ASPECT_UNKNOWN); } else { mvpw_set_image(iw, path); } mvpw_show(iw); mvpw_focus(iw); loaded_offset = 0; loaded_status = 0; fb_next_image(1); } else if (is_playlist(item)) { if (current_pl) free(current_pl); current_pl = strdup(path); mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); playlist_clear(); playlist_play(NULL); } } }