/**
* Indexes of import data in the stream
*/
-typedef struct timeshift_index
+typedef struct timeshift_index_iframe
{
- off_t pos; ///< Position in the file
- union {
- int64_t time; ///< Packet time
- void *data; ///< Associated data
- };
- TAILQ_ENTRY(timeshift_index) link; ///< List entry
-} timeshift_index_t;
+ off_t pos; ///< Position in the file
+ int64_t time; ///< Packet time
+ TAILQ_ENTRY(timeshift_index_iframe) link; ///< List entry
+} timeshift_index_iframe_t;
-typedef TAILQ_HEAD(timeshift_index_list,timeshift_index) timeshift_index_list_t;
+typedef TAILQ_HEAD(timeshift_index_iframe_list,timeshift_index_iframe) timeshift_index_iframe_list_t;
+
+/**
+ * Indexes of import data in the stream
+ */
+typedef struct timeshift_index_data
+{
+ off_t pos; ///< Position in the file
+ void *data; ///< Associated data
+ TAILQ_ENTRY(timeshift_index_data) link; ///< List entry
+} timeshift_index_data_t;
+
+typedef TAILQ_HEAD(timeshift_index_data_list,timeshift_index_data) timeshift_index_data_list_t;
/**
* Timeshift file
*/
typedef struct timeshift_file
{
- int fd; ///< Write descriptor
- char *path; ///< Full path to file
+ int fd; ///< Write descriptor
+ char *path; ///< Full path to file
- time_t time; ///< Files coarse timestamp
- size_t size; ///< Current file size;
- int64_t last; ///< Latest timestamp
+ time_t time; ///< Files coarse timestamp
+ size_t size; ///< Current file size;
+ int64_t last; ///< Latest timestamp
- uint8_t bad; ///< File is broken
+ uint8_t bad; ///< File is broken
- int refcount; ///< Reader ref count
+ int refcount; ///< Reader ref count
- timeshift_index_list_t iframes; ///< I-frame indexing
- timeshift_index_list_t sstart; ///< Stream start messages
+ timeshift_index_iframe_list_t iframes; ///< I-frame indexing
+ timeshift_index_data_list_t sstart; ///< Stream start messages
TAILQ_ENTRY(timeshift_file) link; ///< List entry
} timeshift_file_t;
{
char *dpath;
timeshift_file_t *tsf;
- timeshift_index_t *ti;
+ timeshift_index_iframe_t *ti;
+ timeshift_index_data_t *tid;
streaming_message_t *sm;
pthread_mutex_lock(×hift_reaper_lock);
while (timeshift_reaper_run) {
TAILQ_REMOVE(&tsf->iframes, ti, link);
free(ti);
}
- while ((ti = TAILQ_FIRST(&tsf->sstart))) {
- TAILQ_REMOVE(&tsf->sstart, ti, link);
- sm = ti->data;
+ while ((tid = TAILQ_FIRST(&tsf->sstart))) {
+ TAILQ_REMOVE(&tsf->sstart, tid, link);
+ sm = tid->data;
streaming_msg_free(sm);
- free(ti);
+ free(tid);
}
free(tsf->path);
free(tsf);
int fd;
struct timespec tp;
timeshift_file_t *tsf_tl, *tsf_hd, *tsf_tmp;
- timeshift_index_t *ti;
+ timeshift_index_data_t *ti;
char path[512];
/* Return last file */
TAILQ_INSERT_TAIL(&ts->files, tsf_tmp, link);
/* Copy across last start message */
- if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_list))) {
+ if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list))) {
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d copy smt_start to new file",
ts->id);
#endif
- timeshift_index_t *ti2 = calloc(1, sizeof(timeshift_index_t));
- ti2->pos = ti->pos;
+ timeshift_index_data_t *ti2 = calloc(1, sizeof(timeshift_index_data_t));
ti2->data = streaming_msg_clone(ti->data);
TAILQ_INSERT_TAIL(&tsf_tmp->sstart, ti2, link);
}
int64_t now, deliver;
streaming_message_t *sm = NULL, *ctrl;
timeshift_file_t *cur_file = NULL, *tsi_file = NULL;
- timeshift_index_t *tsi = NULL;
+ timeshift_index_iframe_t *tsi = NULL;
/* Poll */
struct epoll_event ev;
if (cur_speed < 0) {
if (!tsi) {
TAILQ_FOREACH_REVERSE(tsi, &tsi_file->iframes,
- timeshift_index_list, link) {
+ timeshift_index_iframe_list, link) {
if (tsi->time < last_time) break;
}
}
/* Next index */
if (cur_speed < 0)
- tsi = TAILQ_PREV(tsi, timeshift_index_list, link);
+ tsi = TAILQ_PREV(tsi, timeshift_index_iframe_list, link);
else
tsi = TAILQ_NEXT(tsi, link);
streaming_message_t *sm = *smp;
if (sm->sm_type == SMT_START) {
err = 0;
- timeshift_index_t *ti = calloc(1, sizeof(timeshift_index_t));
+ timeshift_index_data_t *ti = calloc(1, sizeof(timeshift_index_data_t));
ti->pos = tsf->size;
ti->data = sm;
*smp = NULL;
/* Index video iframes */
if (pkt->pkt_componentindex == ts->vididx &&
pkt->pkt_frametype == PKT_I_FRAME) {
- timeshift_index_t *ti = calloc(1, sizeof(timeshift_index_t));
+ timeshift_index_iframe_t *ti = calloc(1, sizeof(timeshift_index_iframe_t));
ti->pos = tsf->size;
ti->time = sm->sm_time;
TAILQ_INSERT_TAIL(&tsf->iframes, ti, link);