From: Jaroslav Kysela Date: Wed, 25 Nov 2015 20:34:13 +0000 (+0100) Subject: transcode: use metadata from streaming_start message, fixes #3331 X-Git-Tag: v4.2.1~1464 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97cbcb3fa472b4eb05b6a272a966c791949559bb;p=thirdparty%2Ftvheadend.git transcode: use metadata from streaming_start message, fixes #3331 --- diff --git a/src/plumbing/transcoding.c b/src/plumbing/transcoding.c index 4c024d67c..a3f1ece65 100644 --- a/src/plumbing/transcoding.c +++ b/src/plumbing/transcoding.c @@ -53,6 +53,8 @@ typedef struct transcoder_stream { 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; @@ -494,14 +496,14 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) 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"); } } @@ -1179,14 +1181,13 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) 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)); } } @@ -1511,6 +1512,8 @@ transcoder_packet(transcoder_t *t, th_pkt_t *pkt) 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); } @@ -1531,8 +1534,11 @@ transcoder_init_stream(transcoder_t *t, streaming_start_component_t *ssc) 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, @@ -1562,7 +1568,7 @@ transcoder_destroy_subtitle(transcoder_t *t, transcoder_stream_t *ts) av_free(ss->sub_octx); } - free(ts); + transcoder_destroy_stream(t, ts); } @@ -1601,6 +1607,10 @@ transcoder_init_subtitle(transcoder_t *t, streaming_start_component_t *ssc) 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; @@ -1649,7 +1659,7 @@ transcoder_destroy_audio(transcoder_t *t, transcoder_stream_t *ts) av_audio_fifo_free(as->fifo); - free(ts); + transcoder_destroy_stream(t, ts); } @@ -1695,6 +1705,10 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc) 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; @@ -1760,7 +1774,7 @@ transcoder_destroy_video(transcoder_t *t, transcoder_stream_t *ts) vs->flt_graph = NULL; } - free(ts); + transcoder_destroy_stream(t, ts); } @@ -1796,6 +1810,10 @@ transcoder_init_video(transcoder_t *t, streaming_start_component_t *ssc) 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;