1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.desktoputil.wizard;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.codec.*;
import org.jitsi.service.resources.*;
/**
* The encodings configuration panel (used in the account configuration wizards)
*
* @author Boris Grozev
*/
public class EncodingsPanel
extends TransparentPanel
{
/**
* The <tt>ResourceManagementService</tt> used by this class
*/
private static ResourceManagementService resourceService
= UtilActivator.getResources();
/**
* The "override global settings" checkbox.
*/
private final JCheckBox overrideCheckBox;
/**
* The <tt>MediaConfiguration</tt> instance we'll use to obtain most of the
* <tt>Component</tt>s for the panel
*/
private final MediaConfigurationService mediaConfiguration;
/**
* A panel to hold the audio encodings table
*/
private JPanel audioPanel;
/**
* The audio encodings table (and "up"/"down" buttons)
*/
private Component audioControls;
/**
* A panel to hold the video encodings table
*/
private JPanel videoPanel;
/**
* The video encodings table (and "up"/"down" buttons)
*/
private Component videoControls;
/**
* Holds the properties we need to get/set for the encoding preferences
*/
private Map<String, String> encodingProperties
= new HashMap<String, String>();
/**
* An <tt>EncodingConfiguration</tt> we'll be using to manage preferences
* for us
*/
private EncodingConfiguration encodingConfiguration;
/**
* The "reset" button
*/
private JButton resetButton = new JButton(resourceService.getI18NString(
"plugin.jabberaccregwizz.RESET"));
/**
* Builds an object, loads the tables with the global configuration..
*/
public EncodingsPanel()
{
super(new BorderLayout());
overrideCheckBox = new SIPCommCheckBox(resourceService.
getI18NString("plugin.jabberaccregwizz.OVERRIDE_ENCODINGS"),
false);
overrideCheckBox.addChangeListener(new ChangeListener()
{
public void stateChanged(ChangeEvent e)
{
updateTableState();
}
});
mediaConfiguration
= UtilActivator.getMediaConfiguration();
//by default (on account creation) use an <tt>EncodingConfiguration</tt>
//loaded with the global preferences. But make a new instance, because
//we do not want to change the current one
encodingConfiguration = mediaConfiguration.getMediaService()
.createEmptyEncodingConfiguration();
encodingConfiguration.loadEncodingConfiguration(mediaConfiguration
.getMediaService().getCurrentEncodingConfiguration());
audioControls = mediaConfiguration.
createEncodingControls(MediaType.AUDIO, encodingConfiguration);
videoControls = mediaConfiguration.
createEncodingControls(MediaType.VIDEO, encodingConfiguration);
JPanel mainPanel = new TransparentPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
add(mainPanel, BorderLayout.NORTH);
JPanel checkBoxPanel
= new TransparentPanel(new BorderLayout());
checkBoxPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
checkBoxPanel.add(overrideCheckBox,BorderLayout.WEST);
resetButton.setToolTipText(resourceService.getI18NString(
"plugin.jabberaccregwizz.RESET_DESCRIPTION"));
checkBoxPanel.add(resetButton,BorderLayout.EAST);
resetButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
encodingConfiguration.loadEncodingConfiguration(
mediaConfiguration.getMediaService()
.getCurrentEncodingConfiguration());
encodingConfiguration.storeProperties(encodingProperties,
ProtocolProviderFactory.ENCODING_PROP_PREFIX+".");
resetTables();
}
});
audioPanel = new TransparentPanel(new BorderLayout(10, 10));
audioPanel.setBorder(BorderFactory.createTitledBorder(
resourceService.getI18NString("plugin.jabberaccregwizz.AUDIO")));
audioPanel.add(audioControls);
videoPanel = new TransparentPanel(new BorderLayout(10, 10));
videoPanel.setBorder(BorderFactory.createTitledBorder(
resourceService.getI18NString("plugin.jabberaccregwizz.VIDEO")));
videoPanel.add(videoControls);
mainPanel.add(checkBoxPanel);
mainPanel.add(audioPanel);
mainPanel.add(videoPanel);
}
/**
* Saves the settings we hold in <tt>registration</tt>
* @param registration the <tt>EncodingsRegistrationUtil</tt> to use
*/
public void commitPanel(EncodingsRegistrationUtil registration)
{
registration.setOverrideEncodings(overrideCheckBox.isSelected());
encodingConfiguration.storeProperties(encodingProperties,
ProtocolProviderFactory.ENCODING_PROP_PREFIX+".");
registration.setEncodingProperties(encodingProperties);
}
/**
* Loads encoding configuration from given <tt>encodingsReg</tt> object.
*
* @param encodingsReg the encoding registration object to use.
*/
public void loadAccount(EncodingsRegistrationUtil encodingsReg)
{
overrideCheckBox.setSelected(encodingsReg.isOverrideEncodings());
encodingConfiguration
= encodingsReg.createEncodingConfig(
mediaConfiguration.getMediaService());
encodingConfiguration.storeProperties(encodingProperties);
resetTables();
}
/**
* Recreates the audio and video controls. Necessary when
* our encodingConfiguration reference has changed.
*/
private void resetTables()
{
audioPanel.remove(audioControls);
videoPanel.remove(videoControls);
audioControls = mediaConfiguration.
createEncodingControls(MediaType.AUDIO, encodingConfiguration);
videoControls = mediaConfiguration.
createEncodingControls(MediaType.VIDEO, encodingConfiguration);
audioPanel.add(audioControls);
videoPanel.add(videoControls);
updateTableState();
}
/**
* Enables or disables the encodings tables based on the override checkbox.
*/
private void updateTableState()
{
audioControls.setEnabled(overrideCheckBox.isSelected());
videoControls.setEnabled(overrideCheckBox.isSelected());
}
}
|