[Telepathy-commits] [telepathy-gabble/master] Reject transport-infos changing rate/channels
Will Thompson
will.thompson at collabora.co.uk
Thu Mar 5 06:21:48 PST 2009
Also, reject transport-infos which try to add new codecs.
---
src/jingle-media-rtp.c | 24 ++++++++++++++++++++----
tests/twisted/jingle/test-description-info.py | 17 ++++++++++++++---
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 29c1540..ec58d9c 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -368,8 +368,21 @@ update_one_codec (GabbleJingleMediaRtp *self,
return FALSE;
}
- old_codec->clockrate = new_codec->clockrate;
- old_codec->channels = new_codec->channels;
+ if (old_codec->clockrate != new_codec->clockrate)
+ {
+ SET_BAD_REQ ("Changing clockrate (of payload-type %u from %u to %u) "
+ "is meaningless", old_codec->id, old_codec->clockrate,
+ new_codec->clockrate);
+ return FALSE;
+ }
+
+ if (old_codec->channels != new_codec->channels)
+ {
+ SET_BAD_REQ ("Changing channels (of payload-type %u from %u to %u) "
+ "is meaningless", old_codec->id, old_codec->channels,
+ new_codec->channels);
+ return FALSE;
+ }
tmp = old_codec->params;
old_codec->params = new_codec->params;
@@ -379,8 +392,11 @@ update_one_codec (GabbleJingleMediaRtp *self,
}
if (l == NULL)
- DEBUG ("Codec with id %u ('%s') unknown; ignoring update",
- new_codec->id, new_codec->name);
+ {
+ SET_BAD_REQ ("Codec with id %u ('%s') unknown", new_codec->id,
+ new_codec->name);
+ return FALSE;
+ }
return TRUE;
}
diff --git a/tests/twisted/jingle/test-description-info.py b/tests/twisted/jingle/test-description-info.py
index 7b4ebed..a0e36c6 100644
--- a/tests/twisted/jingle/test-description-info.py
+++ b/tests/twisted/jingle/test-description-info.py
@@ -152,11 +152,22 @@ def test(q, bus, conn, stream):
assert sorted(payload_types_tupled) == sorted(new_codecs[0:2]), \
(payload_types_tupled, new_codecs[0:2])
- # Instead, the remote end decides to change the clockrate of and add a
- # parameter to the third codec.
+ # The remote end decides it wants to change the number of channels in the
+ # third codec. This is not meant to happen, so Gabble should send it an IQ
+ # error back.
+ node = jp.SetIq(jt2.peer, jt2.jid, [
+ jp.Jingle(jt2.sid, jt2.peer, 'description-info', [
+ jp.Content('stream1', 'initiator', 'both', [
+ jp.Description('audio', [
+ jp.PayloadType('PCMU', '1600', '0') ]) ]) ]) ])
+ stream.send(jp.xml(node))
+ q.expect('stream-iq', iq_type='error',
+ predicate=lambda x: x.stanza['id'] == node[2]['id'])
+
+ # Instead, the remote end decides to add a parameter to the third codec.
new_codecs = [ ('GSM', 3, 8000, {}),
('PCMA', 8, 8000, {}),
- ('PCMU', 0, 1600, {'choppy': 'false'}),
+ ('PCMU', 0, 8000, {'choppy': 'false'}),
]
# As per the XEP, it only sends the ones which have changed.
c = new_codecs[2]
--
1.5.6.5
More information about the telepathy-commits
mailing list