[telepathy-gabble/telepathy-gabble-0.8] Implement C_Media_Capabilities_Immutable_Streams
Will Thompson
will.thompson at collabora.co.uk
Wed Oct 7 03:50:49 PDT 2009
The tests needed changing because the definition of the
Immutable_Streams cap implies that contacts who can only make audio
calls should have that flag set. Most of the tests were changed to make
the contacts video capable too; the jingle-caps test checks that Google
Video contacts (who are capable of both audio and video) have this flag
set.
---
src/media-channel.c | 11 +++++++++
tests/twisted/caps/caps-cache.py | 12 +++++----
tests/twisted/caps/from-bare-jid.py | 9 ++++---
tests/twisted/caps/hashed-caps.py | 41 ++++++++++++++-------------------
tests/twisted/caps/jingle-caps.py | 16 ++++++++++---
tests/twisted/caps/receive-jingle.py | 18 ++++++++++----
tests/twisted/constants.py | 1 +
7 files changed, 66 insertions(+), 42 deletions(-)
diff --git a/src/media-channel.c b/src/media-channel.c
index f806fbe..eecf729 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2860,6 +2860,7 @@ _gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps)
GabblePresenceCapabilities jingle_video =
PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO |
PRESENCE_CAP_JINGLE_RTP_VIDEO;
+ gboolean just_google, one_media_type;
/* this is intentionally asymmetric to the previous function - we don't
* require the other end to advertise the GTalk-P2P transport capability
@@ -2874,6 +2875,16 @@ _gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps)
((caps & any_transport) && (caps & jingle_video)))
typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
+ /* If this contact only supports Google Talk, or supports exactly one media
+ * type, set Immutable_Streams. */
+ just_google = (caps & (PRESENCE_CAP_GOOGLE_VOICE | PRESENCE_CAP_GOOGLE_VIDEO))
+ && !(caps & (PRESENCE_CAP_JINGLE_RTP | PRESENCE_CAP_JINGLE015));
+ one_media_type = (typeflags == TP_CHANNEL_MEDIA_CAPABILITY_AUDIO)
+ || (typeflags == TP_CHANNEL_MEDIA_CAPABILITY_VIDEO);
+
+ if (just_google || one_media_type)
+ typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_IMMUTABLE_STREAMS;
+
return typeflags;
}
diff --git a/tests/twisted/caps/caps-cache.py b/tests/twisted/caps/caps-cache.py
index a654d74..e7e37ab 100644
--- a/tests/twisted/caps/caps-cache.py
+++ b/tests/twisted/caps/caps-cache.py
@@ -17,19 +17,21 @@ from caps_helper import (
client = 'http://telepathy.freedesktop.org/fake-client'
features = [
- 'http://jabber.org/protocol/jingle',
- 'http://jabber.org/protocol/jingle/description/audio',
- 'http://www.google.com/transport/p2p',
+ ns.JINGLE_015,
+ ns.JINGLE_015_AUDIO,
+ ns.JINGLE_015_VIDEO,
+ ns.GOOGLE_P2P,
]
def expect_caps(q, conn, h):
- # we can now do audio calls
+ # we can now do audio and video calls
event = q.expect('dbus-signal', signal='CapabilitiesChanged')
check_caps(conn, h)
def check_caps(conn, h):
- assertContains((h, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, cs.MEDIA_CAP_AUDIO),
+ assertContains((h, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO),
conn.Capabilities.GetCapabilities([h]))
def update_contact_caps(q, conn, stream, contact, caps, disco = True,
diff --git a/tests/twisted/caps/from-bare-jid.py b/tests/twisted/caps/from-bare-jid.py
index 5664650..cdf51fe 100644
--- a/tests/twisted/caps/from-bare-jid.py
+++ b/tests/twisted/caps/from-bare-jid.py
@@ -24,9 +24,10 @@ def test(q, bus, conn, stream):
# Gabble gets a presence stanza from a bare JID, which is a tad surprising.
features = [
- 'http://jabber.org/protocol/jingle',
- 'http://jabber.org/protocol/jingle/description/audio',
- 'http://www.google.com/transport/p2p',
+ ns.JINGLE_015,
+ ns.JINGLE_015_AUDIO,
+ ns.JINGLE_015_VIDEO,
+ ns.GOOGLE_P2P,
]
caps = {'node': client,
'hash': 'sha-1',
@@ -48,7 +49,7 @@ def test(q, bus, conn, stream):
# Gabble lets us know their caps have changed. (Gabble used to ignore the
# reply.)
streamed_media_caps = (contact_handle, cs.CHANNEL_TYPE_STREAMED_MEDIA,
- 0, 3, 0, 1)
+ 0, 3, 0, cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO)
e = q.expect('dbus-signal', signal='CapabilitiesChanged')
assertContains(streamed_media_caps, e.args[0])
diff --git a/tests/twisted/caps/hashed-caps.py b/tests/twisted/caps/hashed-caps.py
index 206acdd..375f92e 100644
--- a/tests/twisted/caps/hashed-caps.py
+++ b/tests/twisted/caps/hashed-caps.py
@@ -34,6 +34,13 @@ from caps_helper import (
caps_changed_flag = False
+jingle_av_features = [
+ ns.JINGLE_015,
+ ns.JINGLE_015_AUDIO,
+ ns.JINGLE_015_VIDEO,
+ ns.GOOGLE_P2P,
+ ]
+
def caps_changed_cb(dummy):
# Workaround to bug 9980: do not raise an error but use a flag
# https://bugs.freedesktop.org/show_bug.cgi?id=9980
@@ -74,10 +81,7 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
# send good reply
stream.send(make_caps_disco_reply(stream, event.stanza,
- [ 'http://jabber.org/protocol/jingle',
- 'http://jabber.org/protocol/jingle/description/audio',
- 'http://www.google.com/transport/p2p',
- ]))
+ jingle_av_features))
# we can now do audio calls
event = q.expect('dbus-signal', signal='CapabilitiesChanged')
@@ -139,13 +143,7 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
# send correct presence
- features = [
- 'http://jabber.org/protocol/jingle',
- 'http://jabber.org/protocol/jingle/description/audio',
- 'http://www.google.com/transport/p2p',
- ]
-
- ver = compute_caps_hash([], features, fake_client_dataforms)
+ ver = compute_caps_hash([], jingle_av_features, fake_client_dataforms)
caps = {
'node': client,
'ver': ver,
@@ -166,7 +164,7 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
assert caps_changed_flag == False
# send good reply
- result = make_caps_disco_reply(stream, event.stanza, features,
+ result = make_caps_disco_reply(stream, event.stanza, jingle_av_features,
fake_client_dataforms)
stream.send(result)
@@ -209,12 +207,7 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
assert conn.Capabilities.GetCapabilities([contact_handle2]) == basic_caps
# send updated presence with Jingle caps info
- features = [
- 'http://jabber.org/protocol/jingle',
- 'http://jabber.org/protocol/jingle/description/audio',
- 'http://www.google.com/transport/p2p',
- ]
- ver = compute_caps_hash([], features, {})
+ ver = compute_caps_hash([], jingle_av_features, {})
caps = {
'node': client,
'ver': ver,
@@ -236,7 +229,7 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
sync_dbus(bus, q, conn)
assert caps_changed_flag == False
- result = make_caps_disco_reply(stream, event.stanza, features)
+ result = make_caps_disco_reply(stream, event.stanza, jingle_av_features)
if broken_hash:
# make the hash break!
@@ -259,19 +252,19 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
assert caps_changed_flag == False
# send good reply
- result = make_caps_disco_reply(stream, event.stanza, features)
+ result = make_caps_disco_reply(stream, event.stanza, jingle_av_features)
stream.send(result)
# we can now do audio calls with both contacts
event = q.expect('dbus-signal', signal='CapabilitiesChanged',
- # what are the good values?!
- args=[[(contact_handle2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3, 0, 1)]])
+ args=[[(contact_handle2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3, 0,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO)]])
if not broken_hash:
# if the first contact failed to provide a good hash, it does not
# deserve its capabilities to be understood by Gabble!
event = q.expect('dbus-signal', signal='CapabilitiesChanged',
- # what are the good values?!
- args=[[(contact_handle1, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3, 0, 1)]])
+ args=[[(contact_handle1, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3, 0,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO)]])
caps_changed_flag = False
diff --git a/tests/twisted/caps/jingle-caps.py b/tests/twisted/caps/jingle-caps.py
index 892e118..72c063b 100644
--- a/tests/twisted/caps/jingle-caps.py
+++ b/tests/twisted/caps/jingle-caps.py
@@ -17,7 +17,7 @@ all_transports = [
ns.GOOGLE_P2P
]
-def test_caps(q, conn, stream, contact, features, audio, video):
+def test_caps(q, conn, stream, contact, features, audio, video, google=False):
caps['ver'] = compute_caps_hash ([], features, {})
h = presence_and_disco(q, conn, stream, contact, True,
@@ -30,6 +30,11 @@ def test_caps(q, conn, stream, contact, features, audio, video):
if video:
cflags |= cs.MEDIA_CAP_VIDEO
+ # If the contact can only do one of audio or video, or uses a Google
+ # client, they'll have the ImmutableStreams cap.
+ if cflags < (cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO) or google:
+ cflags |= cs.MEDIA_CAP_IMMUTABLE_STREAMS
+
assertContains((h, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, cflags),
conn.Capabilities.GetCapabilities([h]))
@@ -69,15 +74,18 @@ def test(q, bus, conn, stream):
# Google media doesn't need a transport at all
features = [ ns.GOOGLE_FEAT_VOICE, ns.GOOGLE_FEAT_VIDEO ]
- test_caps(q, conn, stream, "full at google", features, True, True)
+ test_caps(q, conn, stream, "full at google", features, True, True,
+ google=True)
# Google video only
features = [ ns.GOOGLE_FEAT_VIDEO ]
- test_caps(q, conn, stream, "video at google", features, False, True)
+ test_caps(q, conn, stream, "video at google", features, False, True,
+ google=True)
# Google audio only
features = [ ns.GOOGLE_FEAT_VOICE ]
- test_caps(q, conn, stream, "audio at google", features, True, False)
+ test_caps(q, conn, stream, "audio at google", features, True, False,
+ google=True)
if __name__ == '__main__':
diff --git a/tests/twisted/caps/receive-jingle.py b/tests/twisted/caps/receive-jingle.py
index 498ccd2..3d7a808 100644
--- a/tests/twisted/caps/receive-jingle.py
+++ b/tests/twisted/caps/receive-jingle.py
@@ -74,7 +74,8 @@ def test(q, bus, conn, stream):
# we can now do audio and video calls
event = q.expect('dbus-signal', signal='CapabilitiesChanged',
- args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3, 0, 3)]])
+ args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 3,
+ 0, cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO)]])
caps = conn.Contacts.GetContactAttributes([2], [cs.CONN_IFACE_CAPS], False)
assert caps.keys() == [2L]
@@ -91,16 +92,21 @@ def test(q, bus, conn, stream):
})
stream.send(presence)
- # we can now do only audio calls
+ # we can now do only audio calls (and as a result have the ImmutableStreams
+ # cap)
event = q.expect('dbus-signal', signal='CapabilitiesChanged',
- args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, 3, 3, 1)]])
+ args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, 3,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_IMMUTABLE_STREAMS)]])
caps = conn.Contacts.GetContactAttributes([2], [cs.CONN_IFACE_CAPS], False)
assert caps.keys() == [2L]
assert icaps_attr in caps[2L]
assert len(caps[2L][icaps_attr]) == 2
assert basic_caps[0] in caps[2L][icaps_attr]
- assert (2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, 1) in caps[2L][icaps_attr]
+ assert (2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_IMMUTABLE_STREAMS) \
+ in caps[2L][icaps_attr]
# go offline
presence = make_presence('bob at foo.com/Foo', type='unavailable')
@@ -108,7 +114,9 @@ def test(q, bus, conn, stream):
# can't do audio calls any more
event = q.expect('dbus-signal', signal='CapabilitiesChanged',
- args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, 0, 1, 0)]])
+ args=[[(2, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, 0,
+ cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_IMMUTABLE_STREAMS,
+ 0)]])
# Contact went offline and the handle is now invalid
assert conn.Contacts.GetContactAttributes(
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 5696300..48c21e8 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -231,6 +231,7 @@ MEDIA_CAP_VIDEO = 2
MEDIA_CAP_STUN = 4
MEDIA_CAP_GTALKP2P = 8
MEDIA_CAP_ICEUDP = 16
+MEDIA_CAP_IMMUTABLE_STREAMS = 32
PRESENCE_OFFLINE = 1
PRESENCE_AVAILABLE = 2
--
1.5.6.5
More information about the telepathy-commits
mailing list