private String [ ] getRequestedFileExtensions ( MediaArgs mediaArgs ) { // get file extension defined in media args Set < String > mediaArgsFileExtensions = new HashSet < String > ( ) ; if ( mediaArgs . getFileExtensions ( ) != null && mediaArgs . getFileExtensions ( ) . length > 0 ) { mediaArgsFileExtensions . addAll ( ImmutableList . copyOf ( mediaArgs . getFileExtensions ( ) ) ) ; } // get file extensions from media formats final Set < String > mediaFormatFileExtensions = new HashSet < String > ( ) ; visitMediaFormats ( mediaArgs , new MediaFormatVisitor < Object > ( ) { @ Override public Object visit ( MediaFormat mediaFormat ) { if ( mediaFormat . getExtensions ( ) != null && mediaFormat . getExtensions ( ) . length > 0 ) { mediaFormatFileExtensions . addAll ( ImmutableList . copyOf ( mediaFormat . getExtensions ( ) ) ) ; } return null ; } } ) ; // if extensions are defined both in mediaargs and media formats use intersection of both final String [ ] fileExtensions ; if ( ! mediaArgsFileExtensions . isEmpty ( ) && ! mediaFormatFileExtensions . isEmpty ( ) ) { Collection < String > intersection = Sets . intersection ( mediaArgsFileExtensions , mediaFormatFileExtensions ) ; if ( intersection . isEmpty ( ) ) { // not intersected file extensions - return null to singal no valid file extension request return null ; } else { fileExtensions = intersection . toArray ( new String [ intersection . size ( ) ] ) ; } } else if ( ! mediaArgsFileExtensions . isEmpty ( ) ) { fileExtensions = mediaArgsFileExtensions . toArray ( new String [ mediaArgsFileExtensions . size ( ) ] ) ; } else { fileExtensions = mediaFormatFileExtensions . toArray ( new String [ mediaFormatFileExtensions . size ( ) ] ) ; } return fileExtensions ; }
Get merged list of file extensions from both media formats and media args .