O'Reilly Emerging Telephony

oreilly.comSafari Books Online.Conferences.
advertisement
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA
AddThis Social Bookmark Button

Print Subscribe to Telephony Subscribe to Newsletters

OpenZoep: An Open Source VoIP Engine
Pages: 1, 2, 3

Jabber Streams

Now that you've mastered OpenZoep's basic methods, it's time to open the stream and make a phone call.



To open the stream, the following stanza should be sent:

  <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
      <stream:stream to='jabber.voipster.com' xmlns='jabber:client'
      xmlns:stream='http://etherx.jabber.org/streams'>

There are two things to notice here. The first is the mandatory UTF-8 encoding, and the second is the host name of the Jabber server. Just replace jabber.voipster.com with your own Jabber server.

The following steps outline the lifecycle of a Jabber stream:

  1. Start a session by calling api_register_account().
  2. Set up the stream as described above.
  3. Inform the OpenZoep engine about your configuration settings by sending the configuration:iq stanza (see trac.web1.openzoep.org/main/wiki/MoipApiSubsystemPresence3 for details).
  4. Request the authorization method (see www.openzoep.org/docs/api/primer/311.htm).
  5. Log in (see www.openzoep.org/docs/api/primer/312.htm).
  6. Send a presence notification (see www.openzoep.org/docs/api/primer/314.htm).
  7. (Recurring) Send and receive messages during the lifetime of the application.
  8. Log out (see www.openzoep.org/docs/api/primer/313.htm).
  9. Close the stream (see www.openzoep.org/docs/api/primer/310.htm).
  10. Close the session by calling api_unregister_account().

The action happens in step 7. Here are some examples of stanzas (XML messages) you can send during step 7.

Making Phone Calls

The OpenZoep client-side engine can be instructed to establish a peer-to-peer phone call to Joe by sending this stanza:

   <voice id="phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109"
      to="joe@jabber.voipster.com/Zoep" type="join">
      <call_id>show</call_id>
      <private>yes</private>
   </voice>

The id attribute of the voice element should contain a globally unique ID (most programming languages offer a library for generating a GUID). The to attribute contains the address of the Jabber contact you want to talk to. The call_id and private attributes are defined by XMPP but are not used by OpenZoep.

Making a call to a "normal" phone (land line or mobile) goes as follows:

   <voice id="phonecall_93a7ba89-4a99-45da-ac82-62f0ee6b4cad"
      to="unknown/#003110123456" type="join">
      <call_id>show</call_id>
      <private>yes</private>
   </voice>

Notice that the Jabber ID should be set to unknown and the number you wish to dial should be preceded by a hash sign (#) and a fully qualified international number. You also need to establish a call credit account with an OpenZoep PSTN provider in order to make phone calls to PSTN numbers (currently the only provider is zoep.com).

Answering Phone Calls

Answering an incoming call from Suzan is just as easy:

   <voice from='suzan@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='erik@jabber.voipster.com/Zoep' type='join'>
   </voice>

Send a message with the type attribute set to joined to accept the call. The to attribute specifies the Jabber ID of the callee:

   <voice id="phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109"
      to="suzan@jabber.voipster.com/Zoep" type="joined"/>

After sending this message, you get the following response from Suzan:

   <voice from='suzan@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='erik@jabber.voipster.com/Zoep' type='joined'>
   </voice>

Suzan receives a similar message, only with the from and to attributes reversed:

   <voice from='erik@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='suzan@jabber.voipster.com/Zoep' type='joined'>
   </voice>

By the way, the join and joined terms originate from the fact that OpenZoep is fully prepared to handle multi-person conferences. Although technically not implemented yet, internally even two-person calls are handled as conferences.

Pages: 1, 2, 3

Next Pagearrow




Search Emerging Telephony

Search

Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom
Advertisement
Sign up today to receive special discounts,
product alerts, and news from O'Reilly.
Privacy Policy >
View Sample Newsletter >
  • Youtube
  • http://www.youtube.com/OreillyMedia
  • Twitter
  • Subscribe
  • View All RSS Feeds >
O'Reilly Media

800-889-8969 or 707-827-7019
Monday-Friday 7:30am-5pm PT
©2011, O'Reilly Media, Inc.
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
  • About O'Reilly
  • Academic Solutions
  • Contacts
  • Customer Service
  • Careers
  • Press Room
  • Privacy Policy
  • Terms of Service
  • Writing for O'Reilly
  • Community
  • Authors
  • Forums
  • Membership
  • Newsletters
  • RSS Feeds
  • User Groups
  • Partner Sites
  • makezine.com
  • makerfaire.com
  • craftzine.com
  • igniteshow.com
  • PayPal Developer Zone
  • O'Reilly Insights on Forbes.com