timeshift: for initial pts value, scan more packets (now 6)
This commit is contained in:
parent
6106b71a6e
commit
82b17a74fd
2 changed files with 19 additions and 2 deletions
|
@ -170,8 +170,21 @@ static void timeshift_input
|
|||
|
||||
/* Record (one-off) PTS delta */
|
||||
if (sm->sm_type == SMT_PACKET && ts->pts_delta == PTS_UNSET) {
|
||||
if (pkt->pkt_pts != PTS_UNSET)
|
||||
ts->pts_delta = getmonoclock() - ts_rescale(pkt->pkt_pts, 1000000);
|
||||
if (pkt->pkt_pts != PTS_UNSET) {
|
||||
int i;
|
||||
int64_t smallest = INT64_MAX;
|
||||
for (i = 0; i < ARRAY_SIZE(ts->pts_val); i++) {
|
||||
int64_t i64 = ts->pts_val[i];
|
||||
if (i64 == PTS_UNSET) {
|
||||
ts->pts_val[i] = pkt->pkt_pts;
|
||||
break;
|
||||
}
|
||||
if (i64 < smallest)
|
||||
smallest = i64;
|
||||
}
|
||||
if (i >= ARRAY_SIZE(ts->pts_val))
|
||||
ts->pts_delta = getmonoclock() - ts_rescale(smallest, 1000000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Buffer to disk */
|
||||
|
@ -256,6 +269,7 @@ 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);
|
||||
|
@ -271,6 +285,8 @@ streaming_target_t *timeshift_create
|
|||
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);
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ typedef struct timeshift {
|
|||
time_t max_time; ///< Maximum period to shift
|
||||
int ondemand; ///< Whether this is an on-demand timeshift
|
||||
int64_t pts_delta; ///< Delta between system clock and PTS
|
||||
int64_t pts_val[6]; ///< Decision PTS values for multiple packets
|
||||
|
||||
enum {
|
||||
TS_INIT,
|
||||
|
|
Loading…
Add table
Reference in a new issue