For matroska we need a few pieces of info for each stream (sample rate, # channels, video resolution, etc).

If we are unable to extract this data from an elementary stream for 5 seconds, skip the stream in recorded file.

Hopefully fixes ticket #261 and #244
This commit is contained in:
Andreas Öman 2010-08-19 18:58:02 +00:00
parent eb72517b15
commit 049fcadbf9
4 changed files with 57 additions and 19 deletions

View file

@ -362,13 +362,14 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss)
}
tvhlog(LOG_INFO, "dvr",
"%2d %-20s %-4s %-16s %-10s %-10s",
"%2d %-20s %-4s %-16s %-10s %-10s %s",
ssc->ssc_index,
streaming_component_type2txt(ssc->ssc_type),
ssc->ssc_lang,
res,
sr,
ch);
ch,
ssc->ssc_disabled ? "<disabled, no valid input>" : "");
}
}

View file

@ -45,6 +45,7 @@ typedef struct mk_track {
int merge;
int type;
int tracknum;
int disabled;
int64_t nextpts;
} mk_track;
@ -172,6 +173,11 @@ mk_build_tracks(mk_mux_t *mkm, const struct streaming_start *ss)
for(i = 0; i < ss->ss_num_components; i++) {
ssc = &ss->ss_components[i];
mkm->tracks[i].disabled = ssc->ssc_disabled;
if(ssc->ssc_disabled)
continue;
mkm->tracks[i].index = ssc->ssc_index;
mkm->tracks[i].type = ssc->ssc_type;
mkm->tracks[i].nextpts = PTS_UNSET;
@ -670,7 +676,7 @@ mk_mux_write_pkt(mk_mux_t *mkm, struct th_pkt *pkt)
}
}
if(t != NULL) {
if(t != NULL && !t->disabled) {
if(t->merge)
pkt = pkt_merge_header(pkt);
mk_write_frame_i(mkm, t, pkt);

View file

@ -34,6 +34,8 @@ typedef struct globalheaders {
} globalheaders_t;
#define MAX_SCAN_TIME 5000 // in ms
/**
*
@ -85,9 +87,7 @@ apply_header(streaming_start_component_t *ssc, th_pkt_t *pkt)
pktbuf_ref_inc(ssc->ssc_gh);
}
break;
}
}
@ -95,7 +95,29 @@ apply_header(streaming_start_component_t *ssc, th_pkt_t *pkt)
*
*/
static int
headers_complete(globalheaders_t *gh)
header_complete(streaming_start_component_t *ssc)
{
if((SCT_ISAUDIO(ssc->ssc_type) || SCT_ISVIDEO(ssc->ssc_type)) &&
ssc->ssc_frameduration == 0)
return 0;
if(SCT_ISAUDIO(ssc->ssc_type) &&
(ssc->ssc_sri == 0 || ssc->ssc_channels == 0))
return 0;
if(ssc->ssc_gh == NULL &&
(ssc->ssc_type == SCT_H264 ||
ssc->ssc_type == SCT_MPEG2VIDEO ||
ssc->ssc_type == SCT_AAC))
return 0;
return 1;
}
/**
*
*/
static int
headers_complete(globalheaders_t *gh, int64_t qd)
{
streaming_start_t *ss = gh->gh_ss;
streaming_start_component_t *ssc;
@ -106,19 +128,14 @@ headers_complete(globalheaders_t *gh)
for(i = 0; i < ss->ss_num_components; i++) {
ssc = &ss->ss_components[i];
if((SCT_ISAUDIO(ssc->ssc_type) || SCT_ISVIDEO(ssc->ssc_type)) &&
ssc->ssc_frameduration == 0)
return 0;
if(!header_complete(ssc)) {
if(SCT_ISAUDIO(ssc->ssc_type) &&
(ssc->ssc_sri == 0 || ssc->ssc_channels == 0))
return 0;
if(ssc->ssc_gh == NULL &&
(ssc->ssc_type == SCT_H264 ||
ssc->ssc_type == SCT_MPEG2VIDEO ||
ssc->ssc_type == SCT_AAC))
return 0;
if(qd > (MAX_SCAN_TIME * 90)) {
ssc->ssc_disabled = 1;
} else {
return 0;
}
}
}
return 1;
@ -142,6 +159,19 @@ convertpkt(streaming_start_component_t *ssc, th_pkt_t *pkt)
}
/**
*
*/
static int64_t
gh_queue_delay(globalheaders_t *gh)
{
th_pktref_t *f = TAILQ_FIRST(&gh->gh_holdq);
th_pktref_t *l = TAILQ_LAST(&gh->gh_holdq, th_pktref_queue);
return l->pr_pkt->pkt_dts - f->pr_pkt->pkt_dts;
}
/**
*
*/
@ -168,7 +198,7 @@ gh_hold(globalheaders_t *gh, streaming_message_t *sm)
free(sm);
if(!headers_complete(gh))
if(!headers_complete(gh, gh_queue_delay(gh)))
break;
// Send our modified start

View file

@ -35,6 +35,7 @@ typedef struct streaming_start_component {
int16_t ssc_height;
uint8_t ssc_sri;
uint8_t ssc_channels;
uint8_t ssc_disabled;
pktbuf_t *ssc_gh;