]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
debug: added extra debug for deep analysis of packet handling
authorAdam Sutton <dev@adamsutton.me.uk>
Tue, 4 Mar 2014 09:03:30 +0000 (09:03 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Tue, 4 Mar 2014 09:03:30 +0000 (09:03 +0000)
src/parsers/parsers.c
src/timeshift.c
src/timeshift/timeshift_reader.c

index 9adc8b20dcf8eb126dbd4c7b92b6805569e6e364..c3f21803778b4cc4b84c4ce6ced1ff3ca9121de8 100644 (file)
@@ -1387,15 +1387,21 @@ parser_deliver(service_t *t, elementary_stream_t *st, th_pkt_t *pkt, int error)
       pkt->pkt_pts < t->s_current_pts - 180000))
     t->s_current_pts = pkt->pkt_pts;
 
-#if 0
-  printf("PARSE: %-12s %d %10"PRId64" %10"PRId64" %10d %10d\n",
-        streaming_component_type2txt(st->es_type),
-        pkt->pkt_frametype,
-        pkt->pkt_dts,
-        pkt->pkt_pts,
-        pkt->pkt_duration,
-        pktbuf_len(pkt->pkt_payload));
+  tvhtrace("parser",
+           "pkt stream %2d %-12s type %c dts %10"PRId64" pts %10"PRId64
+           " dur %10d len %10"PRIsize_t,
+           st->es_index,
+           streaming_component_type2txt(st->es_type),
+           pkt_frametype_to_char(pkt->pkt_frametype),
+#if 1
+           ts_rescale(pkt->pkt_pts, 1000000),
+           ts_rescale(pkt->pkt_dts, 1000000),
+#else
+           pkt->pkt_dts,
+           pkt->pkt_pts,
 #endif
+           pkt->pkt_duration,
+           pktbuf_len(pkt->pkt_payload));
 
   pkt->pkt_aspect_num = st->es_aspect_num;
   pkt->pkt_aspect_den = st->es_aspect_den;
index 9ca7201dd240fcc59cadf9f3f042006447998f0c..c669bdc81b7cddc45537bc448fa953163501e9b1 100644 (file)
@@ -117,6 +117,7 @@ static void timeshift_input
 {
   int exit = 0;
   timeshift_t *ts = opaque;
+  th_pkt_t *pkt = sm->sm_data;
 
   pthread_mutex_lock(&ts->state_mutex);
 
@@ -136,6 +137,19 @@ static void timeshift_input
       ts->state  = TS_LIVE;
     }
 
+    if (sm->sm_type == SMT_PACKET) {
+      tvhtrace("timeshift",
+               "ts %d pkt in  - stream %d type %c pts %10"PRId64
+               " dts %10"PRId64" dur %10d len %"PRIsize_t,
+               ts->id,
+               pkt->pkt_componentindex,
+               pkt_frametype_to_char(pkt->pkt_frametype),
+               ts_rescale(pkt->pkt_pts, 1000000),
+               ts_rescale(pkt->pkt_dts, 1000000),
+               pkt->pkt_duration,
+               pktbuf_len(pkt->pkt_payload));
+    }
+
     /* Pass-thru */
     if (ts->state <= TS_LIVE) {
       if (sm->sm_type == SMT_START) {
@@ -154,7 +168,6 @@ static void timeshift_input
 
     /* Record (one-off) PTS delta */
     if (sm->sm_type == SMT_PACKET && ts->pts_delta == PTS_UNSET) {
-      th_pkt_t *pkt = sm->sm_data;
       if (pkt->pkt_pts != PTS_UNSET)
         ts->pts_delta = getmonoclock() - ts_rescale(pkt->pkt_pts, 1000000);
     }
@@ -163,6 +176,18 @@ static void timeshift_input
     if ((ts->state > TS_LIVE) || (!ts->ondemand && (ts->state == TS_LIVE))) {
       sm->sm_time = getmonoclock();
       streaming_target_deliver2(&ts->wr_queue.sq_st, sm);
+      if (sm->sm_type == SMT_PACKET) {
+        tvhtrace("timeshift",
+                 "ts %d pkt buf - stream %d type %c pts %10"PRId64
+                 " dts %10"PRId64" dur %10d len %"PRIsize_t,
+                 ts->id,
+                 pkt->pkt_componentindex,
+                 pkt_frametype_to_char(pkt->pkt_frametype),
+                 ts_rescale(pkt->pkt_pts, 1000000),
+                 ts_rescale(pkt->pkt_dts, 1000000),
+                 pkt->pkt_duration,
+                 pktbuf_len(pkt->pkt_payload));
+      }
     } else
       streaming_msg_free(sm);
 
index afcb517fb36089c5eef60f746e782450163f7789..3c007d13f09b8503df5509d43830e6abb177eb4d 100644 (file)
@@ -731,17 +731,19 @@ void *timeshift_reader ( void *p )
                (((cur_speed < 0) && (sm->sm_time >= deliver)) ||
                ((cur_speed > 0) && (sm->sm_time <= deliver))))) {
 
-#if ENABLE_TRACE
-      if (skip)
-      {
-        time_t pts = 0;
-        int64_t delta = now - sm->sm_time;
-        if (sm->sm_type == SMT_PACKET)
-          pts = ((th_pkt_t*)sm->sm_data)->pkt_pts;
-        tvhtrace("timeshift", "ts %d deliver %"PRId64" pts=%"PRItime_t " shift=%"PRIu64,
-               ts->id, sm->sm_time, pts, delta);
+      if (sm->sm_type == SMT_PACKET) {
+        th_pkt_t *pkt = sm->sm_data;
+        tvhtrace("timeshift",
+                 "ts %d pkt out - stream %d type %c pts %10"PRId64
+                 " dts %10"PRId64 " dur %10d len %"PRIsize_t" time %"PRItime_t,
+                 ts->id,
+                 pkt->pkt_componentindex,
+                 pkt_frametype_to_char(pkt->pkt_frametype),
+                 ts_rescale(pkt->pkt_pts, 1000000),
+                 ts_rescale(pkt->pkt_dts, 1000000),
+                 pkt->pkt_duration,
+                 pktbuf_len(pkt->pkt_payload), sm->sm_time);
       }
-#endif
       streaming_target_deliver2(ts->output, sm);
       last_time = sm->sm_time;
       sm        = NULL;