LIST_ENTRY(transcoder_stream) ts_link;
int ts_first;
+ pktbuf_t *ts_input_gh;
+
void (*ts_handle_pkt) (struct transcoder *, struct transcoder_stream *, th_pkt_t *);
void (*ts_destroy) (struct transcoder *, struct transcoder_stream *);
} transcoder_stream_t;
if (!avcodec_is_open(ictx)) {
if (icodec->id == AV_CODEC_ID_AAC || icodec->id == AV_CODEC_ID_VORBIS) {
- if (pkt->pkt_meta) {
- ictx->extradata_size = pktbuf_len(pkt->pkt_meta);
+ if (ts->ts_input_gh) {
+ ictx->extradata_size = pktbuf_len(ts->ts_input_gh);
ictx->extradata = av_malloc(ictx->extradata_size);
memcpy(ictx->extradata,
- pktbuf_ptr(pkt->pkt_meta), pktbuf_len(pkt->pkt_meta));
+ pktbuf_ptr(ts->ts_input_gh), pktbuf_len(ts->ts_input_gh));
} else {
- /* wait for metadata */
- return;
+ tvherror("transcode", "%04X: missing meta data for %s",
+ shortid(t), icodec->id == AV_CODEC_ID_AAC ? "AAC" : "VORBIS");
}
}
if (!avcodec_is_open(ictx)) {
if (icodec->id == AV_CODEC_ID_H264) {
- if (pkt->pkt_meta) {
- ictx->extradata_size = pktbuf_len(pkt->pkt_meta);
+ if (ts->ts_input_gh) {
+ ictx->extradata_size = pktbuf_len(ts->ts_input_gh);
ictx->extradata = av_malloc(ictx->extradata_size);
memcpy(ictx->extradata,
- pktbuf_ptr(pkt->pkt_meta), pktbuf_len(pkt->pkt_meta));
+ pktbuf_ptr(ts->ts_input_gh), pktbuf_len(ts->ts_input_gh));
} else {
- /* wait for metadata */
- return;
+ tvherror("transcode", "%04X: missing meta data for H264", shortid(t));
}
}
static void
transcoder_destroy_stream(transcoder_t *t, transcoder_stream_t *ts)
{
+ if (ts->ts_input_gh)
+ pktbuf_ref_dec(ts->ts_input_gh);
free(ts);
}
LIST_INSERT_HEAD(&t->t_stream_list, ts, ts_link);
- if(ssc->ssc_gh)
+ if(ssc->ssc_gh) {
+ pktbuf_ref_inc(ssc->ssc_gh);
+ ts->ts_input_gh = ssc->ssc_gh;
pktbuf_ref_inc(ssc->ssc_gh);
+ }
tvhinfo("transcode", "%04X: %d:%s ==> Passthrough",
shortid(t), ssc->ssc_index,
av_free(ss->sub_octx);
}
- free(ts);
+ transcoder_destroy_stream(t, ts);
}
ss->ts_target = t->t_output;
ss->ts_handle_pkt = transcoder_stream_subtitle;
ss->ts_destroy = transcoder_destroy_subtitle;
+ if (ssc->ssc_gh) {
+ ss->ts_input_gh = ssc->ssc_gh;
+ pktbuf_ref_inc(ssc->ssc_gh);
+ }
ss->sub_icodec = icodec;
ss->sub_ocodec = ocodec;
av_audio_fifo_free(as->fifo);
- free(ts);
+ transcoder_destroy_stream(t, ts);
}
as->ts_target = t->t_output;
as->ts_handle_pkt = transcoder_stream_audio;
as->ts_destroy = transcoder_destroy_audio;
+ if (ssc->ssc_gh) {
+ as->ts_input_gh = ssc->ssc_gh;
+ pktbuf_ref_inc(ssc->ssc_gh);
+ }
as->aud_icodec = icodec;
as->aud_ocodec = ocodec;
vs->flt_graph = NULL;
}
- free(ts);
+ transcoder_destroy_stream(t, ts);
}
vs->ts_target = t->t_output;
vs->ts_handle_pkt = transcoder_stream_video;
vs->ts_destroy = transcoder_destroy_video;
+ if (ssc->ssc_gh) {
+ vs->ts_input_gh = ssc->ssc_gh;
+ pktbuf_ref_inc(ssc->ssc_gh);
+ }
vs->vid_icodec = icodec;
vs->vid_ocodec = ocodec;