* suppoed to take care of)
*/
th_pkt_t *
-pkt_alloc(const void *data, size_t datalen, int64_t pts, int64_t dts)
+pkt_alloc(streaming_component_type_t type, const void *data, size_t datalen,
+ int64_t pts, int64_t dts)
{
th_pkt_t *pkt;
pkt = calloc(1, sizeof(th_pkt_t));
if (pkt) {
+ pkt->pkt_type = type;
if(datalen)
pkt->pkt_payload = pktbuf_alloc(data, datalen);
pkt->pkt_dts = dts;
*/
void
pkt_trace_(const char *file, int line, int subsys, th_pkt_t *pkt,
- int index, streaming_component_type_t type, const char *fmt, ...)
+ const char *fmt, ...)
{
char buf[512], _dts[22], _pts[22], _type[2];
va_list args;
" dur %d len %zu err %i%s",
fmt ? fmt : "",
fmt ? " (" : "",
- index,
- streaming_component_type2txt(type),
+ pkt->pkt_componentindex,
+ streaming_component_type2txt(pkt->pkt_type),
_type[0] ? " type " : "", _type,
pts_to_string(pkt->pkt_dts, _dts),
pts_to_string(pkt->pkt_pts, _pts),
int pkt_duration;
int pkt_refcount;
- uint8_t pkt_commercial;
+ uint8_t pkt_type;
+ uint8_t pkt_err;
uint8_t pkt_componentindex;
+ uint8_t pkt_commercial;
+
uint8_t pkt_frametype;
uint8_t pkt_field; // Set if packet is only a half frame (a field)
uint8_t pkt_channels;
uint8_t pkt_sri;
uint8_t pkt_ext_sri;
- uint8_t pkt_err;
uint16_t pkt_aspect_num;
uint16_t pkt_aspect_den;
#define PKTREF_FOREACH(item, queue) TAILQ_FOREACH((item), (queue), pr_link)
-th_pkt_t *pkt_alloc(const void *data, size_t datalen, int64_t pts, int64_t dts);
+th_pkt_t *pkt_alloc(streaming_component_type_t type,
+ const void *data, size_t datalen, int64_t pts, int64_t dts);
th_pkt_t *pkt_copy_shallow(th_pkt_t *pkt);
void pkt_trace_
(const char *file, int line, int subsys, th_pkt_t *pkt,
- int index, streaming_component_type_t type, const char *fmt, ...);
+ const char *fmt, ...);
-#define pkt_trace(subsys, pkt, index, type, fmt, ...) \
+#define pkt_trace(subsys, pkt, fmt, ...) \
do { \
if (tvhtrace_enabled()) \
- pkt_trace_(__FILE__, __LINE__, subsys, pkt, index, type, fmt, ##__VA_ARGS__); \
+ pkt_trace_(__FILE__, __LINE__, subsys, pkt, fmt, ##__VA_ARGS__); \
} while (0)
/*
if(st->es_curdts == PTS_UNSET)
return NULL;
- th_pkt_t *pkt = pkt_alloc(NULL, slot_len + 7, st->es_curdts, st->es_curdts);
+ th_pkt_t *pkt = pkt_alloc(st->es_type, NULL, slot_len + 7, st->es_curdts, st->es_curdts);
pkt->pkt_commercial = t->s_tt_commercial_advice;
pkt->pkt_duration = st->es_frame_duration;
sub[off++] = 0;
- th_pkt_t *pkt = pkt_alloc(sub, off, pts, pts);
+ th_pkt_t *pkt = pkt_alloc(st->es_type, sub, off, pts, pts);
pkt->pkt_componentindex = st->es_index;
streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_pkt(pkt));
int len, int64_t dts, int duration, int channels, int sri,
int errors)
{
- th_pkt_t *pkt = pkt_alloc(buf, len, dts, dts);
+ th_pkt_t *pkt = pkt_alloc(st->es_type, buf, len, dts, dts);
pkt->pkt_commercial = t->s_tt_commercial_advice;
pkt->pkt_duration = duration;
if(st->es_curpkt != NULL)
pkt_ref_dec(st->es_curpkt);
- pkt = pkt_alloc(NULL, 0, st->es_curpts, st->es_curdts);
+ pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
pkt->pkt_frametype = frametype;
pkt->pkt_duration = st->es_frame_duration;
pkt->pkt_commercial = t->s_tt_commercial_advice;
if (st->es_frame_duration == 0)
st->es_frame_duration = 1;
- pkt = pkt_alloc(NULL, 0, st->es_curpts, st->es_curdts);
+ pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
pkt->pkt_frametype = pkttype;
pkt->pkt_field = isfield;
pkt->pkt_duration = st->es_frame_duration;
if (r > 0)
return PARSER_APPEND;
- st->es_curpkt = pkt_alloc(NULL, 0, st->es_curpts, st->es_curdts);
+ st->es_curpkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
st->es_curpkt->pkt_frametype = pkttype;
st->es_curpkt->pkt_field = 0;
st->es_curpkt->pkt_duration = st->es_frame_duration;
// end_of_PES_data_field_marker
if(buf[psize - 1] == 0xff) {
- pkt = pkt_alloc(buf, psize - 1, st->es_curpts, st->es_curdts);
+ pkt = pkt_alloc(st->es_type, buf, psize - 1, st->es_curpts, st->es_curdts);
pkt->pkt_commercial = t->s_tt_commercial_advice;
pkt->pkt_err = st->es_buf.sb_err;
parser_deliver(t, st, pkt);
if(psize >= 46) {
teletext_input((mpegts_service_t *)t, st, buf, psize);
- pkt = pkt_alloc(buf, psize, st->es_curpts, st->es_curdts);
+ pkt = pkt_alloc(st->es_type, buf, psize, st->es_curpts, st->es_curdts);
pkt->pkt_commercial = t->s_tt_commercial_advice;
pkt->pkt_err = st->es_buf.sb_err;
parser_deliver(t, st, pkt);
t->s_current_pts = (pkt->pkt_pts + (int64_t)t->s_pts_shift * 900) % PTS_MASK;
}
- pkt_trace(LS_PARSER, pkt, st->es_index, st->es_type, "deliver");
+ pkt->pkt_componentindex = st->es_index;
+
+ pkt_trace(LS_PARSER, pkt, "deliver");
pkt->pkt_aspect_num = st->es_aspect_num;
pkt->pkt_aspect_den = st->es_aspect_den;
}
/* Forward packet */
- pkt->pkt_componentindex = st->es_index;
-
streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_pkt(pkt));
/* Decrease our own reference to the packet */
if (!st->es_buf.sb_err)
return;
- pkt = pkt_alloc(NULL, 0, PTS_UNSET, PTS_UNSET);
+ pkt = pkt_alloc(st->es_type, NULL, 0, PTS_UNSET, PTS_UNSET);
pkt->pkt_err = st->es_buf.sb_err;
parser_deliver(t, st, pkt);
st->es_buf.sb_err = 0;
int64_t pts = pkt->pkt_pts;
pkt->pkt_dts = pts_no_backlog(dts);
pkt->pkt_pts = pts_no_backlog(pts);
- pkt_trace(LS_PARSER, pkt, st->es_index, st->es_type, "backlog");
+ pkt_trace(LS_PARSER, pkt, "backlog");
pkt->pkt_dts = dts;
pkt->pkt_pts = pts;
}
return;
}
- pkt_trace(LS_GLOBALHEADERS, pkt, pkt->pkt_componentindex, ssc->ssc_type, "hold receive");
+ pkt_trace(LS_GLOBALHEADERS, pkt, "hold receive");
pkt_ref_inc(pkt);
extra_size = 7;
}
- n = pkt_alloc(NULL, packet.size + extra_size, packet.pts, packet.pts);
+ n = pkt_alloc(ts->ts_type, NULL, packet.size + extra_size, packet.pts, packet.pts);
memcpy(pktbuf_ptr(n->pkt_payload) + extra_size, packet.data, packet.size);
n->pkt_componentindex = ts->ts_index;
if ((ts->ts_type == SCT_H264 || ts->ts_type == SCT_HEVC) &&
octx->extradata_size &&
(ts->ts_first || octx->coded_frame->pict_type == AV_PICTURE_TYPE_I)) {
- n = pkt_alloc(NULL, octx->extradata_size + epkt->size, epkt->pts, epkt->dts);
+ n = pkt_alloc(ts->ts_type, NULL, octx->extradata_size + epkt->size, epkt->pts, epkt->dts);
memcpy(pktbuf_ptr(n->pkt_payload), octx->extradata, octx->extradata_size);
memcpy(pktbuf_ptr(n->pkt_payload) + octx->extradata_size, epkt->data, epkt->size);
ts->ts_first = 0;
} else {
- n = pkt_alloc(epkt->data, epkt->size, epkt->pts, epkt->dts);
+ n = pkt_alloc(ts->ts_type, epkt->data, epkt->size, epkt->pts, epkt->dts);
}
switch (octx->coded_frame->pict_type) {
if (!vs->vid_first_sent) {
/* notify global headers that we're live */
/* the video packets might be delayed */
- pkt2 = pkt_alloc(NULL, 0, pkt->pkt_pts, pkt->pkt_dts);
+ pkt2 = pkt_alloc(ts->ts_type, NULL, 0, pkt->pkt_pts, pkt->pkt_dts);
pkt2->pkt_componentindex = pkt->pkt_componentindex;
sm = streaming_msg_create_pkt(pkt2);
streaming_target_deliver2(ts->ts_target, sm);
static void
tsfix_packet_drop(tfstream_t *tfs, th_pkt_t *pkt, const char *reason)
{
- pkt_trace(LS_TSFIX, pkt, tfs->tfs_index, tfs->tfs_type, "drop");
+ pkt_trace(LS_TSFIX, pkt, "drop");
pkt_ref_dec(pkt);
}
deliver:
if (tvhtrace_enabled()) {
char _odts[22], _opts[22];
- pkt_trace(LS_TSFIX, pkt, tfs->tfs_index, tfs->tfs_type,
+ pkt_trace(LS_TSFIX, pkt,
"deliver odts %s opts %s ref %"PRId64" epoch %"PRId64,
pts_to_string(odts, _odts), pts_to_string(opts, _opts),
ref, tfs->tfs_dts_epoch);