28.04.2015 Views

JSR 281 IMS Services API - Oracle Software Delivery Cloud

JSR 281 IMS Services API - Oracle Software Delivery Cloud

JSR 281 IMS Services API - Oracle Software Delivery Cloud

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong><br />

for Java Micro Edition<br />

Maintenance Release Version 1.1<br />

<strong>JSR</strong> <strong>281</strong> Expert Group<br />

jsr-<strong>281</strong>-comments@ericsson.com<br />

Java Community Process<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 1 of 199


<strong>JSR</strong> <strong>281</strong> SPECIFICATION LICENSE AGREEMENT (”AGREEMENT”)<br />

ERICSSON AB (“ERICSSON”) IS WILLING TO LICENSE THIS SPECIFICATION (AS DEFINED BELOW)<br />

TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS AND CONDITIONS<br />

OF THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS CAREFULLY. BY ACCESSING<br />

OR USING THE SPECIFICATION (AS DEFINED BELOW) YOU WILL BE BOUND BY THE TERMS AND<br />

CONDITIONS OF THIS AGREEMENT.<br />

DEFINITIONS<br />

“Specification” shall mean <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> specification<br />

“Independent Implementation” shall mean an implementation of the Specification that neither derives<br />

from nor includes any of source code or binary code materials of the Reference Implementation.<br />

“Licensee” shall mean the individual downloading the Specification and where such individual downloads<br />

the Specification for other than private use, the legal entity represented by such individual.<br />

“Reference Implementation” shall mean the reference implementation of the Specification.<br />

“Reserved Name Space” shall mean the public class or interface declarations whose names begin with<br />

javax.microedition.ims or their equivalents in any subsequent naming convention adopted through the Java<br />

Community Process, or any recognized successors or replacements thereof.<br />

“TCK” and “Technology Compatibility Kit” shall mean technology compatibility kit for the Specification.<br />

1 LICENSE GRANTS<br />

1.1 Ericsson hereby grants Licensee a non-exclusive, non-transferable, worldwide, royalty free, fully paid up<br />

limited license (without the right to sublicense), solely under the intellectual property rights licensable by<br />

Ericsson to view, down load, use and reproduce the Specification only for the purpose of internal evaluation.<br />

1.2 Subject to the reciprocity requirement set forth below, Ericsson hereby grants Licensee a non-exclusive,<br />

non-transferable, worldwide, royalty free, fully paid up limited license (without the right to sublicense), solely<br />

under the intellectual property rights licensable by Ericsson to view, down load, use and reproduce the<br />

Specification only for the purposes of development of Independent Implementations. The Specification<br />

contains proprietary information of Ericsson and may only be used in accordance with the license terms set<br />

forth herein. For the avoidance of any possible doubts, no right to further distribute the Specification is<br />

granted by this Agreement.<br />

1.3 Subject to the reciprocity requirement set forth below, Ericsson hereby grants Licensee a perpetual,<br />

non-exclusive, worldwide, fully paid-up, royalty free, limited license (without the rights to sublicense) under<br />

its licensable (i) copyrights in the Specification and (ii) patent claims for which there is no technically feasible<br />

way of avoiding infringement in the course of implementing the Specification, to create and/or distribute<br />

Independent Implementations that<br />

a) fully implement the Specification including all its required interfaces and functionality;<br />

b) do not modify, subset, superset or otherwise extend the Reserved Name Space, or<br />

include any public or protected packages, classes, Java interfaces, fields or methods<br />

within the Reserved Name Space other than those required/authorized by the<br />

Specification; and<br />

c) pass the Technology Compatibility Kit (including satisfying the requirements of the<br />

applicable TCK Users Guide) for the Specification.<br />

1.4 Licensee needs not to include limitations (a)-(c) from Section 1.3 above or any other particular “pass<br />

through” requirements in any license Licensee grants concerning the use of Licensee’s Independent<br />

Implementation or products derived from it. However, except with respect to implementations of the<br />

Specification (and products derived from them) by Licensee’s licensee that satisfy limitations of Section 1.3<br />

(a)-(c) above, Licensee may neither: (i) grant or otherwise pass through to Licensee’s licensees any<br />

licenses under intellectual property rights licensable by Ericsson; nor (ii) authorize Licensee’s licensees to<br />

make any claims concerning their implementation’s compliance with the Specification.<br />

1.5 Other than the limited license granted in this Agreement, Licensee acquire no right, license, title or interest<br />

in or to the Specification or any other intellectual property rights of Ericsson or its licensors.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 2 of 199


1.6 The licenses granted by Ericsson in Sections 1.2 and 1.3 of this Agreement are subject to a reciprocity<br />

requirement and therefore conditional upon Licensee committing to offer to any party seeking a license from<br />

Licensee, under Licensee’s patent rights, which are or would be infringed by all technically feasible<br />

implementations of the Specification, on the following terms:<br />

(i)<br />

(ii)<br />

(iii)<br />

(iv)<br />

(v)<br />

the license grant shall be under each patent claim that Licensee own, will own or have the<br />

authority to license, and<br />

the license shall be granted on fair, reasonable and non-discriminatory terms, and<br />

the license shall be perpetual, non-exclusive, non-transferable and worldwide within the<br />

scope of the licenses granted above by Ericsson, and<br />

the license shall permit the development, distribution and use of an Independent<br />

Implementation that satisfies the requirements set forth in 1.3(a) – (c) above, and the use<br />

of a licensed Reference Implementation, in whole or in part, as a part of such Independent<br />

Implementation, and<br />

the license shall permit the use of the TCK.<br />

1.7 Nothwithstanding Section 1.6 above, Licensee shall not be required to grant a license:<br />

(i)<br />

(ii)<br />

(iii)<br />

to a licensee not willing to grant a reciprocal license under its patent rights to Licensee<br />

and to any other party seeking such license with respect to the enforcement of such<br />

licensee’s patent claims where there is no technically feasible alternative that would avoid<br />

the infringement of such claims (with respect to Licensee’s exercise of the rights<br />

described in subparagraphs (iv) – (v) immediately above); or<br />

with respect to any portion of any product and any combinations thereof the sole purpose<br />

and function of which is not required in order to be fully compliant with the Specification:<br />

with respect to technology that is not required for at least one of the following: using the<br />

Reference Implementation, using the TCK, or developing, distributing or using an<br />

Independent Implementation.<br />

1.8 Licensee’s licenses to Ericsson’s own patent rights granted under this Agreement shall be considered null<br />

and void should Licensee initiate a claim that Ericsson has, in the course of performing its duties as<br />

Ericsson, induced any entity to infringe Licensee’s patent rights.<br />

1.9 For the purposes of Sections 1.6-1.8 above, Licensee shall mean “Licensee” and any party for which<br />

Licensee are authorized to act with respect to the Java Specification Participation Agreement applicable to<br />

the Specification.<br />

1.10 This Agreement will terminate immediately without notice from Ericsson if Licensee fails to comply with any<br />

material provision of this Agreement or act outside the scope of the licenses granted above.<br />

2 TRADEMARKS<br />

2.1 Licensee’s access to this Specification shall not be construed as granting, any license or right to use any<br />

marks appearing in the Specification without the prior written consent of Ericssonand or Ericsson’s<br />

licensors.<br />

2.2 Licensee shall not be allowed to remove any of the copyright statements or disclaimers or other proprietary<br />

notices contained in the Specification and Licensee are obliged to include the copyright statement and the<br />

disclaimers, if any, in any copies of the Specification Licensee makes.<br />

3 DISCLAIMER OF WARRANTIES<br />

3.1 SUBJECT TO ANY STATUTORY WARRANTIES OR CONDITIONS WHICH CANNOT BE EXCLUDED,<br />

THE SPECIFICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OR CONDITION OF ANY KIND<br />

EITHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED<br />

WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE<br />

AND NON-INFRINGEMENT. ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, AND<br />

STATUTORY ARE HEREBY DISCLAIMED. THE ENTIRE RISK ARISING OUT OF OR RELATING TO THE<br />

USE OR PERFORMANCE OF THE SPECIFICATION REMAINS WITH LICENSEE.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 3 of 199


3.2 THE SPECIFICATION MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS.<br />

CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE<br />

INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. ERICSSON MAY MAKE<br />

IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED<br />

IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by<br />

the then-current license for the applicable version of the Specification.<br />

4 LIMITATION OF LIABILITY<br />

4.1 TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT WILL ERICSSON OR ITS SUPPLIERS<br />

BE LIABLE FOR ANY LOST PROFITS, LOST SAVINGS, LOST REVENUE, LOST DATA,<br />

PROCUREMENT OF SUBSTITUTE GOODS, OR FOR ANY DIRECT, INDIRECT, INCIDENTIAL,<br />

SPECIAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, EVEN IF THE SPECIFICATION LEAD OR ITS<br />

SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES OR DAMAGES. IN<br />

ADDITION ERICSSON AND ITS SUPPLIERS WILL NOT BE LIABLE FOR ANY DAMAGES CLAIMED BY<br />

LICENSEE BASED ON ANY THIRD PARTY CLAIM.<br />

4.2 Some jurisdictions do not allow the exclusion of implied warranties, or the limitation for consequential<br />

damages, so Section 4.1 may not apply to Licensee in whole, but in such case Section 4.1 will apply to<br />

Licensee to the maximum extent permitted by applicable law.<br />

4.3 Licensee will indemnify, hold harmless, and defend Ericsson and its licensors from any claims arising or<br />

resulting from: (i) Licensee’s use of the Specification; (ii) the use or distribution of Licensee’s Java<br />

application, applet and/or Independent Implementation; and/or (iii) any claims that later versions or<br />

releases of any Specification furnished to Licensee are incompatible with the Specification provided to<br />

Licensee under this license.<br />

5 FEEDBACK<br />

5.1 The following paragraph applies to Licensee only if Licensee is not (i) a member of Java Community<br />

Process, or (ii) bound by obligations of the Java Specification participation Agreement or Individual Expert<br />

Participation Agreement applicable for the Specification.<br />

5.2 Licensee may wish to report any observations, ambiquities, inconsistencies or inaccuracies Licensee may<br />

find in connection with Licensee’s use and implementation of the Specification (“Feedback”). To the extent<br />

that Licensee provides Ericsson with any Feedback, Licensee hereby: (i) agree that such Feedback is<br />

provided on a non-proprietary and non-confidential basis, and (ii) grants to Ericsson a perpetual,<br />

non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple<br />

levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose<br />

related to the Specification and future versions, implementations, and test suites thereof.<br />

6 EXPORT CONTROL<br />

6.1 Licensee shall follow all export control laws and regulations relating to Specification.<br />

7 RESTRICTED RIGHTS LEGEND<br />

7.1 Note to U.S. Government Users. The Specification is a “Commercial Items”, as that term is defined at 48<br />

C.F.R. 2.101, consisting of “Commercial Computer <strong>Software</strong>” and “Commercial Computer <strong>Software</strong><br />

Documentation”, as such terms are used in 48 C.F.R. 12.212 or 48 C.F.R.227.7202, as applicable.<br />

Consistent with 48 C.F.R.12.212 or 48 C.F.R.227.7202-1 through 227.7202-4, as applicable, the<br />

Commercial Computer <strong>Software</strong> Documentation are being licensed to U.S. Government end users a) only<br />

as Commercial Items and b) with only those rights as are granted to all other end users pursuant to the<br />

terms and conditions herein. Unpublished-rights reserved under the copyright laws of the United States.<br />

8 GOVERNING LAW AND ARBITRATION<br />

8.1 This agreement shall be governed by and construed in accordance with the laws of Sweden, without regard<br />

to its conflict of law rules.<br />

8.2 The English language shall be used in all documents and correspondence related to this agreement.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 4 of 199


8.3 The Parties shall use their best efforts to settle by amicable negotiations any differences, which may occur<br />

between them in connection with this agreement. If the Parties fail to reach such an amicable settlement<br />

within thirty (30) days from the commencement of such amicable negotiations, either party may refer such<br />

differences to arbitration as provided below.<br />

8.4 All disputes, differences or questions arising out of or in connection with this agreement shall be finally<br />

settled under the Rules of Arbitration of the International Chamber of Commerce by three (3) arbitrators<br />

appointed in accordance with the said rules. The arbitral proceedings shall be conducted in the English<br />

language and shall take place in Stockholm, Sweden. All awards shall be final and binding and may if<br />

necessary be enforced by any court having jurisdiction in the same manner as a judgement in such court.<br />

8.5 The Parties undertake and agree that all arbitral proceedings conducted under this section 8 shall be kept<br />

strictly confidential, and all information, documentation, materials in whatever form disclosed in the course of<br />

such arbitral proceeding shall be used solely for the purpose of those proceedings.<br />

8.6 Notwithstanding the aforesaid, nothing in this Section 8 shall prevent the Parties from seeking any interim or<br />

final injunctive or equitable relief by a court of competent jurisdiction.<br />

9 GENERAL<br />

9.1 The legality of any part of this Agreement shall not affect the legality of any other part. If any provision of this<br />

Agreement shall be held by a court of competent jurisdiction to be invalid, illegal or unenforceable, the<br />

validity, legality and enforceability of the remaining provisions shall in no way be affected or impaired<br />

thereby and the invalid illegal or unenforceable<br />

9.2 If a court or agency of competent jurisdiction holds any term of this Agreement invalid, illegal, or<br />

unenforceable for any reason, the remainder of this Agreement shall be valid and enforceable and the<br />

Parties shall negotiate in good faith a substitute, valid, enforceable provision which most nearly effects the<br />

parties intent in entering into this Agreement.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 5 of 199


Contents<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong>..........................................................................................................................................1<br />

Preface .........................................................................................................................................................................7<br />

Package javax.microedition.ims .............................................................................................................................24<br />

Class Configuration.................................................................................................................................................32<br />

Class ConnectionState............................................................................................................................................36<br />

Interface ConnectionStateListener..........................................................................................................................38<br />

Class ImsException.................................................................................................................................................40<br />

Interface ReasonInfo...............................................................................................................................................41<br />

Interface Service .....................................................................................................................................................43<br />

Class ServiceClosedException ...............................................................................................................................45<br />

Package javax.microedition.ims.core.....................................................................................................................46<br />

Interface Capabilities...............................................................................................................................................48<br />

Interface CapabilitiesListener..................................................................................................................................51<br />

Interface CoreService .............................................................................................................................................52<br />

Class CoreServiceException...................................................................................................................................58<br />

Interface CoreServiceListener.................................................................................................................................59<br />

Class ImscoreProtocolPermission ..........................................................................................................................61<br />

Interface Message...................................................................................................................................................64<br />

Interface MessageBodyPart....................................................................................................................................70<br />

Interface PageMessage ..........................................................................................................................................72<br />

Interface PageMessageListener .............................................................................................................................76<br />

Interface Publication................................................................................................................................................77<br />

Interface PublicationListener...................................................................................................................................81<br />

Interface Reference.................................................................................................................................................83<br />

Interface ReferenceListener....................................................................................................................................91<br />

Interface ServiceMethod .........................................................................................................................................93<br />

Interface Session.....................................................................................................................................................98<br />

Interface SessionDescriptor ..................................................................................................................................111<br />

Interface SessionListener......................................................................................................................................115<br />

Interface Subscription ...........................................................................................................................................118<br />

Interface SubscriptionListener...............................................................................................................................122<br />

Package javax.microedition.ims.core.media .......................................................................................................124<br />

Interface BasicReliableMedia................................................................................................................................126<br />

Interface BasicReliableMediaListener...................................................................................................................129<br />

Interface BasicUnreliableMedia ............................................................................................................................130<br />

Interface BasicUnreliableMediaListener ...............................................................................................................133<br />

Interface FramedMedia .........................................................................................................................................134<br />

Interface FramedMediaListener ............................................................................................................................140<br />

Interface Media......................................................................................................................................................143<br />

Interface MediaDescriptor .....................................................................................................................................152<br />

Interface MediaListener.........................................................................................................................................156<br />

Class MediaPermission.........................................................................................................................................157<br />

Interface StreamMedia..........................................................................................................................................160<br />

Appendix A: Implementation guidelines ..............................................................................................................166<br />

Appendix B: MIDP 2.0 PushRegistry for <strong>JSR</strong> <strong>281</strong> ...............................................................................................195<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 6 of 199


Preface<br />

This document defines the <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> (<strong>IMS</strong><strong>API</strong>), a Java <strong>API</strong> for the IP Multimedia Subsystem (<strong>IMS</strong>) on<br />

mobile devices. The <strong>IMS</strong><strong>API</strong> is an optional package for the Java ME platform. The <strong>API</strong> provides a toolbox of <strong>IMS</strong><br />

building blocks which the developer can use to create <strong>IMS</strong> applications. <strong>IMS</strong> is an effort driven by the telecom world<br />

to build multimedia rich highly networked services and applications for the new high capacity IP based<br />

telecommunication networks. Java can play an important role in the deployment and adoption of <strong>IMS</strong> at large,<br />

because of the volume of installed Java profiles on mobile devices. The <strong>IMS</strong><strong>API</strong> is designed accordingly.<br />

The <strong>API</strong> features a high level of abstraction, hiding the technology and protocol details, but can still prove to be<br />

useful and powerful enough for non-experts in <strong>IMS</strong> to create new <strong>IMS</strong> applications. Therefore, the <strong>IMS</strong><strong>API</strong> is useful<br />

for the entire Java ME developer community. The knowledge required to create simple <strong>IMS</strong> applications is how to<br />

use a telephone for ordinary voice calls, and some programming experience on the MIDP2.0 platform. Creating an<br />

<strong>IMS</strong>-aware application is only just a few steps away. It allows the developer to concentrate on the logic of the<br />

application. To satisfy Java developers who know <strong>IMS</strong>, the <strong>API</strong> provides limited access to the underlying protocols<br />

using low level <strong>API</strong>s in a controlled way.<br />

If a developer has an idea for an application that includes a component for sharing multi-media content with others,<br />

then the <strong>IMS</strong><strong>API</strong> is a <strong>JSR</strong> to consider.<br />

Revision History<br />

Date Version Description<br />

10-February-2006 <strong>IMS</strong> Specification First draft provided by the Specification Lead<br />

18-July-2006<br />

Draft version 0.2 Changes and clarifications<br />

25-July-2006 Draft version 0.3 Changes as a consequence of F2F meeting Kista 06/06<br />

27-September-2006 EDR version 0.4 Proposal for Early Draft Review<br />

31-October-2006<br />

EDR version 0.5 Early Draft Review<br />

7-September-2007 PDR version 0.9 Proposal for Public Draft<br />

29-February-2008<br />

PFD version 0.95 Proposed Final Draft<br />

13-June-2008 FR version 1.0 Final Release<br />

08-April-2009 MR version 1.1 Maintenance Release<br />

Who Should Use This Specification<br />

This document is targeted at the following audiences:<br />

• The Java Community Process (JCP) expert group defining this optional package.<br />

• Implementers of <strong>IMS</strong><strong>API</strong>.<br />

• Developers writing applications using the <strong>IMS</strong><strong>API</strong>.<br />

• Network operators deploying infrastructure to support <strong>IMS</strong><strong>API</strong> enabled devices.<br />

How This Specification Is Organized<br />

The document is composed of the Preface part, JavaDoc documentation of the <strong>IMS</strong><strong>API</strong> packages, and an appendix.<br />

It is intentional that it is sufficient for an application developer to have to look only at the JavaDoc parts. The<br />

appendix is used as a guide for implementers of the specification.<br />

References<br />

This reference list is informational.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 7 of 199


• [<strong>JSR</strong>75] <strong>JSR</strong> 75 FileConnection <strong>API</strong><br />

• [<strong>JSR</strong>118] <strong>JSR</strong> 118 MIDP2.1<br />

• [<strong>JSR</strong>135] <strong>JSR</strong> 135 Mobile Media <strong>API</strong><br />

• [<strong>JSR</strong>139] <strong>JSR</strong> 139 CLDC 1.1<br />

• [<strong>JSR</strong>307] <strong>JSR</strong> 307 Network Mobility and Mobile Data <strong>API</strong><br />

• [23.003] 3GPP TS 23.003 Numbering, addressing and identification. Release 6<br />

• [22.228] 3GPP TS 22.228 Service requirements for the Internet Protocol (IP) Multimedia Core Network<br />

Subsystem; Stage 1, Release 6<br />

• [23.228] 3GPP TS 23.228 IP Multimedia Subsystem (<strong>IMS</strong>). Stage 2, Release 6<br />

• [24.229] 3GPP TS 24.229 IP Multimedia Call Control Protocol based on Session Initiation Protocol (SIP)<br />

and Session Description Protocol (SDP). Stage 3, Release 6<br />

• [26.114] 3GPP TS 26.114 Multimedia Telephony; Media handling and interaction. Release 7.<br />

• [26.235] 3GPP TS 26.235 Packet switched conversational multimedia applications; Default codecs<br />

• [26.244] 3GPP TS 26.244 3GPP file format (3GP). Release 6<br />

• [RFC2045] RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One<br />

• [RFC2046] RFC 2046 Multipurpose Internet Mail Extensions (MIME) Part Two<br />

• [RFC2119] RFC 2119 Key words for use in RFCs to Indicate Requirement Levels<br />

• [RFC2215] RFC 2215 General Characterization Parameters for Integrated Service Network Elements<br />

• [RFC2396] RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax<br />

• [RFC3261] RFC 3261 SIP Session Initiation Protocol<br />

• [RFC3515] RFC 3515 The Session Initiation Protocol (SIP) Refer Method<br />

• [RFC3840] RFC 3840 Indicating User Agent Capabilities in the Session Initiation Protocol (SIP)<br />

• [RFC3841] RFC 3841 Caller Preferences for the Session Initiation Protocol (SIP)<br />

• [RFC3966] RFC 3966 The tel URI for Telephone Numbers<br />

• [RFC4145] RFC 4145 TCP-Based Media Transport in the Session Description Protocol<br />

• [RFC4488] RFC 4488 Suppression of Session Initiation Protocol (SIP) REFER method Implicit Subscription<br />

• [RFC4566] RFC 4566 SDP Session Description Protocol<br />

• [RFC4975] RFC 4975 The Message Session Relay Protocol<br />

• [RFC5322] RFC 5322 Internet Message Format<br />

• [draft-ietf-simple-msrp-acm-00] IETF Internet Draft draft-ietf-simple-msrp-acm-00.txt<br />

Terms and Abbreviations<br />

Terms and abbreviations used in the document:<br />

• 3GPP: Third Generation Partnership Project. Standardizes mobile communication.<br />

• AMS: Application Management System.<br />

• Application Capability: Name for composed non-standard capability. This capability includes<br />

application-specific <strong>IMS</strong> logic.<br />

• Access Network: The network used to access the <strong>IMS</strong> network.<br />

• Application Capability: A capability attributed to an <strong>IMS</strong> application.<br />

• AppId: <strong>IMS</strong><strong>API</strong> Application Identifier.<br />

• Basic capability: A built-in capability of the <strong>IMS</strong><strong>API</strong>, and is either a media type or an event package.<br />

• BasicMedia: Collective name for BasicUnreliableMedia and BasicReliableMedia media types.<br />

• canRead: A media mode property that if set to true, enable reading data from the media flow.<br />

• canWrite: A media mode property that if set to true, enable writing data to the media flow.<br />

• Capability: The ability of a device to process a particular kind of content.<br />

• Composed capability: A capability that has been built up of other capabilities. (See Basic capability).<br />

• exists: a media mode property that if true, means that the data flow is created.<br />

• Feature: Describes an aspect of a device or resource.<br />

• Feature Tag: The syntax of a feature.<br />

• Flowspec: Flow specification.<br />

• GCF: Generic Connection Framework.<br />

• IARI: <strong>IMS</strong> Application Reference Identifier.<br />

• ICSI: <strong>IMS</strong> Communication Service Identifier.<br />

• IETF: Internet Engineering Task Force. Standardizes Internet communication in the form of RFCs.<br />

• <strong>IMS</strong>: IP Multimedia Subsystem.<br />

• <strong>IMS</strong><strong>API</strong>: Java <strong>JSR</strong> <strong>281</strong> IP Multimedia Subsystem <strong>API</strong>.<br />

• <strong>IMS</strong> Application: A realization of a number of <strong>IMS</strong> capabilities for a well-defined end user purpose.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 8 of 199


• imscore: connector string: A string specification used as input to create a core service object<br />

• [media] mode property: one of exists, canRead and canWrite: a boolean property that describes the state<br />

of a media data flow<br />

• MSRP: Message Session Relay Protocol. A protocol for transmitting a series of related instant messages in<br />

the context of a session.<br />

• Originating endpoint: The endpoint that is initiating an <strong>IMS</strong> communication.<br />

• PoC: Push-to-talk Over Cellular.<br />

• PSI: Public Service Identifier.<br />

• QoS: Quality of Service.<br />

• RFC: Request For Comment. Documents delivered by IETF.<br />

• Service: When used as a technical term in the <strong>IMS</strong><strong>API</strong>, it represents a context of service methods.<br />

• Service Method: A common name for end-to-end forms of communication in the <strong>IMS</strong><strong>API</strong>: Session,<br />

Capability, Publication, Subscription, PageMessage and Reference.<br />

• SDP: Session Description Protocol.<br />

• SIP: Session Initiation Protocol.<br />

• Terminating endpoint: The endpoint that is receiving an <strong>IMS</strong> communication.<br />

• User Identity: An <strong>IMS</strong> Public User Identity.<br />

• URI: Uniform Resource Identifier.<br />

• URN: Uniform Resource Name. A type of URI.<br />

<strong>JSR</strong> <strong>281</strong> Expert Group<br />

The following companies, listed in alphabetical order, were members of the <strong>JSR</strong> <strong>281</strong> Expert Group:<br />

• China Mobile Communications Co. Ltd<br />

• Ericsson AB<br />

• Esmertec AG<br />

• IBM<br />

• Infineon Technologies AG<br />

• LG Electronics Inc.<br />

• Lucent Technologies<br />

• Motorola<br />

• NEC Corporation<br />

• NMS Communications<br />

• Nokia Corporation<br />

• Orange France SA<br />

• Qisda Corporation<br />

• Research In Motion, LTD (RIM)<br />

• Samsung Electronics Corporation<br />

• SBC<br />

• Siemens AG<br />

• Sirf Technology Holdings, Inc<br />

• Sony Ericsson Mobile Communications AB<br />

• Sprint<br />

• Sun Microsystems, Inc.<br />

• T-Mobile Austria GmbH<br />

• Telecom Italia<br />

• Vodafone Group <strong>Services</strong> Limited<br />

Document Conventions<br />

This document uses definitions based upon those specified in [RFC2119].<br />

Term<br />

MUST<br />

MUST<br />

NOT<br />

Definition<br />

The associated definition is an absolute requirement of this specification.<br />

The definition is an absolute prohibition of this specification.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 9 of 199


SHOULD<br />

SHOULD<br />

NOT<br />

MAY<br />

Indicates a recommended practice. There may exist valid reasons in particular circumstances to ignore<br />

this recommendation, but the full implications must be understood and carefully weighed before<br />

choosing a different course.<br />

Indicates a non-recommended practice. There may exist valid reasons in particular circumstances<br />

when the particular behavior is acceptable or even useful, but the full implications should be<br />

understood and the case carefully weighed before implementing any behavior described with this label.<br />

Indicates that an item is truly optional.<br />

Formatting Conventions<br />

This specification uses the following formatting conventions.<br />

Convention Description<br />

Courier New Used in all Java code including keywords, data types, constants, method names, variables, class<br />

names, and interface names.<br />

Italic Used for emphasis and to signify the first use of a term.<br />

Report and Contact<br />

Your comments on this specification are welcome and appreciated. Please send your comments to:<br />

jsr-<strong>281</strong>-comments@ericsson.com<br />

Overview<br />

IP Multimedia Subsystem<br />

The IP Multimedia Subsystem (<strong>IMS</strong>) can be seen as an evolution of the traditional voice telephone systems, taking<br />

advantage of high speed data networking, multimedia, and increased processing power in end user devices.<br />

However, many old principles are still preserved. An operator runs a network, allowing subscribers (e.g. Alice and<br />

Bob) to attach their devices to network endpoints. Alice and Bob get unique identities on the network. Alice can call<br />

Bob using his identity. The network creates a path between Alice's and Bob's devices for the call and they can start<br />

their exchange. The exchange part is where the most obvious difference is; going from the single media of voice in<br />

telephony to multimedia in <strong>IMS</strong>.<br />

Single- and Multimedia<br />

The media is the part that has changed most. For ordinary telephony, it was a single media format of voice<br />

between Alice and Bob. In <strong>IMS</strong>, Alice and Bob can handle media in multiple formats that can be any combination of<br />

the following: Video and audio streaming (including voice), instant messaging (as in a chat), exchange of any<br />

application-specific data (as in gaming). This degree of freedom in media formats has major implications for the<br />

functionality of Alice's and Bob's devices (described below).<br />

<strong>IMS</strong> Call<br />

Making an <strong>IMS</strong> call follows the traditional telephony pattern. Suppose Alice wants to call Bob. Then Alice is the<br />

originating endpoint, and Bob is the terminating endpoint. At Alice's device, the following procedure applies:<br />

1. Start the calling application on the device.<br />

2. Identify Bob's identity (possibly with the help of the phone book).<br />

3. Wait for answer.<br />

4. At answer, communication begins.<br />

5. Later, the communication ends by hanging up.<br />

Procedure at Bob's device:<br />

1. Phone is ringing, and the called application is shown on the device screen.<br />

2. Bob decides to take the call.<br />

3. Communication takes place.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 10 of 199


4. Hang up.<br />

If Alice wants to call a service (that is, where the remote end is not a subscriber), she does it the same way but<br />

uses its service identity instead of a subscriber.<br />

Even though <strong>IMS</strong> is (here) seen as an evolution of telephony, there are important contributions from data<br />

communication seen in many places of <strong>IMS</strong>. An <strong>IMS</strong> enabled device can in general handle several <strong>IMS</strong> calls to<br />

many subscribers and network services at the same time. It is similar to how a computer can handle multiple<br />

network connections to one or several other computers. The precise behavior is application-specific, but it should<br />

be remembered that just because one <strong>IMS</strong> call is active, it does not imply that other calls cannot be handled.<br />

User identification in <strong>IMS</strong><br />

<strong>IMS</strong> users are reachable on the <strong>IMS</strong> networks with their Public User Identities, that takes the form of an Uniform<br />

Resource Identifier (URI). Two types of URI are supported:<br />

• A SIP URI (as defined in RFC3261), like sip:alice@ims.example.com. Such URIs are suitable for use from<br />

the Internet.<br />

• A TEL URI (as defined in RFC3966), like tel:+4680123456. This format enables an <strong>IMS</strong> terminal to be<br />

reachable in traditional telephone networks.<br />

The operator allocates one or more public user identities for use within a subscription.<br />

When the device is switched on and connects to the <strong>IMS</strong> network, the device and the network engage in a process<br />

called <strong>IMS</strong> registration to make the user reachable under some of the identities.<br />

It is possible to be reachable using several public user identities at the same time. For example, if a SIP identity<br />

works on the Internet, and the TEL identity on the telephone network, it makes sense to have them both registered<br />

at the same time to be equally reachable from both worlds. The operator usually makes sure that in such case, if<br />

the user wants to be reachable on one of them, it implies also being reachable from the other.<br />

Service Identification in <strong>IMS</strong><br />

<strong>Services</strong> in traditional telephony, like conferencing or supplementary service self administration, are accessed<br />

using special phone numbers. A similar situation holds in <strong>IMS</strong> where a service is accessed using a Public Service<br />

Identity. If Alice wants to take part in a conference, she dials into the conference using its public service identity.<br />

The conference server arranges for her participation. The identity is formatted as a SIP URI.<br />

User and Service Addressing<br />

In the <strong>IMS</strong><strong>API</strong>, the user can influence registration by indicating the public user identity the user would like to be<br />

reachable under on the terminal via the call to Connector.open.<br />

To establish communications to remote endpoints on the <strong>IMS</strong> network, the <strong>JSR</strong> provides a set of interfaces called<br />

Service methods. To create a Service method, an address to the remote is given in the to argument in the form of<br />

a SIP or TEL URI. Examples:<br />

sip:alice@atlanta.com<br />

sip:bob@biloxi.com<br />

tel:+358-555-1234567<br />

tel:863-1234;phone-context=+1-914-555<br />

tel:7197999;phone-context=ims.mnc015.mcc235.3gppnetworks.org<br />

The URI can be a public user identity or a public service identity as explained above, but does not have to. The<br />

argument accepts an optional display name, and in that case the URI is surrounded with angle brackets. For<br />

example:<br />

Bob <br />

Alice Smith <br />

The URI can be a public user identity or a public service identity.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 11 of 199


The From argument accepts an URI with optional display name, that indicates the originator of the request. The<br />

argument is the identity to be presented as when the request reaches the remote. If the argument is null then it is<br />

by default set to the preferred public user identity. If it includes an URI with the domain anonymous.invalid then<br />

the request will be anonymized.<br />

The format of SIP URI is described in [RFC3261], TEL URI in [RFC3966], and display names in general in<br />

[RFC5322].<br />

<strong>IMS</strong> and <strong>JSR</strong> <strong>281</strong><br />

The transition from single-media in voice telephony, to multi-media formats in <strong>IMS</strong>, means that the subscriber<br />

devices need the capability to handle such media. This is made possible since the phone has evolved from being a<br />

single-purpose device into a multi-purpose device. The devices can now also differ in their capabilities.<br />

Single-media handling capability in voice telephony<br />

In a network connecting only single purpose devices like traditional voice, it is assumed that all devices share that<br />

voice capability, regardless of their model and manufacturer. The network operator decides the standard to use<br />

such that all devices handle voice the same. If they don't they will not operate together. All devices are equivalent in<br />

terms of voice interoperability, and they have been developed for that purpose. When Alice calls Bob, she does not<br />

care about Bob's phone model, the brand or other particular characteristics; only that she can talk to him. For Alice<br />

to call Bob, their devices need to be the same in this respect. It creates symmetry of equivalence in capabilities<br />

between the endpoints in the context of the call made. Before <strong>IMS</strong>, the equivalence could be assumed to hold for<br />

voice and was trivial, but with <strong>IMS</strong> it is a problem that needs to be solved.<br />

Multiple-media handling capabilities in <strong>IMS</strong><br />

The devices on the <strong>IMS</strong> vary in the multi-media capabilities and data formats they are capable of handling. For<br />

example, suppose a mobile phone and a PDA can do instant messaging. Then they are equivalent because they<br />

have that particular capability in common. Suppose further that the phone can do high quality voice communication,<br />

or that the PDA can stream live video from its high resolution built-in camera. If these capabilities are not met, there<br />

is no equivalence and it is meaningless to try to set up the calls.<br />

A shared symmetrical view of <strong>IMS</strong> devices cannot be assumed from just their presence on the network. It is crucial<br />

to decide whether they are equivalent when making an <strong>IMS</strong> call so that the multimedia exchange can work between<br />

the endpoints in the way intended. Internet and <strong>IMS</strong> standards use a notation that allows an <strong>IMS</strong> device to be<br />

marked as having certain capabilities. The set of common markers for a pair of devices describes the shared<br />

capabilities. If an <strong>IMS</strong> call requires a certain capability and its marker is in the common set, then there is<br />

equivalence. Advantages with this approach are that it will work regardless of device characteristics, and that new<br />

markers can be added for devices with new capabilities. A marker in a common set shows that capability can be<br />

used regardless of its semantics.<br />

The scheme of computing capabilities works not only for devices with a fixed set of built-in capabilities. It can also<br />

work for devices with a changeable set as well. Hardware related capabilities can change with plug-in accessories.<br />

<strong>Software</strong> related capabilities can change with downloadable applications. This latter approach is made possible<br />

with the <strong>IMS</strong> application model that the <strong>JSR</strong> <strong>281</strong> assumes.<br />

Capabilities of a <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> Application<br />

When writing an <strong>IMS</strong> application in <strong>JSR</strong> <strong>281</strong>, it is fundamental to indicate its complete set of capabilities, the<br />

application capabilities, in the correct way. This is necessary for an <strong>IMS</strong> call to be routed through the <strong>IMS</strong> network<br />

to the right <strong>IMS</strong> application on the right device of the called subscriber.<br />

The application capabilities follow from the application program and are known at development time. When writing<br />

the application, the developer records the capabilities to be installed together with the application onto the end user<br />

device.<br />

The capabilities are of two types, basic and composed, described next.<br />

Basic Capabilities<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 12 of 199


Basic capabilities are known in the <strong>IMS</strong><strong>API</strong>. The <strong>IMS</strong> application gets them as a result of interacting with certain<br />

interfaces to <strong>IMS</strong> functionalities. Basic capabilities are of two subtypes:<br />

• Media capabilities, caused from using media interfaces.<br />

• Event capabilities, caused from using Subscription and Publication interfaces with event packages.<br />

The notation of capabilities, in relation to the Registry description, are described further below.<br />

Composed Capabilities<br />

Composed capabilities are capabilities that originate in the application, and are unknown to the <strong>IMS</strong><strong>API</strong>. They can<br />

be composed of basic capabilities and other functionality.<br />

ICSI and IARI according to 3GPP standards<br />

3GPP has defined a framework to cover capabilities used in standardized network-based services. If a device<br />

implements a client for such a service, the capability is indicated in an <strong>IMS</strong> Communication Service Identifier (ICSI).<br />

The ICSI is defined in the service standard. The following is an example of an ICSI that may be defined by 3GPP<br />

for use in Multimedia Telephony standard:<br />

• urn:urn-xxx:3gpp-service.ims.icsi.mmtel<br />

The network operator manages the services, and an end user is allowed access to the service according to the<br />

subscription. Examples of services that can be coded as ICSIs are instant messaging, conferencing, Push-to-Talk<br />

Over Cellular (PoC).<br />

One of the strengths of <strong>IMS</strong>, and a prime purpose of the <strong>JSR</strong> <strong>281</strong>, is to allow developers to write new <strong>IMS</strong> based<br />

applications, and have end users download and install them into their devices. These <strong>IMS</strong> applications have not<br />

undergone a standardization process, and have new capabilities not seen on the network before. This can for<br />

example be peer-to-peer games, or a new application of an existing network service, or some combination. To<br />

indicate such altogether new application capabilities, the <strong>IMS</strong> Application Reference Identifier (IARI) is used. The<br />

chess game could have an IARI that looks something like:<br />

• urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.chess<br />

Usage of ICSI and IARI<br />

An <strong>IMS</strong> application can support several ICSIs and IARIs at any given time. This section discusses the effect of<br />

using various combinations.<br />

Having multiple ICSIs has a straightforward use case where the <strong>IMS</strong> application is a client towards several<br />

standardized network communication services.<br />

An application that realizes several IARIs, might seem less logical considering the explanation above, but is useful<br />

in the following scenario. Suppose two <strong>IMS</strong> applications are developed, and are given IARI1 and IARI2,<br />

respectively. The applications become successful and well known. Then a third application is developed that adds<br />

a new functionality, while still supports both old applications. The third application gets, in addition to its IARI3,<br />

IARI1 and IARI2 as well. This enables backward compatibility.<br />

An <strong>IMS</strong> application can have any combination of ICSI and IARI. If it has no ICSI and no IARI, it means that no<br />

particular network services are used and the application adds no extra capability in itself. Such an application builds<br />

only on standardized media capabilities, or on standardized capabilities for a service not part of the ICSI/IARI<br />

framework. Examples are a streaming media player, a peer-to-peer chat application, or an application building on a<br />

standard outside the 3GPP application reference. If it has ICSI and no IARI, the application realizes a client for the<br />

service according to the standard, a default application. If it has no ICSI but an IARI, the application realizes its new<br />

logic without using any particular network service. Many peer-to-peer applications, like games, would be in this<br />

category. If it has both ICSI and IARI, the application makes use of standardized network service to create a new<br />

capability.<br />

Note on the format of ICSI and IARI<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 13 of 199


ICSI and IARI are represented as Universal Resources Names (URN). URNs consists of a name space, and a<br />

name space specific string. The owner of the name space has control over allowed URNs. For ICSI, the<br />

standardisation organization is the name space owner and it has defined the ICSI URN. For IARI, the URNs are<br />

issued from any valid name space owner. The process of how to allocate an IARI is outside the scope of this<br />

specification.<br />

ICSI and IARI Recommendations in <strong>JSR</strong> <strong>281</strong><br />

When developing <strong>IMS</strong> applications in the <strong>IMS</strong><strong>API</strong>, it is normal practice to assign them IARIs for the necessary<br />

network and device routing. The <strong>IMS</strong><strong>API</strong> implementation makes sure the application has an appropriate network<br />

behavior. The developer has the responsibility to create the appropriate IARI according to the procedure of the<br />

name space owner, and tag it to the application for distribution.<br />

If an <strong>IMS</strong> application includes a communication service, the recommended procedure is to use an enabler <strong>API</strong> for<br />

that service if available, and the ICSI is handled according to the definition of that enabler <strong>API</strong>. No such enablers<br />

are part of <strong>JSR</strong> <strong>281</strong>, but may be in other complementary <strong>JSR</strong>s. Nonetheless, <strong>JSR</strong> <strong>281</strong> offers the possibility for an<br />

application to implement a client for a communication service on top of the <strong>IMS</strong><strong>API</strong> where the developer explicitly<br />

tags the <strong>IMS</strong> application with an ICSI, and possibly also with the "explicit" and "require" parameters (see<br />

[RFC3841]). This is an advanced functionality, and should be used with caution because <strong>JSR</strong> <strong>281</strong> cannot enforce<br />

that the application is according to the standard specification.<br />

Feature Tags<br />

There are <strong>IMS</strong> related standards that can be implemented as an <strong>IMS</strong> application, that have their own set of feature<br />

tags, including the "explicit" and "require" parameters (see [RFC3841]), that are not part of the 3GPP ICSI and IARI<br />

framework. These feature tags should be considered as alternatives to ICSI and are indicated with the application.<br />

The same recommendations apply as for the ICSI case. There can be several feature tags, and can be combined<br />

with ICSI and IARI.<br />

Application Control of Capability Usage<br />

When the <strong>IMS</strong> application makes an <strong>IMS</strong> call, a set of capabilities is included such that the <strong>IMS</strong> network and the<br />

remote device can route the call correctly.<br />

For many <strong>IMS</strong> applications, that set contains all application capabilities. Hence, all <strong>IMS</strong> calls are handled the same<br />

way. Other applications are required to handle certain calls differently based on the semantics of the capabilities.<br />

The <strong>JSR</strong> <strong>281</strong> supports creating named subsets of the composed capability set, and then making <strong>IMS</strong> calls based<br />

on those sets. This way, an improved granularity and diversification of <strong>IMS</strong> calls is achieved.<br />

<strong>IMS</strong> Applications<br />

The general <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> application model defines an <strong>IMS</strong> application as:<br />

• A realization of one or more <strong>IMS</strong> capabilities for some well defined end user purpose.<br />

The definition is useful because any arbitrary set of capabilities, or markers, does not make sense unless they are<br />

part of a function. It enables a simpler view of interoperability. If a pair of devices has an equivalent <strong>IMS</strong> application,<br />

they can communicate. Note that the concept of an <strong>IMS</strong> application is independent of programming language, <strong>API</strong>s,<br />

and devices. Even though the model is employed in <strong>JSR</strong> <strong>281</strong>, it is independent of its particular interfaces and Java.<br />

It is important to keep <strong>IMS</strong> application and Java application as distinct concepts, even though they are related in<br />

the <strong>IMS</strong><strong>API</strong>.<br />

An <strong>IMS</strong> application can be implemented on some device, perhaps using special hardware and software interfaces.<br />

All possible implementations can be seen as portings, some can be based on the <strong>JSR</strong> <strong>281</strong>. On a particular device,<br />

there can be several coexisting implementations of the same <strong>IMS</strong> application, differing in any non-interoperability<br />

related aspect, for example, look and feel.<br />

On the <strong>IMS</strong> network, any device with a particular <strong>IMS</strong> application implementation is a potential target for a<br />

successful <strong>IMS</strong> call.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 14 of 199


An <strong>IMS</strong> application, like many other applications, has a life cycle. It can be installed to, executed on, and<br />

uninstalled from, a device. How this works for <strong>JSR</strong> <strong>281</strong> is explained further below.<br />

The relation an <strong>IMS</strong> application has towards the <strong>IMS</strong> device is similar in many respects (but not all) to the relation<br />

an <strong>IMS</strong> device has to its network. The network is responsible for routing an <strong>IMS</strong> call to the appropriate device; the<br />

device routes an incoming call to the right <strong>IMS</strong> application. An <strong>IMS</strong> device can be on or off the network; an <strong>IMS</strong><br />

application can be installed or uninstalled. The <strong>IMS</strong> device exposes its capabilities on the network; an <strong>IMS</strong><br />

application exposes its capabilities to the device.<br />

myChess: An example <strong>IMS</strong>-based game<br />

An example <strong>IMS</strong> application that may be suitable to implement using the <strong>IMS</strong><strong>API</strong>, is a networked chess application<br />

called myChess. The application allows the user (Alice) to initiate an <strong>IMS</strong> call to a peer (Bob) with an invitation to<br />

play chess. If Bob accepts, the call is established and a new game begins, or a saved one resumes. When one of<br />

the players makes a move, it is sent over a media stream to the other endpoint which updates its game state. To<br />

further increase the gaming experience, the <strong>IMS</strong> application polls the presence of potential players and displays it<br />

to the user on demand. The game allows the players to chat.<br />

In addition, myChess can manage several chess game sessions at the same time.<br />

The chess application will be used in this specification to illustrate various aspects of the <strong>IMS</strong><strong>API</strong>.<br />

Summary<br />

This completes the description of the <strong>IMS</strong><strong>API</strong> model of <strong>IMS</strong> applications. A Java application realizes a number of<br />

<strong>IMS</strong> applications in its program code. An <strong>IMS</strong> application is defined as purposefully realizing a number of <strong>IMS</strong><br />

capabilities, Basic and Composed. Basic capabilities are from the <strong>IMS</strong><strong>API</strong>, composed capabilities are application<br />

intrinsic. The application is identified using an internal handle, the application identifier (the AppId). All <strong>IMS</strong><br />

applications have static properties, some of which are capability related. To account for the diversity of capabilities<br />

with different semantics, the <strong>IMS</strong><strong>API</strong> introduces the Core service objects to group capabilities that can be handled<br />

the same. Core services are the platform which the application then uses to make and receive <strong>IMS</strong> calls end-to-end,<br />

that is, sessions with different types of media for different capabilities.<br />

Further reading of <strong>IMS</strong><br />

The <strong>IMS</strong><strong>API</strong> is primarily based on 3GPP <strong>IMS</strong> Release 6. The Stage 1 Service Requirements Specification [22.228]<br />

provides an introduction to <strong>IMS</strong> that is also useful for those who are not experts. The Stage 2 Group <strong>Services</strong> and<br />

System Aspects [23.228] and the Stage 3 describe the architecture, technical realization and protocol details of the<br />

<strong>IMS</strong> [24.229]. These documents are for the most technically interested reader.<br />

The concept of <strong>IMS</strong> applications of the <strong>IMS</strong><strong>API</strong> is rooted in the 3GPP explanation of the term in [22.228]<br />

reproduced here:<br />

"IP multimedia application: an application that handles one or more media simultaneously such as speech, audio,<br />

video and data (e.g. chat text, shared whiteboard) in a synchronized way from the user’s point of view. A<br />

multimedia application may involve multiple parties, multiple connections, and the addition or deletion of resources<br />

within a single IP multimedia session. A user may invoke concurrent IP multimedia applications in an IP multimedia<br />

session." - [22.228, section 3.1].<br />

The last sentence seems to contradict the definition of <strong>IMS</strong> applications and <strong>IMS</strong> session used in the <strong>IMS</strong><strong>API</strong>. This<br />

is however not the case. The 3GPP definition relates to multiple usage of media streams within a session. In the<br />

<strong>IMS</strong><strong>API</strong>, any such functionality can be aggregated within a single <strong>IMS</strong> application using multiple Core Service<br />

objects.<br />

The <strong>IMS</strong> capabilities play a very central role in the <strong>IMS</strong><strong>API</strong>. In the 3GPP specifications, capabilities are less<br />

emphasized in the texts. This is because <strong>JSR</strong> <strong>281</strong> describes a framework of <strong>IMS</strong> applications, which 3GPP leaves<br />

open in its specifications. For the framework to function correctly for multiple <strong>IMS</strong> applications, and possible to<br />

scale, capabilities are absolutely necessary. The support for ICSI and IARI as capabilities is part of 3GPP Release<br />

7.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 15 of 199


The capabilities framework of the <strong>IMS</strong><strong>API</strong> is based on IETF RFCs [RFC3840, RFC3841] for the caller preferences<br />

framework.<br />

The <strong>IMS</strong> uses SIP and SDP as its main signaling protocols. This is described in [RFC3261] and [RFC4566].<br />

User and Service Addressing<br />

In the <strong>IMS</strong><strong>API</strong>, the user can influence registration by indicating the public user identity the user would like to be<br />

reachable under on the terminal via the call to Connector.open.<br />

To establish communications to remote endpoints on the <strong>IMS</strong> network, the <strong>JSR</strong> provides a set of interfaces called<br />

Service methods. To create a Service method, an address to the remote is given in the to argument in the form of<br />

a SIP or TEL URI. Examples:<br />

sip:alice@atlanta.com<br />

sip:bob@biloxi.com<br />

tel:+358-555-1234567<br />

tel:863-1234;phone-context=+1-914-555<br />

tel:7197999;phone-context=ims.mnc015.mcc235.3gppnetworks.org<br />

The URI can be a public user identity or a public service identity as explained above, but does not have to. The<br />

argument accepts an optional display name, and in that case the URI is surrounded with angle brackets. For<br />

example:<br />

Bob <br />

Alice Smith <br />

The URI can be a public user identity or a public service identity.<br />

The From argument accepts an URI with optional display name, that indicates the originator of the request. The<br />

argument is the identity to be presented as when the request reaches the remote. If the argument is null then it is<br />

by default set to the preferred public user identity. If it includes an URI with the domain anonymous.invalid then<br />

the request will be anonymized.<br />

The format of SIP URI is described in [RFC3261], TEL URI in [RFC3966], and display names in general in<br />

[RFC5322].<br />

Overview <strong>IMS</strong> Applications in <strong>IMS</strong><strong>API</strong><br />

The <strong>IMS</strong><strong>API</strong> is an <strong>API</strong> for programming <strong>IMS</strong> applications in Java. The underlying execution environment for the <strong>IMS</strong><br />

applications is called the <strong>IMS</strong> Engine. The <strong>API</strong> provides interfaces to allow the <strong>IMS</strong> applications access to <strong>IMS</strong><br />

functionality.<br />

An <strong>IMS</strong> application consists of three parts in the <strong>API</strong>:<br />

• <strong>IMS</strong> application identifier (AppId): A string uniquely identifying the <strong>IMS</strong> application in the suite.<br />

• Java program: This is the Java application that realizes the <strong>IMS</strong> application logic, called the owning Java<br />

application.<br />

• The Registry: A set of static properties including the <strong>IMS</strong> application capabilities. The <strong>IMS</strong> engine keeps the<br />

Registry in a data base.<br />

The <strong>IMS</strong> engine associates the three parts, such that it is known which Java application that realizes a particular<br />

<strong>IMS</strong> application. A Java application can realize one or more <strong>IMS</strong> applications. Even though the underlying Java VM<br />

may only be capable of running a single Java application at the moment, multiple <strong>IMS</strong> applications can be running.<br />

Java and <strong>IMS</strong> application suites are related in the sense that the Java suite owns the <strong>IMS</strong> suite. When the Java<br />

suite is installed/uninstalled, the <strong>IMS</strong> suite is installed/uninstalled as well.<br />

The <strong>IMS</strong> application developer writes the <strong>JSR</strong> <strong>281</strong> MIDlets and defines the Registry contents before packaging the<br />

suite. The jad file or jar manifest file contains properties that defines the AppId, Registry and the owning Java<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 16 of 199


MIDlet (in case the profile is MIDP). The jar/jad files are downloaded to the device and installed using the<br />

mechanisms that applies for the profile. For example, the chess application could include a line in the MIDP jad file:<br />

MicroEdition-<strong>IMS</strong>-1-Identity: myChess, com.company.MyChess<br />

where myChess is the AppId, and com.company.MyChess is the MIDlet class name. The MIDlet will as the first step<br />

connect the <strong>IMS</strong> application to the <strong>IMS</strong> network. <strong>JSR</strong> <strong>281</strong> makes use of the Generic Connection Framework (GCF)<br />

of CLDC, and the code looks like:<br />

cs = (CoreService)Connector.open("imscore://myChess");<br />

The call has the following effects:<br />

• The MIDlet has a handle to the <strong>IMS</strong> engine to further work with that <strong>IMS</strong> application.<br />

• The <strong>IMS</strong> engine creates a connection to the <strong>IMS</strong> network where this <strong>IMS</strong> application becomes visible,<br />

meaning that it is possible to initiate and receive <strong>IMS</strong> calls with it according to the capabilities in the users<br />

<strong>IMS</strong> subscription with the operator.<br />

Later in its code, the MIDlet can create <strong>IMS</strong> calls using the <strong>JSR</strong> <strong>281</strong> core interfaces:<br />

session = cs.createSession("Alice ", "Bob ");<br />

For further information on the jad file properties, Registry and installation aspects, see the package description of<br />

javax.microedition.ims. For further information on how to use the core apis and create <strong>IMS</strong> calls, refer to<br />

javax.microedition.ims.core package.<br />

The integration to GCF enables two opportunities for the developer. Firstly, a connection in the particular access<br />

network could be created using some other <strong>API</strong> (e.g. the <strong>JSR</strong> 307 [<strong>JSR</strong>307]) and some desired characteristics, like<br />

bandwidth and delay constraints. Then that connection can be reused for the imscore: connection. Secondly, the<br />

owning Java application can be push registered in MIDP2 using the imscore: connector string, for example,<br />

started based on an incoming <strong>IMS</strong> call. Basically, a connector string is placed in the MIDlet-push attributes, or used<br />

in a call to PushRegistry.registerConnection(). The connector string is the same as used in connector.open.<br />

Push registration of <strong>JSR</strong> <strong>281</strong> MIDlets are described in Appendix B.<br />

In the <strong>IMS</strong> application model, push registration means that the <strong>IMS</strong> application is started when the Java<br />

environment is started, while the owning Java application start is delayed until there is an incoming request that<br />

needs to be handled.<br />

Security<br />

<strong>IMS</strong> Security<br />

The <strong>JSR</strong> <strong>281</strong> is transparent and shall be kept independent to the security mechanisms used for <strong>IMS</strong> of the device.<br />

This concerns both security for media streams, signalling, and authentication of the user.<br />

Java Security<br />

The <strong>IMS</strong><strong>API</strong> is an <strong>API</strong> that can cause considerable network activity on the device. All implementations of <strong>IMS</strong><strong>API</strong><br />

MUST ensure that only applications that have appropriate permissions can perform protected <strong>IMS</strong><strong>API</strong> calls. The<br />

mechanisms for granting permissions are implementation dependent. However, if the <strong>IMS</strong><strong>API</strong> is implemented on a<br />

platform that supports MIDP, then the security framework of MIDP MUST be used as defined below. If no MIDP<br />

profile is used then defined permissions MUST be implemented using the mechanisms of the platform. The<br />

definitions of MIDP security policy terms may be found in the appropriate MIDP Specification.<br />

To access a protected function, the MIDlet MUST have the appropriate permission, or a SecurityException is<br />

thrown. Below, follows a list of permission names, the included protected method calls, and the mapping to a<br />

function group.<br />

Permission Name (MIDP 2) Permitted Java <strong>API</strong> Call Function Group<br />

javax.microedition.io.Connector.imscore Connector.open("imscore://..") Net Access<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 17 of 199


javax.microedition.ims.Media.read FramedMedia.sendFile Read User Data Access<br />

javax.microedition.ims.Media.write FramedMedia.receiveFile Write User Data Access<br />

Permission classes for MIDP 3 mappings<br />

The table below shows how the permission names from MIDP 2 corresponds with MIDP 3 permission classes.<br />

Permission Name (MIDP 2) Permission Class (MIDP 3)<br />

javax.microedition.io.Connector.imscore javax.microedition.ims.core.ImscoreProtoco<br />

lPermission("imscore://*")<br />

javax.microedition.ims.Media.read<br />

javax.microedition.ims.Media.write<br />

Identification of the <strong>IMS</strong><strong>API</strong><br />

javax.microedition.ims.Media.MediaPermissi<br />

on("", "read")<br />

javax.microedition.ims.Media.MediaPermissi<br />

on("", "write")<br />

To identify the <strong>IMS</strong><strong>API</strong>, implementations of this specification MUST include a system property according to the<br />

table below:<br />

System Property Key value<br />

javax.microedition.ims.version 1.1<br />

If the device implementation supports the requested package, the value that represents the <strong>IMS</strong><strong>API</strong> version MUST<br />

be returned.<br />

If the implementation does not support the requested package then the key is not defined and null MUST be<br />

returned.<br />

Media profiles in <strong>JSR</strong> <strong>281</strong><br />

A Media profile in <strong>JSR</strong> <strong>281</strong> specifies a set of codecs and associated signalling for use in an <strong>IMS</strong> application. A<br />

profile builds on a standard, and generally if the device has native support for the standard then that suffices to<br />

make the media profile available to the <strong>IMS</strong><strong>API</strong>. Some functionality of the standard that is not required in the<br />

<strong>IMS</strong><strong>API</strong> may be excluded from a profile, even though the device natively supports that.<br />

A <strong>JSR</strong> <strong>281</strong> implementation can support several profiles, depending on the media capabilities of the device. Within<br />

the realm of some composed capability (ICSI, IARI or Feature Tags), the <strong>IMS</strong> application can require support for a<br />

certain media profile.<br />

This specification defines two media profiles, the basic profile and the MMTel profile. Media profiles are identified in<br />

the <strong>IMS</strong><strong>API</strong> using string identifiers, called short name.<br />

Basic Profile<br />

The basic media profile MUST be supported in all <strong>JSR</strong> <strong>281</strong> implementations that supports streaming media, for<br />

audio and video, respectively. It provides the smallest set of media codecs shared between <strong>JSR</strong> <strong>281</strong><br />

implementations.<br />

3GPP Default codecs for <strong>IMS</strong> [26.235] MUST be supported in the device. Below follows a summary of contents of<br />

the profile based on this specification:<br />

Audio<br />

For streaming audio, the following MUST be included in the profile:<br />

• The narrow-band AMR codec for speech.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 18 of 199


• The AMR wideband codec, if the device supports wideband speech at 16 kHz sampling frequency.<br />

All other audio codecs and their modes of operation that the device natively supports for <strong>IMS</strong> SHOULD be<br />

supported in the Basic profile. This means that the <strong>IMS</strong> Engine can use them in media negotiation.<br />

Video<br />

A device that has a camera and supports streaming video, the following MUST be included in the profile:<br />

• H.263 profile 0 level 45<br />

The following SHOULD be supported:<br />

• H.263 profile 3 level 45<br />

• MPEG-4 Visual Simple Profile Level 0b.<br />

• H.264 (AVC) Baseline Profile Level 1b.<br />

For further details of codec properties and operation, see [26.235].<br />

All other video codecs and their modes of operation that the device natively supports for <strong>IMS</strong> SHOULD be<br />

supported in the Basic profile.<br />

Short name<br />

The short name for the Basic profile is "basic".<br />

MMTel profile<br />

A device that complies to [26.114] suffice to enable the MMTel profile. Hence, such a device MUST support this<br />

profile, else it MUST NOT be supported.<br />

The purpose of the MMTel profile is to support devices that are capable of supporting conversational-grade speech<br />

and video comparable to that of traditional circuit-switched services. The profile includes advanced optimization<br />

and adaptive mechanisms to handle varying network conditions to maintain quality of service.<br />

For streaming audio, the following MUST be included in the profile, according to [26.114]:<br />

Audio<br />

• The narrow-band AMR codec for speech with all modes of operation [26.114].<br />

• The AMR wideband codec with all modes of operation [26.114], if the device supports wideband speech at<br />

16 kHz sampling frequency.<br />

Encoding of DTMF MUST NOT be supported within the profile.<br />

All other requirements from [26.114] placed on audio apply.<br />

Video<br />

The following video codecs MUST be supported:<br />

• H.263 profile 0 level 45<br />

The following SHOULD be supported:<br />

• MPEG-4 Visual Simple Profile Level 3<br />

• H.264 (AVC) Baseline Profile Level 1b.<br />

All other requirements from [26.114] placed on video apply.<br />

Real-time Text<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 19 of 199


If the terminal supports Real-time text, then that MUST NOT be available in the profile.<br />

Other considerations<br />

The <strong>IMS</strong><strong>API</strong> includes no requirements for interworking with the circuit-switched domain. It is only applicable within<br />

the packet switched domain.<br />

Short name<br />

The short name for the MMTel profile is "mmtel".<br />

File formats<br />

The device MUST support the 3GP file format for supported audio and video, as of the 3GP specification [26.244].<br />

NAT and Firewall considerations<br />

A device may be faced with a NAT or firewall placed in the access network towards <strong>IMS</strong>. While the <strong>IMS</strong> engine will<br />

manage the situation for signalling and the media stream in general, there are spome remaining cases for some<br />

media types where the application MUST be programmed in a certain way for it to work properly. This is<br />

documented for the media type in the interface documentation.<br />

If the <strong>JSR</strong> <strong>281</strong> enabled device has support to work towards a NAT or firewall, then the NAT guidelines found in<br />

Appendix A MUST be followed.<br />

Support for alternative connection models for MSRP<br />

The implementation MUST support the alternative connection model for MSRP as described in<br />

[draft-ietf-simple-msrp-acm-00]. The implementation MAY support the standard connection model as described in<br />

[RFC4975].<br />

Quality-of-Service management in <strong>IMS</strong><strong>API</strong><br />

Quality of Service (QoS) is an important requirement in <strong>IMS</strong>. In the 3GPP service specification [22.228], QoS is<br />

addressed in four of the eleven requirements. QoS is a broad concept with many interpretations depending on the<br />

approach. In <strong>JSR</strong> <strong>281</strong>, QoS is rooted in the end user experience. If the user is satisfied about the performance of<br />

an <strong>IMS</strong> application, then the QoS is sufficient. If not, the system delivers insufficient QoS. This assumes that the<br />

end user has an expectation of an appropriate level of quality. It depends on the application, even for the same<br />

types of media. For example, an <strong>IMS</strong> telephony application has a different notion of quality than a streaming media<br />

player application even though they are both based on audio media.<br />

If there is a QoS problem with an application, then this is because the system is unaware of the expected or<br />

accepted usage. If it had known, the problem could have been addressed from the start and actions could have<br />

been taken. In the best case, the user will be happy. In the worst case, the application may not run at all if the<br />

quality is below any acceptable level.<br />

QoS is about how the complete system (all parts of the <strong>IMS</strong>, end to end) meets the expectation of the end user. By<br />

providing sufficiently detailed information about what an application should be used for to the system, the system<br />

will return resources in the <strong>IMS</strong> system as necessary to keep the user happy.<br />

To address QoS, two parts must be considered:<br />

1. Problem domain: A description of the need for the quality wanted for the particular service or <strong>IMS</strong><br />

application.<br />

2. Solutions domain: Means to reserve resources in the complete chain of network links, nodes between and<br />

including the end user terminals and the particular <strong>IMS</strong> applications.<br />

The problem domain is approached in the <strong>API</strong> in the division of Media into subtypes. Each has its own intended<br />

usage.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 20 of 199


StreamMedia<br />

StreamMedia is used to stream audio and video in real-time between end-points. It is handled in the <strong>JSR</strong><br />

implementation by codecs supplied from the device for the data formats. That media is streamed in real-time will<br />

give indications of delay requirements. The media source also gives clues. If an audio-media is sourced from a<br />

mobile phone microphone, the codec should be selected accordingly. Some devices are equipped with built-in<br />

cameras (for video telephony and video camcorder), and the same applies here. If the media is sourced from a file,<br />

then the file format decides the codec.<br />

The codecs give the main information on the needed QoS. The application can give a preference for a certain level<br />

of quality via the setQuality method (Low, Medium and High) and this will affect which codecs the device chooses<br />

of those supported, for the format.<br />

BasicMedia<br />

For basic media, the quality needed depends completely on how the application processes the BasicMedia streams,<br />

and the quality need must be provided in full to the system. The media flow is characteristized in the Registry at<br />

installation time.<br />

BasicMedia flows<br />

The Java application implements the codecs for the data formats that will cause network activity. The codecs are<br />

unknown to the system, as they are application specific. Using them creates network activity, and the application<br />

has the option to specify the quality need explicitly, or use a default best effort approach. If there is a quality need,<br />

then flow specifications (flowspecs) [RFC2215] are used as input for the system to reserve system resources. The<br />

Registry lists them by serviceId, MIME content type, and associated flow specs in the send and receive directions.<br />

Flow specification<br />

A flow spec includes the following quantities:<br />

• Average rate - Specifies the permitted rate in bytes per second at which data can be transmitted over the<br />

life of the media. NOTE: This includes only the data that the application owns, not the overhead created by<br />

the system.<br />

• Buffer size - Expected buffer size needed in bytes to accommodate for momentary deviations from the<br />

average rate.<br />

• Peak rate - The maximum data rate in bytes per second at any given time.<br />

• Delay - Maximum acceptable transmission delay of data in milliseconds.<br />

• DelayVariance - Difference between the maximum and minimum possible transmission delay in<br />

milliseconds.<br />

• Maximum chunk size - The maximum size in bytes of transmitted application data chunks.<br />

• Minimal policed unit - This is the minimum size in bytes of transmitted application data chunks.<br />

A flowspec represents a contract between the application and the system. If the application processes data<br />

according to specification, then the system grants transmission within the delay limits. If the application fails, then<br />

there is no guarantee.<br />

Flowspecs are set at development time in the Registry Qos property.<br />

If there is no flow specification, best effort is used. This may be sufficient for applications with modest non-critical<br />

network demands.<br />

FramedMedia<br />

FramedMedia is used for session-based instant messaging, and file transfer. Short textual messages are expected<br />

to be delivered rather fast, while transfer of large files can take time and has lower precedence to other types of<br />

streams. This is in itself sufficient information for the system to set QoS.<br />

Mandatory and optional Parts of the <strong>IMS</strong><strong>API</strong><br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 21 of 199


Generally, the policy is that all <strong>JSR</strong> <strong>281</strong> Core <strong>API</strong> interfaces MUST be implemented according to the specification.<br />

Details and allowed deviations are described below.<br />

Core service support<br />

The device MUST be able to maintain one core service object.<br />

Service method support<br />

A <strong>JSR</strong> <strong>281</strong> enabled device MUST implement all service methods and MUST be able to:<br />

• Handle at least one Session object through its lifecycle, either sent to a remote or received from it.<br />

• Handle at least one Capabilities object. The device MUST be able to respond to an incoming OPTIONS.<br />

• Handle at least one Reference object, sent or received.<br />

• Handle at least one PageMessage object to send, and handle at least one PageMessage object received.<br />

• Maintain at least one Subscription object, and be able to receive notifications.<br />

• Maintain at least one Publication object.<br />

Session support<br />

A session MUST be able to:<br />

• Include least two media objects with flows in an established session<br />

• Include least one instance of a supported media type in an established session.<br />

• Handle one Reference inside a session.<br />

• Handle one Capabilities in a session.<br />

Streaming Media support<br />

The StreamMedia interface is conditionally mandatory, meaning that if the device supports streaming then<br />

StreamMedia MUST be implemented.<br />

If the device supports streaming audio<br />

• The streaming audio part of the StreamMedia interface MUST be implemented.<br />

• Sourcing audio from "capture://audio" MUST be implemented.<br />

If the device supports streaming video<br />

• The streaming audio and video parts of the StreamMedia interface MUST be implemented.<br />

• Sourcing audio from "capture://audio" MUST be implemented.<br />

• Sourcing video from "capture://video" MUST be implemented.<br />

The Basic media profile MUST be supported. See further details in the Media profiles section.<br />

Player Controls<br />

The following table outlines the <strong>JSR</strong> 135 Mobile Media <strong>API</strong> controls that MUST be implemented for the streaming<br />

media players.<br />

Controls Implementation Requirements<br />

VolumeControl Mandatory if streaming audio or video is supported<br />

VideoControl Mandatory if streaming video is supported<br />

Requirements on the StreamMedia Player<br />

Player creation<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 22 of 199


The <strong>IMS</strong><strong>API</strong> uses the concept of Players, defined in [<strong>JSR</strong>118] and [<strong>JSR</strong>135], to capture and render streaming<br />

media. The Player is created by the <strong>IMS</strong><strong>API</strong> implementation and is retrieved by the application by invoking a<br />

method in the <strong>IMS</strong><strong>API</strong>. When the Player is retrieved it is in the Realized state and controls can immediately be<br />

obtained.<br />

Player limitations<br />

The following table outlines the limitations for the Player interface.<br />

Method<br />

Implementation Requirements<br />

Player.setLoopCount Setting the loop count will succeed, but it will have no meaning for the implementation<br />

Player.setMediaTime Setting media time is not supported<br />

The following control interfaces are limited:<br />

Interface Implementation Requirements<br />

Controlling the playback rate is not supported.<br />

RateControl<br />

The control can be added but has no impact<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 23 of 199


Package javax.microedition.ims<br />

Package javax.microedition.ims<br />

This package collects classes and interfaces to install and configure <strong>IMS</strong> applications.<br />

See:<br />

Description<br />

Interface Summary<br />

ConnectionStateListener A listener type for receiving notifications about changes to the <strong>IMS</strong> connection. 38<br />

ReasonInfo<br />

Service<br />

The ReasonInfo interface enables an application to get details on why a<br />

method call failed.<br />

Service is the base interface for <strong>IMS</strong> <strong>Services</strong>, and follows the Generic<br />

Connection Framework (GCF).<br />

Page<br />

41<br />

43<br />

Class Summary<br />

Configuration<br />

ConnectionState<br />

The Configuration class realizes dynamic installation of <strong>IMS</strong> applications with the pair<br />

of methods setRegistry and removeRegistry.<br />

The ConnectionState class is used to monitoring the <strong>IMS</strong> connection and accessing<br />

user identities.<br />

Page<br />

32<br />

36<br />

Exception Summary<br />

ImsException An ImsException indicates an unexpected error condition in a method. 40<br />

ServiceClosedException<br />

A ServiceClosedException indicates that a method is invoked on a Service<br />

that is closed.<br />

Package javax.microedition.ims Description<br />

This package collects classes and interfaces to install and configure <strong>IMS</strong> applications. There is also functionality to<br />

monitor the <strong>IMS</strong> registration status. Below follows information about how to use the <strong>IMS</strong><strong>API</strong> and a description of the<br />

application model.<br />

Using the <strong>IMS</strong><strong>API</strong><br />

A <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> application goes through three generic steps:<br />

1. Access the <strong>IMS</strong> functionality of the device.<br />

2. Go online to the <strong>IMS</strong> network using a selected identity.<br />

3. Connect a call including media flows with a remote <strong>IMS</strong> device.<br />

Access the <strong>IMS</strong> functionality<br />

To access the <strong>IMS</strong> functionality of the device, the <strong>IMS</strong> application needs to be installed. This can be done in two<br />

different ways, static and dynamic installation. Static installation is done by adding properties in the jad file.<br />

Dynamic installation is performed in runtime by invoking Configuration.setRegistry. Both installation methods<br />

are mentioned below.<br />

Go online<br />

The application creates a Service when it is prepared to handle calls. A Service is created by calling<br />

Connector.open. In order to receive incoming calls, it is recommended that the CoreServiceListener is set as<br />

soon as the Service is opened.<br />

Page<br />

45<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 24 of 199


Package javax.microedition.ims<br />

Connect a call<br />

The final step that needs to be done is to create a Session that will manage the call. The call can be configured by<br />

adding various media and is then initiated by calling Session.start.<br />

Example code<br />

This example code only show the <strong>IMS</strong> specific java code that needs to be done in order to initiate a call including a<br />

streaming media.<br />

myCoreService = (CoreService) Connector.open(“imscore://com.myCompany.CallApp”);<br />

myCoreService.setListener(this);<br />

mySession = myCoreService.createSession(null, sip:bob@home.net);<br />

mySession.setListener(this);<br />

myMedia = (StreamMedia) mySession.createMedia(“StreamMedia”, Media.DIRECTION_SEND_RECEIVE);<br />

myMedia.setSource(“capture://audio”);<br />

mySession.start();<br />

The <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> Application Registry<br />

In this section, the logic and structure of the Registry is described in detail. In the following two sections, the<br />

notation used at static and dynamic install is specified.<br />

A Registry consists of the owning Java application class name, the <strong>IMS</strong> application identifier, and an unordered set<br />

of properties, which represent aspects of the <strong>IMS</strong> application. The properties include all capabilities, but there are<br />

also other types of information as well. This is also described below.<br />

Owning Java application class name<br />

The Java application that owns the <strong>IMS</strong> application, is indicated using fully package qualified string.<br />

<strong>IMS</strong> Application Identifier<br />

The <strong>IMS</strong> Application Identifier (AppId) is a non-empty string case-insensitive unique within the <strong>IMS</strong> application suite.<br />

It is recommended that the AppId is chosen such that the vendor and name of the <strong>IMS</strong> application is clearly<br />

specified, for example like a package-qualified Java class. The AppId has relevance in the context of the <strong>IMS</strong><strong>API</strong> to<br />

identify the Registry for an <strong>IMS</strong> application within the <strong>IMS</strong> application suite. It is not used in the <strong>IMS</strong> signalling, and<br />

has no relevance for interoperability.<br />

Registry properties<br />

A property has a type name and zero, one, or more values. The number of values and their format depends<br />

completely on the type. A Registry contains unique properties, where the uniqueness depends on the property type.<br />

This specification defines a number of properties that have meaning to the <strong>JSR</strong> implementation.<br />

Since an <strong>IMS</strong> application must realize at least one <strong>IMS</strong> capability, it follows that a Registry must contain at least<br />

one of the <strong>IMS</strong> properties StreamMedia, FramedMedia, BasicMedia, Event, or CoreService.<br />

StreamMedia property<br />

Type name: Stream<br />

Motivation: Declares that the application has the basic capability to stream audio and/or video media types.<br />

Description: A Registry contains this property if the <strong>IMS</strong> application uses StreamMedia somewhere in its code. If it<br />

does not, then the Registry does not include the property.<br />

Value: A set that contains the types of StreamMedia used. One or both of Audio and Video.<br />

Uniqueness: There is at most one StreamMedia property in a Registry.<br />

FramedMedia property<br />

Type name: Framed<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 25 of 199


Package javax.microedition.ims<br />

Motivation: Declares a basic capability of messaging.<br />

Description: A Registry contains this property if the <strong>IMS</strong> application uses FramedMedia somewhere in its code. If it<br />

does not, then the Registry does not include the property.<br />

Value: The value has two parts. The first part consists of the set of all content types. The second part is optional<br />

and is the maximum size of any transfer. It is used on the terminating endpoint to generate an answer to the<br />

originating endpoint sent before session accept.<br />

Uniqueness: There is at most one FramedMedia property in a Registry.<br />

BasicMedia property<br />

Type name: Basic<br />

Motivation: Declares a basic capability to transfer media content of some MIME content type.<br />

Description: A Registry contains this property if the <strong>IMS</strong> application uses BasicUnreliableMedia and/or<br />

BasicReliableMedia somewhere in its code. If not, then the Registry does not include the property.<br />

Value: The value is a set of all MIME content types used in the media. This is used on the MT side<br />

Uniqueness: There can be maximum one BasicMedia property in a Registry.<br />

Event property<br />

Type name: Event<br />

Motivation: Declares a basic capability of handling event packages.<br />

Description: A Registry contains this property if the <strong>IMS</strong> application uses event packages somewhere in its code<br />

(part of Subscription and Publication interfaces). If not, then the Registry does not include the property.<br />

Value: The value is a set of all event package names.<br />

Uniqueness: There can be maximum one event property in a Registry.<br />

CoreService property<br />

Type name: CoreService<br />

Motivation: Declare composed capabilities of core services.<br />

Description: A Registry contains a property for each core service object it creates. It shows which composed<br />

capability of the <strong>IMS</strong> application shall be mapped into each service. For any useful <strong>IMS</strong> application the Registry has<br />

at least one CoreService property.<br />

Value: The value has four parts: a serviceId, zero or one IARI, ICSIs, and Feature Tags on standardized formats.<br />

ICSI and Feature Tags can also have the explicit and require flags. A white space is used as separator if more then<br />

one ICSI or Feature Tag. The serviceId is an alphanumeric name of any length. An empty name is allowed, and is<br />

useful for applications with one service.<br />

Uniqueness: All Core Service properties MUST have a unique serviceId within the scope of the <strong>IMS</strong> application.<br />

QosProfile property<br />

Type name: Qos<br />

Motivation: Support QoS aware BasicMedia.<br />

Description: BasicMedia specifies data flows in the send and receive directions to get QoS. The flow specifications<br />

are tied to a MIME content type for a CoreService property.<br />

Value: The value consists of four parts: a serviceId, a MIME content type, a sending flow specification (flowspec),<br />

and a receiving flowspec. serviceId is a serviceId specified in a CoreService property for this <strong>IMS</strong> application. A<br />

flowspec consists of the quantities described in the chapter on Quality of Service. If the receive flowspec is empty,<br />

the send flowspec is also used in the receive direction.<br />

Uniqueness: A QosProfile property must have a unique combination of MIME content type and serviceId.<br />

Advanced properties<br />

These properties are meant for the advanced user and they require specific <strong>IMS</strong> knowledge and should be used<br />

with caution. Setting these properties will not only configure the application, but they might have an impact on the<br />

<strong>IMS</strong> engine and other applications as well.<br />

Registration header property<br />

Type name: Reg<br />

Motivation: Added headers to SIP registration message.<br />

Description: The property contains the SIP headers with names and values using standard syntax.<br />

Value: The value is a list of parts. The first part is a serviceId, and all remaining parts are the headers.<br />

Uniqueness: There can be maximum one Registration header property per serviceId.<br />

Write header property<br />

Type name: Write<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 26 of 199


Package javax.microedition.ims<br />

Motivation: Allow the <strong>JSR</strong> implementation write access in SIP message headers.<br />

Description: The property contains all names of headers where the <strong>IMS</strong> application writes values.<br />

Value: A set of header names.<br />

Uniqueness: There can be maximum one write header property in a Registry.<br />

Read header property<br />

Type name: Read<br />

Motivation: Allow the <strong>JSR</strong> implementation read access in SIP message headers.<br />

Description: The property contains all names of headers where the <strong>IMS</strong> application reads values.<br />

Value: A set of header names.<br />

Uniqueness: There can be maximum one read header property in a Registry.<br />

Configure capability property<br />

Type name: Cap<br />

Motivation: Configures a Capabilities request or response.<br />

Description: The <strong>IMS</strong> engine creates a default Session Description Protocol (SDP) for outgoing capability requests<br />

and responses and this method is used to extend the SDP with application specific properties.<br />

Value: The value consists of three parts: a sector identifier (sectorId), messageType and the SDP field(s). The<br />

sectorId indicates where to put the SDP field, as session-level or media-level. The messageType is used to indicate<br />

if the SDP field should be added to an outgoing capability request, response or both. The last part is the SDP<br />

field(s) to be added. It is not guaranteed that the properties are added to the actual SDP, for example if there is a<br />

conflict between application configurations the SDP field(s) might be modified or removed.<br />

Uniqueness: There can be zero or more capability properties in a Registry.<br />

Media profile property<br />

Type name: Mprof<br />

Motivation: Make <strong>IMS</strong> application media handling use a media profile.<br />

Description: The property expresses a dependency from the <strong>IMS</strong> application to a media profile. As the profile is<br />

expected to be used in the realm of composed capabilities, the profile is associated to a core service. When the<br />

application creates a session based on that core service, the media handling follows the media profile definition. An<br />

<strong>IMS</strong> application can support several profiles. If no media profile has been specified for the core service, then the<br />

basic profile is assumed by default.<br />

Value: The value consists of two parts: a serviceID, and the media profile short name as a string: "basic", "vs",<br />

"mmtel" or any other short name for a profile defined outside this specification.<br />

Uniqueness: There can be at most one media profile per ServiceId.<br />

Connection property<br />

Type name: Connection<br />

Motivation: Select the connection model for MSRP protocol used in FramedMedia.<br />

Description: If the property is present, the MSRP connection model is that of the standard MSRP procedure as<br />

defined in [RFC4975]. If it is not present, the model follows that of [draft-ietf-simple-msrp-acm-00]. The property<br />

applies per core service to enable the application to bind it to the capabilities.<br />

Value: The value is a serviceId.<br />

Uniqueness: There can be at most one connection property per serviceId.<br />

Other constraints for Registry<br />

A Registry MUST have some capability-carrying property defined.<br />

If a Registry does not comply to the rules above, it is declared inconsistent or corrupt. It is not possible to create a<br />

core service on a corrupt registry.<br />

Dynamic Installation<br />

Dynamic installation uses the method Configuration.setRegistry, that binds an <strong>IMS</strong> application to a Java<br />

application, with the Registry contents. In this call, the Registry is represented as an array of properties. A property<br />

is an array of strings, where the first element is the type. The value, beginning at second element position, is none,<br />

one, or more string elements following the general pattern:<br />

• A simple value is represented as a string.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 27 of 199


Package javax.microedition.ims<br />

• A set value is represented as a space-delimited string enumerating the members. No duplicates are<br />

allowed.<br />

• A multi-valued property is represented as strings over several element positions in a defined order in the<br />

string array. If a value can be empty, then the empty string is used as a place holder. Each value may<br />

define their own internal string syntax.<br />

The property type names and their possible values, as used in a dynamic installation, are shown below:<br />

Stream<br />

Value: One or both of Audio and Video.<br />

Example: { "Stream", "Audio Video" }<br />

Framed<br />

Value: Set of MIME content types.<br />

Example: { "Framed", "text/plain image/png", "4096" }<br />

Basic<br />

Value: Set of MIME content types.<br />

Example: { "Basic", "application/myChess" }<br />

Event<br />

Value: Set of event package names.<br />

Example: { "Event", "presence" }<br />

CoreService<br />

Value: The CoreService property is multi-valued, where the contents of Service definitions are elements in<br />

the order: serviceId, IARI, ICSIs, and Feature Tags. Individual ICSIs and Feature Tags can be appended<br />

with ;require and/or ;explicit to flag them for require and explicit processing. A white space is used as<br />

separator if more then one ICSI or Feature Tag.<br />

Example of a core service with IARI but no ICSI and Feature Tags:<br />

{ "CoreService", "myChess", "urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.chess", "", "" }<br />

Example of a core service with an ICSI flagged for both require and explicit processing:<br />

{ "CoreService", "myChess", "", "urn:URN-3gpp:org.3gpp.icsi;require;explicit", "" }<br />

Example of a core service with two ICSIs and three feature tags:<br />

{ "CoreService", "myChess", "", "urn:3gpp:org.3gpp.icsi urn:3gpp:3gpp-service.ims.icsi.mmtel", "Audio<br />

Video;explicit Duplex;require" }<br />

Qos<br />

Value: The Qos profile is multi-valued with complex parts. The property values are given in the following<br />

order: serviceId, MIME ContentType, send flowspec, receive flowspec. Flowspec strings consist of<br />

space-separated integers in the form: " <br />

".<br />

Example: { "Qos", "myChess", "application/myChess", "1024 5000 1500 0 0 100 10", "" }<br />

Reg<br />

Value: The Reg property is multi-valued, where the first value is the serviceId, and the remaining values<br />

are the SIP headers.<br />

Example: { "Reg", "myChess", "Require: pref" }<br />

Write<br />

Value: Set of SIP header names for write access.<br />

Example: { "Write", "P-ImageIncluded" }<br />

Read<br />

Value: Set of SIP header names for read access.<br />

Example: { "Read", "P-ImageIncluded" }<br />

Cap<br />

Value: The Cap property is multi-valued, where the first value is the sectorId that can be "Session",<br />

"Framed", "StreamAudio" or "StreamVideo". The second value is a messageType that can be "Req",<br />

"Resp" or "Req_Resp". The remaining values are one or more SDP fields.<br />

Example: { "Cap", "Session", "Req_Resp", "a=X-type:videolive" }<br />

Mprof<br />

Value: The Mprof property has two values, where the first value is a ServiceId for some CoreService<br />

property in this Registry, and the second value is a media profile short name.<br />

Example: { "Mprof", "myChess", "vs" }<br />

Connection<br />

Value: The Connection property has a serviceID value for some CoreService property in this Registry.<br />

Example: { "Connection", "myChess" }<br />

Whitespace is deleted from the beginning and end of each value string. Any embedded string of whitespace is<br />

interpreted as a separator.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 28 of 199


Package javax.microedition.ims<br />

An example of the Configuration.setRegistry call expected for the myChess application:<br />

String[][] registry = new String[][] {<br />

{ "Basic", "application/myChess" },<br />

{ "Framed", "text/plain image/png", "4096" },<br />

{ "Event", "Presence" },<br />

{ "CoreService", "myChess", "urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.iari.myChess", "", "" },<br />

{ "Qos", "myChess", "application/myChess", "2 3 2 10 5 2 3", "" },<br />

{ "Reg", "myChess", "Require: pref" },<br />

{ "Write", "P-ImageIncluded" },<br />

{ "Read", "P-ImageIncluded" },<br />

{ "Cap", "Framed", "Req_Resp", "a=max-size:4096" },<br />

{ "Mprof", "myChess", "vs" },<br />

{ "Connection", "myChess" }<br />

};<br />

Configuration.setRegistry("org.jsr<strong>281</strong>.myChess", "MyChess", registry);<br />

Static Installation<br />

<strong>IMS</strong> applications can be installed at the time of Java application installation. The properties are represented as<br />

attributes in the manifest file. If the MIDP jad file is used, it must be in accordance with the MIDP 2.0 specification.<br />

The manifest representation is designed to be close to the form of the registry argument to<br />

Configuration.setRegistry. One property corresponds to one attribute line (see further below). The value<br />

consists of a number of comma-separated fields following the pattern:<br />

• A simple value is represented in its own syntax in one field.<br />

• A set value is represented as a space-delimited member enumeration in one field. The field MUST NOT<br />

contain duplicates.<br />

• The component values of a multi-valued property are represented in their own fields. If a value is empty,<br />

the field is empty. The values may define their own syntax as long as no ambiguity is introduced on the<br />

manifest attribute line.<br />

A manifest attribute name is created based on the property type name. It must be unique within the file. The<br />

following factors are considered:<br />

• The scope of the manifest file is the complete Java application suite. To avoid possible name collisions with<br />

attributes of other packages, all attributes names for the <strong>IMS</strong><strong>API</strong> begin with MicroEdition-<strong>IMS</strong>-.<br />

• A Java application suite can contain several <strong>IMS</strong> applications. To properly associate <strong>IMS</strong> properties to the<br />

right application, a suite-unique serial number is part of the attribute name. All attributes with the same<br />

number in their name belong to the same <strong>IMS</strong> application. If the suite has n <strong>IMS</strong> applications, the serial<br />

number ranges from 1 up to n in that order.<br />

• An <strong>IMS</strong> application can contain one or more CoreService properties. A serial number is used, and it must<br />

be unique within the <strong>IMS</strong> application. If an <strong>IMS</strong> application has m Core<strong>Services</strong>, the serial number ranges<br />

from 1 up to m in that order.<br />

• An <strong>IMS</strong> application can contain zero or more QosProfile properties. A serial number is used here, as for<br />

CoreService properties. Note that a QosProfile is bound to a CoreService, but the QosProfile attribute<br />

name does not include the CoreService serial number. As for the dynamic case, the serviceId identifies the<br />

CoreService.<br />

More specifically, the attribute names are in accordance with the following list. See Dynamic Installation for values<br />

that can be set.<br />

MicroEdition-<strong>IMS</strong>--Identity<br />

This is the extra non-property related line used to identify an <strong>IMS</strong> application. It assigns a serial number i.<br />

The jad attribute value is the AppId, and the MIDlet class name, as specified in the MIDlet- attribute of<br />

MIDP:<br />

MicroEdition-<strong>IMS</strong>--Identity: , <br />

MicroEdition-<strong>IMS</strong>--Stream<br />

Encodes the Stream property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Stream: <br />

MicroEdition-<strong>IMS</strong>--Framed<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 29 of 199


Package javax.microedition.ims<br />

Encodes the Framed property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Framed: , <br />

MicroEdition-<strong>IMS</strong>--Basic<br />

Encodes the Basic property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Basic: <br />

MicroEdition-<strong>IMS</strong>--Event<br />

Encodes the Event property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Event: <br />

MicroEdition-<strong>IMS</strong>--CoreService-<br />

Encodes the j-th CoreService property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--CoreService-: , , ... , ... <br />

The and may have the flags ;require and/or ;explicit appended. A white<br />

space is used as separator if more then one ICSI or Feature Tag.<br />

MicroEdition-<strong>IMS</strong>--Qos-<br />

Encodes the j-th QosProfile property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Qos-: , , ,<br />

<br />

MicroEdition-<strong>IMS</strong>--Reg-<br />

Encodes the j-th Registration header property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Reg-: , , ..., <br />

MicroEdition-<strong>IMS</strong>--Write<br />

Encodes the Write property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Write: <br />

MicroEdition-<strong>IMS</strong>--Read<br />

Encodes the Read property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Read: <br />

MicroEdition-<strong>IMS</strong>--Cap-<br />

Encodes the j-th Configure capabilities property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Cap-: , , , ..., <br />

MicroEdition-<strong>IMS</strong>--Mprof-<br />

Encodes the j-th Mprof property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Mprof-: , <br />

MicroEdition-<strong>IMS</strong>--Connection-<br />

Encodes the j-th Connection property for <strong>IMS</strong> application i.<br />

MicroEdition-<strong>IMS</strong>--Connection-: <br />

Leading and trailing whitespace is deleted from each attribute and field. Any embedded string of whitespace in a<br />

field is treated as a separator.<br />

An example of the manifest attributes expected for the myChess application:<br />

MicroEdition-<strong>IMS</strong>-1-Identity: org.jsr<strong>281</strong>.myChess, MyChess<br />

MicroEdition-<strong>IMS</strong>-1-Basic: application/myChess<br />

MicroEdition-<strong>IMS</strong>-1-Framed: text/plain image/png, 4096<br />

MicroEdition-<strong>IMS</strong>-1-Event: Presence<br />

MicroEdition-<strong>IMS</strong>-1-CoreService-1: myChess, urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.iari.myChess, ,<br />

MicroEdition-<strong>IMS</strong>-1-Qos-1: myChess, application/myChess, 2 3 2 10 5 2 3,<br />

MicroEdition-<strong>IMS</strong>-1-Reg-1: myChess, Require: pref<br />

MicroEdition-<strong>IMS</strong>-1-Write: P-ImageIncluded<br />

MicroEdition-<strong>IMS</strong>-1-Read: P-ImageIncluded<br />

MicroEdition-<strong>IMS</strong>-1-Cap-1: Framed, Req_Resp, a=max-size:4096<br />

MicroEdition-<strong>IMS</strong>-1-Mprof-1: myChess, vs<br />

MicroEdition-<strong>IMS</strong>-1-Connection-1: myChess<br />

Executing <strong>IMS</strong> applications<br />

An <strong>IMS</strong> application is said to be started, or executing, whenever it is visible on the <strong>IMS</strong> network. This happens<br />

when its capabilities. A <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> application is executing whenever at least one of its Core <strong>Services</strong> are<br />

created and active.<br />

The imscore connector string<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 30 of 199


Package javax.microedition.ims<br />

The imscore connector string is supplied as argument to Connector.open to create the core service. A properly<br />

formatted imscore connector string uniquely identifies a core service of the system. It follows the pattern:<br />

imscore:;userId=;serviceId=<br />

The detailed syntax is specified according to the production below:<br />

Left hand side<br />

right hand side<br />

::= "imscore://"[]<br />

::= <br />

::= string of alphanumeric characters<br />

<br />

<br />

<br />

<br />

<br />

::= *(| )<br />

::= ";serviceId=" | ";serviceId="<br />

::= string of alphanumeric characters<br />

::= ";userId=" | ";userId="<br />

::= SIP or TEL URI with optional display name<br />

While the Core Service object is open, or Push registered, the capabilities are exposed on the network. The <strong>IMS</strong><br />

application is now able to initiate and receive <strong>IMS</strong> calls with media. It is programmed to handle them according to<br />

its own logic conformant to the capabilities. See the <strong>API</strong> documentation.<br />

To stop execution, the <strong>IMS</strong> application closes each active service with calling Service.close.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 31 of 199


Class Configuration<br />

Class Configuration<br />

javax.microedition.ims<br />

java.lang.Object<br />

javax.microedition.ims.Configuration<br />

final public class Configuration<br />

extends Object<br />

The Configuration class realizes dynamic installation of <strong>IMS</strong> applications with the pair of methods setRegistry<br />

and removeRegistry. While an <strong>IMS</strong> application is installed, it has an associated Registry. The Registry is a small<br />

data base that stores <strong>IMS</strong> application properties. See the package documentation and the chapter on the Registry<br />

and its role in static and dynamic installation.<br />

Dynamic installation complements the static installation where the installation of <strong>IMS</strong> application takes place at<br />

Java application installation.<br />

Method Summary<br />

static getConfiguration()<br />

Configuration<br />

Returns a Configuration that enables dynamic installation of <strong>IMS</strong> applications.<br />

String[] getLocalAppIds()<br />

Returns all AppIds for the local endpoint.<br />

String[][] getRegistry(String appId)<br />

Returns the registry for an <strong>IMS</strong> application with the specified appId.<br />

boolean hasRegistry(String appId)<br />

Returns true if there is a registry for the <strong>IMS</strong> application with the specified appId, else<br />

false.<br />

void removeRegistry(String appId)<br />

Removes the registry for the <strong>IMS</strong> application and deletes the binding to the owning<br />

Java application.<br />

void setRegistry(String appId, String classname, String[][] registry)<br />

Sets the registry for an <strong>IMS</strong> application and binds it to a parent Java application.<br />

Page<br />

32<br />

34<br />

34<br />

34<br />

34<br />

32<br />

Method Detail<br />

getConfiguration<br />

public static synchronized Configuration getConfiguration()<br />

Returns a Configuration that enables dynamic installation of <strong>IMS</strong> applications.<br />

Returns:<br />

a Configuration instance that enables dynamic installation of <strong>IMS</strong> applications.<br />

setRegistry<br />

public void setRegistry(String appId,<br />

String classname,<br />

String[][] registry)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 32 of 199


Class Configuration<br />

Sets the registry for an <strong>IMS</strong> application and binds it to a parent Java application. Any previous registry and<br />

binding for that <strong>IMS</strong> application is deleted (including all properties), this does not affect services that are<br />

already created. The new registry is defined in the registry argument.<br />

The classname argument identifies a Java application according to the particular Java runtime environment.<br />

For a MIDP2-based implementation, the classname must be registered with the Midlet- attribute.<br />

The registry argument specifies a registry as an unordered array of <strong>IMS</strong> properties. The general pattern<br />

of the registry argument is as follows. The property type name is in bold face, the value placeholder is in<br />

italic.<br />

{{ "Stream", "Media types" },<br />

{ "Framed", "MIME Content types", "max-size" },<br />

{ "Basic", "MIME Content types" },<br />

{ "Event", "Event package names" },<br />

{ "CoreService", "ServiceId",<br />

"Zero or one IARI",<br />

"Zero or more ICSIs",<br />

"Zero or more Feature Tags" },<br />

{ "Qos", "ServiceId",<br />

"MIME Content type",<br />

"Flowspec send",<br />

"Flowspec receive" },<br />

{ "Reg", "ServiceId",<br />

"Header 1",<br />

... ,<br />

"Header n" },<br />

{ "Write", "Write access SIP headers" },<br />

{ "Read", "Read access SIP headers" },<br />

{ "Cap", "sectorId",<br />

"messageType",<br />

"SDP field 1",<br />

... ,<br />

"SDP field n" },<br />

{ "Mprof", "ServiceId", "Media profile" },<br />

{ "Connection", "ServiceId"}<br />

}<br />

String myAppId = "com.myCompany.games.chess";<br />

Configuration myConfiguration = Configuration.getConfiguration();<br />

String[][] registry =<br />

new String[][] {<br />

{"Framed", "text/plain image/png", "4096"},<br />

{"Basic", "application/myChess"},<br />

{"Event", "presence"},<br />

{<br />

"CoreService",<br />

"myChess",<br />

"urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.iari.myChess",<br />

"urn:3gpp:org.3gpp.icsi;require urn:3gpp:3gpp-service.ims.icsi.mmtel",<br />

""},<br />

{"Qos", "myChess", "application/myChess", "2 3 2 10 5 2 3", ""},<br />

{"Reg", "myChess", "Require: pref"}, {"Write", "P-ImageIncluded"},<br />

{"Read", "P-ImageIncluded"},<br />

{"Cap", "Framed", "Req_Resp", "a=max-size:4096"},<br />

{"Mprof", "myChess", "vs"},};<br />

myConfiguration.setRegistry(myAppId, classname, registry);<br />

Parameters:<br />

appId - the application id<br />

classname - the classname of the Java application that the <strong>IMS</strong> application is bound to<br />

registry - an array of arrays, specifying key and value(s)<br />

Throws:<br />

IllegalArgumentException - if the appId or classname argument is null,<br />

if the registry argument is null or if it has invalid syntax,<br />

if the classname argument is not specified as a MIDlet- attribute (for MIDP implementations)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 33 of 199


Class Configuration<br />

See Also:<br />

getRegistry(String)<br />

getRegistry<br />

public String[][] getRegistry(String appId)<br />

Returns the registry for an <strong>IMS</strong> application with the specified appId.<br />

Parameters:<br />

appId - the application id<br />

Returns:<br />

the registry for the <strong>IMS</strong> application specified by the appId argument<br />

Throws:<br />

IllegalArgumentException - if appId is not set in the registry<br />

See Also:<br />

setRegistry(String, String, String[][])<br />

removeRegistry<br />

public synchronized void removeRegistry(String appId)<br />

Removes the registry for the <strong>IMS</strong> application and deletes the binding to the owning Java application. This<br />

applies to both static and dynamic installations. If this method is invoked, the local endpoint will no longer<br />

be able to create new services with the application identity specified by the appId argument, this does not<br />

affect services that are already created.<br />

Parameters:<br />

appId - the application id<br />

Throws:<br />

IllegalArgumentException - if appId is not set in the registry<br />

hasRegistry<br />

public boolean hasRegistry(String appId)<br />

Returns true if there is a registry for the <strong>IMS</strong> application with the specified appId, else false.<br />

Parameters:<br />

appId - the application id<br />

Returns:<br />

true if there is a registry for the <strong>IMS</strong> application specified by the appId argument, else false<br />

Throws:<br />

IllegalArgumentException - if the appId argument is null<br />

See Also:<br />

setRegistry(String, String, String[][])<br />

getLocalAppIds<br />

public String[] getLocalAppIds()<br />

Returns all AppIds for the local endpoint. An empty string array will be returned if no AppId could be<br />

retrieved.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 34 of 199


Class Configuration<br />

Returns:<br />

a string array containing all AppIds for the local endpoint<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 35 of 199


Class ConnectionState<br />

Class ConnectionState<br />

javax.microedition.ims<br />

java.lang.Object<br />

javax.microedition.ims.ConnectionState<br />

final public class ConnectionState<br />

extends Object<br />

The ConnectionState class is used to monitoring the <strong>IMS</strong> connection and accessing user identities.<br />

The <strong>IMS</strong> engine runs autonomously on the device and therefore the application cannot assume that the device is<br />

connected or disconnected to the <strong>IMS</strong> network. If the <strong>IMS</strong> engine is not connected when the application creates a<br />

service with Connector.open the <strong>IMS</strong> engine will connect to the <strong>IMS</strong> network.<br />

While being connected to the <strong>IMS</strong> network, an application can retrieve the available network-provisioned user<br />

identities.<br />

Method Summary<br />

static getConnectionState()<br />

ConnectionState<br />

Returns a ConnectionState that monitors the connection to the <strong>IMS</strong> network.<br />

String[] getUserIdentities()<br />

Returns network provisioned user identities.<br />

boolean isBehindNat()<br />

Determine whether there is a NAT/Firewall placed on the access network connecting<br />

the local endpoint to the <strong>IMS</strong> network.<br />

boolean isConnected()<br />

This method can be used to determine if the device is connected to the <strong>IMS</strong> network.<br />

boolean isSuspended()<br />

Returns whether the connection is in a suspended state.<br />

void setListener(ConnectionStateListener listener)<br />

Sets a listener for this ConnectionState, replacing any previous<br />

ConnectionStateListener.<br />

Page<br />

36<br />

37<br />

37<br />

36<br />

37<br />

37<br />

Method Detail<br />

getConnectionState<br />

public static ConnectionState getConnectionState()<br />

Returns a ConnectionState that monitors the connection to the <strong>IMS</strong> network.<br />

Returns:<br />

a ConnectionState instance that monitors the connection to the <strong>IMS</strong> network<br />

isConnected<br />

public boolean isConnected()<br />

This method can be used to determine if the device is connected to the <strong>IMS</strong> network.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 36 of 199


Class ConnectionState<br />

Returns:<br />

true if the device is connected to the <strong>IMS</strong> network, false otherwise<br />

isBehindNat<br />

public boolean isBehindNat()<br />

Determine whether there is a NAT/Firewall placed on the access network connecting the local endpoint to<br />

the <strong>IMS</strong> network. If this is the case then the application MUST consider how it is maintaining media flows in<br />

BasicReliableMedia and BasicUnreliableMedia.<br />

Returns:<br />

true if the device is behind a NAT/FW, false otherwise<br />

Throws:<br />

IllegalStateException - if the device is not connected to the <strong>IMS</strong> network<br />

setListener<br />

public void setListener(ConnectionStateListener listener)<br />

Sets a listener for this ConnectionState, replacing any previous ConnectionStateListener. A null<br />

reference is allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null to remove it<br />

getUserIdentities<br />

public String[] getUserIdentities()<br />

Returns network provisioned user identities. The first item is the network-chosen default user identity. The<br />

user identities can be used as an argument to creating services.<br />

The user identities are formatted according to SIP or TEL URI, see [RFC3261] and [RFC3966].<br />

Returns:<br />

the network provisioned user identities, an empty string array will be returned if no user identities<br />

are available<br />

isSuspended<br />

public boolean isSuspended()<br />

Returns whether the connection is in a suspended state.<br />

Returns:<br />

true if the <strong>IMS</strong> connection is suspended, false otherwise<br />

Throws:<br />

IllegalStateException - if the device is not connected to the <strong>IMS</strong> network<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 37 of 199


Interface ConnectionStateListener<br />

Interface ConnectionStateListener<br />

javax.microedition.ims<br />

public interface ConnectionStateListener<br />

A listener type for receiving notifications about changes to the <strong>IMS</strong> connection.<br />

See Also:<br />

ConnectionState.isConnected()<br />

Method Summary<br />

void connectionResumed()<br />

Notifies the application when its suspended <strong>IMS</strong> connection is resumed, meaning the<br />

connection now allows throughput.<br />

void connectionSuspended()<br />

Notifies the application when its current <strong>IMS</strong> connection is suspended, meaning there is no<br />

data throughput.<br />

void imsConnected()<br />

Notifies the application when the device is connected to the <strong>IMS</strong> network.<br />

void imsDisconnected()<br />

Notifies the application when the device is disconnected from the <strong>IMS</strong> network.<br />

Page<br />

38<br />

38<br />

38<br />

38<br />

Method Detail<br />

imsConnected<br />

void imsConnected()<br />

Notifies the application when the device is connected to the <strong>IMS</strong> network.<br />

imsDisconnected<br />

void imsDisconnected()<br />

Notifies the application when the device is disconnected from the <strong>IMS</strong> network.<br />

connectionSuspended<br />

void connectionSuspended()<br />

Notifies the application when its current <strong>IMS</strong> connection is suspended, meaning there is no data<br />

throughput.<br />

connectionResumed<br />

void connectionResumed()<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 38 of 199


Interface ConnectionStateListener<br />

Notifies the application when its suspended <strong>IMS</strong> connection is resumed, meaning the connection now<br />

allows throughput.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 39 of 199


Class ImsException<br />

Class ImsException<br />

javax.microedition.ims<br />

java.lang.Object<br />

java.lang.Throwable<br />

java.lang.Exception<br />

javax.microedition.ims.ImsException<br />

public class ImsException<br />

extends Exception<br />

An ImsException indicates an unexpected error condition in a method.<br />

Constructor Summary<br />

ImsException()<br />

Constructs an ImsException with null as its error detail message.<br />

ImsException(String reason)<br />

Constructs an ImsException with the specified detail message.<br />

Page<br />

40<br />

40<br />

Constructor Detail<br />

ImsException<br />

public ImsException()<br />

Constructs an ImsException with null as its error detail message.<br />

ImsException<br />

public ImsException(String reason)<br />

Constructs an ImsException with the specified detail message. The error message string reason can later<br />

be retrieved by the Throwable.getMessage() method of class java.lang.Throwable.<br />

Parameters:<br />

reason - the detail message<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 40 of 199


Interface ReasonInfo<br />

Interface ReasonInfo<br />

javax.microedition.ims<br />

public interface ReasonInfo<br />

The ReasonInfo interface enables an application to get details on why a method call failed.<br />

Field Summary<br />

int REASONTYPE_INCONSISTENT_REGISTRY<br />

Identifier for the reason type inconsistent registry.<br />

int REASONTYPE_LOCAL_TIMEOUT<br />

Identifier for the reason type local timeout.<br />

int REASONTYPE_RESPONSE<br />

Identifier for the reason type response.<br />

int REASONTYPE_USER_ACTION<br />

Identifier for the reason type user action.<br />

Page<br />

42<br />

41<br />

41<br />

41<br />

Method Summary<br />

String getReasonPhrase()<br />

Returns the SIP reason phrase.<br />

int getReasonType()<br />

Returns the reason type.<br />

int getStatusCode()<br />

Returns the SIP status code.<br />

Page<br />

42<br />

42<br />

42<br />

Field Detail<br />

REASONTYPE_RESPONSE<br />

public static final int REASONTYPE_RESPONSE<br />

Identifier for the reason type response.<br />

REASONTYPE_USER_ACTION<br />

public static final int REASONTYPE_USER_ACTION<br />

Identifier for the reason type user action.<br />

REASONTYPE_LOCAL_TIMEOUT<br />

public static final int REASONTYPE_LOCAL_TIMEOUT<br />

Identifier for the reason type local timeout.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 41 of 199


Interface ReasonInfo<br />

REASONTYPE_INCONSISTENT_REGISTRY<br />

public static final int REASONTYPE_INCONSISTENT_REGISTRY<br />

Identifier for the reason type inconsistent registry.<br />

Method Detail<br />

getReasonType<br />

int getReasonType()<br />

Returns the reason type.<br />

Returns:<br />

the reason type<br />

getReasonPhrase<br />

String getReasonPhrase()<br />

throws IllegalStateException<br />

Returns the SIP reason phrase.<br />

Returns:<br />

the reason phrase<br />

Throws:<br />

IllegalStateException - if reason type is not REASONTYPE_RESPONSE<br />

getStatusCode<br />

int getStatusCode()<br />

throws IllegalStateException<br />

Returns the SIP status code.<br />

Returns:<br />

the status code<br />

Throws:<br />

IllegalStateException - if reason type is not REASONTYPE_RESPONSE<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 42 of 199


Interface Service<br />

Interface Service<br />

javax.microedition.ims<br />

All Superinterfaces:<br />

javax.microedition.io.Connection<br />

All Known Subinterfaces:<br />

CoreService<br />

public interface Service<br />

extends javax.microedition.io.Connection<br />

Service is the base interface for <strong>IMS</strong> <strong>Services</strong>, and follows the Generic Connection Framework (GCF).<br />

Creating services using the Generic Connection Framework<br />

The application creates services using the Connector.open() where the string argument has the general form<br />

(described in [RFC2396]):<br />

where:<br />

• :[]<br />

• scheme is a supported <strong>IMS</strong> scheme. In this specification the imscore is defined in the CoreService<br />

interface<br />

• target is an AppId. An AppId should follow the form of fully qualified Java class names or any naming<br />

syntax that provides a natural way to differentiate between vendors.<br />

• params are optional semi-colon separated parameters particular to the <strong>IMS</strong> scheme used. If the parameter<br />

value is set incorrectly an IllegalArgumentException is thrown.<br />

The returned Service object depends on the used scheme.<br />

The call to Connector.open() is synchronous, and for some services the call might take several seconds to<br />

complete. Also observe that the following actions to open a service are equivalent:<br />

Connector.open("imscore://myAppId;ServiceID=") and Connector.open("imscore://myAppId").<br />

Exceptions when opening a service<br />

The following exceptions can be thrown when calling Connector.Open().<br />

• IllegalArgumentException - If a parameter is invalid.<br />

• ConnectionNotFoundException - If the target of the name cannot be found, or if the requested protocol<br />

type is not supported.<br />

• IOException - If some other kind of I/O error occurs.<br />

• SecurityException - May be thrown if access to the protocol handler is prohibited.<br />

The following exceptions can be throws due to <strong>IMS</strong> specific errors.<br />

• IOException - The <strong>IMS</strong> profile is missing or corrupt.<br />

• IOException - The Internet profile is missing or corrupt.<br />

• IOException - The subscriber failed to authenticate within the <strong>IMS</strong> network.<br />

• IOException - The Register request failed to reach the <strong>IMS</strong> network.<br />

• IOException - The <strong>IMS</strong> network responded with a service or server specific error code.<br />

• ConnectionNotFoundException - The AppId is not an installed <strong>IMS</strong> Application.<br />

Closing a service<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 43 of 199


Interface Service<br />

The application SHOULD invoke close() on the Service when it is finished using the Service.<br />

See Also:<br />

CoreService<br />

Method Summary<br />

String getAppId()<br />

Returns the application id string that this Service was created with.<br />

String getScheme()<br />

Returns the scheme used for this Service.<br />

Page<br />

44<br />

44<br />

Methods inherited from interface javax.microedition.io.Connection<br />

close<br />

Method Detail<br />

getAppId<br />

String getAppId()<br />

Returns the application id string that this Service was created with.<br />

Returns:<br />

the application id of this Service<br />

getScheme<br />

String getScheme()<br />

Returns the scheme used for this Service.<br />

Returns:<br />

the scheme used for this Service<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 44 of 199


Class ServiceClosedException<br />

Class ServiceClosedException<br />

javax.microedition.ims<br />

java.lang.Object<br />

java.lang.Throwable<br />

java.lang.Exception<br />

java.io.IOException<br />

javax.microedition.ims.ServiceClosedException<br />

public class ServiceClosedException<br />

extends java.io.IOException<br />

A ServiceClosedException indicates that a method is invoked on a Service that is closed.<br />

Constructor Summary<br />

ServiceClosedException()<br />

Constructs a ServiceClosedException with null as its error detail message.<br />

ServiceClosedException(String reason)<br />

Constructs a ServiceClosedException with the specified detail message.<br />

Page<br />

45<br />

45<br />

Constructor Detail<br />

ServiceClosedException<br />

public ServiceClosedException()<br />

Constructs a ServiceClosedException with null as its error detail message.<br />

ServiceClosedException<br />

public ServiceClosedException(String reason)<br />

Constructs a ServiceClosedException with the specified detail message. The error message string<br />

reason can later be retrieved by the Throwable.getMessage() method of class java.lang.Throwable.<br />

Parameters:<br />

reason - the detail message<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 45 of 199


Package javax.microedition.ims.core<br />

Package javax.microedition.ims.core<br />

This package collects classes and interfaces that enable an application to create <strong>IMS</strong> services.<br />

See:<br />

Description<br />

Interface Summary<br />

Capabilities<br />

CapabilitiesListener<br />

CoreService<br />

CoreServiceListener<br />

Message<br />

MessageBodyPart<br />

PageMessage<br />

PageMessageListener<br />

The Capabilities is used to query a remote endpoint whether it has matching<br />

capabilities matching the local ones.<br />

This listener type is used to notify the application about responses to capability<br />

queries.<br />

The CoreService gives the application the possibility to call remote peers over the<br />

<strong>IMS</strong> network.<br />

A listener type for receiving notifications on remotely initiated core service<br />

methods.<br />

The Message interface provides functionality to manipulate headers and body parts<br />

of SIP messages.<br />

A MessageBodyPart can contain different kinds of content, for example text, an<br />

image or an audio clip.<br />

The PageMessage interface is used for simple instant messages or exchange of<br />

small amounts of content outside of a session.<br />

This listener type is used to notify the application about the status of sent page<br />

messages.<br />

Publication The Publication is used for publishing event state to a remote endpoint. 77<br />

PublicationListener<br />

Reference<br />

ReferenceListener<br />

ServiceMethod<br />

This listener type is used to notify the application of the status of requested<br />

publications.<br />

The Reference is used for referring a remote endpoint to a third party user or<br />

service.<br />

This listener type is used to notify an application about events regarding a<br />

Reference.<br />

The ServiceMethod interface provides methods to manipulate the next outgoing<br />

request message and to inspect previously sent request and response messages.<br />

Session The Session is a representation of a media exchange between two <strong>IMS</strong> endpoints. 98<br />

SessionDescriptor<br />

The Session Description Protocol (SDP) [RFC4566] is used to convey information<br />

about media streams in a session such that the endpoints can connect and<br />

participate.<br />

SessionListener A listener type for receiving notification on session events. 115<br />

Subscription<br />

SubscriptionListener<br />

A Subscription is used for subscribing to events of the event package sent from<br />

the remote server endpoint.<br />

This listener type is used to notify the application about subscription status and the<br />

event state of the subscribed event package.<br />

Page<br />

48<br />

51<br />

52<br />

59<br />

64<br />

70<br />

72<br />

76<br />

81<br />

83<br />

91<br />

93<br />

111<br />

118<br />

122<br />

Class Summary<br />

ImscoreProtocolPermission<br />

This class represents permission to connections using the imscore connector<br />

string.<br />

Page<br />

61<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 46 of 199


Package javax.microedition.ims.core<br />

Exception Summary<br />

CoreServiceException A CoreServiceException indicates that a CoreService could not be created. 58<br />

Package javax.microedition.ims.core Description<br />

This package collects classes and interfaces that enable an application to create <strong>IMS</strong> services.<br />

Page<br />

Static Structure<br />

Figure 1: Static structure of the package.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 47 of 199


Interface Capabilities<br />

Interface Capabilities<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface Capabilities<br />

extends ServiceMethod<br />

The Capabilities is used to query a remote endpoint whether it has matching capabilities matching the local<br />

ones.<br />

Example use of Capabilities<br />

public void checkSupport(CoreService service){<br />

try {<br />

Capabilities caps;<br />

caps = service.createCapabilities(null, "Alice ");<br />

caps.setListener(this);<br />

caps.queryCapabilities(false);<br />

} catch(Exception e){<br />

// handle Exceptions<br />

}<br />

}<br />

public void capabilityQueryDelivered(Capabilities caps){<br />

String conn = "imscore://com.myCompany.games.chess";<br />

boolean feat = caps.hasCapabilities(conn);<br />

if (feat) {<br />

cs = (CoreService)Connector.open(conn);<br />

...<br />

}<br />

See Also:<br />

CoreService.createCapabilities(String, String)<br />

Field Summary<br />

int STATE_ACTIVE<br />

The capability response is received.<br />

int STATE_INACTIVE<br />

The capability request has not been sent.<br />

int STATE_PENDING<br />

The capability request is sent and the platform is waiting for a response.<br />

Page<br />

49<br />

49<br />

49<br />

Method Summary<br />

String[] getRemoteUserIdentities()<br />

Returns an array of strings representing valid user identities for the remote endpoint.<br />

int getState()<br />

Returns the current state of this Capabilities.<br />

boolean hasCapabilities(String connection)<br />

This method returns true if the remote endpoint is believed to be sufficiently capable of<br />

handling requests from a certain core service on the local endpoint.<br />

void queryCapabilities(boolean sdpInRequest)<br />

Sends a capability request to a remote endpoint.<br />

Page<br />

49<br />

50<br />

50<br />

49<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 48 of 199


Interface Capabilities<br />

void setListener(CapabilitiesListener listener)<br />

Sets a listener for this Capabilities, replacing any previous CapabilitiesListener.<br />

50<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_INACTIVE<br />

public static final int STATE_INACTIVE<br />

The capability request has not been sent.<br />

STATE_PENDING<br />

public static final int STATE_PENDING<br />

The capability request is sent and the platform is waiting for a response.<br />

STATE_ACTIVE<br />

public static final int STATE_ACTIVE<br />

The capability response is received.<br />

Method Detail<br />

queryCapabilities<br />

void queryCapabilities(boolean sdpInRequest)<br />

throws ServiceClosedException<br />

Sends a capability request to a remote endpoint.<br />

The Capabilities will transit to STATE_PENDING after calling this method.<br />

Parameters:<br />

sdpInRequest - if true, the <strong>IMS</strong> engine will add a Session Description Protocol (SDP) to the<br />

capability request<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Capabilities is not in STATE_INACTIVE<br />

getRemoteUserIdentities<br />

String[] getRemoteUserIdentities()<br />

Returns an array of strings representing valid user identities for the remote endpoint.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 49 of 199


Interface Capabilities<br />

Returns:<br />

an array of user identities, an empty array will be returned if no user identities could be retrieved<br />

Throws:<br />

IllegalStateException - if the Capabilities is not in STATE_ACTIVE<br />

getState<br />

int getState()<br />

Returns the current state of this Capabilities.<br />

Returns:<br />

the current state of this Capabilities<br />

hasCapabilities<br />

boolean hasCapabilities(String connection)<br />

This method returns true if the remote endpoint is believed to be sufficiently capable of handling requests<br />

from a certain core service on the local endpoint. The core service is specified with an imscore connector<br />

string.<br />

Note: Even if this method returns true, it is not guaranteed that requests are indeed supported at the<br />

remote.<br />

Example:<br />

String imscore = "imscore://com.myCompany.games.chess";<br />

if (caps.hasCapabilities(imscore)) {<br />

CoreService = (CoreService)Connector.open(imscore);<br />

...<br />

} else {<br />

// No point in trying to create the service.<br />

}<br />

Parameters:<br />

connection - the imscore connector string to check.<br />

Returns:<br />

true if the remote endpoint has the capabilities, otherwise false<br />

Throws:<br />

IllegalStateException - if the Capabilities is not in STATE_ACTIVE<br />

IllegalArgumentException - if the connection argument is null, unknown or invalid syntax<br />

setListener<br />

void setListener(CapabilitiesListener listener)<br />

Sets a listener for this Capabilities, replacing any previous CapabilitiesListener. A null reference is<br />

allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 50 of 199


Interface CapabilitiesListener<br />

Interface CapabilitiesListener<br />

javax.microedition.ims.core<br />

public interface CapabilitiesListener<br />

This listener type is used to notify the application about responses to capability queries.<br />

See Also:<br />

Capabilities.setListener(CapabilitiesListener)<br />

Method Summary<br />

void capabilityQueryDelivered(Capabilities capabilities)<br />

Notifies the application that the capability query response from the remote endpoint was<br />

successfully received.<br />

void capabilityQuery<strong>Delivery</strong>Failed(Capabilities capabilities)<br />

Notifies the application that the capability query response from the remote endpoint was not<br />

successfully received.<br />

Page<br />

51<br />

51<br />

Method Detail<br />

capabilityQueryDelivered<br />

void capabilityQueryDelivered(Capabilities capabilities)<br />

Notifies the application that the capability query response from the remote endpoint was successfully<br />

received.<br />

The Capabilities has transited to STATE_ACTIVE.<br />

Parameters:<br />

capabilities - the concerned Capabilities<br />

capabilityQuery<strong>Delivery</strong>Failed<br />

void capabilityQuery<strong>Delivery</strong>Failed(Capabilities capabilities)<br />

Notifies the application that the capability query response from the remote endpoint was not successfully<br />

received.<br />

The Capabilities has transited to STATE_INACTIVE.<br />

Parameters:<br />

capabilities - the concerned Capabilities<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 51 of 199


Interface CoreService<br />

Interface CoreService<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

javax.microedition.io.Connection, Service<br />

public interface CoreService<br />

extends Service<br />

The CoreService gives the application the possibility to call remote peers over the <strong>IMS</strong> network. There is a set of<br />

basic call types in the CoreService that can be created via factory methods, see ServiceMethod.<br />

The application can react to incoming <strong>IMS</strong> calls by implementing the listener interface CoreServiceListener.<br />

Integration of CoreService to GCF<br />

Connector.open(String name)<br />

A CoreService is created with Connector.open, see Service, using an imscore connector string as name:<br />

• imscore:[]<br />

where target is the application id, and are the optional semi-colon separated parameters:<br />

• userId= is the local user identity that the user prefers to be in effect for this core<br />

service. The preference is used to override the default public user identity of the device. The userId<br />

parameter accepts a display name together with the URI using standard syntax.<br />

• serviceId= is set if this CoreService shall support the service alias specified in the<br />

Registry. If this parameter is unspecified, the service alias defaults to the empty string.<br />

The javax.microedition.io.Connector class is defined in the CLDC specifications (<strong>JSR</strong>30, <strong>JSR</strong>139) and is<br />

used here to create services. The Open method allows some variation, and it is shown below how this works for the<br />

imscore: connector string.<br />

Connector.open(String name, String mode)<br />

The optional second parameter 'mode' in Connector.open specifies the access mode that can be READ, WRITE,<br />

READ_WRITE. The mode is not relevant.<br />

Connector.open(String name, String mode, boolean timeouts)<br />

The optional third parameter is a boolean flag that indicates if the calling code can handle timeout exceptions when<br />

creating the service.<br />

Exceptions when opening a CoreService<br />

The following exceptions can be throws due to CoreService specific errors, see Service for more exceptions.<br />

• CoreServiceException - The CoreService could not be created, see javax.microedition.ims.core for<br />

more information. The reason for not creating the CoreService could be retrieved from the ReasonInfo<br />

interface.<br />

...<br />

} catch (CoreServiceException cse) {<br />

ReasonInfo info;<br />

String reasonPhrase;<br />

int reasonType;<br />

int statusCode;<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 52 of 199


Interface CoreService<br />

}<br />

info = cse.getReasonInfo();<br />

reasonPhrase = info.getReasonPhrase();<br />

reasonType = info.getReasonType();<br />

statusCode = info.getStatusCode();<br />

...<br />

CoreService creation rules<br />

For a given application identity and no service identity, it is possible to create at most one instance of a<br />

CoreService. For a given application identity and a service identity, it is possible to have at most one<br />

CoreService.<br />

Examples<br />

This code shows how to create a CoreService with the application identity com.myCompany.games.chess. In the<br />

first example the user identity will be the default user identity provisioned by the <strong>IMS</strong> network. In the second<br />

example the application overrides the user identity to use in this CoreService. The third example shows a call<br />

used to create a CoreService with a service identity specified.<br />

service = (CoreService) Connector.open("imscore://com.myCompany.games.chess");<br />

service = (CoreService) Connector.open("imscore://com.myCompany.games.chess;<br />

userId=Alice ");<br />

service = (CoreService) Connector.open("imscore://com.myCompany.games.chess;<br />

userId=Alice <br />

serviceId=game");<br />

Closing a CoreService<br />

The application SHOULD invoke close on the CoreService when it is finished using the CoreService. The <strong>IMS</strong><br />

engine may also close the CoreService due to external events. This will trigger a call to serviceClosed on the<br />

CoreServiceListener interface.<br />

Creating a service method, example<br />

Alice invites Bob using their public user identities as addresses:<br />

coreService.createSession("sip:alice@home.net", "sip:bob@home.net");<br />

The sender requests anonymity in this request by using "Anonymous" as display name in the from argument:<br />

coreService.createSession("Anonymous ",<br />

"sip:bob@home.net");<br />

Alice uses her display name when inviting Bob:<br />

coreService.createSession("Alice ", "sip:bob@home.net");<br />

For more information on the contents of the from and to arguments in service methods, please see section on<br />

User and Service Addressing in the overview.<br />

See Also:<br />

CoreServiceListener<br />

Method Summary<br />

Capabilities createCapabilities(String from, String to)<br />

Creates a Capabilities with from as sender, addressed to to.<br />

Page<br />

56<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 53 of 199


Interface CoreService<br />

PageMessage createPageMessage(String from, String to)<br />

Creates a PageMessage with from as sender, addressed to to.<br />

Publication createPublication(String from, String to, String event)<br />

Creates a Publication for an event package with from as sender and to as the user<br />

identity to publish event state on.<br />

Reference createReference(String from, String to, String referTo, String referMethod)<br />

Creates a Reference with from as sender, addressed to to and referTo as the URI to<br />

refer to.<br />

Session createSession(String from, String to)<br />

Creates a Session with from as sender, with to as recipient.<br />

Subscription createSubscription(String from, String to, String event)<br />

Creates a Subscription for an event package with from as sender and to as the user<br />

identity to subscribe event state on.<br />

String getLocalUserId()<br />

Returns the display name and public user identity for the CoreService.<br />

void setListener(CoreServiceListener listener)<br />

Sets a listener for this CoreService, replacing any previous CoreServiceListener.<br />

54<br />

55<br />

57<br />

56<br />

55<br />

54<br />

57<br />

Methods inherited from interface javax.microedition.ims.Service<br />

getAppId, getScheme<br />

Methods inherited from interface javax.microedition.io.Connection<br />

close<br />

Method Detail<br />

getLocalUserId<br />

String getLocalUserId()<br />

Returns the display name and public user identity for the CoreService. This is either the value of the<br />

userId= parameter of the imscore: locator used to create the core service, or default value of the device.<br />

Returns:<br />

a public user identity, possibly with a display name<br />

createPageMessage<br />

PageMessage createPageMessage(String from,<br />

String to)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a PageMessage with from as sender, addressed to to.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If null, from is assumed to be<br />

the local user identity of the Service<br />

to - the recipient SIP or TEL URI with an optional display name to send a PageMessage to<br />

Returns:<br />

a new PageMessage<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 54 of 199


Interface CoreService<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the PageMessage could not be created<br />

IllegalArgumentException - if the to argument is null,<br />

if the syntax of the from or to argument is invalid<br />

createPublication<br />

Publication createPublication(String from,<br />

String to,<br />

String event)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a Publication for an event package with from as sender and to as the user identity to publish<br />

event state on.<br />

The event package must be defined as a JAD file property or set with the setRegistry method in the<br />

Configuration class.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If null, from is assumed to be<br />

the local user identity of the Service<br />

to - the recipient SIP or TEL URI with an optional display name to publish event state information<br />

on. If null, to is assumed to be the local user of the Service<br />

event - the event package to publish event state information on<br />

Returns:<br />

a new Publication<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the Publication could not be created<br />

IllegalArgumentException - if the syntax of the from or to argument is invalid,<br />

if the event argument is not a defined event package<br />

createSubscription<br />

Subscription createSubscription(String from,<br />

String to,<br />

String event)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a Subscription for an event package with from as sender and to as the user identity to<br />

subscribe event state on.<br />

The event package must be defined as a JAD file property or set with the setRegistry method in the<br />

Configuration class.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If null, from is assumed to be<br />

the local user identity of the Service<br />

to - the recipient SIP or TEL URI with an optional display name to subscribe state information on. If<br />

null, to is assumed is assumed to be the local user of the Service<br />

event - the event package to subscribe state information on<br />

Returns:<br />

a new Subscription<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 55 of 199


Interface CoreService<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the Subscription could not be created<br />

IllegalArgumentException - if the syntax of the from or to argument is invalid,<br />

if the event argument is not a defined event package<br />

createCapabilities<br />

Capabilities createCapabilities(String from,<br />

String to)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a Capabilities with from as sender, addressed to to.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If null, from is assumed to be<br />

the local user identity of the Service<br />

to - the recipient SIP or TEL URI with an optional display name.<br />

Returns:<br />

a new Capabilities<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the Capabilities could not be created<br />

IllegalArgumentException - if the to argument is null,<br />

if the syntax of the from or to argument is invalid<br />

createSession<br />

Session createSession(String from,<br />

String to)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a Session with from as sender, with to as recipient.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If the argument is null then it is<br />

by default set to the preferred public user identity from this core service. If it has a domain name of<br />

anonymous.invalid then the originator will be kept anonymous according to [RFC3323] and<br />

[RFC3325].<br />

The format of SIP URI is described in [RFC3261], TEL URI in [RFC3966], and display names in<br />

general in [RFC5322].<br />

to - the recipient SIP or TEL URI with an optional display name.<br />

Returns:<br />

a new Session<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the Session could not be created<br />

IllegalArgumentException - if the to argument is null,<br />

if the syntax of the from or to argument is invalid<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 56 of 199


Interface CoreService<br />

createReference<br />

Reference createReference(String from,<br />

String to,<br />

String referTo,<br />

String referMethod)<br />

throws ServiceClosedException,<br />

ImsException<br />

Creates a Reference with from as sender, addressed to to and referTo as the URI to refer to.<br />

Parameters:<br />

from - the sender SIP or TEL URI with an optional display name. If null, it is assumed to be the<br />

local user identity of the Service<br />

to - the recipient SIP or TEL URI with an optional display name<br />

referTo - any URI, not just a user id<br />

referMethod - the reference method to be used by the reference request, e.g. "INVITE", "BYE" or<br />

null<br />

Returns:<br />

a new Reference<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

ImsException - if the Reference could not be created<br />

IllegalArgumentException - if the to or referTo argument is null,<br />

if the syntax of the from, to is invalid, or if referTo argument is null,<br />

if the syntax of the referMethod argument is invalid<br />

setListener<br />

void setListener(CoreServiceListener listener)<br />

Sets a listener for this CoreService, replacing any previous CoreServiceListener. A null removes any<br />

existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 57 of 199


Class CoreServiceException<br />

Class CoreServiceException<br />

javax.microedition.ims.core<br />

java.lang.Object<br />

java.lang.Throwable<br />

java.lang.Exception<br />

java.io.IOException<br />

javax.microedition.ims.core.CoreServiceException<br />

public class CoreServiceException<br />

extends java.io.IOException<br />

A CoreServiceException indicates that a CoreService could not be created.<br />

Constructor Summary<br />

CoreServiceException(ReasonInfo reason)<br />

Constructs a CoreServiceException with the specified detail message.<br />

Page<br />

58<br />

Method Summary<br />

ReasonInfo getReasonInfo()<br />

Returns a ReasonInfo that indicates why the CoreService was closed.<br />

Page<br />

58<br />

Constructor Detail<br />

CoreServiceException<br />

public CoreServiceException(ReasonInfo reason)<br />

Constructs a CoreServiceException with the specified detail message. The error message string reason<br />

can later be retrieved by the Throwable.getMessage() method of class java.lang.Throwable.<br />

Parameters:<br />

reason - the detail message<br />

Method Detail<br />

getReasonInfo<br />

public ReasonInfo getReasonInfo()<br />

Returns a ReasonInfo that indicates why the CoreService was closed.<br />

Returns:<br />

a ReasonInfo<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 58 of 199


Interface CoreServiceListener<br />

Interface CoreServiceListener<br />

javax.microedition.ims.core<br />

public interface CoreServiceListener<br />

A listener type for receiving notifications on remotely initiated core service methods.<br />

See Also:<br />

CoreService.setListener(CoreServiceListener)<br />

Method Summary<br />

void pageMessageReceived(CoreService service, PageMessage message)<br />

Notifies the application when a page message is received from a remote endpoint.<br />

void referenceReceived(CoreService service, Reference reference)<br />

Notifies the application when a reference request is received from a remote endpoint.<br />

void serviceClosed(CoreService service, ReasonInfo reason)<br />

Notifies the application when a CoreService is closed.<br />

void sessionInvitationReceived(CoreService service, Session session)<br />

Notifies the application when a session invitation is received from a remote endpoint.<br />

void unsolicitedNotifyReceived(CoreService service, Message notify)<br />

Notifies the application when an unsolicited notify is received.<br />

Page<br />

59<br />

60<br />

60<br />

59<br />

60<br />

Method Detail<br />

pageMessageReceived<br />

void pageMessageReceived(CoreService service,<br />

PageMessage message)<br />

Notifies the application when a page message is received from a remote endpoint.<br />

Parameters:<br />

service - the concerned Service<br />

message - the received PageMessage<br />

sessionInvitationReceived<br />

void sessionInvitationReceived(CoreService service,<br />

Session session)<br />

Notifies the application when a session invitation is received from a remote endpoint.<br />

Parameters:<br />

service - the concerned Service<br />

session - the received session invitation<br />

See Also:<br />

Session.accept(), Session.reject()<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 59 of 199


Interface CoreServiceListener<br />

referenceReceived<br />

void referenceReceived(CoreService service,<br />

Reference reference)<br />

Notifies the application when a reference request is received from a remote endpoint.<br />

Only references that are created outside of a session are notified in this method.<br />

Parameters:<br />

service - the concerned Service<br />

reference - the received reference<br />

unsolicitedNotifyReceived<br />

void unsolicitedNotifyReceived(CoreService service,<br />

Message notify)<br />

Notifies the application when an unsolicited notify is received. This notify request is received outside any<br />

existing subscription.<br />

Parameters:<br />

service - the concerned Service<br />

notify - the received notify<br />

serviceClosed<br />

void serviceClosed(CoreService service,<br />

ReasonInfo reason)<br />

Notifies the application when a CoreService is closed.<br />

Parameters:<br />

service - the concerned Service<br />

reason - a ReasonInfo to indicate why the CoreService was closed<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 60 of 199


Class ImscoreProtocolPermission<br />

Class ImscoreProtocolPermission<br />

javax.microedition.ims.core<br />

java.lang.Object<br />

java.security.Permission<br />

javax.microedition.io.GCFPermission<br />

javax.microedition.ims.core.ImscoreProtocolPermission<br />

public class ImscoreProtocolPermission<br />

extends javax.microedition.io.GCFPermission<br />

This class represents permission to connections using the imscore connector string. There is no action list defined<br />

for the class.<br />

The syntax of the imscore connector string is defined in javax.microedition.imscore package.<br />

Constructor Summary<br />

ImscoreProtocolPermission(String imscore)<br />

Creates a new ImscorePermission with the specified imscore connector string as its name.<br />

Page<br />

61<br />

Method Summary<br />

boolean equals(Object obj)<br />

Checks two ImscorePermission objects for equality.<br />

String getActions()<br />

Returns the canonical string representation of the actions, which currently is the empty string<br />

"", since there are no actions defined for ImscoreProtocolPermission.<br />

int hashCode()<br />

Returns the hash code value for this object.<br />

boolean implies(java.security.Permission p)<br />

Checks if this ImscoreProtocolPermission object "implies" the specified permission.<br />

Page<br />

62<br />

62<br />

62<br />

62<br />

Methods inherited from class javax.microedition.io.GCFPermission<br />

getProtocol, getURI<br />

Methods inherited from class java.security.Permission<br />

getName, newPermissionCollection, toString<br />

Constructor Detail<br />

ImscoreProtocolPermission<br />

public ImscoreProtocolPermission(String imscore)<br />

Creates a new ImscorePermission with the specified imscore connector string as its name. The string<br />

must either conform to the specification of the imscore connector string identifying a core service, or be<br />

"imscore://*" meaning that the permission applies to any imscore connector string in the <strong>IMS</strong> application<br />

suite.<br />

Parameters:<br />

imscore - the imscore URI connector string<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 61 of 199


Class ImscoreProtocolPermission<br />

Throws:<br />

IllegalArgumentException - if imscore is null or otherwise malformed<br />

Method Detail<br />

equals<br />

public boolean equals(Object obj)<br />

Checks two ImscorePermission objects for equality.<br />

Overrides:<br />

equals in class java.security.Permission<br />

Parameters:<br />

obj - the object we are testing for equality with this object.<br />

Returns:<br />

true if obj is a ImscoreProtocolPermission and has the same connector string as this<br />

ImscoreProtocolPermission object<br />

getActions<br />

public String getActions()<br />

Returns the canonical string representation of the actions, which currently is the empty string "", since there<br />

are no actions defined for ImscoreProtocolPermission.<br />

Overrides:<br />

getActions in class java.security.Permission<br />

Returns:<br />

the empty string ""<br />

See Also:<br />

java.security.Permission.getActions()<br />

hashCode<br />

public int hashCode()<br />

Returns the hash code value for this object.<br />

Overrides:<br />

hashCode in class java.security.Permission<br />

Returns:<br />

a hash code value for this object.<br />

implies<br />

public boolean implies(java.security.Permission p)<br />

Checks if this ImscoreProtocolPermission object "implies" the specified permission. This is always<br />

false, since there are no permissions implied for ImscoreProtocolPermission.<br />

Overrides:<br />

implies in class java.security.Permission<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 62 of 199


Class ImscoreProtocolPermission<br />

Parameters:<br />

p - the permission to check against.<br />

Returns:<br />

false<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 63 of 199


Interface Message<br />

Interface Message<br />

javax.microedition.ims.core<br />

public interface Message<br />

The Message interface provides functionality to manipulate headers and body parts of SIP messages.<br />

This is an interface for use in advanced applications.<br />

A Message can be retrieved by calling ServiceMethod.getNextRequest, ServiceMethod.getPreviousRequest,<br />

ServiceMethod.getNextResponse or ServiceMethod.getPreviousResponses.<br />

Modifying headers<br />

The <strong>IMS</strong><strong>API</strong> allows the application to read and write to SIP message headers. A header with no predefined<br />

meaning or standard can be read and written without restriction. If the header is covered in a standard, then any<br />

modification to the header must be in accordance to the standard.<br />

Modifying the 'Content-Type' header<br />

The 'Content-Type' header can only be set on messages with more than one bodypart, and only to 'multipart/*'. See<br />

also section below on Modifying message bodies.<br />

Read-only headers<br />

These headers can only be read, an ImsException should be thrown if the application tries to modify them:<br />

Accept-Contact, Call-ID, Contact, Content-Length, CSeq, Event, From, P-Access-Network-Info,<br />

P-Asserted-Identity, P-Associated-URI, P-Preferred-Identity, RAck, Refer-To, Referred-By, Replaces,<br />

RSeq, To, WWW-Authenticate<br />

Inaccessible headers<br />

These headers can not be read or modified, an ImsException should be thrown if the application tries to read or<br />

modify them:<br />

Authentication-Info, Authorization, Max-Forwards, Min-Expires, Proxy-Authenticate,<br />

Proxy-Authorization, Record-Route, Security-Client, Security-Server, Security-Verify,<br />

Service-Route, Via<br />

Modifying message bodies<br />

The interface allows the application to create non-recursive multi-part SIP messages bodies. The following shows<br />

how the object structure is mapped to the SIP message structure. For the sending side:<br />

• If a Message has one MessageBodyPart then the Message will have the body content and content type set<br />

to the MessageBodyPart content and content type.<br />

• If a Message has several MessageBodyParts, then each MessageBodyPart ( recursive MessageBodyPart<br />

are not possible) is mapped to a part in the SIP message body (content and headers, including the content<br />

type). The message body content type is by default set to multipart/mixed, but can be overridden by the<br />

application to be of another subtype to multipart.<br />

NOTE: For the case where the <strong>IMS</strong> engine has an SDP attached to the SIP message, then that is handled<br />

as if it were a MessageBodyPart not accessible to the application.<br />

For the receiving side:<br />

• A SIP message with a body where content type is not multipart is handled as a Message with one<br />

MessageBodyPart and that content type.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 64 of 199


Interface Message<br />

• A multipart message (of any subtype) is parsed and each part on the top level is mapped to a<br />

MessageBodyPart (nested multi-part messages cannot be mapped to recursive MessageBodyParts).<br />

Note: Any SDP part discovered here shall not be mapped to a MessageBodyPart accessible to the<br />

application, unless it is part of an OPTIONS response.<br />

See [RFC3261] for more information about headers and body parts in a request messages.<br />

See Also:<br />

ServiceMethod<br />

Field Summary<br />

int CAPABILITIES_QUERY<br />

Identifier for the queryCapabilities method on the Capabilities interface.<br />

int PAGEMESSAGE_SEND<br />

Identifier for the send method on the PageMessage interface.<br />

int PUBLICATION_PUBLISH<br />

Identifier for the publish method on the Publication interface.<br />

int PUBLICATION_UNPUBLISH<br />

Identifier for the unpublish method on the Publication interface.<br />

int REFERENCE_REFER<br />

Identifier for the refer method on the Reference interface.<br />

int SESSION_START<br />

Identifier for the start method on the Session interface.<br />

int SESSION_TERMINATE<br />

Identifier for the terminate method on the Session interface.<br />

int SESSION_UPDATE<br />

Identifier for the update method on the Session interface.<br />

int STATE_RECEIVED<br />

This state specifies that this Message was received from a remote endpoint.<br />

int STATE_SENT<br />

This state specifies that the Message is sent from the local endpoint.<br />

int STATE_UNSENT<br />

This state specifies that the Message is unsent.<br />

int SUBSCRIPTION_POLL<br />

Identifier for the poll method on the Subscription interface.<br />

int SUBSCRIPTION_SUBSCRIBE<br />

Identifier for the subscribe method on the Subscription interface.<br />

int SUBSCRIPTION_UNSUBSCRIBE<br />

Identifier for the unsubscribe method on the Subscription interface.<br />

Page<br />

66<br />

66<br />

66<br />

66<br />

66<br />

66<br />

67<br />

67<br />

67<br />

67<br />

67<br />

67<br />

67<br />

67<br />

Method Summary<br />

void addHeader(String key, String value)<br />

Adds a header value, either on a new header or appending a new value to an<br />

already existing header.<br />

MessageBodyPart createBodyPart()<br />

Creates a new MessageBodyPart and adds it to the message.<br />

MessageBodyPart[] getBodyParts()<br />

Returns all body parts that are added to the message.<br />

String[] getHeaders(String key)<br />

Returns the value(s) of a header in this message.<br />

Page<br />

68<br />

68<br />

68<br />

68<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 65 of 199


Interface Message<br />

String getMethod()<br />

Returns the SIP method for this Message.<br />

String getReasonPhrase()<br />

Returns the reason phrase of the response.<br />

int getState()<br />

Returns the current state of this Message.<br />

int getStatusCode()<br />

Returns the status code of the response.<br />

69<br />

69<br />

69<br />

69<br />

Field Detail<br />

CAPABILITIES_QUERY<br />

public static final int CAPABILITIES_QUERY<br />

Identifier for the queryCapabilities method on the Capabilities interface.<br />

PAGEMESSAGE_SEND<br />

public static final int PAGEMESSAGE_SEND<br />

Identifier for the send method on the PageMessage interface.<br />

PUBLICATION_PUBLISH<br />

public static final int PUBLICATION_PUBLISH<br />

Identifier for the publish method on the Publication interface.<br />

PUBLICATION_UNPUBLISH<br />

public static final int PUBLICATION_UNPUBLISH<br />

Identifier for the unpublish method on the Publication interface.<br />

REFERENCE_REFER<br />

public static final int REFERENCE_REFER<br />

Identifier for the refer method on the Reference interface.<br />

SESSION_START<br />

public static final int SESSION_START<br />

Identifier for the start method on the Session interface.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 66 of 199


Interface Message<br />

SESSION_UPDATE<br />

public static final int SESSION_UPDATE<br />

Identifier for the update method on the Session interface.<br />

SESSION_TERMINATE<br />

public static final int SESSION_TERMINATE<br />

Identifier for the terminate method on the Session interface.<br />

SUBSCRIPTION_SUBSCRIBE<br />

public static final int SUBSCRIPTION_SUBSCRIBE<br />

Identifier for the subscribe method on the Subscription interface.<br />

SUBSCRIPTION_UNSUBSCRIBE<br />

public static final int SUBSCRIPTION_UNSUBSCRIBE<br />

Identifier for the unsubscribe method on the Subscription interface.<br />

SUBSCRIPTION_POLL<br />

public static final int SUBSCRIPTION_POLL<br />

Identifier for the poll method on the Subscription interface.<br />

STATE_UNSENT<br />

public static final int STATE_UNSENT<br />

This state specifies that the Message is unsent.<br />

STATE_SENT<br />

public static final int STATE_SENT<br />

This state specifies that the Message is sent from the local endpoint.<br />

STATE_RECEIVED<br />

public static final int STATE_RECEIVED<br />

This state specifies that this Message was received from a remote endpoint.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 67 of 199


Interface Message<br />

Method Detail<br />

createBodyPart<br />

MessageBodyPart createBodyPart()<br />

throws ImsException<br />

Creates a new MessageBodyPart and adds it to the message.<br />

Returns:<br />

a MessageBodyPart<br />

Throws:<br />

ImsException - if the body part could not be created<br />

IllegalStateException - if the Message is not in STATE_UNSENT<br />

getBodyParts<br />

MessageBodyPart[] getBodyParts()<br />

Returns all body parts that are added to the message.<br />

Note: If the body part is a Session Description Protocol (SDP) it is only returned if the Message is a<br />

response to a capability request.<br />

Returns:<br />

a copy of all MessageBodyParts in the message body, an empty array will be returned if there are<br />

no body parts in the Message<br />

addHeader<br />

void addHeader(String key,<br />

String value)<br />

throws ImsException<br />

Adds a header value, either on a new header or appending a new value to an already existing header.<br />

The header(s) that can be added must be defined in the Write property of the JAD file or set with the<br />

setRegistry method in the Configuration class.<br />

Parameters:<br />

key - the header name, in full form (see RFC3261)<br />

value - the header value<br />

Throws:<br />

ImsException - if the key is not a defined header or a restricted header<br />

IllegalArgumentException - if the key is null or invalid,<br />

if the value is null or invalid<br />

IllegalStateException - if the Message is not in STATE_UNSENT<br />

getHeaders<br />

String[] getHeaders(String key)<br />

throws ImsException<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 68 of 199


Interface Message<br />

Returns the value(s) of a header in this message. The header must be defined in the Read property of the<br />

JAD file or set with the setRegistry method in the Configuration class.<br />

Parameters:<br />

key - the header name, in full form (see RFC3261)<br />

Returns:<br />

an array of all value(s) of the header, an empty array is returned if the header does not exist<br />

Throws:<br />

ImsException - if the key is not a defined header or a restricted header<br />

getMethod<br />

String getMethod()<br />

Returns the SIP method for this Message.<br />

Returns:<br />

SIP method name, INVITE, UPDATE, BYE, etc. or null if the method is not available<br />

getState<br />

int getState()<br />

Returns the current state of this Message.<br />

Returns:<br />

the current state of this Message<br />

getStatusCode<br />

int getStatusCode()<br />

Returns the status code of the response. This method can only be used for response messages as request<br />

messages do not have a status code.<br />

See [RFC3261] (chapter 7.2 Responses) for more detailed information.<br />

Returns:<br />

the status code, returns 0 if the status code is not available<br />

getReasonPhrase<br />

String getReasonPhrase()<br />

Returns the reason phrase of the response. This method can only be used for response messages as<br />

request messages do not have a reason phrase.<br />

Returns:<br />

the reason phrase or null if the reason phrase is not available<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 69 of 199


Interface MessageBodyPart<br />

Interface MessageBodyPart<br />

javax.microedition.ims.core<br />

public interface MessageBodyPart<br />

A MessageBodyPart can contain different kinds of content, for example text, an image or an audio clip.<br />

There are two main uses for a MessageBodyPart:<br />

• A MessageBodyPart can be created and attached to the next outgoing request Message by calling<br />

createBodyPart on a Message.<br />

• A MessageBodyPart can be extracted from a previously sent or received Message by calling getBodyParts<br />

on a Message.<br />

See [RFC2045, 2046] for more information about body parts. [RFC2045] also describes some possible headers to<br />

set with the setHeader method.<br />

See Also:<br />

ServiceMethod, Message<br />

Method Summary<br />

String getHeader(String key)<br />

Returns the value of a header in this MessageBodyPart.<br />

java.io.InputStream openContentInputStream()<br />

Opens an InputStream to read the content of the MessageBodyPart.<br />

java.io.OutputStream openContentOutputStream()<br />

Opens an OutputStream to write the content of the MessageBodyPart.<br />

void setHeader(String key, String value)<br />

Sets a header to the MessageBodyPart.<br />

Page<br />

71<br />

70<br />

70<br />

71<br />

Method Detail<br />

openContentInputStream<br />

java.io.InputStream openContentInputStream()<br />

throws java.io.IOException<br />

Opens an InputStream to read the content of the MessageBodyPart.<br />

Returns:<br />

an InputStream to read the content of the MessageBodyPart<br />

Throws:<br />

java.io.IOException - if the InputStream could not be opened<br />

See Also:<br />

openContentOutputStream()<br />

openContentOutputStream<br />

java.io.OutputStream openContentOutputStream()<br />

throws java.io.IOException<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 70 of 199


Interface MessageBodyPart<br />

Opens an OutputStream to write the content of the MessageBodyPart. If the OutputStream is not closed, it<br />

will be closed by the ServiceMethod that invoked a transmission of the Message.<br />

Returns:<br />

an OutputStream to write the content of the MessageBodyPart<br />

Throws:<br />

java.io.IOException - if the OutputStream could not be opened or if the OutputStream already<br />

has been opened<br />

IllegalStateException - if the Message is not in STATE_UNSENT<br />

See Also:<br />

openContentInputStream()<br />

setHeader<br />

void setHeader(String key,<br />

String value)<br />

Sets a header to the MessageBodyPart. If the header key already exists the value will be replaced.<br />

Only headers with the prefix "Content-" are allowed to set with this method.<br />

Parameters:<br />

key - the header name, in full form (see RFC3261)<br />

value - the header value<br />

Throws:<br />

IllegalArgumentException - if the key is null or invalid,<br />

if the value is null or invalid<br />

IllegalStateException - if the Message is not in STATE_UNSENT<br />

See Also:<br />

getHeader(String)<br />

getHeader<br />

String getHeader(String key)<br />

Returns the value of a header in this MessageBodyPart.<br />

Only headers with the prefix "Content-" are allowed to be retrieved with this method.<br />

Parameters:<br />

key - the header name, in full form (see RFC3261)<br />

Returns:<br />

a string containing the header value or null if the header does not exist<br />

Throws:<br />

IllegalArgumentException - if the key is null or invalid<br />

See Also:<br />

setHeader(String, String)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 71 of 199


Interface PageMessage<br />

Interface PageMessage<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface PageMessage<br />

extends ServiceMethod<br />

The PageMessage interface is used for simple instant messages or exchange of small amounts of content outside<br />

of a session.<br />

The life cycle consist of three states, STATE_UNSENT, STATE_SENT and STATE_RECEIVED.<br />

A PageMessage created with the factory method createPageMessage in the CoreService interface will reside in<br />

STATE_UNSENT. When the message is sent with the send method the state will transit to STATE_SENT and further<br />

send requests cannot be made on the same PageMessage.<br />

An incoming PageMessage will always reside in STATE_RECEIVED.<br />

Example of sending a simple PageMessage<br />

try {<br />

PageMessage pageMessage;<br />

pageMessage = service.createPageMessage(null, "sip:baloo@lalaa.net");<br />

pageMessage.setListener(this);<br />

pageMessage.send("Hi, I'm Alice!".getBytes(),"text/plain");<br />

} catch (Exception e) {<br />

//handle Exceptions<br />

}<br />

Example of sending a multipart PageMessage<br />

try {<br />

PageMessage pageMessage;<br />

pageMessage = service.createPageMessage(null, "sip:baloo@lalaa.net");<br />

pageMessage.setListener(this);<br />

Message message = pageMessage.getNextRequest();<br />

// add first body part<br />

MessageBodyPart part1 = message.createBodyPart();<br />

part1.setHeader("Content-Type", "text/plain");<br />

OutputStream os = part1.openContentOutputStream();<br />

os.write(...);<br />

os.close();<br />

// add following body parts<br />

MessageBodyPart part2 = message.createBodyPart();<br />

...<br />

// when all body parts has been added<br />

pageMessage.send(null, null);<br />

} catch (Exception e) {<br />

//handle Exceptions<br />

}<br />

Example of receiving a PageMessage<br />

The callback method pageMessageReceived is found in the CoreServiceListener interface.<br />

public void pageMessageReceived(CoreService service,<br />

PageMessage pageMessage) {<br />

pageMessage.getContent();<br />

... // process content<br />

}<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 72 of 199


Interface PageMessage<br />

See Also:<br />

CoreService.createPageMessage(String, String),<br />

CoreServiceListener.pageMessageReceived(CoreService, PageMessage)<br />

Field Summary<br />

int STATE_RECEIVED<br />

This state specifies that this PageMessage was received from a remote endpoint.<br />

int STATE_SENT<br />

This state specifies that the PageMessage is sent.<br />

int STATE_UNSENT<br />

This state specifies that the PageMessage is unsent.<br />

Page<br />

73<br />

73<br />

73<br />

Method Summary<br />

byte[] getContent()<br />

String getContentType()<br />

Returns the content from this PageMessage.<br />

Returns the content MIME type of this PageMessage.<br />

int getState()<br />

Returns the current state of this PageMessage.<br />

void send(byte[] content, String contentType)<br />

Sends the PageMessage.<br />

void setListener(PageMessageListener listener)<br />

Sets a listener for this PageMessage, replacing any previous PageMessageListener.<br />

Page<br />

74<br />

74<br />

75<br />

74<br />

74<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_UNSENT<br />

public static final int STATE_UNSENT<br />

This state specifies that the PageMessage is unsent.<br />

STATE_SENT<br />

public static final int STATE_SENT<br />

This state specifies that the PageMessage is sent.<br />

STATE_RECEIVED<br />

public static final int STATE_RECEIVED<br />

This state specifies that this PageMessage was received from a remote endpoint.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 73 of 199


Interface PageMessage<br />

Method Detail<br />

send<br />

void send(byte[] content,<br />

String contentType)<br />

throws ServiceClosedException<br />

Sends the PageMessage.<br />

This method can be invoked send(null, null) if the application uses the Message interface to fill the<br />

content. In the case that the application uses both the Message interface and send(content,<br />

contentType), the content will be added as the last body part.<br />

The PageMessage will transit to STATE_SENT after calling this method. See example above.<br />

Parameters:<br />

content - a byte array containing the content to be sent<br />

contentType - the content MIME type<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the PageMessage is not in STATE_UNSENT<br />

IllegalArgumentException - if the syntax of the contentType argument is invalid or if one of the<br />

arguments is null<br />

setListener<br />

void setListener(PageMessageListener listener)<br />

Sets a listener for this PageMessage, replacing any previous PageMessageListener. A null reference is<br />

allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

getContent<br />

byte[] getContent()<br />

Returns the content from this PageMessage. This method will return the content from the first body part if<br />

there are more than one.<br />

Returns:<br />

an array containing the content<br />

Throws:<br />

IllegalStateException - if the PageMessage is not in STATE_RECEIVED<br />

getContentType<br />

String getContentType()<br />

Returns the content MIME type of this PageMessage. This method will return the content MIME type from<br />

the first body part if there are more than one.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 74 of 199


Interface PageMessage<br />

Returns:<br />

the content MIME type<br />

Throws:<br />

IllegalStateException - if the PageMessage is not in STATE_RECEIVED<br />

getState<br />

int getState()<br />

Returns the current state of this PageMessage.<br />

Returns:<br />

the current state of this PageMessage<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 75 of 199


Interface PageMessageListener<br />

Interface PageMessageListener<br />

javax.microedition.ims.core<br />

public interface PageMessageListener<br />

This listener type is used to notify the application about the status of sent page messages.<br />

See Also:<br />

PageMessage.setListener(PageMessageListener)<br />

Method Summary<br />

void pageMessageDelivered(PageMessage pageMessage)<br />

Notifies the application that the PageMessage was successfully delivered.<br />

void pageMessage<strong>Delivery</strong>Failed(PageMessage pageMessage)<br />

Notifies the application that the PageMessage was not successfully delivered.<br />

Page<br />

76<br />

76<br />

Method Detail<br />

pageMessageDelivered<br />

void pageMessageDelivered(PageMessage pageMessage)<br />

Notifies the application that the PageMessage was successfully delivered.<br />

Parameters:<br />

pageMessage - the concerned PageMessage<br />

pageMessage<strong>Delivery</strong>Failed<br />

void pageMessage<strong>Delivery</strong>Failed(PageMessage pageMessage)<br />

Notifies the application that the PageMessage was not successfully delivered.<br />

Parameters:<br />

pageMessage - the concerned PageMessage<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 76 of 199


Interface Publication<br />

Interface Publication<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface Publication<br />

extends ServiceMethod<br />

The Publication is used for publishing event state to a remote endpoint. When a publication is created, an event<br />

package must be specified which identifies the type of content that is about to be published. A typical event<br />

package is 'presence' that can be used to publish online information. Other endpoints can then subscribe to that<br />

event package and get callbacks when the subscribed user identity changes online status.<br />

The published event state will be refreshed periodically until unpublish is called. Updates of the published event<br />

state may be achieved by calling the publish method again with modified event state.<br />

The life cycle consist of three states, STATE_INACTIVE, STATE_PENDING and STATE_ACTIVE.<br />

A new Publication starts in STATE_INACTIVE and when publish is called the state transits to STATE_PENDING<br />

and remains there until a response arrives from the remote endpoint.<br />

In STATE_ACTIVE, unpublish can be called to cancel the publication and the state will then transit to<br />

STATE_PENDING and remain there until a response arrives from the remote endpoint.<br />

Example of a simple Publication<br />

try {<br />

pub = service.createPublication(null, "sip:alice@home.net", "presence");<br />

pub.setListener(this);<br />

pub.publish(onlineStatus, "application/pidf+xml");<br />

} catch(Exception e){<br />

//handle Exceptions<br />

}<br />

public void publicationDelivered(Publication pub){<br />

//if the publish was successfull<br />

}<br />

Example of a multipart Publication<br />

try {<br />

pub = service.createPublication(null, "sip:alice@home.net", "presence");<br />

pub.setListener(this);<br />

Message message = pub.getNextRequest();<br />

// add first body part<br />

MessageBodyPart part1 = message.createBodyPart();<br />

part1.setHeader("Content-Type", "application/pidf+xml");<br />

OutputStream os = part1.openContentOutputStream();<br />

os.write(...);<br />

os.close();<br />

// add following body parts<br />

MessageBodyPart part2 = message.createBodyPart();<br />

...<br />

// when all body parts have been added<br />

pub.publish(null, null);<br />

} catch(Exception e){<br />

//handle Exceptions<br />

}<br />

public void publicationDelivered(Publication pub){<br />

// if the publish was successful<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 77 of 199


Interface Publication<br />

}<br />

See Also:<br />

CoreService.createPublication(String, String, String), Subscription<br />

Field Summary<br />

int STATE_ACTIVE<br />

The Publication is active and event state is available for subscription.<br />

int STATE_INACTIVE<br />

The Publication is not active, event state is not published.<br />

int STATE_PENDING<br />

A Publication request is sent and the platform is waiting for a response.<br />

Page<br />

78<br />

78<br />

78<br />

Method Summary<br />

String getEvent()<br />

Returns the event package corresponding to this Publication.<br />

int getState()<br />

Returns the current state of the state machine of this Publication.<br />

void publish(byte[] state, String contentType)<br />

Sends a publication request with an event state to the remote endpoint.<br />

void setListener(PublicationListener listener)<br />

Sets a listener for this Publication, replacing any previous PublicationListener.<br />

void unpublish()<br />

Terminates this publication.<br />

Page<br />

79<br />

80<br />

79<br />

79<br />

79<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_INACTIVE<br />

public static final int STATE_INACTIVE<br />

The Publication is not active, event state is not published.<br />

STATE_PENDING<br />

public static final int STATE_PENDING<br />

A Publication request is sent and the platform is waiting for a response.<br />

STATE_ACTIVE<br />

public static final int STATE_ACTIVE<br />

The Publication is active and event state is available for subscription.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 78 of 199


Interface Publication<br />

Method Detail<br />

publish<br />

void publish(byte[] state,<br />

String contentType)<br />

throws ServiceClosedException<br />

Sends a publication request with an event state to the remote endpoint.<br />

This method can be invoked publish(null, null) if the application uses the Message interface to fill the<br />

event state. In the case that the application uses both the Message interface and publish(state,<br />

contentType), the event state will be added as the last body part.<br />

The Publication will transit to STATE_PENDING after calling this method. See example above.<br />

Parameters:<br />

state - event state to publish<br />

contentType - the content MIME type<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Publication is in STATE_PENDING<br />

IllegalArgumentException - if the syntax of the contentType argument is invalid or if one of the<br />

arguments is null<br />

unpublish<br />

void unpublish()<br />

throws ServiceClosedException<br />

Terminates this publication.<br />

The Publication will transit to STATE_PENDING after calling this method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Publication is not in STATE_ACTIVE<br />

setListener<br />

void setListener(PublicationListener listener)<br />

Sets a listener for this Publication, replacing any previous PublicationListener. A null reference is<br />

allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

getEvent<br />

String getEvent()<br />

Returns the event package corresponding to this Publication.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 79 of 199


Interface Publication<br />

Returns:<br />

the event package<br />

getState<br />

int getState()<br />

Returns the current state of the state machine of this Publication.<br />

Returns:<br />

the current state<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 80 of 199


Interface PublicationListener<br />

Interface PublicationListener<br />

javax.microedition.ims.core<br />

public interface PublicationListener<br />

This listener type is used to notify the application of the status of requested publications.<br />

See Also:<br />

Publication.setListener(PublicationListener)<br />

Method Summary<br />

void publicationDelivered(Publication publication)<br />

Notifies the application that the publication request was successfully delivered.<br />

void publication<strong>Delivery</strong>Failed(Publication publication)<br />

Notifies the application that the publication request was not successfully delivered.<br />

void publicationTerminated(Publication publication)<br />

Notifies the application that the publication was terminated.<br />

Page<br />

81<br />

81<br />

81<br />

Method Detail<br />

publicationDelivered<br />

void publicationDelivered(Publication publication)<br />

Notifies the application that the publication request was successfully delivered.<br />

The Publication has transited to STATE_ACTIVE.<br />

Parameters:<br />

publication - the concerned Publication<br />

publication<strong>Delivery</strong>Failed<br />

void publication<strong>Delivery</strong>Failed(Publication publication)<br />

Notifies the application that the publication request was not successfully delivered.<br />

The Publication has transited to either STATE_ACTIVE or STATE_INACTIVE.<br />

Parameters:<br />

publication - the concerned Publication<br />

publicationTerminated<br />

void publicationTerminated(Publication publication)<br />

Notifies the application that the publication was terminated.<br />

The Publication has transited to STATE_INACTIVE.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 81 of 199


Interface PublicationListener<br />

Parameters:<br />

publication - the concerned Publication<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 82 of 199


Interface Reference<br />

Interface Reference<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface Reference<br />

extends ServiceMethod<br />

The Reference is used for referring a remote endpoint to a third party user or service. The Reference can be<br />

created and received both inside and outside of a session.<br />

Figure 1: The left figure shows the states for the local endpoint, the right figure shows the states for the remote<br />

endpoint.<br />

A Reference has four states: STATE_INITIATED, STATE_PROCEEDING, STATE_REFERRING and STATE_TERMINATED.<br />

Reference States<br />

This section describes the semantics for each of the Reference states at the local and remote endpoint.<br />

Local endpoint<br />

STATE_INITIATED<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 83 of 199


Interface Reference<br />

When a Reference is created it will enter STATE_INITIATED.<br />

A Reference transits to:<br />

• STATE_PROCEEDING when refer is called on the Reference.<br />

STATE_PROCEEDING<br />

When refer is called the Reference enters STATE_PROCEEDING. Once this state is entered the communication with<br />

the remote endpoint starts and a reference is sent to the remote endpoint.<br />

A Reference transits to:<br />

• STATE_REFERRING if the remote endpoint received the reference. The referenceDelivered method will be<br />

invoked.<br />

• STATE_TERMINATED if the remote endpoint did not receive the reference. The reference<strong>Delivery</strong>Failed<br />

method will be invoked. If the reference was sent with the implicitSubscription argument set to false, the<br />

referenceDelivered method will be invoked.<br />

STATE_REFERRING<br />

In this state the Reference has been received but not necessarily accepted by the remote endpoint. The status of<br />

the reference can be monitored by inspecting the message body in notifications that are received in the<br />

referenceNotify callback on the ReferenceListener.<br />

A Reference transits to:<br />

• STATE_TERMINATED if the reference is considered as terminated. The referenceTerminated method will<br />

be invoked.<br />

STATE_TERMINATED<br />

In this state the Reference has been rejected or terminated and any further actions on the Reference object are<br />

invalid.<br />

Remote endpoint<br />

STATE_PROCEEDING<br />

An incoming reference request always starts in STATE_PROCEEDING.<br />

A Reference transits to:<br />

• STATE_REFERRING if accept is called on the reference.<br />

• STATE_TERMINATED if reject is called on the reference.<br />

STATE_REFERRING<br />

The remote endpoint has accepted the reference and is now responsible to contact the third party with the<br />

reference method provided with the getReferMethod. The remote endpoint should also connect the reference to<br />

the <strong>IMS</strong> engine so that notifications can be sent to the endpoint that issued the reference.<br />

A Reference transits to:<br />

• STATE_TERMINATED if the remote endpoint contacted the third party or if the reference has failed. The<br />

referenceTerminated method will be invoked<br />

STATE_TERMINATED<br />

The Reference is considered as terminated and any further actions on the Reference object are invalid.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 84 of 199


Interface Reference<br />

Example usage of Reference<br />

The scenario below illustrates how Reference can be used to make a reference to a third party user, in this case<br />

Charlotte. Figure 2 shows the interaction between Alice, Bob and Charlotte. Alice's application is an <strong>IMS</strong><br />

Application running on her device, for instance a mobile phone.<br />

Create a Reference<br />

In this example code, Alice sends an INVITE refer method to Bob referring to Charlotte, and requests that Bob<br />

sends reference notifications in return.<br />

try {<br />

Reference ref = service.createReference("sip:alice@home.net",<br />

"sip:bob@home.net",<br />

"sip:charlotte@home.net",<br />

"INVITE");<br />

ref.setListener(this)<br />

ref.refer(true);<br />

} catch(Exception e){<br />

//handle Exceptions<br />

}<br />

public void referenceDelivered(Reference reference) {<br />

// if the reference was delivered<br />

}<br />

public void reference<strong>Delivery</strong>Failed(Reference reference) {<br />

// if the reference was not delivered<br />

}<br />

public void referenceNotify(Reference reference, Message notify){<br />

// check progress of the reference<br />

}<br />

public void referenceTerminated(Reference reference) {<br />

// the reference is terminated<br />

}<br />

Accept a Reference<br />

Bob receives a reference request and decides to accept it.<br />

public void referenceReceived(CoreService service, Reference reference) {<br />

String referToUserId = reference.getReferToUserId();<br />

String referMethod = reference.getReferMethod();<br />

// notify the application of the reference<br />

...<br />

reference.accept();<br />

// assume referMethod == "INVITE"<br />

mySession = service.createSession(null, referToUserId);<br />

// Interpret the INVITE refer method as a request to initiate<br />

// a session with the third party<br />

reference.connectReferMethod((ServiceMethod)mySession);<br />

// start the reference with the third party<br />

mySession.start();<br />

}<br />

In the call below, the referTo URI is a local TEL URI:<br />

try {<br />

Reference ref =<br />

service.createReference("Alice ",<br />

"Bob ",<br />

"Carol ",<br />

"INVITE");<br />

ref.refer(true);<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 85 of 199


Interface Reference<br />

The referTo URI is a http URI:<br />

try {<br />

Reference ref =<br />

service.createReference("Alice ",<br />

"Bob ",<br />

"http://example.com",<br />

null);<br />

ref.refer(true);<br />

The referTo URI is a cid:. This is for example used in multiple-refer [RFC5368] to conference servers.<br />

try {<br />

Reference ref =<br />

service.createReference("Alice ",<br />

"Bob ",<br />

"",<br />

null);<br />

// Make sure that the remote can process multiple refer<br />

ref.getNextRequest().addHeader("require", "multiple-refer");<br />

// No notifications wanted<br />

ref.refer(false);<br />

Figure 2: A simplified picture of the interaction between Alice, Bob and Charlotte with reference.refer(true).<br />

referenceNotify listener is not invoked if refer argument is set to false.<br />

See Also:<br />

CoreService.createReference(String, String, String, String), Session.createReference(String,<br />

String), CoreServiceListener, ReferenceListener<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 86 of 199


Interface Reference<br />

Field Summary<br />

int STATE_INITIATED<br />

This state specifies that the Reference is created but not started.<br />

int STATE_PROCEEDING<br />

This state specifies that the Reference has been started.<br />

int STATE_REFERRING<br />

This state specifies that the Reference has been accepted and that the remote endpoint is<br />

referring to the third party.<br />

int STATE_TERMINATED<br />

This state specifies that the Reference has been rejected or terminated.<br />

Page<br />

87<br />

87<br />

88<br />

88<br />

Method Summary<br />

void accept()<br />

Accepts an incoming reference request.<br />

void connectReferMethod(ServiceMethod serviceMethod)<br />

This method connects a service method with this reference and allows the <strong>IMS</strong> engine to<br />

send notifications regarding this reference to the endpoint that initiated this reference.<br />

String getReferMethod()<br />

Returns the reference method to be used.<br />

String getReferToUserId()<br />

Returns the URI to refer to, optionally with a display name.<br />

String getReplaces()<br />

Returns the value of the replaces parameter of the Refer-To header.<br />

int getState()<br />

Returns the current state of this Reference.<br />

void refer(boolean implicitSubscription)<br />

Sends the reference request to the remote endpoint.<br />

void reject()<br />

Rejects an incoming reference request.<br />

void setListener(ReferenceListener listener)<br />

Sets a listener for this Reference, replacing any previous ReferenceListener.<br />

void setReplaces(String sessionId)<br />

Sets the replaces parameter of the Refer-To header to the given identity.<br />

Page<br />

89<br />

90<br />

89<br />

88<br />

89<br />

90<br />

88<br />

90<br />

90<br />

89<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_INITIATED<br />

public static final int STATE_INITIATED<br />

This state specifies that the Reference is created but not started.<br />

STATE_PROCEEDING<br />

public static final int STATE_PROCEEDING<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 87 of 199


Interface Reference<br />

This state specifies that the Reference has been started.<br />

STATE_REFERRING<br />

public static final int STATE_REFERRING<br />

This state specifies that the Reference has been accepted and that the remote endpoint is referring to the<br />

third party.<br />

STATE_TERMINATED<br />

public static final int STATE_TERMINATED<br />

This state specifies that the Reference has been rejected or terminated.<br />

Method Detail<br />

refer<br />

void refer(boolean implicitSubscription)<br />

throws ServiceClosedException<br />

Sends the reference request to the remote endpoint.<br />

The Reference will transit to STATE_PROCEEDING after calling this method.<br />

The implicitSubscription argument indicates if this request should generate a implicit subscription. If<br />

true the Reference transits to STATE_REFERRING and the sender gets reports on the progress of the<br />

reference processing at the remote. If false, the sender will only know if the request was received. The<br />

Reference transits to STATE_TERMINATED when the delivery report is received.<br />

Parameters:<br />

implicitSubscription - true if this Reference should generate an implicit subscription, false<br />

otherwise<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Reference is not in STATE_INITIATED<br />

See Also:<br />

ReferenceListener.referenceDelivered(Reference)<br />

getReferToUserId<br />

String getReferToUserId()<br />

Returns the URI to refer to, optionally with a display name.<br />

Returns:<br />

the URI, optionally with a display name.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 88 of 199


Interface Reference<br />

getReferMethod<br />

String getReferMethod()<br />

Returns the reference method to be used.<br />

Returns:<br />

the reference method<br />

setReplaces<br />

void setReplaces(String sessionId)<br />

Sets the replaces parameter of the Refer-To header to the given identity. The application shall use the<br />

value of SessionDescriptor.getSessionId()<br />

Parameters:<br />

sessionId - the identity of the Session to replace<br />

Throws:<br />

IllegalStateException - if the Reference is not in STATE_INITIATED<br />

IllegalArgumentException - if the sessionId argument does not designate an established<br />

session, is null or an empty string<br />

See Also:<br />

getReplaces(), SessionDescriptor.getSessionId()<br />

getReplaces<br />

String getReplaces()<br />

Returns the value of the replaces parameter of the Refer-To header.<br />

Returns:<br />

the value or null the value is not available<br />

See Also:<br />

setReplaces(String)<br />

accept<br />

void accept()<br />

throws ServiceClosedException<br />

Accepts an incoming reference request.<br />

The Reference will transit to STATE_REFERRING after calling this method.<br />

Note: After calling this method the application has the responsibility to establish a connection to the third<br />

party depending on the refer method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Reference is not in STATE_PROCEEDING<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 89 of 199


Interface Reference<br />

reject<br />

void reject()<br />

throws ServiceClosedException<br />

Rejects an incoming reference request.<br />

The Reference will transit to STATE_TERMINATED after calling this method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Reference is not in STATE_PROCEEDING<br />

connectReferMethod<br />

void connectReferMethod(ServiceMethod serviceMethod)<br />

This method connects a service method with this reference and allows the <strong>IMS</strong> engine to send notifications<br />

regarding this reference to the endpoint that initiated this reference.<br />

Parameters:<br />

serviceMethod - the ServiceMethod to connect<br />

Throws:<br />

IllegalStateException - if the Reference is not in STATE_REFERRING<br />

IllegalArgumentException - if the serviceMethod argument is null<br />

getState<br />

int getState()<br />

Returns the current state of this Reference.<br />

Returns:<br />

the current state of this Reference<br />

setListener<br />

void setListener(ReferenceListener listener)<br />

Sets a listener for this Reference, replacing any previous ReferenceListener. A null value is allowed<br />

and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 90 of 199


Interface ReferenceListener<br />

Interface ReferenceListener<br />

javax.microedition.ims.core<br />

public interface ReferenceListener<br />

This listener type is used to notify an application about events regarding a Reference.<br />

See Also:<br />

Reference.setListener(ReferenceListener)<br />

Method Summary<br />

void referenceDelivered(Reference reference)<br />

Notifies the application that the reference was successfully delivered.<br />

void reference<strong>Delivery</strong>Failed(Reference reference)<br />

Notifies the application that the reference was not successfully delivered.<br />

void referenceNotify(Reference reference, Message notify)<br />

Notifies the application with status reports regarding the Reference.<br />

void referenceTerminated(Reference reference)<br />

Notifies the application that a reference has been terminated.<br />

Page<br />

91<br />

91<br />

92<br />

92<br />

Method Detail<br />

referenceDelivered<br />

void referenceDelivered(Reference reference)<br />

Notifies the application that the reference was successfully delivered.<br />

This method is invoked at the endpoint that sent the reference request.<br />

The Reference has transited to STATE_REFERRING or STATE_TERMINATED depending on if an implicit<br />

subscription was requested or not.<br />

Parameters:<br />

reference - the concerned Reference<br />

See Also:<br />

Reference.refer(boolean)<br />

reference<strong>Delivery</strong>Failed<br />

void reference<strong>Delivery</strong>Failed(Reference reference)<br />

Notifies the application that the reference was not successfully delivered.<br />

This method is invoked at the endpoint that sent the reference request.<br />

The Reference has transited to STATE_TERMINATED.<br />

Parameters:<br />

reference - the concerned Reference<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 91 of 199


Interface ReferenceListener<br />

referenceTerminated<br />

void referenceTerminated(Reference reference)<br />

Notifies the application that a reference has been terminated.<br />

This method is invoked at the endpoint that sent the reference request and at the endpoint that received<br />

the reference request.<br />

The Reference has transited to STATE_TERMINATED.<br />

Parameters:<br />

reference - the concerned Reference<br />

referenceNotify<br />

void referenceNotify(Reference reference,<br />

Message notify)<br />

Notifies the application with status reports regarding the Reference.<br />

This method is invoked at the endpoint that sent the reference request.<br />

Parameters:<br />

reference - the concerned Reference<br />

notify - a status report regarding the Reference<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 92 of 199


Interface ServiceMethod<br />

Interface ServiceMethod<br />

javax.microedition.ims.core<br />

All Known Subinterfaces:<br />

Capabilities, PageMessage, Publication, Reference, Session, Subscription<br />

public interface ServiceMethod<br />

The ServiceMethod interface provides methods to manipulate the next outgoing request message and to inspect<br />

previously sent request and response messages. The headers and body parts that are set will be transmitted in the<br />

next message that is triggered by an interface method, see code example below:<br />

Session mySession;<br />

Message myMessage;<br />

mySession = coreService.createSession(null, "sip:bob@home.net");<br />

myMessage = mySession.getNextRequest();<br />

myMessage.addHeader("P-ImageIncluded", "yes");<br />

mySession.start();<br />

In this code example, mySession.start is the triggering interface method that sends a session invitation with a<br />

header "P-ImageIncluded" that is set to "yes".<br />

The latest transaction is saved for each interface method that triggers messages to be sent, see Message interface<br />

for available message identifiers.<br />

Service Methods<br />

Instances of service methods can be created by using factory methods in the CoreService interface. To learn<br />

more about using the different service methods please refer to the related interfaces, see list below:<br />

• Capabilities<br />

• PageMessage<br />

• Publication<br />

• Session<br />

• Subscription<br />

• Reference<br />

In general the methods in the subinterfaces should supply all the functionality an application needs for each<br />

respective method. Should this not be enough this superinterface gives some additional and powerful control such<br />

as manipulating headers and body.<br />

Service Method Transactions<br />

The simplest form of communication in the <strong>IMS</strong> consists of two messages, an initial request sent to a remote<br />

endpoint and then an answer message or response. This interaction is commonly known as a transaction. Figure 1,<br />

shows an example transaction.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 93 of 199


Interface ServiceMethod<br />

Figure 1: A simple transaction.<br />

The communication can grow in complexity and include several transactions. An example could be the session<br />

invitation procedure with resource reservations, see figure 2 below.<br />

Figure 2: The session invite procedure.<br />

A transaction is defined by one request and its related responses. There can be more than one response for each<br />

request and there can be transactions with no responses at all. All messages in the figure above are given a<br />

number to clarify which transaction the different messages belong to.<br />

Example of how to access headers and body parts<br />

In this example, an image is attached as a separate body part and it is indicated by setting a "P-ImageIncluded"<br />

header in the initial INVITE method on the originating side.<br />

On the terminating side, the application retrieves the image and confirms this by setting the header in the 200 Ok<br />

response message.<br />

Originating endpoint<br />

Session mySession = myService.createSession(...);<br />

...<br />

Message myMessage = mySession.getNextRequest();<br />

myMessage.addHeader("P-ImageIncluded", "yes");<br />

MessageBodyPart messagePart = myMessage.createBodyPart();<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 94 of 199


Interface ServiceMethod<br />

messagePart.setHeader("Content-Type", "image/jpeg");<br />

OutputStream os = messagePart.openContentOutputStream();<br />

os.write(imageData);<br />

os.flush();<br />

os.close();<br />

mySession.start();<br />

Terminating endpoint<br />

public void sessionInvitationReceived(CoreService service, Session session) {<br />

}<br />

Message request = session.getPreviousRequest(Message.SESSION_START);<br />

Message resp;<br />

if ("yes".equals(mess.getHeaders("P-ImageIncluded")[0])) {<br />

MessageBodyPart[] parts = mess.getBodyParts();<br />

for (int i = 0; i < parts.length; i++) {<br />

if ("image/jpeg".equals(parts[i].getHeader("Content-Type"))) {<br />

InputStream is = parts[i].openContentInputStream();<br />

byte[] data = new byte[1024];<br />

// read content<br />

while ((is.read(data)) != -1) {<br />

...<br />

}<br />

}<br />

}<br />

}<br />

// Add header to accept response to session invitation<br />

resp = session.getNextResponse();<br />

resp.addHeader("P-ImageIncluded", "yes");<br />

session.accept();<br />

Method Summary<br />

Message getNextRequest()<br />

This method returns a handle to the next outgoing request Message within this<br />

ServiceMethod to be manipulated by the local endpoint.<br />

Message getNextResponse()<br />

This method returns a handle to the next outgoing response Message within this<br />

ServiceMethod.<br />

Message getPreviousRequest(int method)<br />

This method enables the user to inspect a previously sent or received request message.<br />

Message[] getPreviousResponses(int method)<br />

This method enables the user to inspect previously sent or received response messages.<br />

String[] getRemoteUserId()<br />

Returns the remote user identities of this ServiceMethod.<br />

Page<br />

96<br />

96<br />

96<br />

96<br />

95<br />

Method Detail<br />

getRemoteUserId<br />

String[] getRemoteUserId()<br />

Returns the remote user identities of this ServiceMethod.<br />

Returns:<br />

the remote user identity or null if the remote user identity could not be retrieved<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 95 of 199


Interface ServiceMethod<br />

getNextRequest<br />

Message getNextRequest()<br />

This method returns a handle to the next outgoing request Message within this ServiceMethod to be<br />

manipulated by the local endpoint.<br />

Returns:<br />

the next outgoing request Message created for this ServiceMethod<br />

getPreviousRequest<br />

Message getPreviousRequest(int method)<br />

This method enables the user to inspect a previously sent or received request message. It is only possible<br />

to inspect the last request of each interface method identifier. This method will return null if the interface<br />

method identifier has not been sent/received.<br />

See Message for valid interface method identifiers to retrieve.<br />

Parameters:<br />

method - the interface method identifier<br />

Returns:<br />

the request Message<br />

Throws:<br />

IllegalArgumentException - if the method argument is not a valid identifier<br />

getPreviousResponses<br />

Message[] getPreviousResponses(int method)<br />

This method enables the user to inspect previously sent or received response messages. It is only possible<br />

to inspect the response(s) for the last request of each interface method identifier. This method will return<br />

null if the interface method identifier has not been sent/received.<br />

See Message for valid interface method identifiers to retrieve.<br />

Parameters:<br />

method - the interface method identifier<br />

Returns:<br />

an array containing all responses associated to the method<br />

Throws:<br />

IllegalArgumentException - if the method argument is not a valid identifier<br />

getNextResponse<br />

Message getNextResponse()<br />

This method returns a handle to the next outgoing response Message within this ServiceMethod. It is only<br />

possible to manipulate the responses that are due to an application triggering action. This happens when<br />

the application takes an action in response to a callback: Session.accept and Session.reject from a<br />

session invitation or update. Otherwise null will be returned.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 96 of 199


Interface ServiceMethod<br />

Returns:<br />

the next outgoing response Message created for this ServiceMethod or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 97 of 199


Interface Session<br />

Interface Session<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface Session<br />

extends ServiceMethod<br />

The Session is a representation of a media exchange between two <strong>IMS</strong> endpoints. A Session can be created<br />

either locally through calling CoreService.createSession, or by a remote user, in which case the session will be<br />

passed as a parameter to CoreServiceListener.sessionInvitationReceived.<br />

A Session is able to carry media of the type Media. Media objects represent a media connection and not the<br />

media/content itself. Note that to be able to start a Session it MUST include at least one Media component, or an<br />

ImsException will be thrown.<br />

The <strong>IMS</strong> media connections are negotiated through an offer/answer model. The first offer/answer negotiation may<br />

take place during session establishment. However, new offers may be sent by any of the session's parties at any<br />

time. This is shown below in the session renegotiation procedure.<br />

Session Life Cycle<br />

A Session has eight states: STATE_INITIATED, STATE_NEGOTIATING, STATE_ESTABLISHING, STATE_ESTABLISHED,<br />

STATE_RENEGOTIATING, STATE_REESTABLISHING, STATE_TERMINATING and STATE_TERMINATED. The purpose of<br />

the life cycle states is to ensure that the handling of the session is kept synchronized between the local endpoint<br />

and the remote endpoint. The session life cycle also determines which actions are valid and which information is<br />

accessible in certain states.<br />

Below follows a description of two different scenarios: Session Establishment and Session Renegotiation. The<br />

scenarios are explained from two perspectives: the Mobile Originated-perspective which represents the initiator of<br />

an action. The counterpart is the Mobile Terminated-perspective representing the remote side of the session which<br />

will receive events of the initiators actions. In general terms an action at one side will generate a call to a listener<br />

method on the remote side of the session.<br />

Session Establishment<br />

This section describes how a session invitation is sent to a remote endpoint and the actions needed to respond to<br />

an invitation.<br />

Mobile Originated Session Establishment<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 98 of 199


Interface Session<br />

Figure 1: The mobile originated session establishment states<br />

STATE_INITIATED<br />

When a Session is created through a call to CoreService.createSession, it will enter STATE_INITIATED. After<br />

the Session is created, media can be added by calling Session.createMedia<br />

A Session transits to:<br />

• STATE_NEGOTIATING when start is called on the Session.<br />

• STATE_TERMINATING when terminate is called on the Session.<br />

STATE_NEGOTIATING<br />

Once this state is entered the communication with the remote endpoint starts and a session invitation with the first<br />

media offer is sent.<br />

Within STATE_NEGOTIATING the listener method sessionAlerting will be called when the remote endpoint has<br />

received the session invitation.<br />

A Session transits to:<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 99 of 199


Interface Session<br />

• STATE_ESTABLISHED if the remote endpoint accepts the session invitation. The sessionStarted callback<br />

will then be invoked.<br />

• STATE_TERMINATING if the local endpoint invokes terminate.<br />

• STATE_TERMINATED if the remote endpoint rejects the session invitation. The sessionStartFailed<br />

callback will then be invoked.<br />

Mobile Terminated Session Establishment<br />

Figure 2: The mobile terminated session establishment states<br />

STATE_INITIATED<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 100 of 199


Interface Session<br />

STATE_INITIATED is irrelevant to a receiving terminal because as soon as it is notified of an invitation the session<br />

is already in STATE_NEGOTIATING.<br />

STATE_NEGOTIATING<br />

When a session invitation reaches the terminating application it will be notified by a call to<br />

sessionInvitationReceived and the Session will reside in STATE_NEGOTIATING.<br />

A Session transits to:<br />

• STATE_ESTABLISHING if accept is called on the Session.<br />

• STATE_TERMINATED if reject is called on the Session or when the callback sessionStartFailed is<br />

invoked.<br />

• STATE_TERMINATING if terminate is called on the session.<br />

STATE_ESTABLISHING<br />

In this state accept has been called and the Session is about to be established at both endpoints. A Session<br />

transits to:<br />

• STATE_ESTABLISHED when the callback sessionStarted is invoked.<br />

• STATE_TERMINATED when the callback sessionStartFailed is invoked.<br />

• STATE_TERMINATING if terminate is called on the session.<br />

Session Renegotiation<br />

This section describes how a session renegotiation is handled by the local and remote endpoints. A renegotiation<br />

of the session may include modifications and removal of current media as well as adding new media. The<br />

renegotiation can be initiated by either endpoint. In Figure 1 and Figure 2 the session update is initiated by the<br />

same endpoint that initiated the session.<br />

Mobile Originated Session Renegotiation<br />

STATE_ESTABLISHED<br />

In this state the endpoint can modify the session as well as adding new media. An incoming update from the<br />

remote endpoint will discard all changes that the local endpoint has made to the session.<br />

• STATE_RENEGOTIATING when the callback sessionUpdateRecieved is invoked.<br />

• STATE_TERMINATED when the callback sessionTerminated is invoked.<br />

• STATE_TERMINATING if terminate is called on the session.<br />

STATE_RENEGOTIATING<br />

A Session assumes STATE_RENEGOTIATING through a call to update. Incoming session updates from the remote<br />

endpoint will be discarded in this state.<br />

A Session transits back to STATE_ESTABLISHED when the listener method:<br />

• sessionUpdated is called, meaning that the remote endpoint accepted the new session offer.<br />

• sessionUpdateFailed is called, but here meaning that the remote endpoint rejected the update and the<br />

session keeps its previous settings.<br />

Mobile Terminated Session Renegotiation<br />

STATE_RENEGOTIATING<br />

If the remote endpoint has offered changes to the session, the state will transit to STATE_RENEGOTIATING and the<br />

session will be notified with a call to the sessionUpdateReceived in the SessionListener interface.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 101 of 199


Interface Session<br />

A Session transits to:<br />

• STATE_REESTABLISHING if the accept method of the Session is called, thus the media offer is accepted.<br />

• STATE_ESTABLISHED if the reject method is called but in this case the session will keep its old settings.<br />

• STATE_TERMINATING if terminate is called on the session.<br />

• STATE_TERMINATED when the callback sessionTerminated is invoked.<br />

STATE_REESTABLISHING<br />

In this state accept has been called and the Session is about to be updated at both endpoints. A Session transits<br />

to:<br />

• STATE_ESTABLISHED when the callback sessionUpdated is invoked.<br />

• STATE_TERMINATING if terminate is called on the session.<br />

• STATE_TERMINATED when the callback sessionTerminated is invoked.<br />

Session Termination<br />

The terminate method can be called from both endpoints on the Session and thereby cancel the ongoing session<br />

establishment or terminate a Session in progress.<br />

STATE_TERMINATING<br />

A Session enters STATE_TERMINATING when the terminate method has been called on a Session.<br />

A Session transits to:<br />

• STATE_TERMINATED when the remote endpoint has acknowledged the terminate request. The<br />

sessionTerminated callback will then be invoked.<br />

An incoming terminate request from the remote endpoint is notified with the sessionTerminated callback.<br />

Field Summary<br />

int STATE_ESTABLISHED<br />

This state specifies that the Session is established.<br />

int STATE_ESTABLISHING<br />

This state specifies that the Session is accepted by the mobile terminated endpoint.<br />

int STATE_INITIATED<br />

This state specifies that the Session is created but not started.<br />

int STATE_NEGOTIATING<br />

This state specifies that the Session establishment has been started.<br />

int STATE_REESTABLISHING<br />

This state specifies that the Session update is accepted by the mobile terminated<br />

endpoint.<br />

int STATE_RENEGOTIATING<br />

This state specifies that the Session is negotiating updates to the session.<br />

int STATE_TERMINATED<br />

This state specifies that the Session has been terminated.<br />

int STATE_TERMINATING<br />

This state specifies that an established Session is being terminated by the local endpoint.<br />

int STATUSCODE_433_ANONYMITY_DISALLOWED<br />

Identifier for the SIP status code "433 - Anonymity Disallowed".<br />

Page<br />

104<br />

104<br />

104<br />

104<br />

104<br />

104<br />

105<br />

105<br />

105<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 102 of 199


Interface Session<br />

int STATUSCODE_480_TEMPORARILY_UNAVAILABLE<br />

Identifier for the SIP status code "480 - Temporarily Unavailable".<br />

int STATUSCODE_486_BUSY_HERE<br />

Identifier for the SIP status code "486 - Busy Here".<br />

int STATUSCODE_488_NOT_ACCEPTABLE_HERE<br />

Identifier for the SIP status code "488 - Not Acceptable Here".<br />

int STATUSCODE_600_BUSY_EVERYWHERE<br />

Identifier for the SIP status code "600 - Busy Everywhere".<br />

int STATUSCODE_603_DECLINE<br />

Identifier for the SIP status code "603 - Decline".<br />

105<br />

105<br />

105<br />

105<br />

105<br />

Method Summary<br />

void accept()<br />

This method can be used to accept a session invitation or a session update<br />

depending on the context.<br />

Capabilities createCapabilities()<br />

Creates a Capabilities with the remote endpoint.<br />

Media createMedia(String type, int direction)<br />

Creates a Media object with a media type name and adds it to the Session.<br />

Reference createReference(String referTo, String referMethod)<br />

This method is used for referring the remote endpoint to a third party user or<br />

service.<br />

Media[] getMedia()<br />

Returns the Media that are part of this Session .<br />

SessionDescriptor getSessionDescriptor()<br />

Returns the session descriptor associated with this Session.<br />

int getState()<br />

Returns the current state of this Session.<br />

boolean hasPendingUpdate()<br />

This method checks if there are changes in this Session that have not been<br />

negotiated.<br />

void reject()<br />

This method can be used to reject a session invitation or a session update<br />

depending on the context.<br />

void reject(int statusCode)<br />

This method can be used to reject a session invitation or a session update<br />

depending on the context with a specific SIP status code.<br />

void rejectWithDiversion(String alternativeUserAddress)<br />

This method can be used to reject a session invitation with the SIP status code "302<br />

- Moved Temporarily", along with an alternative contact user address.<br />

void removeMedia(Media media)<br />

void restore()<br />

Removes a Media from the Session.<br />

This method removes all updates that have been made to this Session and to<br />

medias that are part of this Session that have not been negotiated.<br />

void setListener(SessionListener listener)<br />

Sets a listener for this Session, replacing any previous SessionListener.<br />

void start()<br />

Starts a session.<br />

void terminate()<br />

Terminate or cancel a session.<br />

Page<br />

108<br />

108<br />

107<br />

108<br />

108<br />

110<br />

107<br />

110<br />

109<br />

109<br />

109<br />

107<br />

110<br />

106<br />

106<br />

106<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 103 of 199


Interface Session<br />

void update()<br />

Synchronizes the session modifications that an application has done with the<br />

remote endpoint.<br />

106<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_INITIATED<br />

public static final int STATE_INITIATED<br />

This state specifies that the Session is created but not started.<br />

STATE_NEGOTIATING<br />

public static final int STATE_NEGOTIATING<br />

This state specifies that the Session establishment has been started.<br />

STATE_ESTABLISHING<br />

public static final int STATE_ESTABLISHING<br />

This state specifies that the Session is accepted by the mobile terminated endpoint.<br />

STATE_ESTABLISHED<br />

public static final int STATE_ESTABLISHED<br />

This state specifies that the Session is established.<br />

STATE_RENEGOTIATING<br />

public static final int STATE_RENEGOTIATING<br />

This state specifies that the Session is negotiating updates to the session.<br />

STATE_REESTABLISHING<br />

public static final int STATE_REESTABLISHING<br />

This state specifies that the Session update is accepted by the mobile terminated endpoint.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 104 of 199


Interface Session<br />

STATE_TERMINATING<br />

public static final int STATE_TERMINATING<br />

This state specifies that an established Session is being terminated by the local endpoint.<br />

STATE_TERMINATED<br />

public static final int STATE_TERMINATED<br />

This state specifies that the Session has been terminated.<br />

STATUSCODE_433_ANONYMITY_DISALLOWED<br />

public static final int STATUSCODE_433_ANONYMITY_DISALLOWED<br />

Identifier for the SIP status code "433 - Anonymity Disallowed".<br />

STATUSCODE_480_TEMPORARILY_UNAVAILABLE<br />

public static final int STATUSCODE_480_TEMPORARILY_UNAVAILABLE<br />

Identifier for the SIP status code "480 - Temporarily Unavailable".<br />

STATUSCODE_486_BUSY_HERE<br />

public static final int STATUSCODE_486_BUSY_HERE<br />

Identifier for the SIP status code "486 - Busy Here".<br />

STATUSCODE_488_NOT_ACCEPTABLE_HERE<br />

public static final int STATUSCODE_488_NOT_ACCEPTABLE_HERE<br />

Identifier for the SIP status code "488 - Not Acceptable Here".<br />

STATUSCODE_600_BUSY_EVERYWHERE<br />

public static final int STATUSCODE_600_BUSY_EVERYWHERE<br />

Identifier for the SIP status code "600 - Busy Everywhere".<br />

STATUSCODE_603_DECLINE<br />

public static final int STATUSCODE_603_DECLINE<br />

Identifier for the SIP status code "603 - Decline".<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 105 of 199


Interface Session<br />

Method Detail<br />

setListener<br />

void setListener(SessionListener listener)<br />

Sets a listener for this Session, replacing any previous SessionListener. A null reference is allowed and<br />

has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set<br />

update<br />

void update()<br />

throws ImsException<br />

Synchronizes the session modifications that an application has done with the remote endpoint.<br />

Modifications include adding of media, removal of media, and change of existing media (e.g. directionality).<br />

The Session will transit to STATE_RENEGOTIATING after calling this method.<br />

Throws:<br />

ImsException - if a Media in the Session is not initiated correctly or if there are no Media in the<br />

Session<br />

IllegalStateException - if the hasPendingUpdate method returns false, meaning that there are<br />

no updates to be made to the session,<br />

if the Session is not in STATE_ESTABLISHED<br />

start<br />

void start()<br />

throws ImsException<br />

Starts a session. When this method is called the remote endpoint is invited to the session. All media MUST<br />

be initialized (see rules for the respective media type) for the session to start.<br />

The Session will transit to STATE_NEGOTIATING after calling this method.<br />

Throws:<br />

ImsException - if a Media in the Session is not initialized correctly or if there are no Media in the<br />

Session<br />

IllegalStateException - if the Session is not in STATE_INITIATED<br />

terminate<br />

void terminate()<br />

Terminate or cancel a session. A session that has been started should always be terminated using this<br />

method.<br />

The Session will transit to STATE_TERMINATING.<br />

If the Session is STATE_TERMINATING or STATE_TERMINATED this method will not do anything.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 106 of 199


Interface Session<br />

If the Session is STATE_INITIATED the Session will transit directly to STATE_TERMINATED, the<br />

sessionTerminated callback will not be invoked.<br />

getState<br />

int getState()<br />

Returns the current state of this Session.<br />

Returns:<br />

the current state of this Session<br />

createMedia<br />

Media createMedia(String type,<br />

int direction)<br />

throws ImsException<br />

Creates a Media object with a media type name and adds it to the Session. The following type names are<br />

recognized in this specification: BasicUnreliableMedia, BasicReliableMedia, FramedMedia and<br />

StreamMedia.<br />

If a Media is added to an established Session, the application has the responsibility to call update on the<br />

Session.<br />

Parameters:<br />

type - a Media type name<br />

direction - the direction of the Media flow<br />

Returns:<br />

a new Media implementing the type name interface<br />

Throws:<br />

ImsException - if the type could not be created<br />

IllegalArgumentException - if the direction argument is invalid<br />

IllegalStateException - if the Session is not in STATE_ESTABLISHED, STATE_INITIATED<br />

See Also:<br />

Media<br />

removeMedia<br />

void removeMedia(Media media)<br />

Removes a Media from the Session.<br />

If a Media is removed from an established Session, the application has the responsibility to call update on<br />

the Session.<br />

Parameters:<br />

media - the Media to remove from the Session<br />

Throws:<br />

IllegalArgumentException - if the Media does not exist in the Session or null<br />

IllegalStateException - if the Session is not in STATE_ESTABLISHED, STATE_INITIATED<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 107 of 199


Interface Session<br />

getMedia<br />

Media[] getMedia()<br />

Returns the Media that are part of this Session . An empty array will be returned if there are no Media in<br />

the Session.<br />

Returns:<br />

an array of all Media in the Session<br />

Throws:<br />

IllegalStateException - if the Session is in STATE_TERMINATED<br />

accept<br />

void accept()<br />

This method can be used to accept a session invitation or a session update depending on the context.<br />

• It can be used to accept a session invitation in STATE_NEGOTIATING if the remote endpoint has<br />

initiated the session. The Session will transit to STATE_ESTABLISHING.<br />

• It can be used to accept a session update in STATE_RENEGOTIATING if the remote endpoint has<br />

initiated the session update. The Session will transit to STATE_REESTABLISHING.<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_NEGOTIATING or STATE_RENEGOTIATING<br />

createCapabilities<br />

Capabilities createCapabilities()<br />

Creates a Capabilities with the remote endpoint.<br />

Returns:<br />

a new Capabilities<br />

Throws:<br />

ImsException - if the Capabilities could not be created<br />

IllegalStateException - if the Session is not in STATE_ESTABLISHED<br />

createReference<br />

Reference createReference(String referTo,<br />

String referMethod)<br />

This method is used for referring the remote endpoint to a third party user or service.<br />

Parameters:<br />

referTo - the URI with an optional display name to refer to. It can be any URI, not just a user id<br />

referMethod - the reference method to be used by the reference request, e.g. "INVITE", "BYE" or<br />

null for an unspecified refer method.<br />

Returns:<br />

a new Reference<br />

Throws:<br />

IllegalArgumentException - if the referTo argument is null,<br />

if the referMethod argument is not recognized by the device<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 108 of 199


Interface Session<br />

ImsException - if the Reference could not be created<br />

IllegalStateException - if the Session is not in STATE_ESTABLISHED<br />

reject<br />

void reject()<br />

This method can be used to reject a session invitation or a session update depending on the context.<br />

When calling this method the <strong>IMS</strong> Engine will respond with an appropriate SIP status code.<br />

• It can be used to reject a session invitation in STATE_NEGOTIATING if the remote endpoint has<br />

initiated the session. The Session will transit to STATE_TERMINATED .<br />

• It can be used to reject a session update in STATE_RENEGOTIATING if the remote endpoint has<br />

initiated the session update. The Session will transit to STATE_ESTABLISHED and the update is<br />

discarded.<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_NEGOTIATING or STATE_RENEGOTIATING<br />

reject<br />

void reject(int statusCode)<br />

This method can be used to reject a session invitation or a session update depending on the context with a<br />

specific SIP status code.<br />

The following status codes are valid:<br />

STATUSCODE_433_ANONYMITY_DISALLOWED, STATUSCODE_480_TEMPORARILY_UNAVAILABLE,<br />

STATUSCODE_488_NOT_ACCEPABLE_HERE, STATUSCODE_600_BUSY_EVERYWHERE and<br />

STATUSCODE_603_DECLINE.<br />

• It can be used to reject a session invitation in STATE_NEGOTIATING if the remote endpoint<br />

has initiated the session. The Session will transit to STATE_TERMINATED .<br />

Parameters:<br />

statusCode - the status code<br />

Throws:<br />

IllegalArgumentException - if the statusCode argument is not valid identifier<br />

IllegalStateException - if the Session is not in STATE_NEGOTIATING<br />

rejectWithDiversion<br />

void rejectWithDiversion(String alternativeUserAddress)<br />

This method can be used to reject a session invitation with the SIP status code "302 - Moved Temporarily",<br />

along with an alternative contact user address.<br />

• It can be used to reject a session invitation in STATE_NEGOTIATING if the remote endpoint has<br />

initiated the session. The Session will transit to STATE_TERMINATED .<br />

Parameters:<br />

alternativeUserAddress - the alternative SIP or TEL URI were the user wants to be contacted<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_NEGOTIATING<br />

IllegalArgumentException - if the syntax of the alternativeUserAddress argument is invalid<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 109 of 199


Interface Session<br />

getSessionDescriptor<br />

SessionDescriptor getSessionDescriptor()<br />

Returns the session descriptor associated with this Session.<br />

Returns:<br />

the session descriptor<br />

hasPendingUpdate<br />

boolean hasPendingUpdate()<br />

This method checks if there are changes in this Session that have not been negotiated.<br />

Returns:<br />

true if there is a pending update, false otherwise<br />

restore<br />

void restore()<br />

This method removes all updates that have been made to this Session and to medias that are part of this<br />

Session that have not been negotiated.<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_ESTABLISHED<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 110 of 199


Interface SessionDescriptor<br />

Interface SessionDescriptor<br />

javax.microedition.ims.core<br />

public interface SessionDescriptor<br />

The Session Description Protocol (SDP) [RFC4566] is used to convey information about media streams in a<br />

session such that the endpoints can connect and participate. SDP standardizes a textual format for such<br />

information in the application/sdp media type. A content of that type is generally referred to as "an SDP", or "the<br />

SDP" when the reference to the particular content is unambiguous.<br />

The endpoints in a session, exchange SDPs according to the SDP Offer/Answer model [RFC3264] in the SIP<br />

signalling. The <strong>IMS</strong> Engine manages this process at all times. For a session at a particular state, and at an<br />

endpoint, there is a pair of SDPs: an "incoming SDP", part of a SIP message received from the remote, and an<br />

"outgoing SDP", that is to be put in a SIP message to be sent to the remote. Note that not all SIP messages carry<br />

SDP bodies.<br />

The SessionDescriptor is an interface to the session-level part of this SDP pair (for the media-level part, see<br />

MediaDescriptor). The getters read from the last incoming SDP. The setters apply to all outgoing SDPs in the<br />

current session, beginning with the one to be sent next. Note that using the interface setters does not in itself<br />

trigger the <strong>IMS</strong> engine to send the SDP in a SIP message. If there is a point in the session lifetime where the<br />

modifications should cease, the application is responsible to use the setters again, and make sure the SDP is sent.<br />

On the originating endpoint, it is most useful for the application to use the setters when the session is in the initiated<br />

state. The changes will then be in effect from the start of the session. It is not possible to use the getters since<br />

there is no incoming SDP at the first state. In an established session, the originating endpoint for a session update<br />

may read and change the SDP before applying the update.<br />

On the terminating endpoint, the application can read the incoming SDP but not set an outgoing SDP in the<br />

CoreService.SessionInvitationReceived callback. The reason is that all SDP carrying messages have already<br />

been exchanged at the time of callback. If the terminating side wants to add attributes it has to do so when the<br />

session is established, and trigger a session update.<br />

There are several places in the call flow at session setup and session update where the application have no<br />

opportunity to influence the negotiation, for example right after receiving the INVITE at the terminating endpoint. In<br />

this case, the <strong>IMS</strong> engine copies all application-defined SDP attributes from the offer into the answer, and from the<br />

answer into subsequent offers until the session is established or updated.<br />

To use the interface in a meaningful way, a thorough understanding of the SDP protocol and its use in <strong>IMS</strong> and SIP<br />

is assumed.<br />

For a session with a streaming media object of audio and video type, there could be an SDP that looks something<br />

like:<br />

v=0<br />

o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com<br />

s=<br />

c=IN IP4 host.atlanta.example.com<br />

t=0 0<br />

m=audio 49170 RTP/AVP 0 8 97<br />

a=rtpmap:0 PCMU/8000<br />

a=rtpmap:8 PCMA/8000<br />

a=rtpmap:97 iLBC/8000<br />

m=video 51372 RTP/AVP 31 32<br />

a=rtpmap:31 H261/90000<br />

a=rtpmap:32 MPV/90000<br />

The session-level part includes the bold lines. The application can get, and set some SDP lines that are not<br />

reserved for the <strong>IMS</strong> engine. Attributes can be get, set and removed freely except reserved. The following attributes<br />

are classified as reserved and can not be modified using the SessionDescriptor interface: charset,<br />

charset:iso8895-1, group, maxprate, ice-lite, ice-mismatch, ice-options, ice-pwd, ice-ufrag, inactive, sendonly,<br />

recvonly, sendrecv, csup, creq, acap and tcap.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 111 of 199


Interface SessionDescriptor<br />

See Also:<br />

MediaDescriptor<br />

Method Summary<br />

void addAttribute(String attribute)<br />

Adds an attribute (a=) to the Session.<br />

String[] getAttributes()<br />

Returns all attributes (the a= lines) for the session.<br />

String getProtocolVersion()<br />

Returns the version (v=) of the SDP.<br />

String getSessionId()<br />

Returns a unique identifier (o=) for the session.<br />

String getSessionInfo()<br />

Returns textual information (i=) about the session.<br />

String getSessionName()<br />

Returns the textual session name (s=).<br />

void removeAttribute(String attribute)<br />

Removes an attribute (a=) from the session.<br />

void setSessionInfo(String info)<br />

Sets the textual information (i=) about the session.<br />

void setSessionName(String name)<br />

Sets the name of the session (s=).<br />

Page<br />

114<br />

114<br />

112<br />

112<br />

113<br />

113<br />

114<br />

113<br />

113<br />

Method Detail<br />

getProtocolVersion<br />

String getProtocolVersion()<br />

Returns the version (v=) of the SDP.<br />

See [RFC4566], chapter 5.1. for more information.<br />

Returns:<br />

the protocol version or null if the protocol version could not be retrieved<br />

getSessionId<br />

String getSessionId()<br />

Returns a unique identifier (o=) for the session.<br />

See [RFC4566], chapter 5.2. for more information.<br />

Returns:<br />

the Session identifier or null if the session identifier could not be retrieved<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 112 of 199


Interface SessionDescriptor<br />

getSessionName<br />

String getSessionName()<br />

Returns the textual session name (s=).<br />

See [RFC4566], chapter 5.3. for more information.<br />

Returns:<br />

the Session name or null if the session name is not set<br />

See Also:<br />

setSessionName(String)<br />

setSessionName<br />

void setSessionName(String name)<br />

Sets the name of the session (s=).<br />

Parameters:<br />

name - the session name<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_INITIATED<br />

IllegalArgumentException - if the name argument is null<br />

See Also:<br />

getSessionName()<br />

getSessionInfo<br />

String getSessionInfo()<br />

Returns textual information (i=) about the session.<br />

See [RFC4566], chapter 5.4. for more information.<br />

Returns:<br />

session information or null if the session information is not set<br />

See Also:<br />

setSessionInfo(String)<br />

setSessionInfo<br />

void setSessionInfo(String info)<br />

Sets the textual information (i=) about the session.<br />

Parameters:<br />

info - session information<br />

Throws:<br />

IllegalStateException - if the Session is not in STATE_INITIATED<br />

IllegalArgumentException - if the info argument is null<br />

See Also:<br />

getSessionInfo()<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 113 of 199


Interface SessionDescriptor<br />

removeAttribute<br />

void removeAttribute(String attribute)<br />

Removes an attribute (a=) from the session.<br />

The example below removes the "synced" attribute:<br />

SessionDescriptor desc = session.getSessionDescriptor();<br />

desc.removeAttribute("synced");<br />

Parameters:<br />

attribute - the attribute to remove<br />

Throws:<br />

IllegalArgumentException - if the attribute argument is null,<br />

if the attribute does not exist in the Session,<br />

if the attribute is reserved for the <strong>IMS</strong> engine<br />

IllegalStateException - if the Session is not in STATE_INITIATED or STATE_ESTABLISHED state<br />

addAttribute<br />

void addAttribute(String attribute)<br />

Adds an attribute (a=) to the Session. Adding attributes that the <strong>IMS</strong> engine has reserved, such as<br />

"sendonly", "recvonly", "sendrecv", leads to IllegalArgumentException.<br />

Example:<br />

SessionDescriptor desc = session.getSessionDescriptor();<br />

desc.addAttribute("synced");<br />

The resulting attribute line will be:<br />

a=synced<br />

Parameters:<br />

attribute - the attribute to add<br />

Throws:<br />

IllegalArgumentException - if the attribute argument is null or if the syntax of the attribute<br />

argument is invalid,<br />

if the attribute already exists in the Session,<br />

if the attribute is reserved for the <strong>IMS</strong> engine<br />

IllegalStateException - if the Session is not in STATE_INITIATED or STATE_ESTABLISHED state<br />

getAttributes<br />

String[] getAttributes()<br />

Returns all attributes (the a= lines) for the session. If there are no attributes, an empty string array will be<br />

returned.<br />

Returns:<br />

a string array containing the attributes<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 114 of 199


Interface SessionListener<br />

Interface SessionListener<br />

javax.microedition.ims.core<br />

public interface SessionListener<br />

A listener type for receiving notification on session events. When an event is generated for a Session the<br />

application is notified by having one of the methods called on the SessionListener.<br />

See Also:<br />

Session.setListener(SessionListener)<br />

Method Summary<br />

void sessionAlerting(Session session)<br />

Notifies the application that the remote part's terminal is alerting the user of this session<br />

invitation.<br />

void sessionReferenceReceived(Session session, Reference reference)<br />

Notifies the application that a reference request has been received from a remote endpoint.<br />

void sessionStarted(Session session)<br />

Notifies the application that the session has been established.<br />

void sessionStartFailed(Session session)<br />

Notifies the application that the session could not be established.<br />

void sessionTerminated(Session session)<br />

Notifies the application that the session has been terminated or that the session could no<br />

longer stay established.<br />

void sessionUpdated(Session session)<br />

Notifies the application that the session has been updated.<br />

void sessionUpdateFailed(Session session)<br />

Notifies the application that the session update has been rejected.<br />

void sessionUpdateReceived(Session session)<br />

Notifies the application that the remote endpoint adds more media components to an<br />

established session and the local endpoint is now expected to accept or reject the update.<br />

Page<br />

116<br />

117<br />

117<br />

117<br />

115<br />

116<br />

116<br />

116<br />

Method Detail<br />

sessionTerminated<br />

void sessionTerminated(Session session)<br />

Notifies the application that the session has been terminated or that the session could no longer stay<br />

established.<br />

This callback can be invoked by the <strong>IMS</strong> engine if the access network is unavailable.<br />

This method is invoked at both involved endpoints.<br />

The Session has transited to STATE_TERMINATED.<br />

Parameters:<br />

session - the concerned Session<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 115 of 199


Interface SessionListener<br />

sessionUpdateReceived<br />

void sessionUpdateReceived(Session session)<br />

Notifies the application that the remote endpoint adds more media components to an established session<br />

and the local endpoint is now expected to accept or reject the update.<br />

If the remote removed a media component, changed media directions, or updated application-specific<br />

SDP-attributes then this method is not called.<br />

The Session has transited to STATE_RENEGOTIATING.<br />

Parameters:<br />

session - the concerned Session<br />

sessionUpdated<br />

void sessionUpdated(Session session)<br />

Notifies the application that the session has been updated.<br />

This callback is invoked at both involved endpoints.<br />

The Session has transited to STATE_ESTABLISHED.<br />

Parameters:<br />

session - the concerned Session<br />

sessionUpdateFailed<br />

void sessionUpdateFailed(Session session)<br />

Notifies the application that the session update has been rejected.<br />

This callback is invoked at both involved endpoints.<br />

The Session has transited to STATE_ESTABLISHED.<br />

Parameters:<br />

session - the concerned Session<br />

sessionAlerting<br />

void sessionAlerting(Session session)<br />

Notifies the application that the remote part's terminal is alerting the user of this session invitation.<br />

Parameters:<br />

session - the concerned Session<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 116 of 199


Interface SessionListener<br />

sessionStarted<br />

void sessionStarted(Session session)<br />

Notifies the application that the session has been established.<br />

This callback is invoked at both involved endpoints.<br />

The Session has transited to STATE_ESTABLISHED.<br />

Parameters:<br />

session - the concerned Session<br />

sessionStartFailed<br />

void sessionStartFailed(Session session)<br />

Notifies the application that the session could not be established.<br />

This callback is invoked at both involved endpoints.<br />

The Session has transited to STATE_TERMINATED.<br />

Parameters:<br />

session - the concerned Session<br />

sessionReferenceReceived<br />

void sessionReferenceReceived(Session session,<br />

Reference reference)<br />

Notifies the application that a reference request has been received from a remote endpoint.<br />

Only references that are created in a session are notified in this method.<br />

Parameters:<br />

session - the concerned Session<br />

reference - the Reference representing the request<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 117 of 199


Interface Subscription<br />

Interface Subscription<br />

javax.microedition.ims.core<br />

All Superinterfaces:<br />

ServiceMethod<br />

public interface Subscription<br />

extends ServiceMethod<br />

A Subscription is used for subscribing to events of the event package sent from the remote server endpoint. The<br />

application receives event notifications via callbacks to SubscriptionListener.subscriptionNotify method<br />

while being subscribed. There are two types of a subscription: A durative subscription start with a call to subscribe<br />

and ends with a call to unsubscribe. An instant subscription starts with a call to poll and ends when the first<br />

notification is received.<br />

The Subscription life cycle consist of three states, STATE_INACTIVE, STATE_PENDING and STATE_ACTIVE. A<br />

durative subscription can be updated with a call to subscribe while in STATE_ACTIVE.<br />

Figure 1:The subscription states<br />

Client subscription example<br />

To establish a subscription, a Subscription has to be created. The event package to subscribe to must be set,<br />

and the subscription is started by calling subscribe. If the remote endpoint accepts the request, a notification will<br />

immediately be sent with the current event state that corresponds to the subscribed event package.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 118 of 199


Interface Subscription<br />

try {<br />

sub = service.createSubscription(null, "sip:bob@home.net", "presence");<br />

sub.setListener(this);<br />

sub.subscribe();<br />

} catch(Exception e){<br />

// handle Exceptions<br />

}<br />

public void subscriptionStarted(Subscription sub){<br />

// if the subscription was successfull<br />

}<br />

public void subscriptionNotify(Subscription sub, Message notify){<br />

// check the subscribed event state<br />

}<br />

.<br />

.<br />

See Also:<br />

CoreService.createSubscription(String, String, String), Publication<br />

Field Summary<br />

int STATE_ACTIVE<br />

The Subscription is active.<br />

int STATE_INACTIVE<br />

The Subscription is not active.<br />

int STATE_PENDING<br />

A Subscription request is sent and the <strong>IMS</strong> engine is waiting for a response.<br />

Page<br />

120<br />

119<br />

120<br />

Method Summary<br />

String getEvent()<br />

Returns the event package corresponding to this Subscription.<br />

int getState()<br />

Returns the current state of the state machine of the Subscription.<br />

void poll()<br />

Makes an instant subscription.<br />

void setListener(SubscriptionListener listener)<br />

Sets a listener for this Subscription, replacing any previous SubscriptionListener.<br />

void subscribe()<br />

Starts or updates a durative subscription.<br />

void unsubscribe()<br />

Terminates this durative subscription.<br />

Page<br />

121<br />

121<br />

120<br />

121<br />

120<br />

120<br />

Methods inherited from interface javax.microedition.ims.core.ServiceMethod<br />

getNextRequest, getNextResponse, getPreviousRequest, getPreviousResponses, getRemoteUserId<br />

Field Detail<br />

STATE_INACTIVE<br />

public static final int STATE_INACTIVE<br />

The Subscription is not active.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 119 of 199


Interface Subscription<br />

STATE_PENDING<br />

public static final int STATE_PENDING<br />

A Subscription request is sent and the <strong>IMS</strong> engine is waiting for a response.<br />

STATE_ACTIVE<br />

public static final int STATE_ACTIVE<br />

The Subscription is active.<br />

Method Detail<br />

subscribe<br />

void subscribe()<br />

throws ServiceClosedException<br />

Starts or updates a durative subscription.<br />

In STATE_INACTIVE or STATE_ACTIVE the Subscription transits to STATE_PENDING after calling this<br />

method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Subscription is not in STATE_INACTIVE or STATE_ACTIVE<br />

poll<br />

void poll()<br />

throws ServiceClosedException<br />

Makes an instant subscription.<br />

The Subscription will transit to STATE_PENDING after calling this method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

IllegalStateException - if the Subscription is not in STATE_INACTIVE<br />

unsubscribe<br />

void unsubscribe()<br />

throws ServiceClosedException<br />

Terminates this durative subscription.<br />

The Subscription will transit to STATE_PENDING after calling this method.<br />

Throws:<br />

ServiceClosedException - if the Service is closed<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 120 of 199


Interface Subscription<br />

IllegalStateException - if the Subscription is not in STATE_ACTIVE<br />

setListener<br />

void setListener(SubscriptionListener listener)<br />

Sets a listener for this Subscription, replacing any previous SubscriptionListener. A null reference is<br />

allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

getEvent<br />

String getEvent()<br />

Returns the event package corresponding to this Subscription.<br />

Returns:<br />

the event package<br />

getState<br />

int getState()<br />

Returns the current state of the state machine of the Subscription.<br />

Returns:<br />

the current state<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 121 of 199


Interface SubscriptionListener<br />

Interface SubscriptionListener<br />

javax.microedition.ims.core<br />

public interface SubscriptionListener<br />

This listener type is used to notify the application about subscription status and the event state of the subscribed<br />

event package.<br />

See Also:<br />

Subscription.setListener(SubscriptionListener)<br />

Method Summary<br />

void subscriptionNotify(Subscription subscription, Message notify)<br />

Event notification received.<br />

void subscriptionStarted(Subscription subscription)<br />

Notifies the application that the durative subscription was successfully started or updated.<br />

void subscriptionStartFailed(Subscription subscription)<br />

Notifies the application that the durative subscription failed to start or update.<br />

void subscriptionTerminated(Subscription subscription)<br />

Notifies the application that the subscription was terminated.<br />

Page<br />

123<br />

122<br />

122<br />

122<br />

Method Detail<br />

subscriptionStarted<br />

void subscriptionStarted(Subscription subscription)<br />

Notifies the application that the durative subscription was successfully started or updated.<br />

The Subscription has transited to STATE_ACTIVE.<br />

Parameters:<br />

subscription - the concerned Subscription<br />

subscriptionStartFailed<br />

void subscriptionStartFailed(Subscription subscription)<br />

Notifies the application that the durative subscription failed to start or update.<br />

The Subscription has transited to STATE_INACTIVE.<br />

Parameters:<br />

subscription - the concerned Subscription<br />

subscriptionTerminated<br />

void subscriptionTerminated(Subscription subscription)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 122 of 199


Interface SubscriptionListener<br />

Notifies the application that the subscription was terminated.<br />

The Subscription has transited to STATE_INACTIVE.<br />

Parameters:<br />

subscription - the concerned Subscription<br />

subscriptionNotify<br />

void subscriptionNotify(Subscription subscription,<br />

Message notify)<br />

Event notification received. If the subscription is durative, the state remains at STATE_ACTIVE otherwise the<br />

state will transit to STATE_INACTIVE.<br />

Parameters:<br />

subscription - the concerned Subscription<br />

notify - event state of the subscribed event package<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 123 of 199


Package javax.microedition.ims.core.media<br />

Package javax.microedition.ims.core.media<br />

The package contains entities used to create media flows for <strong>IMS</strong>.<br />

See:<br />

Description<br />

Interface Summary<br />

BasicReliableMedia<br />

BasicReliableMediaListener<br />

BasicUnreliableMedia<br />

BasicUnreliableMediaListener<br />

FramedMedia<br />

FramedMediaListener<br />

The BasicReliableMedia represents a session media component that<br />

uses the reliable connection-oriented protocol of TCP to transport the<br />

content.<br />

A listener type for receiving notification of when a connection error has<br />

occurred on the stream(s).<br />

The BasicUnreliableMedia represents a media connection with<br />

application content transported over UDP.<br />

A listener type for receiving notification of when BasicUnreliableMedia<br />

content is available.<br />

The FramedMedia represents a media connection on which content is<br />

delivered in packets.<br />

A listener type for receiving notification of when FramedMedia content is<br />

transferred.<br />

Media The Media interface represents a generic media object of a session. 143<br />

MediaDescriptor MediaDescriptor is an interface towards the media parts of the SDP. 152<br />

MediaListener<br />

StreamMedia<br />

A listener type for receiving notification of when some mode property has<br />

changed on the media flow.<br />

The StreamMedia represents a standardized application-independent<br />

streaming media that can be rendered in real-time.<br />

Page<br />

126<br />

129<br />

130<br />

133<br />

134<br />

140<br />

156<br />

160<br />

Class Summary<br />

MediaPermission This class represents permissions to send or receive files in the <strong>IMS</strong><strong>API</strong>. 157<br />

Package javax.microedition.ims.core.media Description<br />

The package contains entities used to create media flows for <strong>IMS</strong>.<br />

Page<br />

Static Structure<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 124 of 199


Package javax.microedition.ims.core.media<br />

Figure 1: Static structure of the package.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 125 of 199


Interface BasicReliableMedia<br />

Interface BasicReliableMedia<br />

javax.microedition.ims.core.media<br />

All Superinterfaces:<br />

Media<br />

public interface BasicReliableMedia<br />

extends Media<br />

The BasicReliableMedia represents a session media component that uses the reliable connection-oriented<br />

protocol of TCP to transport the content. The connection is established when the media has been negotiated and<br />

accepted in the session according to [RFC4145]. The media flow is accessed as streams, one in each direction.<br />

Initializing the media<br />

The application MUST call the following method before calling Session.start or Session.update:<br />

• setContentType<br />

If not, an ImsException is thrown.<br />

Sending application specific content<br />

myMedia = (BasicReliableMedia)mySession.createMedia("BasicReliableMedia",<br />

Media.DIRECTION_SEND);<br />

myMedia.setContentType("application/myChess");<br />

mySession.start();<br />

OutputStream os = myMedia.getOutputStream();<br />

...<br />

if (myMedia.canWrite()) {<br />

os.write(myGameData.getBytes());<br />

}<br />

Streams<br />

A stream pair is used to access the data flow from the media object. The <strong>IMS</strong> engine creates and manages the<br />

streams, and the application gets them by calling getInputStream and getOutputStream. The streams are<br />

created once and are singleton. If the streams are closed, the application can no longer access the data flow.<br />

read and write on the streams is possible as long as Media.canRead and Media.canWrite returns true.<br />

If Media.canRead returns false while the application is in a call to InputStream.read waiting for input to become<br />

available, IOException is thrown telling that read is no longer allowed.<br />

Receiving application specific content<br />

The input stream is opened and the read method will return when there is content available on the connection.<br />

myMedia =<br />

(BasicReliableMedia)mySession.createMedia("BasicReliableMedia",<br />

Media.DIRECTION_RECEIVE);<br />

myMedia.setContentType("application/myChess");<br />

mySession.start();<br />

InputStream is = myMedia.getInputStream();<br />

int num;<br />

byte[] buf = new byte[1024];<br />

while (myMedia.canRead() && ((num = is.read(buf)) != -1)) {<br />

// Consume the read content<br />

}<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 126 of 199


Interface BasicReliableMedia<br />

NAT and firewall considerations<br />

BasicReliableMedia is affected by NATs and firewalls. To avoid losing the connection if behind a NAT, the<br />

application MUST keep transmitting data on the connection, even during periods of inactive use.<br />

To determine whether the device is behind a NAT or firewall, the isBehindNat method in the ConnectionState<br />

class can be used.<br />

Fields inherited from interface javax.microedition.ims.core.media.Media<br />

DIRECTION_INACTIVE, DIRECTION_RECEIVE, DIRECTION_SEND, DIRECTION_SEND_RECEIVE, STATE_ACTIVE,<br />

STATE_DELETED, STATE_INACTIVE, STATE_PENDING, STATE_PROPOSAL, UPDATE_MODIFIED, UPDATE_REMOVED,<br />

UPDATE_UNCHANGED<br />

Method Summary<br />

String getContentType()<br />

Returns the content type of this Media.<br />

java.io.InputStream getInputStream()<br />

Returns an InputStream where incoming content can be read.<br />

java.io.OutputStream getOutputStream()<br />

Returns an OutputStream where outgoing content can be written.<br />

void setContentType(String contentType)<br />

Sets the content type of this Media.<br />

void setListener(BasicReliableMediaListener listener)<br />

Sets a listener for this BasicReliableMedia, replacing any previous<br />

BasicReliableMediaListener.<br />

Page<br />

128<br />

127<br />

127<br />

128<br />

128<br />

Methods inherited from interface javax.microedition.ims.core.media.Media<br />

canRead, canWrite, exists, getDirection, getMediaDescriptors, getProposal, getState,<br />

getUpdateState, setDirection, setMediaListener<br />

Method Detail<br />

getInputStream<br />

java.io.InputStream getInputStream()<br />

throws java.io.IOException<br />

Returns an InputStream where incoming content can be read. If the Media.exists method returns false<br />

after calling this method, then the stream is closed.<br />

Returns:<br />

an InputStream to read incoming content from<br />

Throws:<br />

java.io.IOException - if Media.exists returns false, or if an I/O error occurs<br />

getOutputStream<br />

java.io.OutputStream getOutputStream()<br />

throws java.io.IOException<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 127 of 199


Interface BasicReliableMedia<br />

Returns an OutputStream where outgoing content can be written. If the Media.exists method returns<br />

false after calling this method, then the stream is closed.<br />

Returns:<br />

an OutputStream to write outgoing content to<br />

Throws:<br />

java.io.IOException - if Media.exists returns false, or if an I/O error occurs<br />

setContentType<br />

void setContentType(String contentType)<br />

Sets the content type of this Media.<br />

See Media for valid content types.<br />

Parameters:<br />

contentType - the content type<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the contentType argument is not a valid media type<br />

See Also:<br />

getContentType()<br />

getContentType<br />

String getContentType()<br />

Returns the content type of this Media.<br />

Returns:<br />

the content type or null if the content type has not been set<br />

See Also:<br />

setContentType(String)<br />

setListener<br />

void setListener(BasicReliableMediaListener listener)<br />

Sets a listener for this BasicReliableMedia, replacing any previous BasicReliableMediaListener. A<br />

null reference is allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 128 of 199


Interface BasicReliableMediaListener<br />

Interface BasicReliableMediaListener<br />

javax.microedition.ims.core.media<br />

public interface BasicReliableMediaListener<br />

A listener type for receiving notification of when a connection error has occurred on the stream(s).<br />

See Also:<br />

BasicReliableMedia<br />

Method Summary<br />

void connectionError(BasicReliableMedia media)<br />

Notifies the application if the connection could not be established.<br />

Page<br />

129<br />

Method Detail<br />

connectionError<br />

void connectionError(BasicReliableMedia media)<br />

Notifies the application if the connection could not be established.<br />

Parameters:<br />

media - the concerned BasicReliableMedia<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 129 of 199


Interface BasicUnreliableMedia<br />

Interface BasicUnreliableMedia<br />

javax.microedition.ims.core.media<br />

All Superinterfaces:<br />

Media<br />

public interface BasicUnreliableMedia<br />

extends Media<br />

The BasicUnreliableMedia represents a media connection with application content transported over UDP.<br />

Initializing the media<br />

To properly initialize the BasicUnrealibleMedia, use the following setter, or an ImsException will be thrown in<br />

Session.start or Session.update.<br />

• setContentType<br />

Sending and receiving content<br />

The application should make sure that Media.canRead and Media.canWrite return true before calling send and<br />

receive.<br />

Sending application specific content<br />

myMedia = (BasicUnreliableMedia)mySession.createMedia("BasicUnreliableMedia",<br />

Media.DIRECTION_SEND);<br />

myMedia.setContentType("application/myChess");<br />

myMedia.setListener(this);<br />

mySession.start();<br />

...<br />

byte[] myChessMove = getChessMove();<br />

myMedia.send(myChessMove);<br />

Receiving application specific content<br />

The content is received and the application is notified through the method contentReceived on the<br />

BasicUnreliableMediaListener interface. The content can be retrieved by calling the receive method.<br />

public void contentReceived(BasicUnreliableMedia media) {<br />

try {<br />

byte[] hisChessMove = media.receive();<br />

} catch (ImsException e) {<br />

...<br />

}<br />

}<br />

NAT and firewall considerations<br />

BasicUnreliableMedia is affected by NATs and firewalls. To avoid losing NAT binding, the application MUST<br />

keep sending periodic keep alive messages during periods of inactivity.<br />

To determine whether the device is behind a NAT or firewall, the method isBehindNat in the ConnectionState<br />

class can be used.<br />

Fields inherited from interface javax.microedition.ims.core.media.Media<br />

DIRECTION_INACTIVE, DIRECTION_RECEIVE, DIRECTION_SEND, DIRECTION_SEND_RECEIVE, STATE_ACTIVE,<br />

STATE_DELETED, STATE_INACTIVE, STATE_PENDING, STATE_PROPOSAL, UPDATE_MODIFIED, UPDATE_REMOVED,<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 130 of 199


Interface BasicUnreliableMedia<br />

UPDATE_UNCHANGED<br />

Method Summary<br />

String getContentType()<br />

Returns the content type of this Media.<br />

byte[] receive()<br />

Receives the payload from the remote endpoint (note that the payload could be empty).<br />

void send(byte[] content)<br />

Sends content to the remote endpoint.<br />

void setContentType(String contentType)<br />

Sets the content type of this Media.<br />

void setListener(BasicUnreliableMediaListener listener)<br />

Sets a listener for this BasicUnreliableMedia, replacing any previous<br />

BasicUnreliableMediaListener.<br />

Page<br />

132<br />

131<br />

131<br />

131<br />

132<br />

Methods inherited from interface javax.microedition.ims.core.media.Media<br />

canRead, canWrite, exists, getDirection, getMediaDescriptors, getProposal, getState,<br />

getUpdateState, setDirection, setMediaListener<br />

Method Detail<br />

receive<br />

byte[] receive()<br />

throws java.io.IOException,<br />

ImsException<br />

Receives the payload from the remote endpoint (note that the payload could be empty). The received<br />

content can only be retrieved once.<br />

Returns:<br />

a byte array with the received content<br />

Throws:<br />

java.io.IOException - if canRead returns false or an I/O error occurs<br />

ImsException - if no payload is received<br />

send<br />

void send(byte[] content)<br />

throws java.io.IOException<br />

Sends content to the remote endpoint.<br />

Parameters:<br />

content - a byte array for the content payload to be sent<br />

Throws:<br />

java.io.IOException - if canWrite returns false or an I/O error occurs<br />

IllegalArgumentException - if the content argument size is greater than 1500 bytes or is null<br />

setContentType<br />

void setContentType(String contentType)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 131 of 199


Interface BasicUnreliableMedia<br />

Sets the content type of this Media.<br />

See Media for valid content types.<br />

Parameters:<br />

contentType - the content type<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the contentType argument is not a valid media type<br />

See Also:<br />

getContentType()<br />

getContentType<br />

String getContentType()<br />

Returns the content type of this Media.<br />

Returns:<br />

the content type or null if the content type has not been set<br />

See Also:<br />

setContentType(String)<br />

setListener<br />

void setListener(BasicUnreliableMediaListener listener)<br />

Sets a listener for this BasicUnreliableMedia, replacing any previous BasicUnreliableMediaListener.<br />

A null reference is allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 132 of 199


Interface BasicUnreliableMediaListener<br />

Interface BasicUnreliableMediaListener<br />

javax.microedition.ims.core.media<br />

public interface BasicUnreliableMediaListener<br />

A listener type for receiving notification of when BasicUnreliableMedia content is available.<br />

See Also:<br />

Media<br />

Method Summary<br />

void contentReceived(BasicUnreliableMedia media)<br />

Notifies the application when new content is available.<br />

Page<br />

133<br />

Method Detail<br />

contentReceived<br />

void contentReceived(BasicUnreliableMedia media)<br />

Notifies the application when new content is available. The content can be retrieved by calling receive on<br />

the BasicUnreliableMedia.<br />

Parameters:<br />

media - the concerned BasicUnreliableMedia<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 133 of 199


Interface FramedMedia<br />

Interface FramedMedia<br />

javax.microedition.ims.core.media<br />

All Superinterfaces:<br />

Media<br />

public interface FramedMedia<br />

extends Media<br />

The FramedMedia represents a media connection on which content is delivered in packets. It can be used for<br />

instant messages, serialized data objects or files. The media is transported with the Message Session Relay<br />

Protocol (MSRP), according to [RFC4975]. There are two different ways to access the send and receive methods:<br />

with content as byte arrays or as files.<br />

Large contents may be divided into multiple transactions. The different parts will be merged together in the remote<br />

terminal. It is possible to send and receive multiple messages simultaneous using the same FramedMedia.<br />

FramedMedia formats the locator string according to <strong>JSR</strong> 75 in sendFile and receiveFile (see [<strong>JSR</strong>75]). The<br />

following code can be used to send a file on a file system, where CFCard is a valid existing file system root name<br />

for a given implementation:<br />

framedMedia.sendFile("file:///CFCard/images/bob.png", "image/png", headers);<br />

Headers that can be set in sendFile, sendBytes and retrieved in getHeader are 'Success-Report', 'Failure-Report'<br />

and those defined in the BNF for 'Other-Mime-header' according to [RFC4975].<br />

Initializing the media<br />

FramedMedia requires no extra initialization before session.start or session.update. However, the developer<br />

should consider calling FramedMedia.setAcceptedContentTypes to restrict the set of content types.<br />

Media flows in FramedMedia<br />

If Media.canRead and Media.canWrite returns true the application may call receiveBytes or receiveFile, and<br />

sendBytes or sendFile. If they return false, IOException is thrown instead.<br />

Sending small instant messages<br />

String[] acceptedTypes = new String[] {"text/plain"};<br />

myMedia = (FramedMedia)mySession.createMedia("FramedMedia",<br />

Media.DIRECTION_SEND_RECEIVE);<br />

myMedia.setAcceptedContentTypes(acceptedTypes);<br />

mySession.start();<br />

...<br />

myMedia.setListener(this);<br />

messageId = myMedia.sendBytes("You move like a queen, Alice :-)".getBytes(),<br />

"text/plain", null);<br />

Sending images as files<br />

String[] acceptedTypes = new String[] {"image/png"};<br />

myMedia = (FramedMedia)mySession.createMedia("FramedMedia",<br />

Media.DIRECTION_SEND_RECEIVE);<br />

myMedia.setAcceptedContentTypes(acceptedTypes);<br />

mySession.start();<br />

...<br />

myMedia.setListener(this);<br />

headers = new String[][] {{"Content-Description",<br />

"a picture of a pawn"}};<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 134 of 199


Interface FramedMedia<br />

messageId = myMedia.sendFile("file:///CFCard/images/pawn.png",<br />

"image/png", headers);<br />

Receiving images and instant messages<br />

The application is notified through the callback contentReceived on the FramedMediaListener interface when<br />

new content is received. When the content has been retrieved it will be removed from the <strong>IMS</strong> engine and further<br />

retrieval for the same messageId will not be possible. Content can be retrieved with the receiveBytes or<br />

receiveFile method, regardless on how it was sent.<br />

public void contentReceived(FramedMedia media,<br />

String messageId,<br />

int size,<br />

String fileName) {<br />

}<br />

String contentType = media.getContentType(messageId);<br />

if (contentType.equals("text/plain")) {<br />

byte[] content = media.receiveBytes(messageId);<br />

...<br />

// do something with content<br />

} else if (contentType.equals("image/png")) {<br />

try {<br />

media.receiveFile(messageId, "" + fileName);<br />

} catch (IOException e) {<br />

...<br />

}<br />

}<br />

Fields inherited from interface javax.microedition.ims.core.media.Media<br />

DIRECTION_INACTIVE, DIRECTION_RECEIVE, DIRECTION_SEND, DIRECTION_SEND_RECEIVE, STATE_ACTIVE,<br />

STATE_DELETED, STATE_INACTIVE, STATE_PENDING, STATE_PROPOSAL, UPDATE_MODIFIED, UPDATE_REMOVED,<br />

UPDATE_UNCHANGED<br />

Method Summary<br />

void cancel(String messageId)<br />

Cancels the ongoing transfer.<br />

String[] getAcceptedContentTypes()<br />

Returns the accepted content type(s) of this media.<br />

String getContentType(String messageId)<br />

Returns the content type of the content that is identified by the messageId parameter.<br />

String getHeader(String messageId, String key)<br />

Returns the header value from the content that is identified by the messageId parameter.<br />

byte[] receiveBytes(String messageId)<br />

Receives content from the remote endpoint.<br />

void receiveFile(String messageId, String locator)<br />

Receives a file from the remote endpoint.<br />

String sendBytes(byte[] content, String contentType, String[][] headers)<br />

Sends the content to the remote endpoint over a reliable connection.<br />

String sendFile(String locator, String contentType, String[][] headers)<br />

Sends a file to the remote endpoint over a reliable connection.<br />

void setAcceptedContentTypes(String[] acceptedContentTypes)<br />

Sets the accepted content type(s) of this media.<br />

Page<br />

138<br />

137<br />

137<br />

137<br />

138<br />

138<br />

136<br />

136<br />

137<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 135 of 199


Interface FramedMedia<br />

void setListener(FramedMediaListener listener)<br />

Sets a listener for this FramedMedia, replacing any previous FramedMediaListener.<br />

139<br />

Methods inherited from interface javax.microedition.ims.core.media.Media<br />

canRead, canWrite, exists, getDirection, getMediaDescriptors, getProposal, getState,<br />

getUpdateState, setDirection, setMediaListener<br />

Method Detail<br />

sendBytes<br />

String sendBytes(byte[] content,<br />

String contentType,<br />

String[][] headers)<br />

throws java.io.IOException<br />

Sends the content to the remote endpoint over a reliable connection. This method is asynchronous.<br />

Parameters:<br />

content - a byte array containing the content to be sent<br />

contentType - the content MIME type<br />

headers - an array of arrays, specifying key and value, null can be used to indicate that no extra<br />

headers are desired<br />

Returns:<br />

an identifier for the content sent<br />

Throws:<br />

java.io.IOException - if canWrite returns false, or if an I/O error occurs<br />

IllegalArgumentException - if the content argument is null,<br />

if the syntax of the contentType or headers argument is invalid,<br />

if the contentType is not part of the accepted content types<br />

sendFile<br />

String sendFile(String locator,<br />

String contentType,<br />

String[][] headers)<br />

throws java.io.IOException<br />

Sends a file to the remote endpoint over a reliable connection. This method is asynchronous.<br />

Parameters:<br />

locator - the location of the file to send<br />

contentType - the content MIME type<br />

headers - an array of arrays, specifying key and value, null can be used to indicate that no extra<br />

headers are desired<br />

Returns:<br />

an identifier for the content sent<br />

Throws:<br />

java.io.IOException - if canWrite returns false, or if an I/O error occurs when operating with<br />

the file or that the file could not be opened<br />

IllegalArgumentException - if the syntax of the contentType or headers argument is invalid,<br />

if the contentType is not part of the accepted content types<br />

SecurityException - if sending a file is not permitted<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 136 of 199


Interface FramedMedia<br />

getContentType<br />

String getContentType(String messageId)<br />

Returns the content type of the content that is identified by the messageId parameter.<br />

Parameters:<br />

messageId - an identifier for the content<br />

Returns:<br />

the content type<br />

Throws:<br />

IllegalArgumentException - if the messageId is not found<br />

setAcceptedContentTypes<br />

void setAcceptedContentTypes(String[] acceptedContentTypes)<br />

Sets the accepted content type(s) of this media.<br />

If the accepted content type(s) has not been set, it will default to "*" and indicate that any content type may<br />

be transferred.<br />

See Media for valid content types.<br />

Parameters:<br />

acceptedContentTypes - an array of content types accepted in this media<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the syntax of the acceptedContentTypes argument is invalid<br />

See Also:<br />

getAcceptedContentTypes()<br />

getAcceptedContentTypes<br />

String[] getAcceptedContentTypes()<br />

Returns the accepted content type(s) of this media.<br />

If the accepted content type(s) has not been set, it will default to "*" and indicate that any content type may<br />

be transferred.<br />

Returns:<br />

the accepted content type(s) of this media<br />

See Also:<br />

setAcceptedContentTypes(String[])<br />

getHeader<br />

String getHeader(String messageId,<br />

String key)<br />

Returns the header value from the content that is identified by the messageId parameter.<br />

Parameters:<br />

messageId - an identifier for the content<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 137 of 199


Interface FramedMedia<br />

key - the header name<br />

Returns:<br />

a string containing the header value or null if the header does not exist<br />

Throws:<br />

IllegalArgumentException - if the messageId is not found,<br />

if the key is null<br />

receiveBytes<br />

byte[] receiveBytes(String messageId)<br />

throws java.io.IOException<br />

Receives content from the remote endpoint.<br />

Parameters:<br />

messageId - identifies which content to receive<br />

Returns:<br />

a byte array containing the received content<br />

Throws:<br />

java.io.IOException - if canRead returns false, or if an I/O error occurs<br />

IllegalArgumentException - if the messageId is not found or if there is no completely<br />

downloaded content corresponding to the messageId<br />

receiveFile<br />

void receiveFile(String messageId,<br />

String locator)<br />

throws java.io.IOException<br />

Receives a file from the remote endpoint. This method will create a new file at the specified location. If the<br />

file already exists, it will be overwritten.<br />

Parameters:<br />

messageId - identifies which file to receive<br />

locator - sets the location where the file will be stored<br />

Throws:<br />

java.io.IOException - if canRead returns false, or if an I/O error occurs when operating with the<br />

file or the file could not be opened<br />

IllegalArgumentException - if the messageId is not found or if there is no completely<br />

downloaded content corresponding to the messageId<br />

SecurityException - if receiving a file is not permitted<br />

cancel<br />

void cancel(String messageId)<br />

Cancels the ongoing transfer. This method can be called for outgoing and incoming content. If no matching<br />

messageId is found or if the content is already transferred, this method will not do anything.<br />

Parameters:<br />

messageId - the identifier corresponding to the content to be canceled<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 138 of 199


Interface FramedMedia<br />

setListener<br />

void setListener(FramedMediaListener listener)<br />

Sets a listener for this FramedMedia, replacing any previous FramedMediaListener. A null reference is<br />

allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 139 of 199


Interface FramedMediaListener<br />

Interface FramedMediaListener<br />

javax.microedition.ims.core.media<br />

public interface FramedMediaListener<br />

A listener type for receiving notification of when FramedMedia content is transferred. When content becomes<br />

available the application is notified by a call to the contentReceived method. The application can then retrieve the<br />

content by either using the receiveBytes or receiveFile method on the FramedMedia interface.<br />

See Also:<br />

FramedMedia<br />

Method Summary<br />

void connectionError(FramedMedia media)<br />

Notifies the application when an I/O error has occurred.<br />

void contentReceived(FramedMedia media, String messageId, int size, String fileName)<br />

Notifies the application when the content is completely received.<br />

void contentReceiveFailed(FramedMedia media, String messageId)<br />

Notifies the application that the content could not be received or that the content has been<br />

canceled by the sending endpoint.<br />

void deliveryFailure(FramedMedia media, String messageId, int statusCode, String<br />

reasonPhrase)<br />

Notifies the application when the content corresponding to the messageId has not been<br />

successfully delivered to the remote endpoint.<br />

void deliverySuccess(FramedMedia media, String messageId)<br />

Notifies the application when the content corresponding to the messageId has been<br />

successfully delivered to the remote endpoint.<br />

void transferProgress(FramedMedia media, String messageId, int bytesTransferred, int<br />

bytesTotal)<br />

Notifies the application when there is progress to be reported.<br />

Page<br />

142<br />

140<br />

141<br />

141<br />

141<br />

141<br />

Method Detail<br />

contentReceived<br />

void contentReceived(FramedMedia media,<br />

String messageId,<br />

int size,<br />

String fileName)<br />

Notifies the application when the content is completely received. The content can now be retrieved by<br />

calling receiveBytes or receiveFile with the corresponding messageId on the FramedMedia object.<br />

Parameters:<br />

media - the FramedMedia that received the content<br />

messageId - identifies the content that is ready for retrieval<br />

size - the size of the content in bytes<br />

fileName - the file name or null if a file name is not associated with the messageId<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 140 of 199


Interface FramedMediaListener<br />

contentReceiveFailed<br />

void contentReceiveFailed(FramedMedia media,<br />

String messageId)<br />

Notifies the application that the content could not be received or that the content has been canceled by the<br />

sending endpoint. The messageId is considered invalid after this callback and further use of this messageId<br />

is not possible.<br />

Parameters:<br />

media - the FramedMedia that could not receive the content<br />

messageId - identifies the content that could not be received<br />

transferProgress<br />

void transferProgress(FramedMedia media,<br />

String messageId,<br />

int bytesTransferred,<br />

int bytesTotal)<br />

Notifies the application when there is progress to be reported. This will be invoked for both outgoing and<br />

incoming content.<br />

Parameters:<br />

media - the FramedMedia that received/sent the content<br />

messageId - identifies the content that is being transferred<br />

bytesTransferred - the number of bytes that is transferred<br />

bytesTotal - the number of total bytes in the content, this parameter is -1 if the size is not known<br />

deliverySuccess<br />

void deliverySuccess(FramedMedia media,<br />

String messageId)<br />

Notifies the application when the content corresponding to the messageId has been successfully delivered<br />

to the remote endpoint. The messageId is considered invalid after this callback and further use of this<br />

messageId is not possible.<br />

This method is invoked at the endpoint that sent the content.<br />

Parameters:<br />

media - the FramedMedia that sent the content<br />

messageId - identifies the content that has been transferred<br />

deliveryFailure<br />

void deliveryFailure(FramedMedia media,<br />

String messageId,<br />

int statusCode,<br />

String reasonPhrase)<br />

Notifies the application when the content corresponding to the messageId has not been successfully<br />

delivered to the remote endpoint. The messageId is considered invalid after this callback and further use of<br />

this messageId is not possible.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 141 of 199


Interface FramedMediaListener<br />

This method is invoked at the endpoint that sent the content.<br />

See [RFC4975] for valid status codes.<br />

Parameters:<br />

media - the FramedMedia that sent the content<br />

messageId - identifies the content that could not be transferred<br />

statusCode - the status code why the transaction failed<br />

reasonPhrase - the reason phrase<br />

connectionError<br />

void connectionError(FramedMedia media)<br />

Notifies the application when an I/O error has occurred.<br />

Parameters:<br />

media - the concerned FramedMedia<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 142 of 199


Interface Media<br />

Interface Media<br />

javax.microedition.ims.core.media<br />

All Known Subinterfaces:<br />

BasicReliableMedia, BasicUnreliableMedia, FramedMedia, StreamMedia<br />

public interface Media<br />

The Media interface represents a generic media object of a session. Methods are provided common for all media<br />

types.<br />

Media objects<br />

When a calling terminal creates a session, a number of media objects can be added. When the session is started,<br />

the <strong>IMS</strong> engine creates a media offer based on the properties of the included media, and sends it to the remote<br />

endpoint. If the session is accepted, the remote endpoint has a sufficient amount of information to allow it to create<br />

the corresponding media objects. In this way, both endpoints get the same view of the media transfer. A common<br />

and useful scenario for <strong>IMS</strong> applications is to stream video and audio to render in real-time. To support efficient<br />

implementations here, an application can pass the stream to a platform-supplied standard Player that supports an<br />

appropriate common codec to do the rendering.<br />

The Media interface is used to represent the generic concept of a media in an <strong>IMS</strong> session. Methods are available<br />

that address the signalling plane of the media, while other methods supports the media plane.<br />

Media objects from a media plane perspective<br />

A media object has an associated media flow. The media flow refers to the actual realtime streaming of media<br />

content between the local and remote endpoints over the <strong>IMS</strong> network. An important function of the <strong>IMS</strong><strong>API</strong> is to<br />

enable an <strong>IMS</strong> application to read and write data on the flow, for example to exchange chat messages, audio and<br />

video or gaming data with the remote. This is the essential part of end-to-end communication of the <strong>IMS</strong>.<br />

While Media is a generic media flow-independent interface, the four media types interfaces extend Media according<br />

to the transport protocol. StreamMedia uses RTP/AVP for the basic profile, and RTP/AVPF also in the MMTel<br />

profile, FramedMedia uses TCP/MSRP, BasicUnreliableMedia uses UDP, and BasicReliableMedia is based on<br />

TCP. A media object part of a session implements one of the four media type interfaces. Because of this mapping,<br />

each media type has its specific uses. For further information on each media type, see their interfaces.<br />

Media flow and mode properties<br />

The <strong>IMS</strong> engine manages three generic boolean properties for a media flow, called media mode properties. By<br />

observing the current state of the mode properties, the application will know what actions are possible on the flow,<br />

for example read or write operations. The mode properties are:<br />

d) exists: True if there is an end-to-end media flow, false otherwise.<br />

e) canRead: True if the fmedia low accepts read of data from it, false otherwise<br />

f) canWrite: True if the flow accepts write of data to it, false otherwise<br />

Each mode mode property depends on a number of mode factors, that describe the media object in general. The<br />

node properties change their values dynamically based on the mode factors.<br />

For 'exists', there is one mode factor for any type of media:<br />

(iv) 'Exists' becomes true when the data flow is set up according to the procedures of the media type transport<br />

protocol, and false when the media flow is torn down.<br />

That mode factor implies 'exists' is false if media is in STATE_INACTIVE, STATE_DELETED and STATE_PROPOSAL.<br />

For 'canRead' the following factors apply for any type of media:<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 143 of 199


Interface Media<br />

• The 'exists' mode is true.<br />

• The media direction is DIRECTION_RECEIVE or DIRECTION_SEND_RECEIVE<br />

• The flow contains, or is capable to contain, data available for read.<br />

For 'canWrite' the following factors apply for any type of media:<br />

• The 'exists' mode is true.<br />

• The media direction is DIRECTION_SEND or DIRECTION_SEND_RECEIVE<br />

• The media is in STATE_ACTIVE<br />

The media must be in STATE_ACTIVE due to that the application should be able to write data before the session is<br />

established.<br />

The <strong>IMS</strong> engine feeds the StreamMedia with input to the flow, and this additional factor applies there for 'canWrite':<br />

• There is data available from the stream media source<br />

'canRead' and 'canWrite' are independent of each other.<br />

Besides the above, device-specific constraints may apply. For example, if there is a higher priority process that<br />

claims networking resources, then 'canRead' and 'canWrite may be set to false until the resources are made<br />

available again to the application.<br />

The boolean methods Media.exists, Media.canRead, and Media.canWrite are available to all media objects to<br />

get the current property values. An application that reads incoming data SHOULD make sure that Media.canRead<br />

returns true before attempting to read, and that Media.canWrite returns true when writing data.<br />

Due to that properties are changed dynamically, the MediaListener callback interface is provided. This interface is<br />

used when the <strong>IMS</strong> engine notifies the application of mode changes on the media.<br />

A note on mode properties and media direction<br />

The direction of the media component is part of the session contract, i.e. it is an agreement between the local and<br />

remote devices on how the media is supposed to be used. By observing the media mode properties to see if it is<br />

allowed to operate on the media flow, the application does not have to consider the media direction in its code.<br />

Media objects from a signaling perspective<br />

There are some aspects of the media objects seen from a signaling perspective. These are described below.<br />

Initializing the media<br />

There are different rules for how a media MUST be initialized between media creation and session start or update.<br />

See further sections for the respective media types.<br />

Content Types<br />

Content types identifies the content type of a Media. They can be registered MIME types or some user defined type<br />

that follow the MIME syntax. See [RFC2045] and [RFC2046].<br />

Example content types:<br />

• "text/plain"<br />

• "image/png"<br />

• "video/mpeg"<br />

• "application/myChess"<br />

Media Life Cycle<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 144 of 199


Interface Media<br />

The life cycle of each Media is independent of other Medias life cycles and has four main states: STATE_INACTIVE,<br />

STATE_PENDING, STATE_ACTIVE and STATE_DELETED. There is also a fifth state, STATE_PROPOSAL, that is not part of<br />

the ordinary life cycle but instead only meant to track changes on a modified Media.<br />

The media life cycle is connected to the life cycle of the Session. A transition in a Media is the effect of a session<br />

transition in the form of a session callback, or a method call in the session, as can be seen in Figure 1.<br />

Figure 1: The media states visible on the originating endpoint, except STATE_PROPOSAL<br />

Update state<br />

The update state is used to track changes that have been done to an active Media on either the originating or<br />

terminating endpoint. If a Media has been accepted in a session the update state will be UPDATE_UNCHANGED.<br />

If a Media is proposed to be removed or modified the getUpdateState reflect the changes but the modifications<br />

does not take place before the Session has been negotiated and accepted. The modifications can however be<br />

traced by inspecting the proposed Media, that can be obtained with the getProposal method, until the Session is<br />

updated.<br />

After a session update the application SHOULD call getMedia on the Session and take actions if needed.<br />

Examples of the Media states and update states<br />

This example shows which state and update state the Media can reside in at the terminating endpoint when<br />

receiving a session invitation or session update. The state and update state will be the same for the originating<br />

endpoint as well.<br />

public void sessionInvitationReceived(CoreService service, Session session) {<br />

// all medias are pending in a session invite<br />

media.getState() == STATE_PENDING;<br />

// getUpdateState is not applicable in this state<br />

}<br />

...<br />

public void sessionUpdateReceived(Session session) {<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 145 of 199


Interface Media<br />

}<br />

// this will show that the media is proposed to be added to the session<br />

media.getState() == STATE_PENDING;<br />

// getUpdateState is not applicable in this state<br />

...<br />

// this will show that the media is proposed to be removed from the session<br />

media.getState() == STATE_ACTIVE;<br />

media.getUpdateState() == UPDATE_REMOVED;<br />

...<br />

// this will show that the media is proposed to be modified in a session<br />

media.getState() == STATE_ACTIVE;<br />

media.getUpdateState() == UPDATE_MODIFIED;<br />

media.getProposal(); // returns a fictious media to track changes<br />

...<br />

// this will show a media that is unchanged in the session update<br />

media.getState() == STATE_ACTIVE;<br />

media.getUpdateState() == UPDATE_UNCHANGED;<br />

This example shows how an application can inspect changes done to a media in a session update.<br />

public void sessionUpdateReceived(Session session) {<br />

// if the first media in the array is a media in STATE_ACTIVE and<br />

// update state is UPDATE_MODIFIED<br />

}<br />

Media currentMedia = session.getMedia()[0];<br />

Media changedMedia = currentMedia.getProposal();<br />

// then the application can track changes, for example<br />

if (currentMedia.getDirection() != changedMedia.getDirection()) {<br />

...<br />

}<br />

// and now the application can decide if the update should be accepted or<br />

// rejected<br />

session.accept();<br />

Field Summary<br />

int DIRECTION_INACTIVE<br />

The Media has an inactive direction, meaning it cannot send or receive content.<br />

int DIRECTION_RECEIVE<br />

The Media can receive content, but not send.<br />

int DIRECTION_SEND<br />

The Media can send content, but not receive.<br />

int DIRECTION_SEND_RECEIVE<br />

The Media can send and receive content, also known as a bi-directional media.<br />

int STATE_ACTIVE<br />

The Media exists in a session and the media offer has been accepted by both parties.<br />

int STATE_DELETED<br />

The Media has been part of an existing session but is now removed, or the Media has<br />

been rejected or deleted by the <strong>IMS</strong> engine.<br />

int STATE_INACTIVE<br />

The Media is created and added to a session.<br />

int STATE_PENDING<br />

The Media exists in a session and a media offer has been sent to the remote endpoint.<br />

int STATE_PROPOSAL<br />

The Media is a fictitious media and is only meant to be inspected to track changes during<br />

a session update.<br />

Page<br />

147<br />

147<br />

148<br />

148<br />

148<br />

148<br />

148<br />

148<br />

148<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 146 of 199


Interface Media<br />

int UPDATE_MODIFIED<br />

This sub-state specifies that this Media is proposed to be modified and must be negotiated<br />

before the modifications can be deployed.<br />

int UPDATE_REMOVED<br />

This sub-state specifies that this Media is proposed to be removed from the session and<br />

must be negotiated before removal can be made.<br />

int UPDATE_UNCHANGED<br />

This sub-state specifies that this Media is unchanged since session establishment or the<br />

last session update.<br />

149<br />

149<br />

149<br />

Method Summary<br />

boolean canRead()<br />

Returns true if it is possible to read from the data flow.<br />

boolean canWrite()<br />

Returns true if it is possible to write to the data flow.<br />

boolean exists()<br />

Returns true if there is a data flow for this media.<br />

int getDirection()<br />

Returns the current direction of this Media.<br />

MediaDescriptor[] getMediaDescriptors()<br />

Returns the media descriptor(s) associated with this Media.<br />

Media getProposal()<br />

Returns a fictitious media that is only meant to track changes that are about to be<br />

made to the media.<br />

int getState()<br />

Returns the current state of this Media.<br />

int getUpdateState()<br />

Returns the current update state of this Media.<br />

void setDirection(int direction)<br />

Sets the direction of this Media.<br />

void setMediaListener(MediaListener listener)<br />

Sets a listener for this Media, replacing any previous MediaListener.<br />

Page<br />

151<br />

151<br />

151<br />

149<br />

149<br />

150<br />

150<br />

150<br />

150<br />

151<br />

Field Detail<br />

DIRECTION_INACTIVE<br />

public static final int DIRECTION_INACTIVE<br />

The Media has an inactive direction, meaning it cannot send or receive content.<br />

DIRECTION_RECEIVE<br />

public static final int DIRECTION_RECEIVE<br />

The Media can receive content, but not send.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 147 of 199


Interface Media<br />

DIRECTION_SEND<br />

public static final int DIRECTION_SEND<br />

The Media can send content, but not receive.<br />

DIRECTION_SEND_RECEIVE<br />

public static final int DIRECTION_SEND_RECEIVE<br />

The Media can send and receive content, also known as a bi-directional media.<br />

STATE_INACTIVE<br />

public static final int STATE_INACTIVE<br />

The Media is created and added to a session.<br />

The Media is not active and there can currently be no content transfer within this Media.<br />

STATE_PENDING<br />

public static final int STATE_PENDING<br />

The Media exists in a session and a media offer has been sent to the remote endpoint. A new Media that is<br />

added in an incoming invite/update also resides in this state.<br />

The Media is not active and there can currently be no content transfer within this Media.<br />

STATE_ACTIVE<br />

public static final int STATE_ACTIVE<br />

The Media exists in a session and the media offer has been accepted by both parties.<br />

The Media is active and content can be transferred within this Media.<br />

STATE_DELETED<br />

public static final int STATE_DELETED<br />

The Media has been part of an existing session but is now removed, or the Media has been rejected or<br />

deleted by the <strong>IMS</strong> engine.<br />

The Media is not active and there can currently be no content transfer within this Media.<br />

STATE_PROPOSAL<br />

public static final int STATE_PROPOSAL<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 148 of 199


Interface Media<br />

The Media is a fictitious media and is only meant to be inspected to track changes during a session update.<br />

After the session update this Media should be considered discarded.<br />

UPDATE_UNCHANGED<br />

public static final int UPDATE_UNCHANGED<br />

This sub-state specifies that this Media is unchanged since session establishment or the last session<br />

update.<br />

UPDATE_MODIFIED<br />

public static final int UPDATE_MODIFIED<br />

This sub-state specifies that this Media is proposed to be modified and must be negotiated before the<br />

modifications can be deployed.<br />

The modifications can be traced by inspecting the proposed Media by calling getProposal.<br />

UPDATE_REMOVED<br />

public static final int UPDATE_REMOVED<br />

This sub-state specifies that this Media is proposed to be removed from the session and must be<br />

negotiated before removal can be made.<br />

Method Detail<br />

getMediaDescriptors<br />

MediaDescriptor[] getMediaDescriptors()<br />

Returns the media descriptor(s) associated with this Media.<br />

Returns:<br />

the media descriptor(s)<br />

getDirection<br />

int getDirection()<br />

Returns the current direction of this Media.<br />

Returns:<br />

the current direction of this Media<br />

See Also:<br />

setDirection(int)<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 149 of 199


Interface Media<br />

setDirection<br />

void setDirection(int direction)<br />

Sets the direction of this Media.<br />

If a Media is changed in an established Session, the application has the responsibility to call update on the<br />

Session.<br />

Note: If the Media is in STATE_ACTIVE the direction will be set on the proposal media until the Session has<br />

been updated. The proposal media can be retrieved with the getProposal method on the Media interface.<br />

Parameters:<br />

direction - the direction of the Media<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE or STATE_ACTIVE<br />

IllegalArgumentException - if the direction argument is invalid<br />

See Also:<br />

getDirection()<br />

getState<br />

int getState()<br />

Returns the current state of this Media.<br />

Returns:<br />

the current state<br />

getUpdateState<br />

int getUpdateState()<br />

Returns the current update state of this Media.<br />

Returns:<br />

the current update state<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_ACTIVE<br />

getProposal<br />

Media getProposal()<br />

Returns a fictitious media that is only meant to track changes that are about to be made to the media.<br />

After the Session has been accepted or rejected this proposed media should be considered discarded.<br />

Returns:<br />

a media proposal<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_ACTIVE,<br />

if the update state is not in UPDATE_MODIFIED<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 150 of 199


Interface Media<br />

exists<br />

boolean exists()<br />

Returns true if there is a data flow for this media.<br />

Returns:<br />

true if a data flow exists, false otherwise<br />

canRead<br />

boolean canRead()<br />

Returns true if it is possible to read from the data flow.<br />

Returns:<br />

true if a data flow allows read, false otherwise<br />

canWrite<br />

boolean canWrite()<br />

Returns true if it is possible to write to the data flow.<br />

Returns:<br />

true if a data flow allows write, false otherwise<br />

setMediaListener<br />

void setMediaListener(MediaListener listener)<br />

Sets a listener for this Media, replacing any previous MediaListener. The method<br />

MediaListener.modeChanged is called directly after setting a MediaListener with this method.<br />

A null reference is allowed and has the effect of removing any existing listener.<br />

Parameters:<br />

listener - the listener to set, or null<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 151 of 199


Interface MediaDescriptor<br />

Interface MediaDescriptor<br />

javax.microedition.ims.core.media<br />

public interface MediaDescriptor<br />

MediaDescriptor is an interface towards the media parts of the SDP. The interface is most useful for applications<br />

that, within the realm of a composed capability (ICSI, IARI and/or other service level feature tags), need to<br />

manipulate media-related fields of the session SDP in general, and add new application-specific attributes in<br />

particular.<br />

The example SDP below shows the media-related parts accessible from the interface in bold.<br />

v=0<br />

o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com<br />

s=<br />

c=IN IP4 host.atlanta.example.com<br />

t=0 0<br />

m=audio 49170 RTP/AVP 0 8 97<br />

a=rtpmap:0 PCMU/8000<br />

a=rtpmap:8 PCMA/8000<br />

a=rtpmap:97 iLBC/8000<br />

m=video 51372 RTP/AVP 31 32<br />

a=rtpmap:31 H261/90000<br />

a=rtpmap:32 MPV/90000<br />

The getters of the interface read fields from the last received SDP. The setters modify all remaining SDPs to be<br />

sent during the lifetime of the media in the session, or until superseded by other modifications.<br />

The application can get, set, and remove SDP lines that are not reserved for the <strong>IMS</strong> engine. Attributes can be get,<br />

set and removed freely except reserved. The following attributes are classified as unconditionally reserved and can<br />

not be modified using the MediaDescriptor interface: des, curr, conf, mid, ice-pwd, ice-ufrag, candidate,<br />

remote-candidates, sendonly, recvonly, sendrecv, inactive, csup, creq, acap, tcap, pcfg, acfg, 3gpp_sync_info.<br />

Depending on the contents of the protocol field in the m-line (in the example SDP the field is set to RTP/AVP) other<br />

attributes are reserved according to the following:<br />

RTP/AVP (set for StreamMedia): rtpmap, fmtp, dccp-service-code, rtcp-mux, rtp-fb, ptime, maxptime, framesize,<br />

framerate, quality<br />

TCP (set for BasicReliableMedia): setup, connection<br />

TCP/MSRP (set for FramedMedia): setup, connection, accept-types, accept-wrapped-types, max-size, path<br />

See Also:<br />

SessionDescriptor<br />

Method Summary<br />

void addAttribute(String attribute)<br />

Adds an attribute (a=) to the Media.<br />

String[] getAttributes()<br />

Returns all attributes (a=) for the Media.<br />

String[] getBandwidthInfo()<br />

Returns the proposed bandwidth (b=) to be used by the media.<br />

String getMediaDescription()<br />

Returns the contents of the media description field (m=) of the current incoming SDP for this<br />

media.<br />

String getMediaTitle()<br />

Returns the title (i=) of the Media.<br />

Page<br />

154<br />

155<br />

154<br />

155<br />

153<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 152 of 199


Interface MediaDescriptor<br />

void removeAttribute(String attribute)<br />

Removes an attribute (a=) from the Media.<br />

void setBandwidthInfo(String[] info)<br />

Sets the proposed bandwidth (b=) to be used by the media.<br />

void setMediaTitle(String title)<br />

Sets a title (i=) to the Media.<br />

154<br />

153<br />

153<br />

Method Detail<br />

setMediaTitle<br />

void setMediaTitle(String title)<br />

Sets a title (i=) to the Media.<br />

Parameters:<br />

title - the Media title to set<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the title argument is null<br />

See Also:<br />

getMediaTitle()<br />

getMediaTitle<br />

String getMediaTitle()<br />

Returns the title (i=) of the Media.<br />

See [RFC4566], chapter 5.4. for more information.<br />

Returns:<br />

the Media title or null if the title has not been set<br />

See Also:<br />

setMediaTitle(String)<br />

setBandwidthInfo<br />

void setBandwidthInfo(String[] info)<br />

Sets the proposed bandwidth (b=) to be used by the media.<br />

See [RFC4566], chapter 5.8. for more information.<br />

Example:<br />

MediaDescriptor desc;<br />

desc.setBandwidthInfo(new String[]{ "AS:128" });<br />

Parameters:<br />

info - the bandwidth info to set<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE or STATE_ACTIVE,<br />

if the current media profile is vs or mmtel.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 153 of 199


Interface MediaDescriptor<br />

IllegalArgumentException - if the info argument is null or if the syntax is invalid<br />

See Also:<br />

getBandwidthInfo()<br />

getBandwidthInfo<br />

String[] getBandwidthInfo()<br />

Returns the proposed bandwidth (b=) to be used by the media. An empty string array will be returned if the<br />

bandwidth information could not be retrieved.<br />

See [RFC4566], chapter 5.8. for more information.<br />

Returns:<br />

bandwidth information<br />

See Also:<br />

setBandwidthInfo(String[])<br />

removeAttribute<br />

void removeAttribute(String attribute)<br />

Removes an attribute (a=) from the Media.<br />

The example below removes the "max-size:2048000" attribute for a FramedMedia.<br />

MediaDescriptor[] desc = framedMedia.getMediaDescriptors();<br />

desc[0].removeAttribute("max-size:2048000");<br />

Note: If the Media is in STATE_ACTIVE the attribute will be removed on the proposal media until the<br />

Session has been updated. The proposal media can be retrieved with the getProposal method on the<br />

Media interface.<br />

Parameters:<br />

attribute - the attribute to remove<br />

Throws:<br />

IllegalArgumentException - if the attribute argument is null,<br />

if the attribute does not exist in the Media,<br />

if the attribute could not be removed<br />

IllegalStateException - if the Media is not in STATE_INACTIVE or STATE_ACTIVE<br />

addAttribute<br />

void addAttribute(String attribute)<br />

Adds an attribute (a=) to the Media. Adding attributes that the <strong>IMS</strong> engine can set, such as "sendonly",<br />

"recvonly", "sendrecv", will lead to an IllegalArgumentException.<br />

The example below adds two attributes for a FramedMedia.<br />

MediaDescriptor[] desc = framedMedia.getMediaDescriptors();<br />

desc[0].addAttribute("max-size:2048000");<br />

desc[0].addAttribute("synced");<br />

The resulting attribute lines will be:<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 154 of 199


Interface MediaDescriptor<br />

a=max-size:2048000<br />

a=synced<br />

Note: If the Media is in STATE_ACTIVE the attribute will be set on the proposal media until the Session has<br />

been updated. The proposal media can be retrieved with the getProposal method on the Media interface.<br />

Parameters:<br />

attribute - the attribute to add<br />

Throws:<br />

IllegalArgumentException - if the attribute argument is null or if the syntax of the attribute<br />

argument is invalid,<br />

if the attribute already exist in the Media,<br />

if the attribute could not be added<br />

IllegalStateException - if the Media is not in STATE_INACTIVE or STATE_ACTIVE<br />

getAttributes<br />

String[] getAttributes()<br />

Returns all attributes (a=) for the Media. If there are no attributes, an empty string array will be returned.<br />

Returns:<br />

a string array containing the attributes<br />

getMediaDescription<br />

String getMediaDescription()<br />

throws IllegalStateException<br />

Returns the contents of the media description field (m=) of the current incoming SDP for this media.<br />

Example of an SDP m-line that may be returned for an audio stream media: audio 4000 RTP/AVP 97 101<br />

Returns:<br />

the media description<br />

Throws:<br />

IllegalStateException - if the Media is in STATE_INACTIVE<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 155 of 199


Interface MediaListener<br />

Interface MediaListener<br />

javax.microedition.ims.core.media<br />

public interface MediaListener<br />

A listener type for receiving notification of when some mode property has changed on the media flow.<br />

See Also:<br />

BasicReliableMedia<br />

Method Summary<br />

void modeChanged(Media media)<br />

The method is called when some media mode property has changed.<br />

Page<br />

156<br />

Method Detail<br />

modeChanged<br />

void modeChanged(Media media)<br />

The method is called when some media mode property has changed. See Media interface for a description<br />

of media mode properties.<br />

Parameters:<br />

media - the concerned Media<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 156 of 199


Class MediaPermission<br />

Class MediaPermission<br />

javax.microedition.ims.core.media<br />

java.lang.Object<br />

java.security.Permission<br />

java.security.BasicPermission<br />

javax.microedition.ims.core.media.MediaPermission<br />

public class MediaPermission<br />

extends java.security.BasicPermission<br />

This class represents permissions to send or receive files in the <strong>IMS</strong><strong>API</strong>. A MediaPermission consists of a<br />

pathname and a set of actions valid for that pathname.<br />

Pathname is the pathname of the file or directory granted the specified actions. A pathname that ends in "/*" (where<br />

"/" is the file separator character, File.separatorChar) indicates all the files and directories contained in that<br />

directory. A pathname consisting of the special token "" matches any file.<br />

The actions to be granted are passed to the constructor in a string containing a list of one or more<br />

comma-separated keywords. The possible keywords are "read" and "write". "read" means permission to read the<br />

contents of the file and send to the remote endpoint. "write" means means permission to receive contents from the<br />

remote and write that to the file pathname.<br />

The actions string is converted to lowercase before processing.<br />

Constructor Summary<br />

MediaPermission(String pathname, String actions)<br />

Creates a new MediaPermission object with the specified actions.<br />

Page<br />

158<br />

Method Summary<br />

boolean equals(Object obj)<br />

Checks two MediaPermission objects for equality.<br />

String getActions()<br />

Returns the "canonical string representation" of the actions.<br />

int hashCode()<br />

Returns the hash code value for this object.<br />

boolean implies(java.security.Permission p)<br />

Checks if this FilePermission object "implies" the specified permission.<br />

Page<br />

158<br />

158<br />

158<br />

159<br />

Methods inherited from class java.security.BasicPermission<br />

newPermissionCollection<br />

Methods inherited from class java.security.Permission<br />

getName, toString<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 157 of 199


Class MediaPermission<br />

Constructor Detail<br />

MediaPermission<br />

public MediaPermission(String pathname,<br />

String actions)<br />

Creates a new MediaPermission object with the specified actions. pathname is the pathname of a file or<br />

directory possibly ending with "/*", or the special token "" matching any file. actions<br />

contains a comma-separated list of the desired actions granted on the file. Possible actions are "read" and<br />

"write".<br />

Parameters:<br />

pathname - the pathname of the file<br />

actions - the action string<br />

Throws:<br />

IllegalArgumentException - if actions is null, empty or contains an action other than the<br />

specified possible actions.<br />

Method Detail<br />

equals<br />

public boolean equals(Object obj)<br />

Checks two MediaPermission objects for equality.<br />

Overrides:<br />

equals in class java.security.BasicPermission<br />

Parameters:<br />

obj - the object we are testing for equality with this object.<br />

Returns:<br />

true if obj is a MediaPermission and has the same path and actions as this MediaPermission<br />

object.<br />

See Also:<br />

java.security.Permission.equals(java.lang.Object)<br />

getActions<br />

public String getActions()<br />

Returns the "canonical string representation" of the actions. That is, this method always returns present<br />

actions in the following order: read, write. For example, if this MediaPermission object allows both write<br />

and read actions, a call to getActions will return the string "read,write".<br />

Overrides:<br />

getActions in class java.security.BasicPermission<br />

Returns:<br />

the canonical string representation of the actions.<br />

See Also:<br />

java.security.Permission.getActions()<br />

hashCode<br />

public int hashCode()<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 158 of 199


Class MediaPermission<br />

Returns the hash code value for this object.<br />

Overrides:<br />

hashCode in class java.security.BasicPermission<br />

Returns:<br />

a hash code value for this object.<br />

implies<br />

public boolean implies(java.security.Permission p)<br />

Checks if this FilePermission object "implies" the specified permission. This method returns true if:<br />

• p is an instanceof FilePermission<br />

• p's actions are a proper subset of this object's actions, and<br />

• p's pathname is implied by this object's pathname. For example, "/tmp/*" implies "/tmp/foo", since<br />

"/tmp/*" encompasses all files in the "/tmp" directory, including the one named "foo".<br />

Overrides:<br />

implies in class java.security.BasicPermission<br />

Parameters:<br />

p - the permission to check against.<br />

Returns:<br />

true if the specified permission is not null and is implied by this object, false otherwise.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 159 of 199


Interface StreamMedia<br />

Interface StreamMedia<br />

javax.microedition.ims.core.media<br />

All Superinterfaces:<br />

Media<br />

public interface StreamMedia<br />

extends Media<br />

The StreamMedia represents a standardized application-independent streaming media that can be rendered in<br />

real-time. The typical use is to stream audio or video content between endpoints in real-time, in for example<br />

telephony applications. The <strong>IMS</strong> engine manages the media formats, codecs and protocols used in the<br />

transmission according to relevant standard. It is possible to stream audio and video separately, as well as<br />

combined audio and video.<br />

By default, the StreamMedia object supports audio streaming, which is mandatory for all devices claiming<br />

streaming support. The data is sourced from a microphone of the device.<br />

The originating endpoint may call StreamMedia.setStreamType to explicitly set the media type for streaming,<br />

regardless of whether it is going to send or receive media. This is not possible for the terminating endpoint. For<br />

video (moving pictures), the camera is used to source video content. Both peripherals are used for the combined<br />

audio video media. If the terminal has several microphones, or cameras, the choice is implementation-specific.<br />

It is possible for an originating endpoint to change the data source to something else if needed. This is not available<br />

to the terminating endpoint, thus limiting it to stream only from microphone and/or camera.<br />

Players<br />

A pair of players is used to control the data flow, and rendering. If canRead returns true, the application may call<br />

Player.start or Player.prefetch on the receiving player, and then the <strong>IMS</strong> engine starts receiving data and<br />

render. If canWrite returns true, the application may call Player.start or Player.prefetch for a sending player,<br />

and then the <strong>IMS</strong> engine starts sending data and render it. If the methods return false, then Player.start and<br />

Player.prefetch throw MediaException.<br />

If canRead and/or canWrite returns false while a receiving and/or sending player is started, respectively, the <strong>IMS</strong><br />

engine calls Player.deallocate on those players.<br />

It may be the case, depending on the underlying session negotiation process, that the players got from the media<br />

are in an Unrealized or Realized state. When canRead and canWrite eventually returns true, the players are<br />

realized to enable player.start.<br />

On a started player, the application can call Player.stop and Player.deallocate even if the media mode<br />

properties (see Media interface) are still true.<br />

A call to Player.close aborts the data flow transfer for that player immediately. It is not possible to recover.<br />

Initializing the media<br />

StreamMedia requires no further initialization before calling Session.start or Session.update. However, the<br />

developer should consider calling setStreamType or setSource, and setPreferredQuality.<br />

Setting up streaming media session<br />

To setup the streaming media in a session, the originating endpoint goes through the following steps:<br />

• Creates streaming media objects<br />

• Set direction<br />

• Set the streaming media type for the objects, or set the data source if needed<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 160 of 199


Interface StreamMedia<br />

• start the session<br />

• get the players and start<br />

The terminating endpoint does the following in response to the invitation<br />

• Inspects the offered media components of the session<br />

• accept session<br />

• get the players and start<br />

Playback Examples<br />

Set up a bidirectional audio media<br />

try {<br />

myMedia =<br />

(StreamMedia)mySession.createMedia("StreamMedia",<br />

Media.DIRECTION_SEND_RECEIVE);<br />

myMedia.setStreamType(STREAM_TYPE_AUDIO);<br />

myMedia.setSource("capture://audio");<br />

mySession.start();<br />

pIn = myMedia.getReceivingPlayer();<br />

pOut = myMedia.getSendingPlayer();<br />

} catch (ImsException ie) {<br />

}<br />

Wait until the media flow mode changes to allow read and write. The code below can be placed in the<br />

MediaListener.modeChanged callback:<br />

if (myMedia.canRead()) {<br />

try {<br />

pIn.start();<br />

} catch (MediaException me) {<br />

}<br />

}<br />

if (myMedia.canWrite()) {<br />

try {<br />

pOut.start();<br />

} catch (MediaException me) {<br />

}<br />

}<br />

Stream from a multiplexed file<br />

try {<br />

myMedia =<br />

(StreamMedia)mySession.createMedia("StreamMedia", Media.DIRECTION_SEND);<br />

myMedia.setStreamType(STREAM_TYPE_AUDIO_VIDEO);<br />

myMedia.setSource("file:///root/sample.mpg");<br />

mySession.start();<br />

pOut = myMedia.getSendingPlayer();<br />

} catch (ImsException ie) {<br />

}<br />

As before, the player is started in the MediaListener.modeChanged callback.<br />

if (myMedia.canWrite()) {<br />

try {<br />

pOut.start();<br />

} catch (MediaException me) {<br />

}<br />

}<br />

Putting a stream media on hold<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 161 of 199


Interface StreamMedia<br />

RFC 3264 An Offer/Answer Model Session Description Protocol [RFC3264] describes a procedure for putting<br />

media streams on hold, i.e. request the remote to (temporarily) stop sending a media flow. A send receive media<br />

will be given direction Send, and a Receive media gets the Inactive direction. In the code example below, myMedia<br />

had direction Send Receive.<br />

try {<br />

myMedia.setDirection(DIRECTION_SEND);<br />

mySendingPlayer.deallocate();<br />

mySession.update();<br />

} catch (ImsException ie) {<br />

}<br />

To resume myMedia, the application restores the original direction and then start players in for example the<br />

MediaListener.modeChanged callback:<br />

try {<br />

if (myMedia.canRead()) {<br />

myReceivingPlayer().start();<br />

}<br />

if (myMedia.canWrite()) {<br />

mySendingPlayer().start();<br />

}<br />

} catch (MediaException me) {<br />

}<br />

Field Summary<br />

int QUALITY_HIGH<br />

Enables the platform to choose a higher quality codec during the negotiation of the media.<br />

int QUALITY_LOW<br />

Enables the platform to choose a lower quality codec during the negotiation of the media.<br />

int QUALITY_MEDIUM<br />

Enables the platform to choose a medium quality codec during the negotiation of the<br />

media.<br />

int STREAM_TYPE_AUDIO<br />

Indicates that the streaming will consist only of audio.<br />

int STREAM_TYPE_AUDIO_VIDEO<br />

Indicates that the streaming will consist of audio and video.<br />

int STREAM_TYPE_VIDEO<br />

Indicates that the streaming will consist only of video.<br />

Page<br />

163<br />

163<br />

163<br />

163<br />

163<br />

163<br />

Fields inherited from interface javax.microedition.ims.core.media.Media<br />

DIRECTION_INACTIVE, DIRECTION_RECEIVE, DIRECTION_SEND, DIRECTION_SEND_RECEIVE, STATE_ACTIVE,<br />

STATE_DELETED, STATE_INACTIVE, STATE_PENDING, STATE_PROPOSAL, UPDATE_MODIFIED, UPDATE_REMOVED,<br />

UPDATE_UNCHANGED<br />

Method Summary<br />

javax.microedition.media.Player<br />

javax.microedition.media.Player<br />

int<br />

void<br />

getReceivingPlayer()<br />

Returns a Player initiated to render the receiving part of this Media.<br />

getSendingPlayer()<br />

Returns a Player initiated to source the sending part of this Media.<br />

getStreamType()<br />

Returns the stream type for the Media.<br />

setPreferredQuality(int quality)<br />

Sets a preferred quality of the media stream.<br />

Page<br />

165<br />

165<br />

164<br />

165<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 162 of 199


Interface StreamMedia<br />

void<br />

void<br />

setSource(String source)<br />

Sets the source to capture media from.<br />

setStreamType(int type)<br />

Sets the stream type for the Media.<br />

164<br />

164<br />

Methods inherited from interface javax.microedition.ims.core.media.Media<br />

canRead, canWrite, exists, getDirection, getMediaDescriptors, getProposal, getState,<br />

getUpdateState, setDirection, setMediaListener<br />

Field Detail<br />

QUALITY_LOW<br />

public static final int QUALITY_LOW<br />

Enables the platform to choose a lower quality codec during the negotiation of the media.<br />

QUALITY_MEDIUM<br />

public static final int QUALITY_MEDIUM<br />

Enables the platform to choose a medium quality codec during the negotiation of the media.<br />

QUALITY_HIGH<br />

public static final int QUALITY_HIGH<br />

Enables the platform to choose a higher quality codec during the negotiation of the media.<br />

STREAM_TYPE_AUDIO<br />

public static final int STREAM_TYPE_AUDIO<br />

Indicates that the streaming will consist only of audio.<br />

STREAM_TYPE_VIDEO<br />

public static final int STREAM_TYPE_VIDEO<br />

Indicates that the streaming will consist only of video.<br />

STREAM_TYPE_AUDIO_VIDEO<br />

public static final int STREAM_TYPE_AUDIO_VIDEO<br />

Indicates that the streaming will consist of audio and video.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 163 of 199


Interface StreamMedia<br />

Method Detail<br />

setSource<br />

void setSource(String source)<br />

Sets the source to capture media from. If this method is not called, then the audio is sourced from a default<br />

microphone of the device, and video is sourced from a default camera.<br />

Supported sources:<br />

• capture://<br />

• file://<br />

device = "audio" / "video" / "audio_video" / dev_name<br />

dev_name = alphanumeric<br />

alphanumeric = 1*( ALPHA / DIGIT )<br />

See [<strong>JSR</strong>135] for more information on the capture locator.<br />

See [<strong>JSR</strong>75] for more information on the file locator.<br />

Parameters:<br />

source - the source locator URI of media to be streamed<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the syntax of the source argument is invalid or not supported<br />

setStreamType<br />

void setStreamType(int type)<br />

Sets the stream type for the Media. This is used as an indication for the <strong>IMS</strong> engine regarding which<br />

stream type to use for this media.<br />

If the stream type has not been set, it will default to STREAM_TYPE_AUDIO.<br />

Note: The use case for this method is when the application adds a StreamMedia to a session with direction<br />

set to DIRECTION_RECEIVE. In this case, the <strong>IMS</strong> engine does not know which kind of StreamMedia to use<br />

in the negotiation. If the setSource method conflicts with the stream type, the setSource method has<br />

priority.<br />

Parameters:<br />

type - the stream type<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the type argument is not a valid identifier or not supported<br />

See Also:<br />

getStreamType()<br />

getStreamType<br />

int getStreamType()<br />

Returns the stream type for the Media.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 164 of 199


Interface StreamMedia<br />

If the stream type has not been set, it will default to STREAM_TYPE_AUDIO.<br />

Returns:<br />

the stream type<br />

See Also:<br />

setStreamType(int)<br />

getReceivingPlayer<br />

javax.microedition.media.Player getReceivingPlayer()<br />

throws java.io.IOException<br />

Returns a Player initiated to render the receiving part of this Media. The returned Player is in the<br />

REALIZED state.<br />

Returns:<br />

a Player<br />

Throws:<br />

java.io.IOException - if the exists property is false for the media<br />

getSendingPlayer<br />

javax.microedition.media.Player getSendingPlayer()<br />

throws java.io.IOException<br />

Returns a Player initiated to source the sending part of this Media. The returned Player is in the<br />

REALIZED state.<br />

Returns:<br />

a Player<br />

Throws:<br />

java.io.IOException - if the exists property is false for the media<br />

setPreferredQuality<br />

void setPreferredQuality(int quality)<br />

Sets a preferred quality of the media stream. This method does not guarantee the desired quality but<br />

enables the platform during the media negotiation to select an appropriate quality of service if possible.<br />

Defaults to QUALITY_MEDIUM.<br />

Parameters:<br />

quality - the preferred quality<br />

Throws:<br />

IllegalStateException - if the Media is not in STATE_INACTIVE<br />

IllegalArgumentException - if the quality argument is invalid<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 165 of 199


Appendix A<br />

Appendix A: Implementation guidelines<br />

This chapter contains implementation best practice using the SIP, SDP and other protocols of <strong>IMS</strong>, to address<br />

interoperability between <strong>IMS</strong><strong>API</strong> implementations and the <strong>IMS</strong> network.<br />

Classes, interfaces and methods are described and it is shown how these will behave and relate to the protocols<br />

and procedures used. The following specifications (and their references) should be considered normative where<br />

applicable:<br />

• 3GPP TS24.229 6.17.0, and the documents that it refers to<br />

• 3GPP TS24.229 7.11.0, only for the parts relevant to ICSI and IARI.<br />

Overview<br />

The <strong>IMS</strong><strong>API</strong> is designed to be an abstraction of <strong>IMS</strong> concepts that allows implementing <strong>IMS</strong> applications, according<br />

to the application model described initially in the specification.<br />

The term <strong>IMS</strong> Engine is used in this chapter to refer to the <strong>IMS</strong> functionality of the device. It can be understood<br />

from the <strong>IMS</strong> application model employed in the <strong>JSR</strong> <strong>281</strong>. For any given general <strong>IMS</strong> application, language and<br />

platform independent, the <strong>API</strong> divides the set of requirements in two:<br />

• Application-specific: The Java <strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> application realizes requirements that map above the <strong>API</strong>.<br />

• <strong>IMS</strong>-specific: The <strong>IMS</strong> Engine realizes requirements that map below the <strong>API</strong>.<br />

The <strong>IMS</strong> engine maintains the fundamental distinction between the signaling and the media plane in the <strong>API</strong>. It<br />

manages the SIP transactions and dialogs according to the standards, formats SIP messages, and creates proper<br />

SDP payloads for sessions and media streams.<br />

SIP methods, with the transactions and dialogs they imply, have abstractions in the <strong>API</strong>.<br />

The core service object relates to <strong>IMS</strong> registration and the SIP REGISTER message.<br />

The service methods (the sub-interfaces to ServiceMethod) correspond to non-REGISTER SIP messages and,<br />

where applicable, the session oriented SDP lines, sent to remote endpoints, including the standardized<br />

transactions and dialogs that the standards imply.<br />

• Session - INVITE, UPDATE, BYE, CANCEL<br />

• Reference - REFER and NOTIFY<br />

• Subscription - SUBSCRIBE and NOTIFY<br />

• Publication - PUBLISH and NOTIFY<br />

• Capabilities - OPTIONS<br />

• PageMessage - MESSAGE<br />

The SIP INFO method has no representation in this <strong>API</strong>.<br />

An important design feature of the <strong>IMS</strong><strong>API</strong> is its level of abstraction that hides protocol specific details from the<br />

developer. This means that an application cannot modify the SIP message sequences. Some support to access the<br />

contents of individual SIP messages is available in the Message interface.<br />

The media types (sub-interfaces to Media) are related to media streams and the media oriented SDP lines. The<br />

StreamMedia type is based on the RTP/AVP-profile, and the media content is handled in the <strong>IMS</strong> engine. The<br />

Framed media type is based on MSRP, where the <strong>IMS</strong> engine handles the MSRP protocol, and the application<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 166 of 199


Appendix A<br />

handles the content. For BasicUnreliableMedia and BasicReliableMedia, the application implements a protocol<br />

on top of UDP and TCP, respectively.<br />

CoreService<br />

RFC: 3840, 3841, Caller preferences framework<br />

The <strong>IMS</strong><strong>API</strong> core service object is related to <strong>IMS</strong> registration. A core service object is in an active state when it can<br />

be used to create service methods, and receive incoming ones. This can happen in two ways:<br />

• The application calls Connector.open(),<br />

• There is a MIDP Push registration with a proper imscore locator as connector string (or some other<br />

equivalent mechanism according to the Java profile).<br />

The <strong>IMS</strong> application Registry contains capabilities that are used in the caller preferences framework. This is the<br />

main mechanism to support multiple <strong>IMS</strong> applications. The <strong>IMS</strong> engine act as a proxy for the <strong>IMS</strong> applications.<br />

Related to the core service, the following tasks are included:<br />

• Behavior for startup and shutdown.<br />

• Creating the ‘Contact’-header.<br />

• Creating ‘Accept-Contact’ headers for outgoing requests.<br />

• Given an incoming request, route the request to the right core service based on the contents of the<br />

‘Accept-Contact’ header.<br />

These items are described:<br />

Startup<br />

Startup means the earliest point in time after the device is switched on, and the Java Application Management<br />

System (AMS) and the native <strong>IMS</strong> engine have started and are operational.<br />

At startup, the <strong>IMS</strong> engine sends a REGISTER message with the capabilities for the Push registered core services.<br />

If the <strong>IMS</strong> engine has already sent a REGISTER with the user's contact address, then this REGISTER updates that<br />

registration. Otherwise, the <strong>IMS</strong> engine uses this as the initial <strong>IMS</strong> registration. The procedures are according to<br />

standard.<br />

The implementation MUST maintain the registration (SIP REGISTER message to the registrar) with respect to the<br />

feature sets for all active core services at all times. The implementation must keep a model of what capabilities is<br />

currently registered, and maintain a mapping to individual active core services. Unnecessary signaling with<br />

REGISTER messages should be avoided.<br />

Update<br />

When <strong>IMS</strong> Engine performs a REGISTER refresh, this can take up to a few seconds depending on the update. If<br />

an application requests an update (i.e. via a Connector.open()) at the same time as the REGISTER refresh<br />

(update collision) the <strong>IMS</strong> Engine shall wait until to the REGISTER refresh is competed.<br />

Shutdown<br />

Shutdown is mainly a device specific matter. If there are no core services active, and hence no reason to maintain<br />

a model of what capabilities are registered, the <strong>IMS</strong> engine may stop maintaining the registration.<br />

Creating Contact header when a core service is activated.<br />

This section describes how to construct a ’Contact’ header with feature tags derived from the Registry contents in<br />

outgoing SIP messages.<br />

Purpose<br />

Update the ‘Contact’ header with features when a core service is activated from a Connector.open() call. The<br />

algorithm is also used for Push registered core services at startup, and in this case the algorithm updates the<br />

header successively for each core service. The <strong>IMS</strong> engine maintains the current ‘Contact’ header value, and this<br />

is the existing ‘Contact’ header value referred to below. The initial value for the ‘Contact’ header is device specific,<br />

where the <strong>IMS</strong> engine supplies with a contact URI, device specific feature tags, and q-value. The device may at the<br />

end of the algorithm remove any added feature tag that cannot be supported.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 167 of 199


Appendix A<br />

Description<br />

Given an existing ‘Contact’ header value, Registry and a core service, the algorithm goes through each capability<br />

carrying <strong>IMS</strong> property and adds feature tags to the ‘Contact’ header. Since other active core services may share<br />

the ‘Contact’, the algorithm counts references to each tag, to be examined when the ‘Contact’ header is modified<br />

again. As a side effect, the algorithm returns a flag that tells whether the header was changed. This flag can be<br />

used to avoid sending redundant REGISTER messages.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 168 of 199


Appendix A<br />

Definitions<br />

Feature or feature params<br />

an expression T on the form feature tag [ = tag-value ]<br />

Feature tag<br />

a token. For a Feature T, then its tag is denoted with T.tag<br />

Tag-value<br />

value for a tag. For a Feature T, then its value is denoted with T.value<br />

Boolean feature<br />

value is either false or true<br />

Enumerated feature<br />

one token within an enumeration<br />

Numeric value<br />

integer or rational<br />

Negation<br />

excluding the particular value<br />

Input to the algorithm<br />

• R – The Registry that belongs to the <strong>IMS</strong> application that owns the input Core service.<br />

• cs – The input core service name.<br />

• F – An existing ‘Contact’ header value.<br />

• F.ref[T] – Reference count for feature T used in F.<br />

Output<br />

• F – Updated ‘Contact’ header value.<br />

• F.ref[T] - Updated reference count of feature T used in F.<br />

• A Boolean flag update.<br />

Procedure<br />

Define operations on F.ref[T]:<br />

• Read with the expression F.ref[T] and can be numerically compared.<br />

• Incremented with F.ref[T]++<br />

• Decremented with F.ref[T]—<br />

• Set to a numeric non-negative value x with F.ref[T] = x<br />

The operator F += T is defined as such:<br />

The feature T is added to the ‘Contact’ header value F ensuring that T is a member of the (equivalent) contact<br />

feature set for F. The reference is counted, and the update flag is set if F was changed.<br />

Procedure of F += T:<br />

• If F already includes T, then F is unchanged. Apply F.ref[T]++<br />

• If T is a (non-negated) Boolean feature, then suffix F with ; and append T.tag to that (so F = F + ";" + T.tag).<br />

Set F.ref[T] = 1. Set update = true<br />

• If T is an enumerated feature then:<br />

If F includes values for T.tag, then suffix the values with , and append T.value to those.<br />

Else append ;T to F.<br />

Note that there are no cases for numeric and negated values.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 169 of 199


Appendix A<br />

Main algorithm:<br />

Set update = false<br />

For the Registry R<br />

For each <strong>IMS</strong> property p in R:<br />

If p is StreamMedia property then<br />

If p is empty or p has both Audio and Video, then F += video and F += audio<br />

Else if Video is in p, then F += video<br />

Else If Audio is in p, then F += audio<br />

Else should not happen<br />

Else if p is FramedMedia then<br />

F += message<br />

Else if p is BasicMedia then<br />

For each content type xxx/yyy in p<br />

If xxx is application then<br />

F += application<br />

F += sub_apptype = yyy (this step is optional)<br />

Else if xxx is video then F += video<br />

Else if xxx is audio then F += audio<br />

Else if p is Event then<br />

For each event e in p<br />

F += events= e<br />

Else if p is a CoreService with the name cs then<br />

For each iari in p do<br />

F += +g.3gpp.iari_ref = iari<br />

For each icsi in p do<br />

F += +g.3gpp.icsi_ref = icsi<br />

(explicit and require flags are not placed in F)<br />

This step could also be used to create P-Preferred-Service SIP headers to the P-CSCF<br />

For each FT in p do<br />

F += FT<br />

(explicit and require flags are not placed in F)<br />

Else p is some other property, and F is unchanged<br />

The device removes all feature tags from F that cannot be supported<br />

Creating Contact header when a core service is closed<br />

Purpose<br />

Remove features from the ‘Contact’ header when a core service is closed.<br />

Description<br />

Given an existing ‘Contact’ header value, Registry and an active core service, the algorithm goes through each<br />

capability carrying <strong>IMS</strong> property and removes obsoleted features from the header. Because other core services<br />

may share the contact, the algorithm counts references to each feature, such that support for others remains valid.<br />

As a side effect, the algorithm returns a flag that tells whether the header was changed. The algorithm is a small<br />

modification of the activating case, and only the details for the new case are shown.<br />

Procedure<br />

Procedure of F -= T:<br />

• If F already includes T, then apply F.ref[T]--. If F.ref[T] == 0 then remove T from F.<br />

Main algorithm:<br />

The algorithm is the same as for the activating case, except that the += operator is replaced with the -= operator.<br />

Creating Accept-Contact header in outgoing non-REGISTER<br />

Given a set of existing ’Accept-Contact’ headers, a Registry, and a core service, the algorithm goes through the<br />

capability carrying <strong>IMS</strong> properties and extends the set accordingly. The headers are put in outgoing requests from<br />

that core service.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 170 of 199


Appendix A<br />

Procedure<br />

Note that the ‘Accept-Contact’ headers in Fs must all match a contact for a call to succeed. When a term T is<br />

added to Fs, some existing Accept-Contact header in Fs will preferably include it with a conjunction, or a new<br />

‘Accept-Contact’ is created and put in Fs. The reason for doing this is that each ‘Accept-Contact’ header must be<br />

internally consistent. This is expected to happen rather frequently in <strong>JSR</strong> <strong>281</strong>, where the +g.3gpp.iari-ref and<br />

+g.3gpp.icsi-ref tags have several values (ICSI + IARI) that all must be matched to the remote. It is also the<br />

case that the ‘require’ and ‘explicit’ flags operate on all feature parameters in the ’Accept-Contact’ header, which<br />

may force extra headers to the Fs.<br />

The operator Fs


Appendix A<br />

{ "Write", "P-ImageIncluded" },<br />

{ "Read", "P-ImageIncluded" },<br />

{ "Cap", "Framed", "Req_Resp", "a=max-size:4096" }<br />

};<br />

It will generate two ‘Accept-Contact’ headers. Reason for the second one is the ‘require’ tag that applies to the IARI,<br />

but not to other features:<br />

• Accept-Contact: *; application; app_subtype=”myChess”; message;events="Presence"<br />

• Accept-Contact: *; +g.3gpp.iari_ref="urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.iari.myChess"; require<br />

Routing and processing of an Accept-Contact header<br />

Purpose<br />

Route incoming request to the right active core service.<br />

Description<br />

If the incoming SIP message lacks ‘Accept-contact’ headers, then the request is passed to the device for further<br />

processing outside the scope of this specification.<br />

Given an incoming SIP message with ‘Accept-Contact’ headers, the core service that a callback should be<br />

generated from is identified. The procedure is based on the Caller Preferences framework [RFC 3841], where each<br />

active core service is treated as a candidate contact. The procedure works by going through each feature in<br />

each ’Accept-Contact’ header for all candidate core services. This process can result in a core service being<br />

excluded as a potential contact. If it is kept, it is assigned a caller preference score. The core service that ranks<br />

highest receives the call.<br />

Definitions<br />

R.prop<br />

gets the value of <strong>IMS</strong> property with name prop from the Registry R<br />

npf<br />

number of features in ‘Accept-Contact’<br />

ncf<br />

number of ‘Accept-Contact’ feature tags where the Registry implies the same tag<br />

nvm<br />

number of value matches between ‘Accept-Contact’ and Registry for a feature tag<br />

nvm_cs<br />

number of matches for IARI, ICSI and Feature Tags fields in the CoreService property for a given cs<br />

nf_cs<br />

total number of features implied from IARI, ICSI and Feature Tags fields in the CoreService property for a<br />

given cs<br />

Score[h]<br />

an Accept-Contact header score for the cs<br />

Procedure<br />

The test V1 == V2 is defined as such:<br />

• If V1 or V2 are not atomic values, then Fail.<br />

• If V1 and V2 not the same types then Fail.<br />

• If V1 and V2 are Boolean or enumerated values, then Success if they are string-equal case insensitive.<br />

• If V1 and V2 are IARI or ICSI, then Success if they are lexically equvalence according to RFC 2141 URN<br />

Syntax.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 172 of 199


Appendix A<br />

• If V1 and V2 are other types of strings, then Success if they are string-equal case sensitive.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 173 of 199


Appendix A<br />

The test VA is_in VR is defined as such:<br />

• If VA is not a feature value from an ‘Accept-Contact’ header, or VR is not a value from a Registry property,<br />

then Fail. Note: VA and VR can have several values.<br />

• For all values a in VA until Success<br />

If there is a value r in VR such that a == r, then Success.<br />

else if a is on the form !b (negation), then if there is no value r in VR such that b == r, then Success<br />

else Fail.<br />

Main algorithm<br />

For each registry R with an active core service cs<br />

set nvm_cs to 0<br />

compute nf_cs for cs<br />

For each accept-contact header<br />

Set npf, ncf, nvm to 0<br />

For each feature f in that accept-contact<br />

npf ++<br />

If f.tag is video then<br />

if Video is in R.Stream or video is in R.Basic then<br />

ncf++<br />

nvm++<br />

else if f.tag is audio then<br />

if Audio is in R.Stream or audio is in R.Basic then<br />

ncf++<br />

nvm++<br />

else if f.tag is message<br />

if R.Framed is defined then<br />

ncf++<br />

nvm++<br />

else if f.tag is events<br />

if R.Event is defined then<br />

ncf++<br />

if f.value is_in R.Event then<br />

nvm++<br />

else if f.tag is application<br />

if application is a top-level type in R.Basic then<br />

ncf++<br />

nvm++<br />

else if f.tag is app_subtype<br />

if application is a top-level type in R.Basic then<br />

ncf++<br />

if some value of f occurs as sub-level of an application content type in R.Basic then<br />

nvm++<br />

else if f.tag is +g.3gpp.iari_ref<br />

if R.CoreService contains an iari<br />

ncf++<br />

if f.value is_in iari for R.CoreService with name cs then<br />

nvm++<br />

nvm_cs++<br />

else if f.tag is +g.3gpp.icsi_ref<br />

if R.CoreService contains some ICSI<br />

ncf++<br />

if f.value is_in icsi for R.CoreService with name cs then<br />

nvm++<br />

nvm_cs++<br />

# This case is for backwards compatibility to older representation of ICSI and IARI<br />

else if f.tag is +g.3gpp.app_ref<br />

if R.CoreService contains some IARI or some ICSI<br />

ncf++<br />

if f.value is_in iari or f.value is_in icsi for R.CoreService with name cs then<br />

nvm++<br />

nvm_cs++<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 174 of 199


Appendix A<br />

else if f.tag is contained in Feature Tags for R.CoreService with name cs<br />

ncf++<br />

let g be that feature of Feature Tags, where f.tag is g.tag<br />

if f.value is_in g.value<br />

nvm++<br />

nvm_cs++<br />

else if f.tag is handled by the device<br />

ncf++<br />

if f.value is allowed in the device for f.tag<br />

nvm++<br />

else<br />

(No action)<br />

when an ‘Accept-Contact’ header has been processed for this cs:<br />

set Score[h] = nvm/npf<br />

if Score[h] < 1.0 then<br />

if the ‘require’ flag is present for this ‘Accept-Contact’ header, then<br />

cs is dropped, and next candidate cs is tried.<br />

else if the ‘explicit’ flag is present, then<br />

set Score[h] = 0;<br />

when all headers for a cs is done:<br />

if nvm_cs < nf_cs then<br />

cs is dropped<br />

else<br />

caller preferences score of this cs (Sc[cs] ) is the arithmetic average of Score[h] for all its ‘Accept-Contact’<br />

headers h<br />

when all cs have been processed:<br />

If the device has an internal policy to override Sc[cs] for some cs, then<br />

Let Sc[cs] = 1.0, for all such cs.<br />

If the device supports an internal callee preference ordering by q-value (q[cs]), then<br />

sort all cs based on q[cs], and for those that have the same q[cs] sort on Sc[cs]<br />

else<br />

sort only on Sc[cs]<br />

select the best cs to receive the request<br />

Processing of Reject-Contact header<br />

The above algorithm can be used to process ‘Reject-Contact’ headers by dropping all cs with Sc[cs] == 1 when<br />

processing features for reject before applying the algorithm for the ‘Accept-Contact’ case.<br />

Processing of Request-Disposition header<br />

The RFC 3840/3841 discusses the ‘Request-Disposition’ header and this may appear in incoming requests. The<br />

device shall not process directives contained in the header. If the cs that takes the request subsequently rejects it,<br />

then this means the request is rejected from the device altogether, and not just from that cs or <strong>IMS</strong> application.<br />

Internal preference handling<br />

The device may implement a callee preference among core services (core service q-value). There are no interfaces<br />

for this in the <strong>JSR</strong> <strong>281</strong> <strong>API</strong>s.<br />

SIP messages and contact headers<br />

The SIP REGISTER MUST have a contact header with the contact address and the feature tags as constructed by<br />

the algorithm above. This means that the <strong>JSR</strong> <strong>281</strong> implementation requires the server to support caller<br />

preferences.<br />

The contact header must also be placed in the following SIP methods: INVITE, NOTIFY, OPTIONS, SUBSCRIBE,<br />

UPDATE, REGISTER, REFER, PUBLISH.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 175 of 199


Appendix A<br />

ConnectionState<br />

When the initial registration has been done, the Public User Identities (SIP URI user identities) returned via the<br />

getUserIdentities() method are taken from the ‘P-Associated-URI’ header of the REGISTER response. If this<br />

header cannot be retrieved (for whatever reason) then the method should be based on the collection of all public<br />

user identities that are made known to the device via the reg event package. The first URI in the list is the default<br />

user identity for the user. The application cannot test whether a certain user id is registered or not; it suffices for it<br />

to know which are usable for creating services. Typical use of the user id is that some can be used as input to<br />

service creation. User identities can also in general be provisioned by some mechanism outside this specification.<br />

Note that getting the list user identities can only be done while the state is connected. Creating core services can in<br />

general be done at any time. If there is no registration when a service is created, the implementation MUST try to<br />

make one.<br />

ConnectionState.isConnected<br />

Returns true if the device has an <strong>IMS</strong> registration active.<br />

ConnectionState.getUserIdentities<br />

This is a list of all identities that the device knows about for the current user, registered or not. The sources for the<br />

list may include the ‘P-Associated-URI’ header, registration events, and user identities otherwise provisioned to the<br />

user.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 176 of 199


Appendix A<br />

ServiceMethod<br />

With the ServiceMethod interface it is possible to add headers and body parts to outgoing SIP request messages<br />

and to inspect previously sent and received SIP messages (both request and responses).<br />

The getNextRequest() method will give a handle to the next outgoing SIP request message in the corresponding<br />

subclassed service method. Calling this method twice before the message is sent will give the same handle. The<br />

SIP request methods that can be manipulated are defined in the Message interface, for example SESSION_START<br />

that has the triggering interface method Session.start.<br />

The getNextResponse()method gives a handle to the next SIP response message. Since the response depends<br />

on a request message, and on a triggering action by an application, there are only a few places in the <strong>API</strong> where it<br />

is possible and meaningful for the application to call the method. In Table 1, the triggering interface methods are<br />

listed, and the response message is what is sent directly afterwards. See also Figure 1a where triggering methods<br />

and responses are shown in bold face.<br />

If getNextResponse()method is called and is not followed by any of the triggering methods listed below, then all<br />

changes made to the response message are discarded.<br />

Call back method<br />

Triggering interface method SIP Response<br />

CoreServiceListener.sessionInvitationReceived Session.accept()<br />

200 Ok<br />

CoreServiceListener.sessionInvitationReceived Session.reject()<br />

486 Busy here<br />

CoreServiceListener.sessionUpdateReceived Session.accept() 200 Ok<br />

CoreServiceListener.sessionUpdateReceived Session.reject() 486 Busy here<br />

Table 1: Triggering interface methods and with available SIP response messages<br />

If a SIP request message was sent/received successfully and it is connected to an identifier in the Message<br />

interface, it should be stored in the <strong>IMS</strong> engine. Only the last SIP request message for each Message identifier has<br />

to be stored. The same logic applies to SIP response messages. All SIP responses to the SIP request message<br />

that has a Message identifier should be stored, but again only the SIP responses to the last SIP request of each<br />

Message identifier.<br />

Table 2 below shows the mapping for a Message identifier and the triggering interface method. It also shows which<br />

SIP method that is expected to be sent. SESSION_UPDATE and SESSION_TERMINATE can use one of two SIP<br />

methods depending on the situation.<br />

Message identifier<br />

CAPABILITIES_QUERY<br />

Triggering interface method SIP method<br />

Capabilities.queryCapabilities() OPTIONS<br />

PAGEMESSAGE_SEND PageMessage.send() MESSAGE<br />

PUBLICATION_PUBLISH Publication.publish() PUBLISH<br />

PUBLICATION_UNPUBLISH Publication.unpublish() PUBLISH<br />

REFERENCE_REFER Reference.refer() REFER<br />

SESSION_START Session.start() INVITE<br />

SESSION_UPDATE Session.update() INVITE,UPDATE<br />

SESSION_TERMINATE Session.terminate() BYE,CANCEL<br />

SUBSCRIPTION_POLL Subscription.poll() SUBSCRIBE<br />

SUBSCRIPTION_SUBSCRIBE Subscription.subscribe() SUBSCRIBE<br />

SUBSCRIPTION_UNSUBSCRIBE Subscription.unsubscribe()<br />

Table 2: Message identifiers and SIP messages to store<br />

SUBSCRIBE<br />

Consider Figure 1a below. If the application calls getPreviousResponses(SESSION_START) at the<br />

sessionAlerting() callback, the following SIP responses should be returned in an array: 183 Session Progress<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 177 of 199


Appendix A<br />

and 180 Ringing (100 Trying may also reside in the array, but it is not shown in the figure). The 183 Session<br />

Progress will reside in the first slot in the array since it was the first response to the SIP INVITE request message. If<br />

the application calls getPreviousRequest(SESSION_START) at the SessionInvitationReceived() callback, the<br />

SIP INVITE request message will be returned.<br />

The algorithm for computing ‘Contact’ and ‘Accept-Contact’ headers described in the section on core service apply<br />

to outgoing SIP messages for all service methods where applicable. For incoming SIP messages, not part of an<br />

existing dialog, the routing algorithm is used to find the best core service to generate the callback from.<br />

getRemoteUserId<br />

This method returns the trusted user identity or identities of the remote endpoint. The value is an array of all<br />

P-Asserted-Identity header values (display name and URI) that can be found in the SIP message exchanged with<br />

the remote in the order they have been found.<br />

User identity management for Core service and Service methods<br />

The device decides on an appropriate default public user identity and a default display name to use with the URI of<br />

the identity whenever supported. If the identity has not been registered, the device must make sure it has been<br />

registered at the time the first Connector.open() is called and the device must also subscribe to the reg event<br />

package. The default identity can be overridden by the application supplying a value for the ‘userId=’ parameter<br />

in the argument to Connector.open(). If this public user identity is not registered, explicitly or implicitly, then the<br />

device shall attempt to register it if explicit registration of additional public user identities according to the procedure<br />

of [24.229] is supported. In any case, the identity and display name shall be the default to put in the<br />

‘P-Preferred-Identity’ header in SIP messages for service methods eventually originating from the local endpoint<br />

and core service object.<br />

The getLocalUserId() method on the CoreService interface returns the overridden user identity instead of the<br />

default user identity (first in the 'P-Associated-URI' header). Again, display names shall be supported.<br />

The from argument in service methods is mapped to the ‘From:’ header in the outgoing SIP message for the<br />

service method. The requirements that RFC3261 places on the contents of the ‘From:’ header apply to the from<br />

argument as well, except for a ‘tag’ parameter that the application is not allowed to insert.<br />

The to argument maps similarly to the ‘To:’ header, and stripped from display name it also form the ‘Request-URI’<br />

of the start line of the request. Hence, the to argument bears more significance to the service method than the<br />

‘To:’ header alone for the SIP request.<br />

Session<br />

Handling of sessions builds on the core SIP specifications, and 3GPP TS 24.229 Rel 6.<br />

RFC: 3261, SIP: Session Initiation Protocol<br />

RFC: 3264, An Offer/Answer Model with the Session Description Protocol (SDP)<br />

RFC: 3312, Integration of Resource Management and SIP<br />

Start a session<br />

When MO call session.start() the <strong>IMS</strong> engine prepares the SDP offer with the media and sends that to the<br />

remote endpoint in the initial SIP INVITE message according to the standards. The offer has an application<br />

independent part that relates to the media components of the session, and an application-dependent part that<br />

relates to SDP lines that the application has set using SessionDescriptor and MediaDescriptor interfaces.<br />

Session setup with and without the precondition extension are supported, and the distinction is kept transparent to<br />

the application. The implementation decides which to use.<br />

If the negotiation (and possible resource reservation) was successful the MT application is notified via the<br />

sessionInvitationReceived() callback.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 178 of 199


Appendix A<br />

Figure 1a: Sequence for preconditional session setup and terminate. Bold sequences show the SIP messages that<br />

were triggered as a direct effect from an application using certain parts of the <strong>API</strong>, so called application-triggered<br />

messages.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 179 of 199


Appendix A<br />

Figure 1b: Sequence for session setup without preconditions including terminate.<br />

Terminate a session<br />

When calling session.terminate() the <strong>IMS</strong> engine will send a SIP BYE or CANCEL request message to the<br />

remote endpoint and request that the session should be terminated.<br />

• SIP CANCEL should be sent if a final response has not been received for the initial SIP INVITE message<br />

that was sent in session.start(). The remote endpoint should respond with 200 OK for the SIP CANCEL<br />

followed by a 487 Request Terminated on the SIP INVITE message. For the application that called<br />

session.terminate, sessionListener.sessionTerminated() is called, and on the other<br />

endpoint sessionListener.startFailed() is called. This happens regardless of MO or MT session.<br />

• SIP BYE should be sent if the session has been established. On both endpoints<br />

sessionListener.sessionTerminated() is called.<br />

• If the network terminates the session before session is established, sessionListener.startFailed() is called<br />

on both endpoints. If it does this after session is established, sessionListener.sessionTerminated() is called<br />

on both endpoints.<br />

Update a session<br />

A session can be updated due to only a number of reasons. The type of update decides how the SIP signaling<br />

should be realized and which listener methods should be called back in response to the update that has been<br />

made. Below follows a listing of cases and how they should be dealt with:<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 180 of 199


Appendix A<br />

1 MO app calls session.update() with added media:<br />

Use SIP reINVITE (possibly with resource reservation, if that is needed) on MO. MT requires reINVITE and<br />

should reject UPDATE. Make call backs on MT side sessionUpdateReceived. The MT app must process<br />

both the offer and accept the update. Call sessionUpdated when SIP ACK is sent and received. (See Figure<br />

2a and 2b)<br />

2 MO app calls session.update() with an updated application-specific offer:<br />

Use reINVITE on MO to send the offer. MT requires reINVITE and should reject UPDATE. Do not call<br />

sessionUpdateReceived. Call sessionUpdated. (see Figure 2c)<br />

3 MO app calls session.update() with removed media and/or changed media directions:<br />

Use SIP UPDATE on MO. On MT accept reINVITE and UPDATE. Call sessionUpdated only. (See figure 2d)<br />

4 MO <strong>IMS</strong> engine, and not the app, calls session.update() with an application-independent update. The offer<br />

include an updated b-line, if changes to that is reserved in the current media profile.<br />

<strong>IMS</strong> engine shall use SIP UPDATE, and no listener on either endpoint should be called. (See figure 2e)<br />

The cases above are listed in decreasing order of impact. There may be a mix of cases in one update, and then the<br />

following applies: Only a mix consists of cases in classes 1-3 is allowed, and if so it is handled according to the<br />

case with lowest number. Class 4 update MUST be handled separately. If there is an ongoing update in class 4,<br />

and an app-initiated update (cases 1-3) occurs, then that shall be queued until the class 4 update is completed, and<br />

vice versa. If MT has an ongoing update, it shall reject the update until the current one completes.<br />

For application-initiated updates (1-3) are handled uch that if a session is updated with several changes the change<br />

that tops the list decides the type of update.<br />

Figure 2a: Sequence for session update using SIP reINVITE with resource reservation. The MT app is to answer<br />

the updated offer and confirm the updated session.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 181 of 199


Appendix A<br />

Figure 2b: Sequence for session update using SIP reINVITE without resource reservation. The MT app is to<br />

answer the updated offer and confirm the updated session.<br />

Figure 2c: Sequence for session update with SIP reINVITE not requiring resource reservation, useful for example<br />

when MO app made only an updated application-specific offer.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 182 of 199


Appendix A<br />

Figure 2d: Sequence for session update with SIP UPDATE, useful when MO app made updates where MT does<br />

not confirm the change.<br />

Figure 2e: Sequence for session update with SIP UPDATE, where <strong>IMS</strong> engines on both sides need not involve the<br />

application at all.<br />

Capabilities<br />

RFC: 3840, Indicating User Agent Capabilities in the Session Initiation Protocol (SIP)<br />

Requesting capabilities<br />

When calling Capabilities.queryCapabilities() the <strong>IMS</strong> engine will send a SIP OPTIONS request message to<br />

the remote endpoint. When the remote endpoints <strong>IMS</strong> engine receives the SIP OPTIONS request it will construct a<br />

response message and respond. Note that this request will not trigger any application to be launched and the user<br />

behind the <strong>IMS</strong> engine will not be aware of this request.<br />

Figure 3: Sequence for queryCapabilities<br />

getRemoteUserIdentities<br />

This method will return all SIP & TEL URI:s that are found in the ‘Contact’ header. For example<br />

mailto:carol@chicago.com must not be returned.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 183 of 199


Appendix A<br />

hasCapabilities<br />

This method checks whether the remote device includes the same capabilities as the local <strong>IMS</strong> application (and<br />

core service) given an imscore:// connector string argument. If there is a match this method will return true.<br />

The comparison is made only on matching feature tags. Use the received ‘Contact’ header as input to the contact<br />

header construction algorithm described earlier. If the output header is the same as the input, true is returned.<br />

If the flag to include SDP is set in the queryCapabilities() method call, then the SDP that the <strong>IMS</strong> engine uses<br />

for OPTIONS responses is used as body in the outgoing request.<br />

PageMessage<br />

RFC: 3428, Session Initiation Protocol (SIP) Extension for Instant Messaging<br />

Send a PageMessage<br />

When calling PageMessage.send(content, contentType) the <strong>IMS</strong> engine will send a SIP MESSAGE request<br />

message to the remote endpoint.<br />

Figure 4: Sequence for send<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 184 of 199


Appendix A<br />

Publication<br />

RFC: 3903, Session Initiation Protocol (SIP) Extension for Event State Publication<br />

Publish<br />

This method will send a SIP PUBLISH request message to the remote endpoint. The <strong>IMS</strong> engine is responsible to<br />

refresh the publication and make sure that the publication does not expire. If the publication is about to be expired,<br />

the <strong>IMS</strong> engine must prepare a SIP PUBLISH request message with the same added headers and body that was<br />

set for the initial message and refresh the publication.<br />

Figure 5: Sequence for publish and unpublish<br />

Unpublish<br />

This method will send a SIP PUBLISH request message to the remote endpoint. The 'Expires' header will be set to<br />

zero and thereby terminating the publication.<br />

Reference<br />

RFC: 3515, The Session Initiation Protocol (SIP) Refer Method<br />

A typical reference involes three user agents, the local endpoint that creates the reference and sends it, the remote<br />

endpoint that receives the REFER request and creates a service method based on the reference method and<br />

sends that to a third party.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 185 of 199


Appendix A<br />

Figure 6: Sequence for a minimal refer implementation<br />

Sending a Reference<br />

The method Reference.refer() will send a SIP REFER request message to a remote endpoint. The 'Refer-To'<br />

header field must be set to the third party that the remote endpoint will refer to.<br />

Receiving a Reference<br />

When a well-formed SIP REFER request is received by the remote endpoint the <strong>IMS</strong> engine should respond with<br />

202 Accepted. The <strong>IMS</strong> engine is also responsible to make a implicit subscription to the ‘refer’ event and<br />

immediately send a SIP NOTIFY to the endpoint that issued the REFER request.<br />

Accepting a Reference<br />

The remote endpoint is now responsible to create a service method based on the refer method to the third party<br />

specified by the 'Refer-To' user identity.<br />

Connecting a Reference<br />

The method connectReferMethod() will connect a service method with the third party specified by the 'Refer-To'<br />

header field. This method enables the <strong>IMS</strong> engine to identify the third party and send notifications to the local<br />

endpoint when the reference is terminated.<br />

Replaces header<br />

The method setReplaces() accepts the contents of the o= line of the SDP. The implementation shall convert this<br />

to the format described in RFC3891 for the local device. For getReplaces() it is the opposite conversion.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 186 of 199


Appendix A<br />

Subscription<br />

RFC: 3265, Session Initiation Protocol (SIP) Specific Event Notification<br />

Subscribe<br />

This method will send a SIP SUBSCRIBE request message to the remote endpoint. The <strong>IMS</strong> engine is responsible<br />

to refresh the subscription and make sure that the subscription does not expire. If the subscription is about to be<br />

expired, the <strong>IMS</strong> engine must prepare a SIP SUBSCRIBE request message with the same added headers and<br />

body that was set for the initial message and refresh the subscription.<br />

Figure 7: Sequence for subscribe and unsubscribe<br />

Update<br />

When a Subscription needs to perform a refresh, this can take up to a few seconds depending on the refresh. If an<br />

Subscription also requests an update (i.e. via a subscribe()) at the same time as the refresh (update collision) the<br />

subscribe call shall wait until the Subscription refresh is completed.<br />

Unsubscribe<br />

This method will send a SIP SUBSCRIBE request message to the remote endpoint with the 'Expires' header set to<br />

zero and thereby terminating the subscription. The <strong>IMS</strong> engine will then receive a SIP NOTIFY that terminates the<br />

subscription and the <strong>IMS</strong> engine should invoke the subscriptionNotify() callback followed by the<br />

subscriptionTerminated() callback.<br />

Anonymize<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 187 of 199


Appendix A<br />

Anonymity for MO<br />

The originating application anonymizes on a per service method basis. It is not possible to anonymize on core<br />

service level.<br />

When the application creates a service method using the CoreService interface and provides a from argument that<br />

includes the anonymous host name of anonymous.invalid, the implementation shall anonymize the service<br />

method using a privacy type value of “id” and perform anonymization of SIP requests and responses part of the<br />

service method as further described in RFC3325.<br />

Anonymity for MT<br />

No support to anonymize responses from the MT side.<br />

Media profiles<br />

Introduction and rationale<br />

The concept of [streaming] media profiles was introduced in the <strong>JSR</strong> <strong>281</strong> because the set of possible devices that<br />

can implement the <strong>281</strong> differ in their media capabilities. This is perhaps most obvious for streaming media where<br />

the <strong>JSR</strong> features an <strong>API</strong> of high abstraction level, for example:<br />

• Details of data transport in RTP and RTCP streams are hidden from the application.<br />

• SDP negotiation mechanism for media offer is hidden.<br />

• Setting up network connections with required quality-of-service is managed by the <strong>IMS</strong> engine.<br />

• Usage of MIDP players, not exposing the data streams to Java space.<br />

The <strong>JSR</strong> <strong>281</strong> Media, StreamMedia and MediaDescriptor interfaces do not specify the implementation<br />

behaviour. It leaves a considerable space open for further requirements. That space not open to applications to<br />

specify because it makes the specification hard to use, making third party developers required to be standards<br />

experts.<br />

If it would be left unspecified, it is harmful for portability of applications from a Java perspective, and interoperability<br />

from an <strong>IMS</strong> perspective. If it would be unambiguously specified in the <strong>JSR</strong> implementation, the set of devices<br />

possible for the <strong>JSR</strong> to target would shrink to only a small set.<br />

There are several ways in SIP and <strong>IMS</strong> today can differentiate and manage variation among SIP and <strong>IMS</strong> devices<br />

in terms of their capabilities:<br />

• The SDP offer/answer model, where the endpoints negotiate to a common set of capabilities on a per session<br />

basis, for example the codecs in media offers.<br />

• Using separate URIs destined to reach endpoints with certain characteristics, for example a voice mail server<br />

has its own URI.<br />

• Using the caller preferences framework where an originating endpoint can make a statement for preferred<br />

characteristics of the terminating endpoint.<br />

Media handling is standardized in <strong>IMS</strong> for a particular service or area of similar services. Since devices are<br />

developed to support certain services, the media profiles in <strong>JSR</strong> <strong>281</strong> are based on specification standards. Hence,<br />

media profiles come close to services that are usually given a feature tag (e.g. ICSI) that indicates that media<br />

profiles would be handled within caller preferences. The <strong>IMS</strong> application in <strong>JSR</strong> <strong>281</strong> defines the media profile that<br />

MUST be used for its composed capability (ICSI, IARI, other other feature tag) in its Registry. An application<br />

installed to a device that lacks the required media profile will not execute because of the lack of media capability.<br />

Note that the media profiles do not have their own feature tags as this would require further standardization, but<br />

rather it is the application that picks the needed profile to realize its capability.<br />

Taken into the caller preferences framework means the following:<br />

• The originating endpoint having a certain feature tag prefers to reach a remote endpoint with the same feature<br />

tag in its session. The definition of the feature tag common for both endpoints, means the media profile is<br />

common as well. This will also work for <strong>IMS</strong> applications that are not using the <strong>JSR</strong> <strong>281</strong> since there is a<br />

standard behind the media profile.<br />

For each installed application, it is known which profile it uses. This solves the portability problem for Java. Each<br />

installed application makes sure it reaches a remote application with the same feature tag. This solves the<br />

interoperability issue for <strong>IMS</strong>.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 188 of 199


Appendix A<br />

Common procedures<br />

The application Registry sets up a composed capability in the CoreService property and a media profile in the<br />

mprof property. This is how the required dependency between a capability and a profile is expressed. If the device<br />

cannot create the dependency, the application cannot be interoperable.<br />

Codecs<br />

On the MO side for session setup, the <strong>IMS</strong> engine MUST place all mandatory codecs of the profile for the media<br />

stream in the SDP offer. All optional codecs in the profile that the device supports SHOULD be offered as well.<br />

Codecs not part of the profile MUST NOT be offered even if they could be used for the media type. On the resulting<br />

set of codecs, the device applies the value of setPreferredQuality to obtain an ordering of the codecs within<br />

the offer according to preference. That ordering is device-specific.<br />

On the MT side, following the standards, the <strong>IMS</strong> engine removes unsupported codecs and MUST remove offered<br />

codecs NOT part of the profile.<br />

Quality of service<br />

Any statement of network bitrate and delay applies as the device sets up network connections to transport media.<br />

This is mostly a matter for the local device.<br />

SDP attributes<br />

SDP attributes that are part of the profile are reserved to the <strong>IMS</strong> engine. This means that the application cannot<br />

access them in Sessiondescriptor and MediaDescriptor. Any values or negotiation rules for SDP lines and<br />

attributes of the profile are managed in the <strong>IMS</strong> engine part of its support for the profile. This also includes any<br />

extra SIP signaling related to the media and specific for the profile.<br />

Feature Tags<br />

Sometimes a standard for a profile contains service or application-related feature tags where the media profile is<br />

expected to be used. This is exempt from the <strong>IMS</strong> engine, and it is up to the application to make the association<br />

between the media profile and feature tags as mentioned above.<br />

Terminal capability requirements<br />

Some profiles may express certain other hardware-related device capabilities in order to realize the profile. Such<br />

requirements are placed here as well.<br />

Basic profile “Basic”<br />

If the device implements [26.235], then it supports the Basic Profile.<br />

MMTel profile “MMTel”<br />

If the device implements [26.114], then it supports the MMTel Profile.<br />

The <strong>IMS</strong> engine shall implement the video adaptation as per [26.114, ch 10.3]<br />

Media handling<br />

The implementation shall process media according to the guidelines below.<br />

Media flow properties<br />

‘exists’ is true when there is a socket (or equivalent) created. When it closes ‘exists’ is false. ‘canRead’ and<br />

‘canWrite’ assume values as described in the <strong>API</strong> based on mode factor conditions that all must be fulfilled. Data<br />

availability is one factor, and for<br />

‘canRead’ for other types of media depends less on data availability. It is set to true as soon as the first data<br />

packets destined for the application arrive at the socket. Subsequent pauses in the data transfer shall not make<br />

‘canRead’ set to false, unless it is known that an IO error has occurred that causes transfer interrupt.<br />

Implementations shall prepare their media flows bidirectionally, even if the media is unidirectional. This is because<br />

the direction can later be renegotiated.<br />

When the session is terminated, the implementation shall allow the application to read any locally buffered data.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 189 of 199


Appendix A<br />

The MediaListener.modeChanged() call back shall be applied for all changes of the mode properties except when<br />

the session is terminated reported to the application via a call to SessionListener.startFailed() or<br />

SessionListener.sessionTerminated().<br />

When the application calls Media.setMediaListener, the call back shall be applied directly afterwards.<br />

BasicUnreliableMedia<br />

BasicUnreliableMedia is based on UDP, and the proto field of the SDP is ‘udp’. The ‘exists’ property is true<br />

whenever the local device starts listening for incoming udp traffic on a server socket. Due to the nature of udp,<br />

sending does not affect ‘exists’ property.<br />

BasicReliableMedia<br />

BasicUnreliableMedia is based on TCP, and the proto field of the SDP is ‘tcp’. The ‘exists’ property is true<br />

whenever a tcp socket connection is established, regardless of the passive or active role used in TCP connection<br />

setup.<br />

StreamMedia<br />

StreamMedia is based on RTP, and the proto field is RTP/AVP. The ‘exists’ property is true whenever the RTP<br />

mechanisms of the device are operational.<br />

Data availability enables ‘canRead’ whenever there is data in the incoming buffers that can be rendered. There is<br />

no requirement that the media must be in an active state for this to happen. This enables the application to start<br />

playing out any received media before the session goes to established state, and will mitigate the risk of losing<br />

initial data. Data availability enables ‘canWrite’ when the source for StreamMedia starts delivering renderable data.<br />

If the source stops or delivers EOF, then ‘canWrite’ becomes false.<br />

FramedMedia<br />

Framed media is based on MSRP protocol of [RFC4975] and the proto field is TCP/MSRP. If the ‘connection’<br />

Registry property is not defined for the core service that the session is created from with a FramedMedia, then the<br />

[draft-ietf-simple-msrp-acm-00] shall be followed. The FramedMediaListener.transferProgress() listener<br />

method available at both the sending and receiving endpoints shall be called between the message chunks<br />

sent/received. That is, if there after having sent/received a message chunk there remains more chunks, then<br />

FramedMediaListener.transferProgress() shall be called.<br />

The <strong>IMS</strong> engine shall manage sending of bodyless requests according to RFC4975. Bodyless requests shall not be<br />

visible for sending or receiving applications.<br />

Error handling<br />

In the case of communication problems, the <strong>IMS</strong> engine should use adequate timeouts and retransmissions in<br />

order to reestablish the communication. If the communication could not be reestablished the <strong>IMS</strong> engine should act<br />

according to the following.<br />

Loss of network, no communication with proxy<br />

The application has a non open service<br />

• The application is notified with imsDisconnected().<br />

The application has an open service<br />

• The service will be closed and notified with serviceClosed() in the case of a CoreService.<br />

• The application is notified with imsDisconnected().<br />

The application has an open service and a service method<br />

• The corresponding service method is terminated, for example sessionTerminated(),<br />

subscriptionTerminated().<br />

• The service will be closed and notified with serviceClosed() in the case of a CoreService.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 190 of 199


Appendix A<br />

• The application is notified with imsDisconnected().<br />

Loss of network, no communication with remote endpoint<br />

If the communication with the remote endpoint cannot be reestablished the application should be notified through<br />

the corresponding service method. For example if the service method is a Session, sessionTerminated() should<br />

be invoked.<br />

Loss of Media connection<br />

• BasicUnreliableMedia - Fire and forget. IOException may be thrown if the <strong>IMS</strong> engine detects loss of<br />

Media connection.<br />

• BasicReliableMedia – connectionError() is invoked on BasicReliableMediaListener. IOException<br />

is thrown when the application tries to read/write to streams.<br />

• FramedMedia – connectionError() is invoked on FramedMediaListener. If the application still tries to<br />

send data deliveryFailure() is invoked.<br />

• StreamMedia - Exception is thrown from the Player.<br />

Reestablishment of communication<br />

When the <strong>IMS</strong> engine is able to reestablish the connection to the <strong>IMS</strong> network, the <strong>IMS</strong> engine should invoke<br />

imsConnected() on the ConnectionStateListener. The application must create and open new services, this in<br />

not done by the <strong>IMS</strong> engine.<br />

Quality of Service guidelines<br />

This sections gives guidance on how to realize quality of service in the UMTS access network for the types of<br />

media supported in the <strong>IMS</strong><strong>API</strong>.<br />

StreamMedia<br />

QoS for StreamMedia follows the procedures in 3GPP standards. The <strong>API</strong> covers the whole streaming functionality<br />

where the <strong>IMS</strong> application can only start and stop the session. The <strong>IMS</strong> engine derives required bitrate and delay<br />

characteristics from its knowledge of the media format and codecs of the session.<br />

At session initiation (i.e. where originating endpoint creates the initial SDP offer), the <strong>IMS</strong> engine shall use the<br />

SetPreferredQuality as a hint to make an initial ordering of codecs in terms of the perceived quality. For high quality,<br />

the codec considered to give the highest perceived quality on the local device should be placed first on the offer,<br />

then the medium codec, and last the low quality codec. For medium, a medium quality codec is placed first followed<br />

by low, then high. For low, the lowest quality is preferred, then followed by medium and then high.<br />

When the session negotiation is completed where codecs have been selected, both endpoints enter the resource<br />

reservation phase.<br />

The <strong>IMS</strong> engine shall assign proper UMTS QoS parameters to the PDP contexts created or modified based on its<br />

knowledge of the session as described in [24.229, chapter 6.1]. A mapping procedure is specified in [29.213,<br />

Chapter 6.5]. It is up to the QoS management of the local device to determine whether the device actually supports<br />

the desired QoS at the moment, considering the network conditions and other usage of the device.<br />

In summary, streaming class is mandatory, conversational is optional.<br />

FramedMedia<br />

For FramedMedia there is in the <strong>API</strong> no information whether the session is going to be used for file transfer or an<br />

interactive chat, awaiting further standardization in this area.<br />

The background class is mandatory to support, and the conversational is optional. It is implementation-specific to<br />

set a priority.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 191 of 199


Appendix A<br />

BasicMedia<br />

BasicUnreliableMedia is an interface to the UDP protocol, and the BasicReliableMedia is TCP. The <strong>IMS</strong> application<br />

is responsible for realizing protocols and codecs part of its code. Hence, the application specifies its QoS<br />

requirements as well. This is done in the Registry Qos property of the CoreService.<br />

The implementation uses the flowspec for two purposes:<br />

* Set the b=AS: parameter in the SDP to be sent out from the device<br />

* Map the flowspec data to UMTS QoS parameters. This is described below.<br />

The flowspec is optional, and if it is present, some of its parts are optional.<br />

The <strong>IMS</strong> engine shall process a flowspec for a BasicMedia in the following way.<br />

Set b=AS: in the SDP media to the peak bitrate if given, otherwise to the average rate if given, otherwise not at all.<br />

If the flowspec is missing, then the UMTS traffic class is background.<br />

If the flowspec includes bitrate, but no delay, then the traffic class is interactive. Set the maximum bitrate to the<br />

peak bitrate, if that is given, otherwise to the average bitrate. The priority is implementation-specific.<br />

If the flowspec includes bitrate and delay, then select Conversational class if the delay is less than 300ms,<br />

otherwise Streaming. Use peak bitrate as maximum and average as guaranteed bitrate.<br />

No mapping exists for the DelayVariance.<br />

User id handling<br />

A user id that the application places in the To argument of service methods can be a local number tel uri without a<br />

phone context parameter. If this is the case, the <strong>IMS</strong> engine shall insert the home network domain name of the<br />

current subscription as value for the parameter into the URI for any requests sent out based on the service method.<br />

If the home network domain name is not known to the local device, an algorithm to create the domain name based<br />

on the <strong>IMS</strong>I is given in 3GPP TS 23.003 that shall be used.<br />

Subscription Update<br />

When <strong>IMS</strong> Engine performs a SUBSCRIBE refresh to the server, this can take up to a few seconds depending on<br />

the update. If an application requests an update (i.e. via Subscription.subscribe()) at the same time as the<br />

SUBSCRIBE refresh (update collision) the <strong>IMS</strong> Engine shall wait until the current refresh is completed.<br />

Securing FW/NAT traversal between the mobile operator and the<br />

Internet<br />

The operator network offers private IP address plan and Network Address Translation (NAT) at the edge of the<br />

Internet. This breaks the originally envisioned model of IP e2e across the Internet since devices inside operator’s<br />

network are not directly addressable from outside the Local Area Network (LAN).<br />

Additionally operators protect their LAN using Firewalls (FW), which usually prohibit terminals in the public internet<br />

to access operator’s network using <strong>IMS</strong> related protocols.<br />

These limitations can be overcome by different mechanism for mapping public IP addresses and private one’s in<br />

the operator’s network behind NAT and keeping the communication channel active using keep-alive signaling. This<br />

puts certain requirements on the implementation provided by the <strong>IMS</strong> stack vendor (terminal vendor) for each<br />

particular type of protocol in use.<br />

These guidelines describe the protocol details and mechanisms to be used for implementation of both SIP control<br />

channel and all four types of media connections provided by <strong>IMS</strong> stack in <strong>JSR</strong>-<strong>281</strong>, StreamMedia, FramedMedia,<br />

BasicReliableMedia, BasicUnreliableMedia.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 192 of 199


Appendix A<br />

SIP<br />

SIP signaling can rely on either TCP or UDP protocol. This guideline recommends to follow the recommendation in<br />

draft-ietf-sip-outbound which is what 3GPP R7 version of TS24.229 refers to, to include the outbound options tag in<br />

the Supported header. Additionally keep-alive signaling should be implemented both in case of TCP and UDP<br />

bearer.<br />

TCP<br />

Keep alive should include double CRLF sequence (CRLFCRLF).<br />

A 3GPP R7 compliant P-CSCF will respond with sending back a single CRLF to indicate to the UE the liveliness of<br />

the TCP connection.<br />

If TCP connection is broken, UE needs to do a new registration to <strong>IMS</strong>.<br />

UDP<br />

Keep alive should include a STUN binding request.<br />

A 3GPP R7 compliant P-CSCF will respond with a STUN binding response. The response can be used by the UE<br />

to determine if the NAT has rebooted and remapped the SIP/UDP flow to another public port, in which case the UE<br />

need to make a new registration to <strong>IMS</strong>.<br />

FramedMedia<br />

FramedMedia provides ability to send and receive any content using MSRP protocol.<br />

Keep-alive using CRLF sequence should be implemented.<br />

Additionally for the purpose of traversing NAT RFC4145 should be implemented in the SIP stack in the terminal<br />

and Session Boarder Gateway (SBG) should be used for the media streams.<br />

It is also recommended to follow the OMA IM example and deviate from the MSRP RFC on the point of using the<br />

address and port conveyed through the SDP c and m lines, instead of the address:port from the MSRP URI in the<br />

a=path line, as destination for the TCP open request for an MSRP connection. The motivations for this can be<br />

found in the I.D draft-blau-msrp-acm.<br />

StreamMedia<br />

StreamMedia provides ability to stream audio or video using RTP protocol. Additionally RTCP protocol is use as the<br />

control protocol for RTCP.<br />

RTP<br />

Keep alive using not negotiated payload format in the header should be implemented.<br />

Additionally for the purpose of traversing NAT Session Boarder Gateway (SBG) should be used for the media<br />

streams.<br />

RTCP<br />

RR/SR can keep the communication channel is sent according to the specification (each 2.5s). Otherwise emptySR<br />

should be sent as keep-alive.<br />

Additionally for the purpose of traversing NAT Session Boarder Gateway (SBG) should be used for the media<br />

streams.<br />

BasicReliableMedia<br />

BasicReliableMedia provides ability to send and receive any application data encapsulated as the payload in the<br />

TCP protocol.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 193 of 199


Appendix A<br />

Terminal vendors should activate, if possible, the system controlled keep-alive for the socket. If not possible the<br />

application needs to actively take care of sending keep-alive and decide what data sequence should be used for<br />

that. The data used for keep-alive should not interfere with the applicationc data.<br />

Additionally for the purpose of traversing NAT, RFC4145 should be implemented in the SIP stack and Session<br />

Boarder Gateway (SBG) should be used for the media streams.<br />

BasicUnreliableMedia<br />

BasicUnreliableMedia provides ability to send and receive any application data encapsulated as the payload in the<br />

UDP protocol.<br />

The application needs to actively take care of sending keep-alive and decide what data sequence should be used<br />

for that. The data used for keep-alive should not interfere with the application data.<br />

Additionally for the purpose of traversing NAT, Session Boarder Gateway (SBG) should be used for the media<br />

streams.<br />

Resolution of keep-alive timer<br />

Following the recommendation in draft-ietf-sip-outbound, which is what 3GPP R7 version of TS24.229 refers to, the<br />

following values should be used:<br />

TCP: 14min<br />

UDP: 29s<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 194 of 199


Appendix A<br />

Appendix B: MIDP 2.0 PushRegistry for <strong>JSR</strong> <strong>281</strong><br />

Introduction<br />

This appendix describes implementation requirements for MIDP 2.0 PushRegistry. It covers connections using<br />

URIs that have the imscore: scheme.<br />

PushRegistry Registration Parameters<br />

This section describes the parameters for static and dynamic push registrations. These are ConnectionURL,<br />

MIDletClassName and AllowedSender. For a static push registration, the parameters are found in the manifest file<br />

or the JAD file for the MIDlet suite under the MIDlet-Push- attribute. For dynamic registration, they are<br />

arguments to the PushRegistry.registerConnection() method.<br />

ConnectionURL Parameter<br />

The connectionURL parameter is the same as the imscore: connector string argument used in the<br />

Connector.open() call. Please refer to the documentation for the javax.microedition.ims package.<br />

AllowedSender Parameter<br />

The allowedSender is a filter specification of incoming requests that are allowed to push start the MIDlet. The list<br />

is composed of three parts. The first part shows domains of allowed remote users. The second part specifies<br />

accepted incoming service methods. The third part allows exclusions of certain unwanted specific URIs. The<br />

allowedSender syntax is shown in the table below:<br />

<br />

::= [ “;method=”] [ “;blacklist=”]<br />

<br />

::= “*” | <br />

<br />

::= “,” | <br />

<br />

::= | <br />

<br />

::= A domain name as found in SIP or TEL URIs<br />

<br />

::= SIP or TEL URI<br />

::= [“,” ]<br />

::= “Session” | “Reference” | “PageMessage” | “Subscribe” ( “ “ “ “ )+<br />

<br />

::= event package name<br />

<br />

::= <br />

The details of an incoming SIP request message is matched to the allowedSender field in order to reject it if it<br />

does not pass and hence avoid constructing objects unnecessarily. The matching process is as follows:<br />

If the white filter is * the match succeeds. Else, SIP and/or TEL URIs shall be taken out of the P-Asserted-Identity<br />

and Contact headers. If some of the domains found there are in the white domain list the request passes this part.<br />

If there is no method part of the filter, then if the SIP method is INVITE then the request passes. For other methods,<br />

it fails. If service methods are listed in the filter, then only SIP messages with methods that would trigger a call back<br />

to the application pass the filter: Session – SIP INVITE, PageMessage – SIP MESSAGE, Reference – SIP REFER,<br />

Subscribe – NOTIFY. For NOTIFY, it is required that the received NOTIFY message matches the SUBSCRIBE to<br />

and event parameters as well.<br />

If the blacklist is present, then if some SIP or TEL URI from P-Asserted-Identity and Contact headers match a<br />

domain name or is equal to some address in the blacklist, then the request fails. To filter out anonymous requests<br />

from launching a MIDlet, then the URI sip:anonymous@anonymous.invalid shall appear in the blacklist.<br />

Failed requests are responded with 488 Not acceptable here.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 195 of 199


Appendix A<br />

Notes for Subscribe<br />

Using Subscribe as allowed method makes the MIDlet push registration create an event subscription directed to the<br />

server at the to address. When a response to that subscription is received, the application is launched. Regardless<br />

of the whitelist and blacklist filters, events from the server always pass. Note that the syntax allows several<br />

subscriptions to be created.<br />

Examples<br />

Explanations are in parenthesis:<br />

* (all requests match)<br />

*;method=Session (Session invitation requests are allowed. Reference, PageMessage and Subscription events are<br />

not allowed.)<br />

Jcp.org;method=PageMessage (Page messages are allowed from jcp.org)<br />

Jcp.org;method=PageMessage,Subscribe sip:server@ims.com presence (Page messages from jcp.org and<br />

Subscribe presence events are accepted)<br />

Jcp.org,ims.org,government.se;blacklist=sip:john@spamsalot.com (all requests from these domains are accepted,<br />

except for those sent from sip:john@spamsalot.com).<br />

Jcp.org,ims.org,government.se;blacklist=tel:+4646232809@ims.org (all requests from these domains are accepted,<br />

except for those sent from tel:+4646232809@ims.org).<br />

Push registrations overview<br />

This section describes the model of <strong>IMS</strong> push registrations used in the <strong>JSR</strong> <strong>281</strong>. A key ingredient is when the SIP<br />

REGISTER message is sent out in relation to the call to Connector.open().<br />

In a manual start of non-push registered MIDlets, the <strong>IMS</strong> registration is updated (via a SIP REGISTER message to<br />

the proxy server) at the time the MIDlet calls Connector.open() as it obtains the core service object. For the<br />

push registered case, the creation of core service follows a lazy scheme, in that the SIP REGISTER is sent before<br />

the MIDlet calls Connector.open(). This can happen in two ways. (1) At system start, the <strong>IMS</strong> engine processes<br />

all imscore push registrations in the system and sends out the SIP REGISTER. (2) For push registrations added at<br />

a later stage, new SIP REGISTER messages are sent out to update the <strong>IMS</strong> registration as they arrive, either via<br />

installation of application suites with static push registrations, or dynamically, via the<br />

PushRegistry.registerConnection() call.<br />

Creating and handling a push registration<br />

The main design principle is outlined in this section.<br />

For push registrations, the AMS acts as client to the <strong>IMS</strong> engine rather than the application. When processing a<br />

push registration (which usually is done at system start) the AMS calls Connector.open() on the<br />

connectionURL strings. The AMS buffers the core service objects, waiting for further activity from the <strong>IMS</strong><br />

network. For the Subscription case, the AMS also creates and buffers a subscription service method object from<br />

the core service.<br />

On an incoming request that targets such a buffered core service created for a push registration, the AMS launches<br />

the MIDlet owning the <strong>IMS</strong> application. When the MIDlet makes the call to Connector.open() with the<br />

connectionURL string, the buffered core service is passed to the MIDlet instead of creating a new one.<br />

Meanwhile, the <strong>IMS</strong> engine has created a service method for the incoming request, and this is passed to the MIDlet<br />

once it has set the appropriate listener on the core service object. At this stage, handover of the core service and<br />

service method is complete. For the subscription case, the event is delivered to the application once the MIDlet has<br />

set the subscription listener. More details of the scenario are given below in the section “AMS accepting incoming<br />

imscore connections”.<br />

Note that the AMS must use internal interfaces to the <strong>IMS</strong> engine in order to monitor the progress of the MIDlet and<br />

perform details of the handover. For example, the AMS should not (meaningfully) set a listener on the created core<br />

service since it does not handle the incoming service method; that is done by the application. This is specific to the<br />

push registry implementation of the device.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 196 of 199


Appendix A<br />

Removing a push registration<br />

A push registration is removed either by uninstalling the application suite, or when the MIDlet calls<br />

Pushregistry.unregisterConnection(). When this happens, then the <strong>IMS</strong> registration at the server MUST<br />

be updated with a new contact header showing the removed push registration is no longer active. In the scenario<br />

above, a saved core service is closed.<br />

Maintaining a push registration<br />

Since it may take some time between a push registration and when an incoming connection is accepted, the push<br />

registry mechanisms for <strong>IMS</strong> MUST monitor the current <strong>IMS</strong> registration. If it happens that the device is<br />

de-registered, the implementation MUST try to recover the <strong>IMS</strong> registration as soon as possible. This should be<br />

done in harmony with the device policy. When the <strong>IMS</strong> network is once again available, registrations shall be<br />

restored.<br />

AMS accepting incoming imscore connections<br />

The process of transferring ownership of objects from the AMS to the MIDlet is called “hand over”, and is a key part<br />

in the push launch.<br />

Hand over requires the MIDlet must be programmed in a certain way. This is however what <strong>IMS</strong> MIDlets would<br />

normally do when using the <strong>IMS</strong><strong>API</strong> for the non-push registered case. In the sections below, the criteria that the<br />

MIDlet program must follow to properly handle a push start are presented.<br />

PageMessage, Reference and Session handling<br />

The MIDlet MUST do:<br />

1. Call Connector.open with the connectionURL string:<br />

cs = (CoreService)Connector.open(“imscore://myApp”);<br />

The <strong>IMS</strong> engine here hands over the core service that the AMS created for the push registration.<br />

2. Set the core service listener, assuming this implements the CoreServiceListener interface:<br />

cs.setListener(this);<br />

The application is handed over the PageMessage via CoreServiceListener.PageMessageReceived(),<br />

Reference via CoreServiceListener.referenceReceived(), and Sessions via<br />

CoreServiceListener.SessionInvitationReceived().<br />

Subscription event handling<br />

The MIDlet MUST do:<br />

1. Call Connector.open with the connectionURL string:<br />

cs = (CoreService)Connector.open(“imscore://myApp”);<br />

The <strong>IMS</strong> engine here returns the core service that the AMS created for the push registration.<br />

2. Set the core service listener, assuming this implements the CoreServiceListener interface:<br />

cs.setListener(this);<br />

3. Create a Subscription with the same to and event arguments as specified in the allowed sender string:<br />

sub = cs.createSubscription(“sip:alice@ims.org”, “sip:server@ims.org”, “myEvent”);<br />

4. Set a subscription listener, assuming this implements the SubscriptionListener interface:<br />

sub.setListener(this);<br />

The application gets SubscriptionListener.subscriptionStarted call back and then the event that<br />

caused it to launch with SubscriptionListener.subscriptionNotify.<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 197 of 199


Appendix A<br />

To summarize, for all push registrations, the AMS is responsible to handle them up until the point where the MIDlet<br />

creates the core service and sets the listener. From that point the MIDlet assumes responsibility. After the core<br />

service is closed (for whatever reason) incoming connections are rejected until the MIDlet opens it again. The <strong>IMS</strong><br />

registration MUST be updated with a contact header that reflects this situation. When the MIDlet terminates, AMS<br />

takes the responsibility again to monitor incoming connections on behalf of the MIDlet. This results in a re-update of<br />

the <strong>IMS</strong> registration to again include an updated contact header for this application.<br />

If the MIDlet fails to do any of these steps, then hand over does not succeed and the AMS could not transfer the<br />

object ownership. For core services not handed over, the AMS buffers them until the push registration is<br />

terminated.<br />

Note that the AMS owns push registered connections up until the MIDlet does setListener on the core service<br />

object.<br />

AMS rejecting incoming imscore connections<br />

This section makes it explicit when the AMS rejects incoming connections for push registry. This happens in the<br />

following cases.<br />

• If an incoming connection could not route to a core service.<br />

• If the connection does not pass the allowedSender field of the push registration.<br />

• If the connection includes a request that does not match the argument list of the connectionURL (note that<br />

Session is accepted if the list is not specified).<br />

In these cases, the MIDlet will not launch. The AMS keeps its ownership. Note that if the application creates the<br />

core service on its own initiative (via connector.open()) then it will receive all incoming requests since it has claimed<br />

ownership.<br />

MIDlet auto-invocation<br />

There is a permission associated with auto-launch of application based on the string<br />

javax.microedition.io.PushRegistry. When the user is prompted, the following information MUST be presented to<br />

the user:<br />

• The name of the MIDlet, and the <strong>IMS</strong> application name.<br />

• The request type (Session, PageMessage, Reference, Subscription event).<br />

• The From and the P-Asserted-Identity header fields of the incoming request. If the request is anonymous,<br />

then this MUST be indicated to the user.<br />

• If there are several incoming requests that attempt to launch the same application, then this MUST be<br />

presented to the user.<br />

Buffering<br />

The section explains details on the buffering of incoming requests until the MIDlet is ready to handle them.<br />

If the device has an <strong>IMS</strong> registration that reflects that it is ready to handle incoming requests targeted at a certain<br />

<strong>IMS</strong> application and some of its core services, then the <strong>IMS</strong> network and remote endpoints should not need to be<br />

aware that the MIDlet is not running yet. Buffering should be implemented as transparently as possible.<br />

The AMS must buffer incoming service methods and subscription events in a first in first served manner. The size<br />

of the buffer is implementation specific. If the buffer overflows, the request shall be rejected with 480 Temporarily<br />

not available.<br />

The AMS MUST buffer at least one service method object and one subscription event for a push registered core<br />

service until some of the following happens:<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 198 of 199


Appendix A<br />

• The AMS can reject the incoming connection according to above.<br />

• The AMS can accept the incoming imscore connection according to above (performs a successful<br />

handover)<br />

• The MIDlet calls Connector.open() using the connectionURL string for the push registered core<br />

service and then closes it without following through on the remaining steps listed as the criteria for<br />

acceptance.<br />

• The push registration is removed.<br />

• The MIDlet is uninstalled from the device.<br />

• Buffered for at least 128 seconds. This is the INVITE transaction timeout T1*64 according to [24.229].<br />

Example jad-file in MIDP 2.0<br />

A chess application is configured to launch based on when the opponent opens a session, or when, for example, a<br />

community server for chess players shows someone is interested in a new game is present.<br />

MicroEdition-<strong>IMS</strong>-1-Identity: org.jsr<strong>281</strong>.myChess, MyChess<br />

MicroEdition-<strong>IMS</strong>-1-Event: Presence<br />

MicroEdition-<strong>IMS</strong>-1-CoreService-1: myChess, urn:<strong>IMS</strong><strong>API</strong>:com.myCompany.iari.myChess, ,<br />

MIDlet-Push-1: imscore://myChess, org.jsr<strong>281</strong>.myChess, *;method=Session, Subscribe<br />

sip:server@chess.ims.org presence<br />

<strong>JSR</strong> <strong>281</strong> <strong>IMS</strong> <strong>Services</strong> <strong>API</strong> -- 2009-04-08 Page 199 of 199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!