int MythProgramInfo::Duration() { MythTimestamp end = cmyth_proginfo_rec_end(*m_proginfo_t); MythTimestamp start = cmyth_proginfo_rec_start(*m_proginfo_t); return end.UnixTime() - start.UnixTime(); //return cmyth_proginfo_length_sec(*m_proginfo_t); }
static int ga_all(struct path_info *info, struct stat *stbuf) { cmyth_conn_t control; cmyth_proglist_t list; int count; int i; pthread_mutex_lock(&mutex); if ((i=lookup_server(info->host)) < 0) { pthread_mutex_unlock(&mutex); return -ENOENT; } control = ref_hold(conn[i].control); if (conn[i].list == NULL) { list = cmyth_proglist_get_all_recorded(control); conn[i].list = list; } else { list = conn[i].list; } list = ref_hold(list); pthread_mutex_unlock(&mutex); stbuf->st_mode = S_IFLNK | 0444; stbuf->st_nlink = 1; count = cmyth_proglist_get_count(list); debug("%s(): file '%s'\n", __FUNCTION__, info->file); for (i=0; i<count; i++) { cmyth_proginfo_t prog; long long len; char *title, *s; char tmp[512]; prog = cmyth_proglist_get_item(list, i); title = cmyth_proginfo_title(prog); s = cmyth_proginfo_subtitle(prog); snprintf(tmp, sizeof(tmp), "%s - %s.nuv", title, s); if (strcmp(tmp, info->file) == 0) { cmyth_timestamp_t ts; time_t t; char *pn; len = cmyth_proginfo_length(prog); pn = cmyth_proginfo_pathname(prog); debug("%s(): file '%s' len %lld\n", __FUNCTION__, tmp, len); stbuf->st_size = strlen(pn) + 8; ts = cmyth_proginfo_rec_end(prog); t = cmyth_timestamp_to_unixtime(ts); stbuf->st_atime = t; stbuf->st_mtime = t; stbuf->st_ctime = t; ref_release(pn); ref_release(prog); ref_release(ts); ref_release(title); ref_release(s); ref_release(control); ref_release(list); return 0; } ref_release(prog); ref_release(title); ref_release(s); } ref_release(control); ref_release(list); return -ENOENT; }
static int show_proglist(cmyth_proglist_t episodes, int level, int show_card) { int count, i; if (episodes == NULL) { return -1; } count = cmyth_proglist_get_count(episodes); for (i=0; i<count; i++) { char *title; char *subtitle=NULL, *channel = NULL; char *description=NULL, *category=NULL, *recgroup=NULL; char *pathname=NULL; cmyth_proginfo_t prog; int rec; prog = cmyth_proglist_get_item(episodes, i); title = cmyth_proginfo_title(prog); rec = cmyth_proginfo_check_recording(control, prog); if (level > 2) { subtitle = cmyth_proginfo_subtitle(prog); channel = cmyth_proginfo_channame(prog); } if (level > 3) { description = cmyth_proginfo_description(prog); category = cmyth_proginfo_category(prog); recgroup = cmyth_proginfo_recgroup(prog); } if (level > 4) { pathname = cmyth_proginfo_pathname(prog); } if (channel) { printf("\tChannel: %s\n", channel); } if (title) { printf("\tTitle: %s\n", title); if (rec > 0) { cmyth_timestamp_t end; char str[32]; end = cmyth_proginfo_rec_end(prog); cmyth_timestamp_to_string(str, end); printf("\t RECORDING on %d until %s\n", rec, str); ref_release(end); } } if (subtitle) { printf("\tSubtitle: %s\n", subtitle); } if (description) { printf("\tDescription: %s\n", description); } if (category) { printf("\tCategory: %s\n", category); } if (recgroup) { printf("\tRecording Group: %s\n", recgroup); } if (pathname) { printf("\tPathname: %s\n", pathname); } if (level > 4) { printf("\tBytes: %lld\n", cmyth_proginfo_length(prog)); } if (level > 1 && show_card) { long card = cmyth_proginfo_card_id(prog); if (card == 0) { printf("\tRecorder: will not record\n"); } else { printf("\tRecorder: %ld\n", card); } } ref_release(channel); ref_release(title); ref_release(subtitle); ref_release(description); ref_release(category); ref_release(recgroup); ref_release(pathname); ref_release(prog); } ref_release(episodes); return count; }
static int get_recorders(int level) { int i, j; for (i=0; i<=32; i++) { cmyth_recorder_t rec; int state; rec = cmyth_conn_get_recorder(control, i); if (rec == NULL) { continue; } state = cmyth_recorder_is_recording(rec); if (state == 0) { printf("Recorder %d is idle\n", i); } else if (state == 1) { cmyth_proginfo_t prog; cmyth_timestamp_t end; char str[32]; char *title; prog = cmyth_recorder_get_cur_proginfo(rec); end = cmyth_proginfo_rec_end(prog); cmyth_timestamp_to_string(str, end); printf("Recorder %d is recording until %s\n", i, str); if (prog && (level > 0)) { title = cmyth_proginfo_title(prog); if (title) { printf("\tTitle: %s\n", title); } ref_release(title); } ref_release(prog); ref_release(end); } else { printf("Recorder %d is in an unknown state\n", i); } if (level > 1) { cmyth_chanlist_t cl; cmyth_channel_t chan; char *name; cl = cmyth_recorder_get_chanlist(rec); for (j=0; j<cmyth_chanlist_get_count(cl); j++) { chan = cmyth_chanlist_get_item(cl, j); name = cmyth_channel_string(chan); printf("\tChannel: %s\n", name); ref_release(name); ref_release(chan); } ref_release(cl); } ref_release(rec); } return 0; }
static int ga_files(struct path_info *info, struct stat *stbuf) { cmyth_conn_t control; cmyth_proglist_t list; int count; int i; pthread_mutex_lock(&mutex); if ((i=lookup_server(info->host)) < 0) { pthread_mutex_unlock(&mutex); return -ENOENT; } control = ref_hold(conn[i].control); if (conn[i].list == NULL) { list = cmyth_proglist_get_all_recorded(control); conn[i].list = list; parse_progs(conn+i); } else { list = conn[i].list; } list = ref_hold(list); pthread_mutex_unlock(&mutex); stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; count = cmyth_proglist_get_count(list); debug("%s(): file '%s'\n", __FUNCTION__, info->file); for (i=0; i<count; i++) { cmyth_proginfo_t prog; long long len; char *pn; prog = cmyth_proglist_get_item(list, i); pn = cmyth_proginfo_pathname(prog); if (strcmp(pn+1, info->file) == 0) { cmyth_timestamp_t ts; time_t t; len = cmyth_proginfo_length(prog); debug("%s(): file '%s' len %lld\n", __FUNCTION__, pn+1, len); stbuf->st_size = len; stbuf->st_blksize = MAX_BSIZE; stbuf->st_blocks = len / MAX_BSIZE; if ((len * MAX_BSIZE) != stbuf->st_blocks) { stbuf->st_blocks++; } ts = cmyth_proginfo_rec_end(prog); t = cmyth_timestamp_to_unixtime(ts); stbuf->st_atime = t; stbuf->st_mtime = t; stbuf->st_ctime = t; ref_release(prog); ref_release(pn); ref_release(ts); ref_release(control); ref_release(list); return 0; } ref_release(prog); ref_release(pn); } ref_release(control); ref_release(list); return -ENOENT; }
time_t MythProgramInfo::RecordingEndTime() { MythTimestamp time = cmyth_proginfo_rec_end(*m_proginfo_t); time_t retval(time.UnixTime()); return retval; }