Fixes a couple of possible NullPointerExceptions. Makes a few fields final or static. Applies minor formatting.

cusax-fix
Lyubomir Marinov 18 years ago
parent f97e7d7732
commit 07c4be6a8a

@ -84,19 +84,19 @@ public class MediaControl
/**
* The list of readers currently using our processor.
*/
private List<Object> processorReaders = new Vector<Object>();
private final List<Object> processorReaders = new Vector<Object>();
/**
* An object that we use for.
*/
private ProcessorUtility processorUtility = new ProcessorUtility();
private final ProcessorUtility processorUtility = new ProcessorUtility();
/**
* The name of the property that could contain the name of a media file
* to use instead of capture devices.
*/
private static final String DEBUG_DATA_SOURCE_URL_PROPERTY_NAME
= "net.java.sip.communicator.impl.media.DEBUG_DATA_SOURCE_URL";
= "net.java.sip.communicator.impl.media.DEBUG_DATA_SOURCE_URL";
/**
* The default constructor.
@ -114,9 +114,8 @@ public MediaControl()
*/
public javax.media.Time getOutputDuration()
{
if (sourceProcessor == null)
return Duration.DURATION_UNKNOWN;
else return sourceProcessor.getDuration();
return (sourceProcessor == null) ? Duration.DURATION_UNKNOWN
: sourceProcessor.getDuration();
}
/**
@ -227,13 +226,13 @@ private void initCaptureDevices()
// Create the av data source
if (audioDataSource != null && videoDataSource != null)
{
DataSource[] allDS = new DataSource[] {
audioDataSource,
videoDataSource
};
try
{
avDataSource = Manager.createMergingDataSource(allDS);
avDataSource
= Manager.createMergingDataSource(new DataSource[] {
audioDataSource,
videoDataSource
});
}
catch (IncompatibleSourceException exc)
{
@ -271,8 +270,7 @@ public void initDebugDataSource(String debugMediaSource)
{
try
{
URL url = new URL(debugMediaSource);
initDataSourceFromURL(url);
initDataSourceFromURL(new URL(debugMediaSource));
}
catch (MalformedURLException e)
{
@ -294,9 +292,8 @@ public void initDataSourceFromURL(URL dataSourceURL)
throws MediaException
{
logger.debug("Using a data source from url: " + dataSourceURL);
MediaLocator locator = new MediaLocator(dataSourceURL);
avDataSource = createDataSource(locator);
avDataSource = createDataSource(new MediaLocator(dataSourceURL));
//avDataSource may be null (Bug report Vince Fourcade)
if (avDataSource != null)
@ -424,9 +421,9 @@ private void calculateSupportedEncodings()
List<String> transmittableAudioEncodings = new ArrayList<String>();
List<String> transmittableVideoEncodings = new ArrayList<String>();
for (int i = 0; i < trackControls.length; i++)
for (TrackControl trackControl : trackControls)
{
Format[] formats = trackControls[i].getSupportedFormats();
Format[] formats = trackControl.getSupportedFormats();
for (int j = 0; j < formats.length; j++)
{
Format format = formats[j];
@ -439,7 +436,6 @@ private void calculateSupportedEncodings()
if (format instanceof AudioFormat)
{
if (!transmittableAudioEncodings.contains(sdp))
{
if (logger.isDebugEnabled())
@ -752,30 +748,30 @@ public DataSource createDataSourceForEncodings(
*/
private void setJpegQuality(Player player, float val)
{
if (player == null
|| player.getState() < Player.Realized)
if ((player == null)
|| (player.getState() < Player.Realized))
return;
Control cs[] = player.getControls();
QualityControl qc = null;
VideoFormat jpegFmt = new VideoFormat(VideoFormat.JPEG);
// Loop through the controls to find the Quality control for
// the JPEG encoder.
for (int i = 0; i < cs.length; i++)
for (Control c : cs)
{
if (cs[i] instanceof QualityControl && cs[i] instanceof Owned)
if (c instanceof QualityControl && c instanceof Owned)
{
Object owner = ( (Owned) cs[i]).getOwner();
Object owner = ((Owned) c).getOwner();
// Check to see if the owner is a Codec.
// Then check for the output format.
if (owner instanceof Codec)
{
Format fmts[] = ( (Codec) owner)
Format fmts[] = ((Codec) owner)
.getSupportedOutputFormats(null);
for (int j = 0; j < fmts.length; j++)
for (Format fmt : fmts)
{
if (fmts[j].matches(jpegFmt))
if (fmt.matches(jpegFmt))
{
qc = (QualityControl) cs[i];
qc = (QualityControl) c;
qc.setQuality(val);
logger.debug("Setting quality to "
+ val + " on " + qc);
@ -804,11 +800,12 @@ private void setJpegQuality(Player player, float val)
private VideoFormat assertSize(VideoFormat sourceFormat)
{
int width, height;
Dimension size = sourceFormat.getSize();
Format jpegFmt = new Format(VideoFormat.JPEG_RTP);
Format h263Fmt = new Format(VideoFormat.H263_RTP);
if (sourceFormat.matches(jpegFmt))
// JPEG
if (sourceFormat.matches(new Format(VideoFormat.JPEG_RTP)))
{
Dimension size = sourceFormat.getSize();
// For JPEG, make sure width and height are divisible by 8.
width = (size.width % 8 == 0)
? size.width
@ -817,7 +814,8 @@ private VideoFormat assertSize(VideoFormat sourceFormat)
? size.height
: (size.height / 8) * 8;
}
else if (sourceFormat.matches(h263Fmt))
// H.263
else if (sourceFormat.matches(new Format(VideoFormat.H263_RTP)))
{
// For H.263, we only support some specific sizes.
//if (size.width < 128)
@ -877,15 +875,12 @@ protected int findFirstMatchingFormat(Format[] availableFormats,
Enumeration<List<String>> formatSets = requestedEncodings.elements();
while (formatSets.hasMoreElements())
{
for (Iterator<String> currentSetIter =
formatSets.nextElement().iterator(); currentSetIter.hasNext();)
for (String currentSetElement : formatSets.nextElement())
{
String currentSetElement = currentSetIter.next();
for (int i = 0; i < availableFormats.length; i++)
{
if (availableFormats[i].getEncoding().equals(
currentSetElement))
currentSetElement))
{
return i;
}
@ -1086,7 +1081,8 @@ public int compare(FormatInfo info0, FormatInfo info1)
public DataSource createLocalVideoDataSource()
{
return (cloneableVideoDataSource == null) ? null
: cloneableVideoDataSource.createClone();
return (cloneableVideoDataSource == null)
? null
: cloneableVideoDataSource.createClone();
}
}

@ -53,19 +53,17 @@ public ProtocolProviderFactorySipImpl()
public AccountID installAccount( String userIDStr,
Map<String, String> accountProperties)
{
BundleContext context
= SipActivator.getBundleContext();
BundleContext context = SipActivator.getBundleContext();
if (context == null)
throw new NullPointerException("The specified BundleContext was null");
if (userIDStr == null)
throw new NullPointerException("The specified AccountID was null");
accountProperties.put(USER_ID, userIDStr);
if (accountProperties == null)
throw new NullPointerException("The specified property map was null");
accountProperties.put(USER_ID, userIDStr);
// serverAddress == null is OK because of registrarless support
String serverAddress = accountProperties.get(SERVER_ADDRESS);
@ -94,8 +92,7 @@ public AccountID installAccount( String userIDStr,
{
//it might happen that load-ing the account fails because of a bad
//initialization. if this is the case, make sure we remove it.
this.removeStoredAccount(SipActivator.getBundleContext(),
accountID);
this.removeStoredAccount(context, accountID);
throw exc;
}

@ -1492,7 +1492,7 @@ public Address getOurSipAddress(SipURI intendedDestination)
{
SipRegistrarConnection src = getRegistrarConnection();
if( src != null & !src.isRegistrarless() )
if( src != null && !src.isRegistrarless() )
return src.getAddressOfRecord();
//we are apparently running in "No Registrar" mode so let's create an

@ -47,12 +47,12 @@ public class ContactInfoDetailsPanel
/**
* The default width of hte avater area.
*/
private final int AVATAR_AREA_WIDTH = 105;
private static final int AVATAR_AREA_WIDTH = 105;
/**
* The default height of hte avater area.
*/
private final int AVATAR_AREA_HEIGHT = 130;
private static final int AVATAR_AREA_HEIGHT = 130;
/**
* Construct a tabbed pane that will have one tab with a summary of info for
@ -531,4 +531,4 @@ public void hyperlinkUpdate(HyperlinkEvent e)
return mainExtendedPanel;
}
}
}

Loading…
Cancel
Save