@@ -700,6 +700,20 @@ describe('MediaController', function () {
700700 expect ( objectUtils . areEqual ( currentTrack , frTrack ) ) . to . be . true ;
701701 } ) ;
702702
703+ it ( 'should check initial media settings to choose initial track based on role' , function ( ) {
704+ mediaController . addTrack ( enTrack ) ;
705+ mediaController . addTrack ( esTrack ) ;
706+ mediaController . addTrack ( enADTrack ) ;
707+
708+ mediaController . setInitialSettings ( trackType , {
709+ role : { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' }
710+ } ) ;
711+ mediaController . setInitialMediaSettingsForType ( trackType , streamInfo ) ;
712+
713+ let currentTrack = mediaController . getCurrentTrackFor ( trackType , streamInfo . id ) ;
714+ expect ( objectUtils . areEqual ( currentTrack , esTrack ) ) . to . be . true ;
715+ } ) ;
716+
703717 it ( 'should not check initial media settings to choose initial track when it has already selected a track' , function ( ) {
704718 mediaController . addTrack ( frTrack ) ;
705719 mediaController . addTrack ( qtzTrack ) ;
@@ -775,7 +789,8 @@ describe('MediaController', function () {
775789 representationCount : track . bitrateList . length ,
776790 audioChannelConfiguration : track . audioChannelConfiguration ? track . audioChannelConfiguration : [ ] ,
777791 selectionPriority : ! isNaN ( track . selectionPriority ) ? track . selectionPriority : 1 ,
778- supplementalProperties : track . supplementalProperties ? track . supplementalProperties : [ ]
792+ supplementalProperties : track . supplementalProperties ? track . supplementalProperties : [ ] ,
793+ roles : track . roles ? track . roles : [ ]
779794 } ;
780795 } ) ;
781796 const selection = mediaController . selectInitialTrack ( type , tracks ) ;
@@ -805,6 +820,83 @@ describe('MediaController', function () {
805820 } ) ;
806821 } )
807822
823+ describe ( 'roleMain flag' , function ( ) {
824+ beforeEach ( function ( ) {
825+ settings . update ( {
826+ streaming : {
827+ selectionModeForInitialTrack : Constants . TRACK_SELECTION_MODE_HIGHEST_BITRATE ,
828+ prioritizeRoleMain : true
829+ }
830+ } ) ;
831+ } ) ;
832+
833+ it ( 'should select track with role set to main if no selectionPriority is provided' , function ( ) {
834+ testSelectInitialTrack (
835+ 'video' ,
836+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'main' } ] } ,
837+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] }
838+ ) ;
839+ } ) ;
840+
841+ it ( 'should select track with role set to main if other tracks have no role' , function ( ) {
842+ testSelectInitialTrack (
843+ 'video' ,
844+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'main' } ] } ,
845+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ ] }
846+ ) ;
847+ } ) ;
848+
849+ it ( 'should select track with role set to main with multiple role descriptors' , function ( ) {
850+ testSelectInitialTrack (
851+ 'video' ,
852+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'main' } , { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] } ,
853+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] }
854+ ) ;
855+ } ) ;
856+
857+ it ( 'should select track with no role if other tracks have role not main' , function ( ) {
858+ testSelectInitialTrack (
859+ 'video' ,
860+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ ] } ,
861+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] }
862+ ) ;
863+ } ) ;
864+
865+ it ( 'should not select track with no role if other tracks have role not main, when disabled in Settings' , function ( ) {
866+ settings . update ( {
867+ streaming : {
868+ assumeDefaultRoleAsMain : false
869+ }
870+ } ) ;
871+ testSelectInitialTrack (
872+ 'video' ,
873+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] } ,
874+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ ] }
875+ ) ;
876+ } ) ;
877+
878+ it ( 'should select track based on selectionPriority, if provided, and disregard role main' , function ( ) {
879+ testSelectInitialTrack (
880+ 'video' ,
881+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] , selectionPriority : 2 } ,
882+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'main' } ] , selectionPriority : 1 }
883+ ) ;
884+ } ) ;
885+
886+ it ( 'should select track based on selectionModeForInitialTrack if roleMain flag is false' , function ( ) {
887+ settings . update ( { streaming : {
888+ prioritizeRoleMain : false ,
889+ selectionModeForInitialTrack : Constants . TRACK_SELECTION_MODE_HIGHEST_BITRATE }
890+ } ) ;
891+
892+ testSelectInitialTrack (
893+ 'video' ,
894+ { bitrateList : [ { bandwidth : 2000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'dub' } ] } ,
895+ { bitrateList : [ { bandwidth : 1000 } ] , roles : [ { schemeIdUri : 'urn:mpeg:dash:role:2011' , value : 'main' } ] }
896+ ) ;
897+ } ) ;
898+ } )
899+
808900 describe ( '"highestSelectionPriority" mode' , function ( ) {
809901 beforeEach ( function ( ) {
810902 settings . update ( { streaming : { selectionModeForInitialTrack : Constants . TRACK_SELECTION_MODE_HIGHEST_EFFICIENCY } } ) ;
0 commit comments