time_t cmyth_recordingrule_endtime(cmyth_recordingrule_t rr) { if (!rr) { return 0; } return cmyth_timestamp_to_unixtime(rr->endtime); }
/* * cmyth_recordingrule_dup() * * Scope: PUBLIC * * Description * * Duplicate a recording rule. * Before forgetting the reference to this recording schedule structure * the caller must call ref_release(). * * Return Value: * * Success: A non-NULL cmyth_recordingrule_t (this type is a pointer) * * Failure: NULL */ cmyth_recordingrule_t cmyth_recordingrule_dup(cmyth_recordingrule_t rule) { cmyth_recordingrule_t rr = cmyth_recordingrule_create(); if (!rr) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_recordingrule_create failed\n", __FUNCTION__); return NULL; } cmyth_recordingrule_set_recordid(rr, rule->recordid); cmyth_recordingrule_set_chanid(rr, rule->chanid); cmyth_recordingrule_set_callsign(rr, rule->callsign); cmyth_recordingrule_set_starttime(rr, cmyth_timestamp_to_unixtime(rule->starttime)); cmyth_recordingrule_set_endtime(rr, cmyth_timestamp_to_unixtime(rule->endtime)); cmyth_recordingrule_set_title(rr, rule->title); cmyth_recordingrule_set_description(rr, rule->description); cmyth_recordingrule_set_type(rr, rule->type); cmyth_recordingrule_set_category(rr, rule->category); cmyth_recordingrule_set_subtitle(rr, rule->subtitle); cmyth_recordingrule_set_recpriority(rr, rule->recpriority); cmyth_recordingrule_set_startoffset(rr, rule->startoffset); cmyth_recordingrule_set_endoffset(rr, rule->endoffset); cmyth_recordingrule_set_searchtype(rr, rule->searchtype); cmyth_recordingrule_set_inactive(rr, rule->inactive); cmyth_recordingrule_set_dupmethod(rr, rule->dupmethod); cmyth_recordingrule_set_dupin(rr, rule->dupin); cmyth_recordingrule_set_recgroup(rr, rule->recgroup); cmyth_recordingrule_set_storagegroup(rr, rule->storagegroup); cmyth_recordingrule_set_playgroup(rr, rule->playgroup); cmyth_recordingrule_set_autotranscode(rr, rule->autotranscode); cmyth_recordingrule_set_userjobs(rr, rule->userjobs); cmyth_recordingrule_set_autocommflag(rr, rule->autocommflag); cmyth_recordingrule_set_autoexpire(rr, rule->autoexpire); cmyth_recordingrule_set_maxepisodes(rr, rule->maxepisodes); cmyth_recordingrule_set_maxnewest(rr, rule->maxnewest); cmyth_recordingrule_set_transcoder(rr, rule->transcoder); cmyth_recordingrule_set_parentid(rr, rule->parentid); cmyth_recordingrule_set_profile(rr, rule->profile); cmyth_recordingrule_set_prefinput(rr, rule->prefinput); cmyth_recordingrule_set_programid(rr, rule->programid); cmyth_recordingrule_set_seriesid(rr, rule->seriesid); cmyth_recordingrule_set_autometadata(rr, rule->autometadata); cmyth_recordingrule_set_inetref(rr, rule->inetref); cmyth_recordingrule_set_season(rr, rule->season); cmyth_recordingrule_set_episode(rr, rule->episode); cmyth_recordingrule_set_filter(rr, rule->filter); return rr; }
cmyth_commbreaklist_t cmyth_get_cutlist(cmyth_conn_t conn, cmyth_proginfo_t prog) { unsigned int len = CMYTH_UTC_LEN + CMYTH_LONGLONG_LEN + 17; int err; int count; char *buf; int r; cmyth_commbreaklist_t breaklist = cmyth_commbreaklist_create(); buf = alloca(len); if (!buf) { return breaklist; } pthread_mutex_lock(&conn->conn_mutex); sprintf(buf,"%s %ld %i", "QUERY_CUTLIST", prog->proginfo_chanId, (int)cmyth_timestamp_to_unixtime(prog->proginfo_rec_start_ts)); if ((err = cmyth_send_message(conn, buf)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_send_message() failed (%d)\n", __FUNCTION__, err); goto out; } count = cmyth_rcv_length(conn); if (count < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_length() failed (%d)\n", __FUNCTION__, count); goto out; } if ((r = cmyth_rcv_commbreaklist(conn, &err, breaklist, count)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_string() failed (%d)\n", __FUNCTION__, r); goto out; } out: pthread_mutex_unlock(&conn->conn_mutex); return breaklist; }
/* * cmyth_timestamp_to_utc(cmyth_timestamp_t ts) * * Scope: PUBLIC * * Description * * Create and fill out a UTC timestamp structure * * Return Value: * * Success: cmyth_timestamp_t structure * * Failure: NULL */ cmyth_timestamp_t cmyth_timestamp_to_utc(cmyth_timestamp_t ts) { time_t l; struct tm tm_datetime; cmyth_timestamp_t ret; if (!ts) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: NULL timestamp\n", __FUNCTION__); return NULL; } if (ts->timestamp_isutc) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: UTC timestamp provided\n", __FUNCTION__); return NULL; } l = cmyth_timestamp_to_unixtime(ts); gmtime_r(&l, &tm_datetime); ret = cmyth_timestamp_from_tm(&tm_datetime); ret->timestamp_isutc = 1; return ret; }
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 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; }