Class EncodingConfiguration

  • Direct Known Subclasses:
    EncodingConfigurationImpl

    public abstract class EncodingConfiguration
    extends Object
    A base class that manages encoding configurations. It holds information about supported formats.
    Author:
    Damian Minkov, Lyubomir Marinov, Boris Grozev
    • Field Detail

      • encodingPreferences

        protected final Map<String,​Integer> encodingPreferences
        That's where we keep format preferences matching SDP formats to integers. We keep preferences for both audio and video formats here in case we'd ever need to compare them to one another. In most cases however both would be decorelated and other components (such as the UI) should present them separately.
    • Constructor Detail

      • EncodingConfiguration

        public EncodingConfiguration()
    • Method Detail

      • setEncodingPreference

        protected abstract void setEncodingPreference​(String encoding,
                                                      double clockRate,
                                                      int pref)
        Sets pref as the preference associated with encoding. Use this method for both audio and video encodings and don't worry if preferences are equal since we rarely need to compare prefs of video encodings to those of audio encodings.
        Parameters:
        encoding - the SDP int of the encoding whose pref we're setting.
        clockRate - clock rate
        pref - a positive int indicating the preference for that encoding.
      • setPriority

        public void setPriority​(MediaFormat encoding,
                                int priority)
        Sets priority as the preference associated with encoding. Use this method for both audio and video encodings and don't worry if the preferences are equal since we rarely need to compare the preferences of video encodings to those of audio encodings.
        Parameters:
        encoding - the MediaFormat specifying the encoding to set the priority of
        priority - a positive int indicating the priority of encoding to set
      • getPriority

        public int getPriority​(MediaFormat encoding)
        Get the priority for a MediaFormat.
        Parameters:
        encoding - the MediaFormat
        Returns:
        the priority
      • getAllEncodings

        public abstract MediaFormat[] getAllEncodings​(org.jitsi.utils.MediaType type)
        Returns all the available encodings for a specific MediaType. This includes disabled ones (ones with priority 0).
        Parameters:
        type - the MediaType we would like to know the available encodings of
        Returns:
        array of MediaFormat supported for the MediaType
      • getEnabledEncodings

        public MediaFormat[] getEnabledEncodings​(org.jitsi.utils.MediaType type)
        Returns the supported MediaFormats i.e. the enabled available MediaFormats, sorted in decreasing priority. Returns only the formats of type type.
        Parameters:
        type - the MediaType of the supported MediaFormats to get
        Returns:
        an array of the supported MediaFormats i.e. the enabled available MediaFormats sorted in decreasing priority. Returns only the formats of type type.
      • compareEncodingPreferences

        protected abstract int compareEncodingPreferences​(MediaFormat enc1,
                                                          MediaFormat enc2)
        Compares the two formats for order. Returns a negative integer, zero, or a positive integer as the first format has been assigned a preference higher, equal to, or greater than the one of the second.
        Parameters:
        enc1 - the first format to compare for preference.
        enc2 - the second format to compare for preference
        Returns:
        a negative integer, zero, or a positive integer as the first format has been assigned a preference higher, equal to, or greater than the one of the second
      • getEncodingPreferenceKey

        protected String getEncodingPreferenceKey​(MediaFormat encoding)
        Gets the key in encodingPreferences which is associated with the priority of a specific MediaFormat.
        Parameters:
        encoding - the MediaFormat to get the key in encodingPreferences of
        Returns:
        the key in encodingPreferences which is associated with the priority of the specified encoding
      • storeProperties

        public void storeProperties​(Map<String,​String> properties,
                                    String prefix)
        Stores the format preferences in this instance in the given Map, using prefix as a prefix to the key. Entries in the format (prefix+formatName, formatPriority) will be added to properties, one for each available format. Note that a "." is not automatically added to prefix.
        Parameters:
        properties - The Map where entries will be added.
        prefix - The prefix to use.
      • storeProperties

        public void storeProperties​(Map<String,​String> properties)
        Stores the format preferences in this instance in the given Map. Entries in the format (formatName, formatPriority) will be added to properties, one for each available format.
        Parameters:
        properties - The Map where entries will be added.
      • loadProperties

        public void loadProperties​(Map<String,​String> properties,
                                   String prefix)
        Parses a Map and updates the format preferences according to it. For each entry, if it's key does not begin with prefix, its ignored. If the key begins with prefix, look for an encoding name after the last ".", and interpret the key value as preference.
        Parameters:
        properties - The Map to parse.
        prefix - The prefix to use.
      • loadEncodingConfiguration

        public void loadEncodingConfiguration​(EncodingConfiguration encodingConfiguration)
        Load the preferences stored in encodingConfiguration
        Parameters:
        encodingConfiguration - the EncodingConfiguration to load preferences from.
      • hasEnabledFormat

        public boolean hasEnabledFormat​(org.jitsi.utils.MediaType mediaType)
        Returns true if there is at least one enabled format for media type type.
        Parameters:
        mediaType - The media type, MediaType.AUDIO or MediaType.VIDEO
        Returns:
        true if there is at least one enabled format for media type type.