diff options
author | dknn <yoann.blein@free.fr> | 2012-06-02 22:41:35 (GMT) |
---|---|---|
committer | dknn <yoann.blein@free.fr> | 2012-09-22 08:49:55 (GMT) |
commit | 174d01d9812694d201f6f3939fc7b8bf4650cfa2 (patch) | |
tree | 2662370404afd5027afea8dd8f990a81d9df83b2 /Swiften/Serializer/PayloadSerializers/UnitTest | |
parent | ed95bc3cb17285a16a201f8ffe26ac38a4403f47 (diff) | |
download | swift-contrib-174d01d9812694d201f6f3939fc7b8bf4650cfa2.zip swift-contrib-174d01d9812694d201f6f3939fc7b8bf4650cfa2.tar.bz2 |
Major part of a RTP description element
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp index b773fd7..bce9259 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/JingleSerializersTest.cpp @@ -15,6 +15,7 @@ #include <Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/RTPPayloadTypeSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/JingleRTPDescriptionSerializer.h> #include <Swiften/Elements/JingleFileTransferDescription.h> #include <Swiften/Elements/StreamInitiationFileInfo.h> #include <Swiften/Elements/JingleIBBTransportPayload.h> @@ -23,6 +24,7 @@ #include <Swiften/Elements/JinglePayload.h> #include <Swiften/Elements/JingleFileTransferReceived.h> #include <Swiften/Elements/RTPPayloadType.h> +#include <Swiften/Elements/JingleRTPDescription.h> #include <Swiften/Base/DateTime.h> using namespace Swift; @@ -51,6 +53,9 @@ class JingleSerializersTest : public CppUnit::TestFixture { CPPUNIT_TEST(testSerialize_RTPPayloadType_Simple); CPPUNIT_TEST(testSerialize_RTPPayloadType_WithSub); + CPPUNIT_TEST(testSerialize_Xep0167_Example1); + CPPUNIT_TEST(testSerialize_Xep0167_Example48); + CPPUNIT_TEST_SUITE_END(); boost::shared_ptr<JinglePayloadSerializer> createTestling() { @@ -565,6 +570,93 @@ class JingleSerializersTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(expected, serializer->serializePayload(payloadType)); } + // http://xmpp.org/extensions/xep-0167.html#example-1 + void testSerialize_Xep0167_Example1() { + std::string expected = + "<jingle action=\"session-initiate\"" + " initiator=\"romeo@montague.lit/orchard\"" + " sid=\"a73sjjvkla37jfea\"" + " xmlns=\"urn:xmpp:jingle:1\">" + "<content creator=\"initiator\" name=\"voice\">" + "<description media=\"audio\" xmlns=\"urn:xmpp:jingle:apps:rtp:1\">" + "<payload-type clockrate=\"16000\" id=\"96\" name=\"speex\"/>" + "<payload-type clockrate=\"8000\" id=\"97\" name=\"speex\"/>" + "<payload-type id=\"18\" name=\"G729\"/>" + "<payload-type id=\"0\" name=\"PCMU\"/>" + "<payload-type channels=\"2\" clockrate=\"16000\" id=\"103\" name=\"L16\"/>" + "<payload-type clockrate=\"8000\" id=\"98\" name=\"x-ISAC\"/>" + "</description>" + //"<transport [...] >" + "</content>" + "</jingle>"; + + JinglePayload::ref payload = boost::make_shared<JinglePayload>(); + payload->setAction(JinglePayload::SessionInitiate); + payload->setInitiator(JID("romeo@montague.lit/orchard")); + payload->setSessionID("a73sjjvkla37jfea"); + + JingleRTPDescription::ref desc = boost::make_shared<JingleRTPDescription>(JingleRTPDescription::Audio); + desc->addPayloadType(RTPPayloadType(96, "speex", 16000)); + desc->addPayloadType(RTPPayloadType(97, "speex", 8000)); + desc->addPayloadType(RTPPayloadType(18, "G729")); + desc->addPayloadType(RTPPayloadType(0, "PCMU")); + desc->addPayloadType(RTPPayloadType(103, "L16", 16000, 2)); + desc->addPayloadType(RTPPayloadType(98, "x-ISAC", 8000)); + + JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>(); + content->setCreator(JingleContentPayload::InitiatorCreator); + content->setName("voice"); + content->addDescription(desc); + + payload->addPayload(content); + + CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload)); + } + + // http://xmpp.org/extensions/xep-0167.html#example-48 + void testSerialize_Xep0167_Example48() { + std::string expected = + "<jingle action=\"content-accept\"" + " initiator=\"romeo@montague.lit/orchard\"" + " sid=\"a73sjjvkla37jfea\"" + " xmlns=\"urn:xmpp:jingle:1\">" + "<content creator=\"initiator\" name=\"webcam\">" + "<description media=\"video\" xmlns=\"urn:xmpp:jingle:apps:rtp:1\">" + "<payload-type clockrate=\"90000\" id=\"98\" name=\"theora\">" + "<parameter name=\"height\" value=\"600\"/>" + //"<parameter name=\"width\" value=\"800\"/>" + //"<parameter name=\"delivery-method\" value=\"inline\"/>" + //"<parameter name=\"configuration\" value=\"somebase16string\"/>" + "<parameter name=\"sampling\" value=\"YCbCr-4:2:2\"/>" + "</payload-type>" + "<bandwidth type=\"AS\">128</bandwidth>" + "</description>" + //"<transport xmlns=\"urn:xmpp:jingle:transports:ice-udp:0\"/>" + "</content>" + "</jingle>"; + + JinglePayload::ref payload = boost::make_shared<JinglePayload>(); + payload->setAction(JinglePayload::ContentAccept); + payload->setInitiator(JID("romeo@montague.lit/orchard")); + payload->setSessionID("a73sjjvkla37jfea"); + + JingleRTPDescription::ref desc = boost::make_shared<JingleRTPDescription>(JingleRTPDescription::Video); + RTPPayloadType payloadType(98, "theora", 90000); + payloadType.addParameter("height", "600"); + payloadType.addParameter("sampling", "YCbCr-4:2:2"); + desc->addPayloadType(payloadType); + desc->setBandwidth("AS", "128"); + + JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>(); + content->setCreator(JingleContentPayload::InitiatorCreator); + content->setName("webcam"); + content->addDescription(desc); + + payload->addPayload(content); + + CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload)); + } + private: FullPayloadSerializerCollection collection; }; |