Ticket #6749: fix-wrong-audio-streams.2

File fix-wrong-audio-streams.2, 1.7 KB (added by Matthias "mortalmatt" Dahl <devel@…>, 15 years ago)
Line 
1--- a/mythtv/libs/libavformat/mpegts.c  2009-07-20 22:51:32.000000000 +0200
2+++ b/mythtv/libs/libavformat/mpegts.c  2009-07-21 17:24:07.925849223 +0200
3@@ -51,6 +51,7 @@
4 static SectionContext *add_section_stream(MpegTSContext *ts, int pid, int stream_type);
5 static void mpegts_cleanup_streams(MpegTSContext *ts);
6 static int is_desired_stream(int type);
7+static int is_audio_stream(int type);
8 static int find_in_list(const int *pids, int pid);
9 static void mpegts_push_section(void *opaque, const uint8_t *section, int section_len);
10 
11@@ -1011,6 +1012,25 @@
12     return val;
13 }
14 
15+static int is_audio_stream(int stream_type)
16+{
17+    int val = 0;
18+    switch (stream_type)
19+    {
20+        case STREAM_TYPE_AUDIO_MPEG1:
21+        case STREAM_TYPE_AUDIO_MPEG2:
22+        case STREAM_TYPE_AUDIO_AAC:
23+        case STREAM_TYPE_AUDIO_AC3:
24+        case STREAM_TYPE_AUDIO_DTS:
25+            val = 1;
26+            break;
27+        default:
28+            /* no audio stream */
29+            break;
30+    }
31+    return val;
32+}
33+
34 static int mpegts_parse_desc(dvb_caption_info_t *dvbci,
35                              uint8_t **p, uint8_t *p_end, int *stream_type)
36 {
37@@ -1173,8 +1193,12 @@
38                 return;
39             }
40 
41-            /* Pretend it's audio if we have a language. */
42-            st = new_pes_av_stream(pes, prog_reg_desc, item->dvbci.language[0] ? 0x1c0 : 0);
43+            int pes_start_code = 0;
44+            if (is_audio_stream(item->type))
45+            {
46+                pes_start_code = 0x1c0;
47+            }
48+            st = new_pes_av_stream(pes, prog_reg_desc, pes_start_code);
49             if (!st)
50             {
51                 av_log(NULL, AV_LOG_ERROR, "mpegts_add_stream: "