private boolean resolveByNames ( MediaArgs mediaArgs ) { // resolved media formats already set? done. if ( mediaArgs . getMediaFormats ( ) != null ) { return true ; } // no media format names present? done. if ( mediaArgs . getMediaFormatNames ( ) == null ) { return true ; } String [ ] mediaFormatNames = mediaArgs . getMediaFormatNames ( ) ; MediaFormat [ ] mediaFormats = new MediaFormat [ mediaFormatNames . length ] ; boolean resolutionSuccessful = true ; for ( int i = 0 ; i < mediaFormatNames . length ; i ++ ) { mediaFormats [ i ] = mediaFormatHandler . getMediaFormat ( mediaFormatNames [ i ] ) ; if ( mediaFormats [ i ] == null ) { log . warn ( "Media format name '" + mediaFormatNames [ i ] + "' is invalid." ) ; resolutionSuccessful = false ; } } mediaArgs . mediaFormats ( mediaFormats ) ; mediaArgs . mediaFormatNames ( ( String [ ] ) null ) ; return resolutionSuccessful ; }
Resolve media format names to media formats so all downstream logic has only to handle the resolved media formats . If resolving fails an exception is thrown .