]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add timeshift support for audio-only channels
authorFlole998 <Flole998@users.noreply.github.com>
Wed, 31 Jan 2024 12:41:24 +0000 (12:41 +0000)
committerFlole998 <Flole998@users.noreply.github.com>
Wed, 31 Jan 2024 12:41:51 +0000 (12:41 +0000)
src/timeshift/private.h
src/timeshift/timeshift_writer.c

index 5c6000e2ae8e2089bd614f664a07683c2efcbfa8..16536229cc5be50169629d2e287d7ade2c74ca33 100644 (file)
@@ -131,6 +131,7 @@ typedef struct timeshift {
   int                         file_segments; ///< Count of segments in files
 
   int                         vididx;     ///< Index of (current) video stream
+  int                         audidx;     ///< Index of (current) audio stream
 
   streaming_start_t          *smt_start;  ///< Streaming start info
 
index 8eb22a167e647a9ed1c592094944b61d5600635d..6f15a38c162088a572a1c2c2350c96fe69620c96 100644 (file)
@@ -249,6 +249,13 @@ static void _update_smt_start ( timeshift_t *ts, streaming_start_t *ss )
       ts->vididx = ss->ss_components[i].es_index;
       break;
     }
+
+  /* Update audio index */
+  for (i = 0; i < ss->ss_num_components; i++)
+    if (SCT_ISAUDIO(ss->ss_components[i].es_type)) {
+      ts->audidx = ss->ss_components[i].es_index;
+      break;
+    }
 }
 
 /*
@@ -283,9 +290,9 @@ static inline ssize_t _process_msg0
     if (err > 0) {
       th_pkt_t *pkt = sm->sm_data;
 
-      /* Index video iframes */
-      if (pkt->pkt_componentindex == ts->vididx &&
-          pkt->v.pkt_frametype    == PKT_I_FRAME) {
+      /* Index video iframes or audio frames for audio-only streams*/
+      if ((pkt->pkt_componentindex == ts->vididx && pkt->v.pkt_frametype == PKT_I_FRAME) ||
+          (ts->vididx == -1 && pkt->pkt_componentindex == ts->audidx)) {
         timeshift_index_iframe_t *ti = calloc(1, sizeof(timeshift_index_iframe_t));
         memoryinfo_alloc(&timeshift_memoryinfo, sizeof(*ti));
         ti->pos  = tsf->size;