[vlc-commits] demux: mp4: add minimal support for exclusive tracks

Francois Cartegnie git at videolan.org
Sat Oct 18 00:42:39 CEST 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Oct 18 00:40:07 2014 +0200| [36cb0f52b867d96eddde8577db118c11ce24d77a] | committer: Francois Cartegnie

demux: mp4: add minimal support for exclusive tracks

VLC supports groups where mp4 defines switch groups.
As an es can't belong to multiple groups, but does in
switch groups, we don't really have a way to provide
the same track exclusion/alternative features without
duplicating es.

Priorities are then set in a way es/tracks from the same
cat/switchgroup are not all selected.

refs #3970

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36cb0f52b867d96eddde8577db118c11ce24d77a
---

 modules/demux/mp4/mp4.c |   24 ++++++++++++++++++++++++
 modules/demux/mp4/mp4.h |    1 +
 2 files changed, 25 insertions(+)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index df9fd4a..1c5fde5 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -37,6 +37,7 @@
 #include <vlc_input.h>
 #include <vlc_aout.h>
 #include <assert.h>
+#include <limits.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -2680,6 +2681,29 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
         p_track->b_enable = true;
         p_track->fmt.i_priority = ES_PRIORITY_SELECTABLE_MIN;
     }
+    else
+    {
+        const MP4_Box_t *p_tsel = MP4_BoxGet( p_box_trak, "udta/tsel" );
+        if ( p_tsel && BOXDATA(p_tsel) && BOXDATA(p_tsel)->i_switch_group )
+        {
+            p_track->i_switch_group = BOXDATA(p_tsel)->i_switch_group;
+            int i_priority = ES_PRIORITY_SELECTABLE_MIN;
+            for ( unsigned int i = 0; i < p_sys->i_tracks; i++ )
+            {
+                const mp4_track_t *p_other = &p_sys->track[i];
+                if( p_other && p_other != p_track &&
+                    p_other->fmt.i_cat == p_track->fmt.i_cat &&
+                    p_track->i_switch_group == p_other->i_switch_group )
+                        i_priority = __MAX( i_priority, p_other->fmt.i_priority + 1 );
+            }
+            /* VLC only support ES priority for AUDIO_ES and SPU_ES.
+               If there's another VIDEO_ES in the same group, we need to unselect it then */
+            if ( p_track->fmt.i_cat == VIDEO_ES && i_priority > ES_PRIORITY_SELECTABLE_MIN )
+                p_track->fmt.i_priority = ES_PRIORITY_NOT_DEFAULTABLE;
+            else
+                p_track->fmt.i_priority = i_priority;
+        }
+    }
 
     p_track->p_es = NULL;
     if( TrackCreateES( p_demux,
diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h
index 2d58f8d..eeb96ab 100644
--- a/modules/demux/mp4/mp4.h
+++ b/modules/demux/mp4/mp4.h
@@ -70,6 +70,7 @@ typedef struct
     int b_enable;           /* is the trak enable by default */
     bool b_selected;  /* is the trak being played */
     bool b_chapter;   /* True when used for chapter only */
+    uint32_t i_switch_group;
 
     bool b_mac_encoding;
 



More information about the vlc-commits mailing list