Skip to content
Snippets Groups Projects
Commit 760604cc authored by Emil Ivov's avatar Emil Ivov
Browse files

Makes a minor API change. Pyload types are now overridden one by one in order...

Makes a minor API change. Pyload types are now overridden one by one in order to match the way we do this for the actual payload types
parent 084e41af
No related branches found
No related tags found
No related merge requests found
...@@ -2859,22 +2859,25 @@ public FECDecoderControl getFecDecoderControl(ReceiveStream receiveStream) ...@@ -2859,22 +2859,25 @@ public FECDecoderControl getFecDecoderControl(ReceiveStream receiveStream)
} }
/** /**
* Adds additional RTP payload mappings that will override the ones in the * Adds an additional RTP payload mapping that will overriding one that
* "dynamicPayloadTypes" map for outgoing packets. This is necessary so * we've set with {@link addDynamicRTPPayloadType(byte, MediaFormat)}.
* that we can support the RFC3264 case where the answerer has the right * This is necessary so that we can support the RFC3264 case where the
* to declare what payload type mappings it wants to receive even if they * answerer has the right to declare what payload type mappings it wants to
* are different from those in the offer. RFC3264 claims this is for * receive RTP packets with even if they are different from those in the
* support of legacy protocols such as H.323 but we've been bumping with * offer. RFC3264 claims this is for support of legacy protocols such as
* a number of cases where multi-component pure SIP systems also need to * H.323 but we've been bumping with a number of cases where multi-component
* behave this way. * pure SIP systems also need to behave this way.
* The <tt>Map<Byte, Byte></tt> maps source payload to payload to use * <p>
* for packets when sending. *
* @param mappingOverride <tt>Map<Byte, Byte></tt> that maps * @param originalPt the payload type that we are overriding
* source payload to payload to use for packets when sending. * @param overloadPt the payload type that we are overriging it with
*/ */
public void setPTMappingOverrides(Map<Byte, Byte> mappingOverride) public void addDynamicRTPPayloadTypeOverride(byte originalPt,
byte overloadPt)
{ {
if(ptTransformEngine != null) if(ptTransformEngine != null)
ptTransformEngine.setPTMappingOverride(mappingOverride); {
ptTransformEngine.addPTMappingOverride(originalPt, overloadPt);
}
} }
} }
...@@ -31,7 +31,13 @@ public class PayloadTypeTransformEngine ...@@ -31,7 +31,13 @@ public class PayloadTypeTransformEngine
* and we do nothing, packets are passed through without modification. * and we do nothing, packets are passed through without modification.
* Maps source payload to target payload. * Maps source payload to target payload.
*/ */
private Map<Byte, Byte> mappingOverride = new HashMap<Byte, Byte>(); private Map<Byte, Byte> mappingOverrides = new HashMap<Byte, Byte>();
/**
* This map is a copy of <tt>mappingOverride</tt> that we use durig actual
* transformation
*/
private Map<Byte, Byte> mappingOverridesCopy = null;
/** /**
* Checks if there are any override mappings, if no setting just pass * Checks if there are any override mappings, if no setting just pass
...@@ -47,10 +53,10 @@ public class PayloadTypeTransformEngine ...@@ -47,10 +53,10 @@ public class PayloadTypeTransformEngine
*/ */
public RawPacket transform(RawPacket pkt) public RawPacket transform(RawPacket pkt)
{ {
if(mappingOverride.isEmpty()) if(mappingOverridesCopy == null || mappingOverridesCopy.isEmpty())
return pkt; return pkt;
Byte newPT = mappingOverride.get(pkt.getPayloadType()); Byte newPT = mappingOverridesCopy.get(pkt.getPayloadType());
if(newPT != null) if(newPT != null)
pkt.setPayload(newPT); pkt.setPayload(newPT);
...@@ -102,15 +108,29 @@ public PacketTransformer getRTCPTransformer() ...@@ -102,15 +108,29 @@ public PacketTransformer getRTCPTransformer()
} }
/** /**
* Adds additional RTP payload mappings used to override the outgoing * Adds an additional RTP payload type mapping used to override the payload
* payload type. The <tt>Map<Byte, Byte></tt> maps source payload to * type of outgoing RTP packets. If an override for <tt>originalPT<tt/>,
* payload to use for packets when sending. * was already being overridden, this call is simply going to update the
* @param mappingOverride <tt>Map<Byte, Byte></tt> that maps * override to the new one.
* source payload to payload to use for packets when sending. * <p>
* This method creates a copy of the local overriding map so that mapping
* overrides could be set during a call (e.g. after a SIP re-INVITE) in a
* thread-safe way without using synchronization.
*
* @param originalPt the payload type that we are overriding
* @param overloadPt the payload type that we are overriging it with
*/ */
public void setPTMappingOverride(Map<Byte, Byte> mappingOverride)
public void addPTMappingOverride(byte originalPt, byte overloadPt)
{ {
if(mappingOverride != null) if (mappingOverrides.containsKey(originalPt)
this.mappingOverride = mappingOverride; && mappingOverrides.get(originalPt) == overloadPt)
{
return;
}
mappingOverrides.put(originalPt, overloadPt);
mappingOverridesCopy = new HashMap(mappingOverrides);
} }
} }
...@@ -238,20 +238,21 @@ public void addDynamicRTPPayloadType( ...@@ -238,20 +238,21 @@ public void addDynamicRTPPayloadType(
public Map<Byte, MediaFormat> getDynamicRTPPayloadTypes(); public Map<Byte, MediaFormat> getDynamicRTPPayloadTypes();
/** /**
* Adds additional RTP payload mappings that will override the ones in the * Adds an additional RTP payload mapping that will overriding one that
* "dynamicPayloadTypes" map for outgoing packets. This is necessary so * we've set with {@link addDynamicRTPPayloadType(byte, MediaFormat)}.
* that we can support the RFC3264 case where the answerer has the right * This is necessary so that we can support the RFC3264 case where the
* to declare what payload type mappings it wants to receive even if they * answerer has the right to declare what payload type mappings it wants to
* are different from those in the offer. RFC3264 claims this is for * receive RTP packets with even if they are different from those in the
* support of legacy protocols such as H.323 but we've been bumping with * offer. RFC3264 claims this is for support of legacy protocols such as
* a number of cases where multi-component pure SIP systems also need to * H.323 but we've been bumping with a number of cases where multi-component
* behave this way. * pure SIP systems also need to behave this way.
* The <tt>Map<Byte, Byte></tt> maps source payload to payload to use * <p>
* for packets when sending. *
* @param mappingOverride <tt>Map<Byte, Byte></tt> that maps * @param originalPt the payload type that we are overriding
* source payload to payload to use for packets when sending. * @param overloadPt the payload type that we are overriging it with
*/ */
public void setPTMappingOverrides(Map<Byte, Byte> mappingOverride); public void addDynamicRTPPayloadTypeOverride(byte originalPt,
byte overloadPt);
/** /**
* Adds or updates an association in this <tt>MediaStream</tt> mapping the * Adds or updates an association in this <tt>MediaStream</tt> mapping the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment