]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
audioes: fix the mime type / suffix audio-detection
authorJaroslav Kysela <perex@perex.cz>
Sat, 15 Oct 2016 18:06:48 +0000 (20:06 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sat, 15 Oct 2016 18:06:48 +0000 (20:06 +0200)
src/muxer/muxer_audioes.c

index 857e4254a145016fedb1456332a162b47e90faf5..79e3810d988c37c73609f0f1598453bfc3df731a 100644 (file)
@@ -67,26 +67,49 @@ audioes_muxer_type(streaming_component_type_t type)
 }
 
 
+/**
+ *
+ */
+static const streaming_start_component_t *
+audioes_get_component(muxer_t *m, const struct streaming_start *ss)
+{
+  const streaming_start_component_t *ssc;
+  muxer_container_type_t mc = MC_UNKNOWN;
+  int i, count;
+
+  for (i = count = 0; i < ss->ss_num_components;i++) {
+    ssc = &ss->ss_components[i];
+
+    if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) {
+      if (m->m_config.m_force_type != MC_UNKNOWN) {
+        mc = audioes_muxer_type(ssc->ssc_type);
+        if (m->m_config.m_force_type != mc)
+          continue;
+      }
+      if (m->m_config.m_index == count)
+        return ssc;
+      count++;
+    }
+  }
+  return NULL;
+}
+
+
 /**
  * Figure out the mimetype
  */
 static const char *
 audioes_muxer_mime(muxer_t *m, const struct streaming_start *ss)
 {
-  int i;
   muxer_container_type_t mc = MC_UNKNOWN;
   const streaming_start_component_t *ssc;
 
   if (m->m_config.m_force_type != MC_UNKNOWN)
     return muxer_container_type2mime(m->m_config.m_force_type, 0);
 
-  for (i = 0; i < ss->ss_num_components; i++) {
-    ssc = &ss->ss_components[i];
-    if (ssc->ssc_disabled)
-      continue;
+  ssc = audioes_get_component(m, ss);
+  if (ssc)
     mc = audioes_muxer_type(ssc->ssc_type);
-    break;
-  }
 
   return muxer_container_type2mime(mc, 0);
 }
@@ -100,27 +123,12 @@ audioes_muxer_reconfigure(muxer_t *m, const struct streaming_start *ss)
 {
   audioes_muxer_t *am = (audioes_muxer_t*)m;
   const streaming_start_component_t *ssc;
-  muxer_container_type_t mc;
-  int i, count = 0;
 
   am->am_index = -1;
 
-  for (i = 0; i < ss->ss_num_components;i++) {
-    ssc = &ss->ss_components[i];
-
-    if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) {
-      if (m->m_config.m_force_type != MC_UNKNOWN) {
-        mc = audioes_muxer_type(ssc->ssc_type);
-        if (m->m_config.m_force_type != mc)
-          continue;
-      }
-      if (m->m_config.m_index == count) {
-        am->am_index = ssc->ssc_index;
-        break;
-      }
-      count++;
-    }
-  }
+  ssc = audioes_get_component(m, ss);
+  if (ssc)
+    am->am_index = ssc->ssc_index;
 
   return 0;
 }