Replaces use of MediaFormat.equals() with MediaFormat.matches() so that audio format parameters would not make audio formats distinctive. Updates libjitsi to r10270.

cusax-fix
Emil Ivov 13 years ago
parent fe9819a395
commit 98f8286b3d

@ -1212,21 +1212,10 @@ protected List<MediaFormat> intersectFormats(
protected MediaFormat findMediaFormat(
List<MediaFormat> formats, MediaFormat format)
{
MediaType mediaType = format.getMediaType();
String encoding = format.getEncoding();
double clockRate = format.getClockRate();
int channels
= MediaType.AUDIO.equals(mediaType)
? ((AudioMediaFormat) format).getChannels()
: MediaFormatFactory.CHANNELS_NOT_SPECIFIED;
Map<String, String> formatParameters = format.getFormatParameters();
for(MediaFormat match : formats)
{
if (AbstractMediaStream.matches(
match,
mediaType,
encoding, clockRate, channels, formatParameters))
if (match.matches(format))
return match;
}
return null;

@ -8,9 +8,7 @@
import java.util.*;
import net.java.sip.communicator.impl.protocol.sip.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.format.*;
/**
@ -96,28 +94,7 @@ public void setLocalPayloadTypePreferences(Map<Byte, String> mappings)
public byte obtainPayloadTypeNumber(MediaFormat format)
throws IllegalStateException
{
MediaType mediaType = format.getMediaType();
String encoding = format.getEncoding();
double clockRate = format.getClockRate();
int channels
= MediaType.AUDIO.equals(mediaType)
? ((AudioMediaFormat) format).getChannels()
: MediaFormatFactory.CHANNELS_NOT_SPECIFIED;
Byte payloadType = null;
Map<String, String> formatParameters
= format.getFormatParameters();
for (Map.Entry<MediaFormat, Byte> payloadTypeMapping
: payloadTypeMappings.entrySet())
{
if (AbstractMediaStream.matches(
payloadTypeMapping.getKey(),
mediaType, encoding, clockRate, channels, formatParameters))
{
payloadType = payloadTypeMapping.getValue();
break;
}
}
Byte payloadType = getPayloadType(format);
//seems like we haven't allocated a payload type for this format yet.
//lets try to do so now.
@ -225,7 +202,10 @@ private Map<MediaFormat, Byte> getDynamicPayloadTypePreferences()
*/
private Byte getPreferredDynamicPayloadType(MediaFormat format)
{
return getDynamicPayloadTypePreferences().get(format);
Map<MediaFormat, Byte> ptPreferences
= getDynamicPayloadTypePreferences();
return getPayloadTypeFromMap(ptPreferences, format);
}
/**
@ -253,7 +233,7 @@ public void addMapping(MediaFormat format, byte payloadType)
MediaFormat alreadyMappedFmt = findFormat(payloadType);
if(alreadyMappedFmt != null)
{
if(alreadyMappedFmt.equals(format))
if(alreadyMappedFmt.matches(format))
{
//we already have the exact same mapping, so no need to
//create a new one override the old PT number.
@ -287,14 +267,11 @@ public void addMapping(MediaFormat format, byte payloadType)
// if the format is already mapped to a PT then we'll keep it and use
// the new one as an override value for sending. we'd still expect to
// receive packets with the value that we had first selected.
if(payloadTypeMappings.containsKey(format))
{
byte originalPayloadType = payloadTypeMappings.get(format);
Byte originalPayloadType = getPayloadType(format);
if(originalPayloadType != payloadType)
{
payloadTypeOverrides.put(originalPayloadType, payloadType);
}
if( originalPayloadType != null && originalPayloadType != payloadType)
{
payloadTypeOverrides.put(originalPayloadType, payloadType);
}
else
{
@ -304,7 +281,7 @@ public void addMapping(MediaFormat format, byte payloadType)
}
/**
* Returns a reference to the <tt>MediaFormat</tt> with the specified
* Return s a reference to the <tt>MediaFormat</tt> with the specified
* mapping or <tt>null</tt> if the number specified by <tt>payloadType</tt>
* has not been allocated yet.
*
@ -371,7 +348,7 @@ private byte nextPayloadTypeNumber()
* are trying to determine as being claimed as preferred or not by a
* media format.
*
* @return the {@link MediaFormat} with the specified
* @return the {@link MediaFormat} with the null
* <tt>payloadTypePreference</tt> or <tt>null</tt> if no {@link MediaFormat}
* has claimed this payload type number as preferred.
*/
@ -407,4 +384,41 @@ public Map<Byte, Byte> getMappingOverrides()
{
return new HashMap<Byte, Byte>(payloadTypeOverrides);
}
/**
* Returns the payload type that is currently mapped to <tt>format</tt> or
* <tt>null</tt> if there is currently no such payload type.
*
* @param format the {@link MediaFormat} whose mapping we are looking for
* @return the payload type that is currently mapped to <tt>format</tt> or
* <tt>null</tt> if there is currently no such payload type.
*/
public Byte getPayloadType(MediaFormat format)
{
return getPayloadTypeFromMap(payloadTypeMappings, format);
}
/**
* Iterates through <tt>formatMap</tt> and returns the payload type that it
* maps to <tt>format</tt> or <tt>null</tt> if there is currently no such
* payload type.
*
* @param format the {@link MediaFormat} whose mapping we are looking for
* @return the payload type that is currently mapped to <tt>format</tt> or
* <tt>null</tt> if there is currently no such payload type.
*/
private static Byte getPayloadTypeFromMap(Map<MediaFormat, Byte> formatMap,
MediaFormat format)
{
for (Map.Entry<MediaFormat, Byte> mapping : formatMap.entrySet())
{
if (mapping.getKey().matches(format))
{
return mapping.getValue();
}
}
return null;
}
}

@ -953,6 +953,8 @@ private void registerDynamicPTsWithStream(
DynamicPayloadTypeRegistry dynamicPayloadTypes
= callPeerMediaHandler.getDynamicPayloadTypes();
StringBuffer dbgMessage = new StringBuffer("Dynamic PT map: ");
//first register the mappings
for (Map.Entry<MediaFormat, Byte> mapEntry
: dynamicPayloadTypes.getMappings().entrySet())
@ -960,9 +962,12 @@ private void registerDynamicPTsWithStream(
byte pt = mapEntry.getValue();
MediaFormat fmt = mapEntry.getKey();
dbgMessage.append(pt).append("=").append(fmt).append("; ");
stream.addDynamicRTPPayloadType(pt, fmt);
}
logger.info(dbgMessage);
dbgMessage = new StringBuffer("PT overrides [");
//now register whatever overrides we have for the above mappings
for (Map.Entry<Byte, Byte> overrideEntry
: dynamicPayloadTypes.getMappingOverrides().entrySet())
@ -970,9 +975,15 @@ private void registerDynamicPTsWithStream(
byte originalPt = overrideEntry.getKey();
byte overridePt = overrideEntry.getValue();
dbgMessage.append(originalPt).append("->")
.append(overridePt).append(" ");
stream.addDynamicRTPPayloadTypeOverride(originalPt, overridePt);
}
dbgMessage.append("]");
logger.info(dbgMessage);
}

Loading…
Cancel
Save