src/net/java/sip/communicator/impl/neomedia/MediaConfigurationImpl.java
/**
     * Creates the UI controls which are to control the details of a specific
     * <tt>AudioSystem</tt>.
     *
     * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to
     * control its details are to be created
     * @param container the <tt>JComponent</tt> into which the UI controls which
     * are to control the details of the specified <tt>audioSystem</tt> are to
     * be added
     */
Creates the UI controls which are to control the details of a specific
AudioSystem.

@param audioSystem the AudioSystem for which the UI controls to
control its details are to be created
@param container the JComponent into which the UI controls which
are to control the details of the specified audioSystem are to
be added
Creates the UI controls which are to control the details of a specific AudioSystem . @param audioSystem the AudioSystem for which the UI controls to control its details are to be created @param container the JComponent into which the UI controls which are to control the details of the specified audioSystem are to be added
public void createAudioSystemControls(
            final AudioSystem audioSystem,
            JComponent container)
    {
        GridBagConstraints cnstrnts = new GridBagConstraints();
        cnstrnts.anchor = GridBagConstraints.NORTHWEST;
        cnstrnts.fill = GridBagConstraints.HORIZONTAL;
        cnstrnts.weighty = 0;
        int audioSystemFeatures = audioSystem.getFeatures();
        boolean featureNotifyAndPlaybackDevices
            = ((audioSystemFeatures
                    & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES)
                != 0);
        cnstrnts.gridx = 0;
        cnstrnts.insets = new Insets(3, 0, 3, 3);
        cnstrnts.weightx = 0;
        cnstrnts.gridy = 0;
        container.add(new JLabel(getLabelText(
            DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), cnstrnts);
        if (featureNotifyAndPlaybackDevices)
        {
            cnstrnts.gridy = 2;
            container.add(new JLabel(getLabelText(
                DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), cnstrnts);
            cnstrnts.gridy = 3;
            container.add(new JLabel(getLabelText(
                DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), cnstrnts);
        }
        cnstrnts.gridx = 1;
        cnstrnts.insets = new Insets(3, 3, 3, 0);
        cnstrnts.weightx = 1;
        JComboBox captureCombo = null;
        if (featureNotifyAndPlaybackDevices)
        {
            captureCombo = new JComboBox();
            captureCombo.setEditable(false);
            captureCombo.setModel(
                    new DeviceConfigurationComboBoxModel(
                            mediaService.getDeviceConfiguration(),
                            DeviceConfigurationComboBoxModel.AUDIO_CAPTURE));
            cnstrnts.gridy = 0;
            container.add(captureCombo, cnstrnts);
        }
        int anchor = cnstrnts.anchor;
        SoundLevelIndicator capturePreview
            = new SoundLevelIndicator(
                    SimpleAudioLevelListener.MIN_LEVEL,
                    SimpleAudioLevelListener.MAX_LEVEL);
        cnstrnts.anchor = GridBagConstraints.CENTER;
        cnstrnts.gridy = (captureCombo == null) ? 0 : 1;
        container.add(capturePreview, cnstrnts);
        cnstrnts.anchor = anchor;
        cnstrnts.gridy = GridBagConstraints.RELATIVE;
        if (featureNotifyAndPlaybackDevices)
        {
            playbackCombo = new JComboBox();
            playbackCombo.setEditable(false);
            playbackCombo.setModel(
                    new DeviceConfigurationComboBoxModel(
                            mediaService.getDeviceConfiguration(),
                            DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK));
            playbackCombo.addActionListener(this);
            container.add(playbackCombo, cnstrnts);
            notifyCombo = new JComboBox();
            notifyCombo.setEditable(false);
            notifyCombo.setModel(
                    new DeviceConfigurationComboBoxModel(
                            mediaService.getDeviceConfiguration(),
                            DeviceConfigurationComboBoxModel.AUDIO_NOTIFY));
            notifyCombo.addActionListener(this);
            container.add(notifyCombo, cnstrnts);
        }
        int[] checkBoxAudioSystemFeatures
            = new int[]
                    {
                        AudioSystem.FEATURE_ECHO_CANCELLATION,
                        AudioSystem.FEATURE_DENOISE,
                        AudioSystem.FEATURE_AGC
                    };
        for (int i = 0; i < checkBoxAudioSystemFeatures.length; i++)
        {
            final int f = checkBoxAudioSystemFeatures[i];
            if ((f & audioSystemFeatures) != 0)
            {
                String textKey;
                boolean selected;
                switch (f)
                {
                case AudioSystem.FEATURE_AGC:
                    textKey = "impl.media.configform.AUTOMATICGAINCONTROL";
                    selected = audioSystem.isAutomaticGainControl();
                    break;
                case AudioSystem.FEATURE_DENOISE:
                    textKey = "impl.media.configform.DENOISE";
                    selected = audioSystem.isDenoise();
                    break;
                case AudioSystem.FEATURE_ECHO_CANCELLATION:
                    textKey = "impl.media.configform.ECHOCANCEL";
                    selected = audioSystem.isEchoCancel();
                    break;
                default:
                    continue;
                }
                final SIPCommCheckBox checkBox
                    = new SIPCommCheckBox(
                            NeomediaActivator.getResources().getI18NString(
                                    textKey));
                /*
                 * First set the selected one, then add the listener in order to
                 * avoid saving the value when using the default one and only
                 * showing to user without modification.
                 */
                checkBox.setSelected(selected);
                checkBox.addItemListener(
                        new ItemListener()
                        {
                            public void itemStateChanged(ItemEvent e)
                            {
                                boolean b = checkBox.isSelected();
                                switch (f)
                                {
                                case AudioSystem.FEATURE_AGC:
                                    audioSystem.setAutomaticGainControl(b);
                                    break;
                                case AudioSystem.FEATURE_DENOISE:
                                    audioSystem.setDenoise(b);
                                    break;
                                case AudioSystem.FEATURE_ECHO_CANCELLATION:
                                    audioSystem.setEchoCancel(b);
                                    break;
                                }
                            }
                        });
                container.add(checkBox, cnstrnts);
            }
        }
        cnstrnts.gridx = 2;
        cnstrnts.insets = new Insets(3, 3, 3, 0);
        cnstrnts.weightx = 0;
        if (featureNotifyAndPlaybackDevices)
        {
            cnstrnts.gridy = 2;
            playbackPlaySoundButton
                = new JButton(new ImageIcon(NeomediaActivator.getResources()
                            .getImageInBytes(
                                "plugin.notificationconfig.PLAY_ICON")));
            playbackPlaySoundButton.setMinimumSize(new Dimension(30,30));
            playbackPlaySoundButton.setPreferredSize(new Dimension(30,30));
            if(((DeviceConfigurationComboBoxModel.CaptureDevice)
                        playbackCombo.getSelectedItem()).info == null)
            {
                playbackPlaySoundButton.setEnabled(false);
            }
            playbackPlaySoundButton.setOpaque(false);
            playbackPlaySoundButton.addActionListener(this);
            container.add(playbackPlaySoundButton, cnstrnts);
            cnstrnts.gridy = 3;
            notificationPlaySoundButton
                = new JButton(new ImageIcon(NeomediaActivator.getResources()
                            .getImageInBytes(
                                "plugin.notificationconfig.PLAY_ICON")));
            notificationPlaySoundButton.setMinimumSize(new Dimension(30,30));
            notificationPlaySoundButton.setPreferredSize(new Dimension(30,30));
            if(((DeviceConfigurationComboBoxModel.CaptureDevice)
                        notifyCombo.getSelectedItem()).info == null)
            {
                notificationPlaySoundButton.setEnabled(false);
            }
            notificationPlaySoundButton.setOpaque(false);
            notificationPlaySoundButton.addActionListener(this);
            container.add(notificationPlaySoundButton, cnstrnts);
        }
        if (audioLevelListenerThread == null)
        {
            audioLevelListenerThread
                = new AudioLevelListenerThread(
                        audioSystem,
                        captureCombo,
                        capturePreview);
        }
        else
        {
            audioLevelListenerThread.init(
                    audioSystem,
                    captureCombo,
                    capturePreview);
        }
    }
public void createAudioSystemControls ( final AudioSystem audioSystem , JComponent container ) { GridBagConstraints cnstrnts = new GridBagConstraints ( ) ; cnstrnts . anchor = GridBagConstraints . NORTHWEST ; cnstrnts . fill = GridBagConstraints . HORIZONTAL ; cnstrnts . weighty = 0 ; int audioSystemFeatures = audioSystem . getFeatures ( ) ; boolean featureNotifyAndPlaybackDevices = ( ( audioSystemFeatures & AudioSystem . FEATURE_NOTIFY_AND_PLAYBACK_DEVICES ) != 0 ) ; cnstrnts . gridx = 0 ; cnstrnts . insets = new Insets ( 3 , 0 , 3 , 3 ) ; cnstrnts . weightx = 0 ; cnstrnts . gridy = 0 ; container . add ( new JLabel ( getLabelText ( DeviceConfigurationComboBoxModel . AUDIO_CAPTURE ) ) , cnstrnts ) ; if ( featureNotifyAndPlaybackDevices ) { cnstrnts . gridy = 2 ; container . add ( new JLabel ( getLabelText ( DeviceConfigurationComboBoxModel . AUDIO_PLAYBACK ) ) , cnstrnts ) ; cnstrnts . gridy = 3 ; container . add ( new JLabel ( getLabelText ( DeviceConfigurationComboBoxModel . AUDIO_NOTIFY ) ) , cnstrnts ) ; } cnstrnts . gridx = 1 ; cnstrnts . insets = new Insets ( 3 , 3 , 3 , 0 ) ; cnstrnts . weightx = 1 ; JComboBox captureCombo = null ; if ( featureNotifyAndPlaybackDevices ) { captureCombo = new JComboBox ( ) ; captureCombo . setEditable ( false ) ; captureCombo . setModel ( new DeviceConfigurationComboBoxModel ( mediaService . getDeviceConfiguration ( ) , DeviceConfigurationComboBoxModel . AUDIO_CAPTURE ) ) ; cnstrnts . gridy = 0 ; container . add ( captureCombo , cnstrnts ) ; } int anchor = cnstrnts . anchor ; SoundLevelIndicator capturePreview = new SoundLevelIndicator ( SimpleAudioLevelListener . MIN_LEVEL , SimpleAudioLevelListener . MAX_LEVEL ) ; cnstrnts . anchor = GridBagConstraints . CENTER ; cnstrnts . gridy = ( captureCombo == null ) ? 0 : 1 ; container . add ( capturePreview , cnstrnts ) ; cnstrnts . anchor = anchor ; cnstrnts . gridy = GridBagConstraints . RELATIVE ; if ( featureNotifyAndPlaybackDevices ) { playbackCombo = new JComboBox ( ) ; playbackCombo . setEditable ( false ) ; playbackCombo . setModel ( new DeviceConfigurationComboBoxModel ( mediaService . getDeviceConfiguration ( ) , DeviceConfigurationComboBoxModel . AUDIO_PLAYBACK ) ) ; playbackCombo . addActionListener ( this ) ; container . add ( playbackCombo , cnstrnts ) ; notifyCombo = new JComboBox ( ) ; notifyCombo . setEditable ( false ) ; notifyCombo . setModel ( new DeviceConfigurationComboBoxModel ( mediaService . getDeviceConfiguration ( ) , DeviceConfigurationComboBoxModel . AUDIO_NOTIFY ) ) ; notifyCombo . addActionListener ( this ) ; container . add ( notifyCombo , cnstrnts ) ; } int [ ] checkBoxAudioSystemFeatures = new int [ ] { AudioSystem . FEATURE_ECHO_CANCELLATION , AudioSystem . FEATURE_DENOISE , AudioSystem . FEATURE_AGC } ; for ( int i = 0 ; i < checkBoxAudioSystemFeatures . length ; i ++ ) { final int f = checkBoxAudioSystemFeatures [ i ] ; if ( ( f & audioSystemFeatures ) != 0 ) { String textKey ; boolean selected ; switch ( f ) { case AudioSystem . FEATURE_AGC : textKey = "impl.media.configform.AUTOMATICGAINCONTROL" ; selected = audioSystem . isAutomaticGainControl ( ) ; break ; case AudioSystem . FEATURE_DENOISE : textKey = "impl.media.configform.DENOISE" ; selected = audioSystem . isDenoise ( ) ; break ; case AudioSystem . FEATURE_ECHO_CANCELLATION : textKey = "impl.media.configform.ECHOCANCEL" ; selected = audioSystem . isEchoCancel ( ) ; break ; default : continue ; } final SIPCommCheckBox checkBox = new SIPCommCheckBox ( NeomediaActivator . getResources ( ) . getI18NString ( textKey ) ) ; /*
                 * First set the selected one, then add the listener in order to
                 * avoid saving the value when using the default one and only
                 * showing to user without modification.
                 */ checkBox . setSelected ( selected ) ; checkBox . addItemListener ( new ItemListener ( ) { public void itemStateChanged ( ItemEvent e ) { boolean b = checkBox . isSelected ( ) ; switch ( f ) { case AudioSystem . FEATURE_AGC : audioSystem . setAutomaticGainControl ( b ) ; break ; case AudioSystem . FEATURE_DENOISE : audioSystem . setDenoise ( b ) ; break ; case AudioSystem . FEATURE_ECHO_CANCELLATION : audioSystem . setEchoCancel ( b ) ; break ; } } } ) ; container . add ( checkBox , cnstrnts ) ; } } cnstrnts . gridx = 2 ; cnstrnts . insets = new Insets ( 3 , 3 , 3 , 0 ) ; cnstrnts . weightx = 0 ; if ( featureNotifyAndPlaybackDevices ) { cnstrnts . gridy = 2 ; playbackPlaySoundButton = new JButton ( new ImageIcon ( NeomediaActivator . getResources ( ) . getImageInBytes ( "plugin.notificationconfig.PLAY_ICON" ) ) ) ; playbackPlaySoundButton . setMinimumSize ( new Dimension ( 30 , 30 ) ) ; playbackPlaySoundButton . setPreferredSize ( new Dimension ( 30 , 30 ) ) ; if ( ( ( DeviceConfigurationComboBoxModel . CaptureDevice ) playbackCombo . getSelectedItem ( ) ) . info == null ) { playbackPlaySoundButton . setEnabled ( false ) ; } playbackPlaySoundButton . setOpaque ( false ) ; playbackPlaySoundButton . addActionListener ( this ) ; container . add ( playbackPlaySoundButton , cnstrnts ) ; cnstrnts . gridy = 3 ; notificationPlaySoundButton = new JButton ( new ImageIcon ( NeomediaActivator . getResources ( ) . getImageInBytes ( "plugin.notificationconfig.PLAY_ICON" ) ) ) ; notificationPlaySoundButton . setMinimumSize ( new Dimension ( 30 , 30 ) ) ; notificationPlaySoundButton . setPreferredSize ( new Dimension ( 30 , 30 ) ) ; if ( ( ( DeviceConfigurationComboBoxModel . CaptureDevice ) notifyCombo . getSelectedItem ( ) ) . info == null ) { notificationPlaySoundButton . setEnabled ( false ) ; } notificationPlaySoundButton . setOpaque ( false ) ; notificationPlaySoundButton . addActionListener ( this ) ; container . add ( notificationPlaySoundButton , cnstrnts ) ; } if ( audioLevelListenerThread == null ) { audioLevelListenerThread = new AudioLevelListenerThread ( audioSystem , captureCombo , capturePreview ) ; } else { audioLevelListenerThread . init ( audioSystem , captureCombo , capturePreview ) ; } }
Creates the UI controls which are to control the details of a specific
 <tt>AudioSystem</tt>.
Creates the UI controls which are to control the details of a specific <tt > AudioSystem< / tt > .
// Adds the play buttons for testing playback and notification devices. // Playback play sound button. // Notification play sound button.