changeset 19640:521f71200591

Display track names in matroska files. Patch by Paul Lebedev _paul d lebedev a gmail d com_.
author eugeni
date Sat, 02 Sep 2006 19:39:24 +0000
parents bbe600db7b83
children 84bf8bd9f9da
files libmpdemux/demux_mkv.c
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Sat Sep 02 19:21:40 2006 +0000
+++ b/libmpdemux/demux_mkv.c	Sat Sep 02 19:39:24 2006 +0000
@@ -76,6 +76,7 @@
 typedef struct mkv_track
 {
   int tnum;
+  char *name;
   
   char *codec_id;
   int ms_compat;
@@ -1006,6 +1007,7 @@
   memset(track, 0, sizeof(*track));
   /* set default values */
   track->default_track = 1;
+  track->name = 0;
   track->language = strdup("eng");
 
   len = length = ebml_read_length (s, &il);
@@ -1025,6 +1027,16 @@
             break;
           }
 
+        case MATROSKA_ID_TRACKNAME:
+          {
+            track->name = ebml_read_utf8 (s, &l);
+            if (track->name == NULL)
+              return 0;
+            mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] |  + Name: %s\n",
+                    track->name);
+            break;
+          }
+          
         case MATROSKA_ID_TRACKTYPE:
           {
             uint64_t num = ebml_read_uint (s, &l);
@@ -1707,22 +1719,32 @@
         case MATROSKA_TRACK_VIDEO:
           type = "video";
           demux_mkv_open_video(demuxer, mkv_d->tracks[i], vid);
+          if (mkv_d->tracks[i]->name)
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VID_%d_NAME=%s\n", vid, mkv_d->tracks[i]->name);
           sprintf (str, "-vid %u", vid++);
           break;
         case MATROSKA_TRACK_AUDIO:
           type = "audio";
           demux_mkv_open_audio(demuxer, mkv_d->tracks[i], aid);
+          if (mkv_d->tracks[i]->name)
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_NAME=%s\n", aid, mkv_d->tracks[i]->name);
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", aid, mkv_d->tracks[i]->language);
           sprintf (str, "-aid %u, -alang %.5s",aid++,mkv_d->tracks[i]->language);
           break;
         case MATROSKA_TRACK_SUBTITLE:
           type = "subtitles";
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
+          if (mkv_d->tracks[i]->name)
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_NAME=%s\n", sid, mkv_d->tracks[i]->name);
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sid, mkv_d->tracks[i]->language);
           sprintf (str, "-sid %u, -slang %.5s",sid++,mkv_d->tracks[i]->language);
           break;
         }
-      mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: %s (%s), %s\n",
+      if (mkv_d->tracks[i]->name)
+        mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: %s (%s) \"%s\", %s\n",
+             mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, mkv_d->tracks[i]->name, str);
+      else
+        mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: %s (%s), %s\n",
              mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, str);
     }
 }
@@ -2658,6 +2680,8 @@
         {
           for (i=0; i<mkv_d->num_tracks; i++)
             {
+              if (mkv_d->tracks[i]->name)
+                free (mkv_d->tracks[i]->name);
               if (mkv_d->tracks[i]->codec_id)
                 free (mkv_d->tracks[i]->codec_id);
               if (mkv_d->tracks[i]->language)