]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
packet: add pcr value to all packets for further usage
authorJaroslav Kysela <perex@perex.cz>
Thu, 27 Apr 2017 16:17:03 +0000 (18:17 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 27 Apr 2017 16:17:03 +0000 (18:17 +0200)
src/packet.c
src/packet.h
src/parsers/parser_latm.c
src/parsers/parser_teletext.c
src/parsers/parsers.c
src/plumbing/transcoding.c

index 9c548eaead1fb58112aa679c0734ea61edea78f5..6c723134da240895d31414daa2caa854c383d16e 100644 (file)
@@ -53,7 +53,7 @@ pkt_destroy(th_pkt_t *pkt)
  */
 th_pkt_t *
 pkt_alloc(streaming_component_type_t type, const void *data, size_t datalen,
-          int64_t pts, int64_t dts)
+          int64_t pts, int64_t dts, int64_t pcr)
 {
   th_pkt_t *pkt;
 
@@ -64,6 +64,7 @@ pkt_alloc(streaming_component_type_t type, const void *data, size_t datalen,
       pkt->pkt_payload = pktbuf_alloc(data, datalen);
     pkt->pkt_dts = dts;
     pkt->pkt_pts = pts;
+    pkt->pkt_pcr = pcr;
     pkt->pkt_refcount = 1;
     memoryinfo_alloc(&pkt_memoryinfo, sizeof(*pkt));
   }
index feb33c21eb37afe855de8cff98cee11904c6c2ae..6d418fbfbbc1b9656cabe27b91aa10e667e009c8 100644 (file)
@@ -51,6 +51,7 @@ static inline char pkt_frametype_to_char ( int frametype )
 typedef struct th_pkt {
   int64_t pkt_dts;
   int64_t pkt_pts;
+  int64_t pkt_pcr;
   int pkt_duration;
   int pkt_refcount;
 
@@ -119,7 +120,8 @@ void pktref_insert_head(struct th_pktref_queue *q, th_pkt_t *pkt);
 #define PKTREF_FOREACH(item, queue) TAILQ_FOREACH((item), (queue), pr_link)
 
 th_pkt_t *pkt_alloc(streaming_component_type_t type,
-                    const void *data, size_t datalen, int64_t pts, int64_t dts);
+                    const void *data, size_t datalen,
+                    int64_t pts, int64_t dts, int64_t pcr);
 
 th_pkt_t *pkt_copy_shallow(th_pkt_t *pkt);
 
index 52727d3fc7ea5295aab73cd11483d65e4997136d..fbcde2664fbc7541a4acc04f119d750ffe2249f6 100644 (file)
@@ -260,7 +260,7 @@ parse_latm_audio_mux_element(service_t *t, elementary_stream_t *st,
   if(st->es_curdts == PTS_UNSET)
     return NULL;
 
-  th_pkt_t *pkt = pkt_alloc(st->es_type, 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, t->s_current_pcr);
 
   pkt->pkt_commercial = t->s_tt_commercial_advice;
   pkt->pkt_duration   = st->es_frame_duration;
index 0df6a2c9e734742eec10c257f4372576748eeb28..14ba05e149f3f5359570c99daabdf5532c5ed87d 100644 (file)
@@ -793,7 +793,7 @@ extract_subtitle(mpegts_service_t *t, elementary_stream_t *st,
 
   sub[off++] = 0;
 
-  th_pkt_t *pkt = pkt_alloc(st->es_type, sub, off, pts, pts);
+  th_pkt_t *pkt = pkt_alloc(st->es_type, sub, off, pts, pts, pts);
   pkt->pkt_componentindex = st->es_index;
 
   streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_pkt(pkt));
index 2baccae44002a0b599614bc5899a7e94419ebc29..966b36be1c6cb4e39580e90ac6eab7bd4cdb4a5f 100644 (file)
@@ -532,7 +532,7 @@ makeapkt(service_t *t, elementary_stream_t *st, const void *buf,
          int len, int64_t dts, int duration, int channels, int sri,
          int errors)
 {
-  th_pkt_t *pkt = pkt_alloc(st->es_type, buf, len, dts, dts);
+  th_pkt_t *pkt = pkt_alloc(st->es_type, buf, len, dts, dts, t->s_current_pcr);
 
   pkt->pkt_commercial = t->s_tt_commercial_advice;
   pkt->pkt_duration = duration;
@@ -1201,7 +1201,7 @@ parse_mpeg2video(service_t *t, elementary_stream_t *st, size_t len,
     if(st->es_curpkt != NULL)
       pkt_ref_dec(st->es_curpkt);
 
-    pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
+    pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts, t->s_current_pcr);
     pkt->v.pkt_frametype = frametype;
     pkt->pkt_duration = st->es_frame_duration;
     pkt->pkt_commercial = t->s_tt_commercial_advice;
@@ -1492,7 +1492,7 @@ parse_h264(service_t *t, elementary_stream_t *st, size_t len,
       if (st->es_frame_duration == 0)
         st->es_frame_duration = 1;
 
-      pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
+      pkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts, t->s_current_pcr);
       pkt->v.pkt_frametype = pkttype;
       pkt->v.pkt_field = isfield;
       pkt->pkt_duration = st->es_frame_duration;
@@ -1617,7 +1617,7 @@ parse_hevc(service_t *t, elementary_stream_t *st, size_t len,
     if (r > 0)
       return PARSER_APPEND;
 
-    st->es_curpkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts);
+    st->es_curpkt = pkt_alloc(st->es_type, NULL, 0, st->es_curpts, st->es_curdts, t->s_current_pcr);
     st->es_curpkt->v.pkt_frametype = pkttype;
     st->es_curpkt->v.pkt_field = 0;
     st->es_curpkt->pkt_duration = st->es_frame_duration;
@@ -1762,7 +1762,7 @@ parse_subtitles(service_t *t, elementary_stream_t *st, const uint8_t *data,
 
     // end_of_PES_data_field_marker
     if(buf[psize - 1] == 0xff) {
-      pkt = pkt_alloc(st->es_type, buf, psize - 1, st->es_curpts, st->es_curdts);
+      pkt = pkt_alloc(st->es_type, buf, psize - 1, st->es_curpts, st->es_curdts, t->s_current_pcr);
       pkt->pkt_commercial = t->s_tt_commercial_advice;
       pkt->pkt_err = st->es_buf.sb_err;
       parser_deliver(t, st, pkt);
@@ -1814,7 +1814,7 @@ parse_teletext(service_t *t, elementary_stream_t *st, const uint8_t *data,
   
   if(psize >= 46 && t->s_current_pcr != PTS_UNSET) {
     teletext_input((mpegts_service_t *)t, st, buf, psize);
-    pkt = pkt_alloc(st->es_type, buf, psize, t->s_current_pcr, t->s_current_pcr);
+    pkt = pkt_alloc(st->es_type, buf, psize, t->s_current_pcr, t->s_current_pcr, t->s_current_pcr);
     pkt->pkt_commercial = t->s_tt_commercial_advice;
     pkt->pkt_err = st->es_buf.sb_err;
     parser_deliver(t, st, pkt);
@@ -1865,7 +1865,7 @@ parser_deliver_error(service_t *t, elementary_stream_t *st)
 
   if (!st->es_buf.sb_err)
     return;
-  pkt = pkt_alloc(st->es_type, NULL, 0, PTS_UNSET, PTS_UNSET);
+  pkt = pkt_alloc(st->es_type, NULL, 0, PTS_UNSET, PTS_UNSET, t->s_current_pcr);
   pkt->pkt_err = st->es_buf.sb_err;
   parser_deliver(t, st, pkt);
   st->es_buf.sb_err = 0;
index d86970b81831ad053c53440e246f0f90c00b7331..f2fa9089006f05c801729611c9603fde8cfab6b3 100644 (file)
@@ -850,7 +850,7 @@ scleanup:
           extra_size = 7;
       }
 
-      n = pkt_alloc(ts->ts_type, NULL, packet.size + extra_size, packet.pts, packet.pts);
+      n = pkt_alloc(ts->ts_type, NULL, packet.size + extra_size, packet.pts, packet.pts, packet.pts);
       memcpy(pktbuf_ptr(n->pkt_payload) + extra_size, packet.data, packet.size);
 
       n->pkt_componentindex = ts->ts_index;
@@ -969,12 +969,12 @@ send_video_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt,
   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(ts->ts_type, 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, 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(ts->ts_type, epkt->data, epkt->size, epkt->pts, epkt->dts);
+    n = pkt_alloc(ts->ts_type, epkt->data, epkt->size, epkt->pts, epkt->dts, epkt->dts);
   }
 
   switch (octx->coded_frame->pict_type) {
@@ -1213,7 +1213,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   if (!vs->vid_first_sent) {
     /* notify global headers that we're live */
     /* the video packets might be delayed */
-    pkt2 = pkt_alloc(ts->ts_type, NULL, 0, pkt->pkt_pts, pkt->pkt_dts);
+    pkt2 = pkt_alloc(ts->ts_type, NULL, 0, pkt->pkt_pts, pkt->pkt_dts, pkt->pkt_dts);
     pkt2->pkt_componentindex = pkt->pkt_componentindex;
     sm = streaming_msg_create_pkt(pkt2);
     streaming_target_deliver2(ts->ts_target, sm);