Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: use reference clock from VIDEO (or AUDIO) streams only, fixes #3296
  • Loading branch information
perexg committed Nov 24, 2015
1 parent 598b632 commit b9882fe
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/dvr/dvr_rec.c
Expand Up @@ -1169,6 +1169,30 @@ dts_pts_valid(th_pkt_t *pkt, int64_t dts_offset)
return 1;
}

/**
*
*/
static int64_t
get_dts_ref(th_pkt_t *pkt, streaming_start_t *ss)
{
const streaming_start_component_t *ssc;
int64_t audio = PTS_UNSET;
int i;

if (pkt->pkt_dts == PTS_UNSET)
return PTS_UNSET;
for (i = 0; i < ss->ss_num_components; i++) {
ssc = &ss->ss_components[i];
if (ssc->ssc_index == pkt->pkt_componentindex) {
if (SCT_ISVIDEO(ssc->ssc_type))
return pkt->pkt_dts;
if (audio == PTS_UNSET && SCT_ISAUDIO(ssc->ssc_type))
audio = pkt->pkt_dts;
}
}
return audio;
}

/**
*
*/
Expand Down Expand Up @@ -1276,7 +1300,7 @@ dvr_thread(void *aux)
pkt2 = sm2->sm_data;
if (pkt2->pkt_dts != PTS_UNSET) {
if (dts_offset == PTS_UNSET)
dts_offset = pkt2->pkt_dts;
dts_offset = get_dts_ref(pkt2, ss);
if (dts_pts_valid(pkt2, dts_offset)) {
pkt3 = pkt_copy_shallow(pkt2);
pkt3->pkt_dts -= dts_offset;
Expand All @@ -1290,8 +1314,8 @@ dvr_thread(void *aux)
}
streaming_msg_free(sm2);
}
if (dts_offset == PTS_UNSET && pkt->pkt_dts != PTS_UNSET)
dts_offset = pkt->pkt_dts;
if (dts_offset == PTS_UNSET)
dts_offset = get_dts_ref(pkt, ss);
if (dts_pts_valid(pkt, dts_offset)) {
pkt3 = pkt_copy_shallow(pkt);
pkt3->pkt_dts -= dts_offset;
Expand Down

0 comments on commit b9882fe

Please sign in to comment.