void streaming_queue_init(streaming_queue_t *sq, int reject_filter, size_t maxsize) { streaming_target_init(&sq->sq_st, streaming_queue_deliver, sq, reject_filter); pthread_mutex_init(&sq->sq_mutex, NULL); pthread_cond_init(&sq->sq_cond, NULL); TAILQ_INIT(&sq->sq_queue); sq->sq_maxsize = maxsize; }
/** * Create timeshift buffer * * max_period of buffer in seconds (0 = unlimited) * max_size of buffer in bytes (0 = unlimited) */ streaming_target_t *timeshift_create (streaming_target_t *out, time_t max_time) { timeshift_t *ts = calloc(1, sizeof(timeshift_t)); memoryinfo_alloc(×hift_memoryinfo, sizeof(timeshift_t)); /* Must hold global lock */ lock_assert(&global_lock); /* Setup structure */ TAILQ_INIT(&ts->files); ts->output = out; ts->path = NULL; ts->max_time = max_time; ts->state = TS_LIVE; ts->exit = 0; ts->full = 0; ts->vididx = -1; ts->id = timeshift_index; ts->ondemand = timeshift_conf.ondemand; ts->dobuf = ts->ondemand ? 0 : 1; ts->packet_mode= 1; ts->last_wr_time = 0; ts->buf_time = 0; ts->start_pts = 0; ts->ref_time = 0; ts->seek.file = NULL; ts->seek.frame = NULL; ts->ram_segments = 0; ts->file_segments = 0; pthread_mutex_init(&ts->state_mutex, NULL); /* Initialise output */ tvh_pipe(O_NONBLOCK, &ts->rd_pipe); /* Initialise input */ streaming_queue_init(&ts->wr_queue, 0, 0); streaming_target_init(&ts->input, ×hift_input_ops, ts, 0); tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts, "tshift-wr"); tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts, "tshift-rd"); /* Update index */ timeshift_index++; return &ts->input; }
void streaming_queue_init(streaming_queue_t *sq, int reject_filter, size_t maxsize) { static streaming_ops_t ops = { .st_cb = streaming_queue_deliver, .st_info = streaming_queue_info }; streaming_target_init(&sq->sq_st, &ops, sq, reject_filter); pthread_mutex_init(&sq->sq_mutex, NULL); tvh_cond_init(&sq->sq_cond); TAILQ_INIT(&sq->sq_queue); sq->sq_maxsize = maxsize; sq->sq_size = 0; }
/** * Create timeshift buffer * * max_period of buffer in seconds (0 = unlimited) * max_size of buffer in bytes (0 = unlimited) */ streaming_target_t *timeshift_create (streaming_target_t *out, time_t max_time) { timeshift_t *ts = calloc(1, sizeof(timeshift_t)); int i; /* Must hold global lock */ lock_assert(&global_lock); /* Setup structure */ TAILQ_INIT(&ts->files); ts->output = out; ts->path = NULL; ts->max_time = max_time; ts->state = TS_INIT; ts->full = 0; ts->vididx = -1; ts->id = timeshift_index; ts->ondemand = timeshift_conf.ondemand; ts->dobuf = ts->ondemand ? 0 : 1; ts->packet_mode= 1; ts->last_time = 0; ts->start_pts = 0; ts->ref_time = 0; for (i = 0; i < TIMESHIFT_BACKLOG_MAX; i++) TAILQ_INIT(&ts->backlog[i]); pthread_mutex_init(&ts->rdwr_mutex, NULL); pthread_mutex_init(&ts->state_mutex, NULL); /* Initialise output */ tvh_pipe(O_NONBLOCK, &ts->rd_pipe); /* Initialise input */ streaming_queue_init(&ts->wr_queue, 0, 0); streaming_target_init(&ts->input, timeshift_input, ts, 0); tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts, "tshift-wr"); tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts, "tshift-rd"); /* Update index */ timeshift_index++; return &ts->input; }
/** * Create timeshift buffer * * max_period of buffer in seconds (0 = unlimited) * max_size of buffer in bytes (0 = unlimited) */ streaming_target_t *timeshift_create (streaming_target_t *out, time_t max_time) { char buf[512]; timeshift_t *ts = calloc(1, sizeof(timeshift_t)); /* Must hold global lock */ lock_assert(&global_lock); /* Create directories */ if (timeshift_filemgr_makedirs(timeshift_index, buf, sizeof(buf))) return NULL; /* Setup structure */ TAILQ_INIT(&ts->files); ts->output = out; ts->path = strdup(buf); ts->max_time = max_time; ts->state = TS_INIT; ts->full = 0; ts->vididx = -1; ts->id = timeshift_index; ts->ondemand = timeshift_ondemand; pthread_mutex_init(&ts->rdwr_mutex, NULL); pthread_mutex_init(&ts->state_mutex, NULL); /* Initialise output */ tvh_pipe(O_NONBLOCK, &ts->rd_pipe); /* Initialise input */ streaming_queue_init(&ts->wr_queue, 0); streaming_target_init(&ts->input, timeshift_input, ts, 0); pthread_create(&ts->wr_thread, NULL, timeshift_writer, ts); pthread_create(&ts->rd_thread, NULL, timeshift_reader, ts); /* Update index */ timeshift_index++; return &ts->input; }
/** * Create timeshift buffer * * max_period of buffer in seconds (0 = unlimited) * max_size of buffer in bytes (0 = unlimited) */ streaming_target_t *timeshift_create (streaming_target_t *out, time_t max_time) { timeshift_t *ts = calloc(1, sizeof(timeshift_t)); int i; /* Must hold global lock */ lock_assert(&global_lock); /* Setup structure */ TAILQ_INIT(&ts->files); ts->output = out; ts->path = NULL; ts->max_time = max_time; ts->state = TS_INIT; ts->full = 0; ts->vididx = -1; ts->id = timeshift_index; ts->ondemand = timeshift_ondemand; ts->pts_delta = PTS_UNSET; for (i = 0; i < ARRAY_SIZE(ts->pts_val); i++) ts->pts_val[i] = PTS_UNSET; pthread_mutex_init(&ts->rdwr_mutex, NULL); pthread_mutex_init(&ts->state_mutex, NULL); /* Initialise output */ tvh_pipe(O_NONBLOCK, &ts->rd_pipe); /* Initialise input */ streaming_queue_init(&ts->wr_queue, 0, 0); streaming_target_init(&ts->input, timeshift_input, ts, 0); tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts); tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts); /* Update index */ timeshift_index++; return &ts->input; }