|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D" xml:lang="en"><title>Example |
|
13 Showing the use of the SDP Codec API</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>The following sections explain how to create an SDP description with the |
|
15 required fields. </p> |
|
16 <ul> |
|
17 <li id="GUID-F95C20F4-0A32-588F-A5A4-25C8C0F1D687"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-5184D372-53E1-5872-9DC0-63E004232D6D">Creating an SDP description</xref> </p> </li> |
|
18 <li id="GUID-ADA89366-B0CD-5520-A6A1-392525042085"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-CD67F58C-5059-50DA-B275-CC07EC5E93EF">Creating a CSdpDocument object</xref> </p> </li> |
|
19 <li id="GUID-ADF16F11-C606-55C8-9E3C-4BCC420342D7"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-35A2A9E8-8AE4-55EA-9DE3-C6F056A3B497">Defining the session name field for the SDP description</xref> </p> </li> |
|
20 <li id="GUID-AAEAAB91-98EB-5A6C-AA18-DA850BED70EB"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-6D04653E-711E-53B3-8DC6-9A35EDE98173">Creating an instance of the Origin field class</xref> </p> </li> |
|
21 <li id="GUID-EFFDBB7F-CF7A-593C-826A-480DBF6D13AB"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-63EE5D34-4AD2-5FC5-8D4C-E4DDEBE4D546">Fetching the network type and the address type</xref> </p> </li> |
|
22 <li id="GUID-58CDD2CF-CCF2-52B2-8C0A-134508FC14EA"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-4CE0F919-97DC-5A4B-81B1-44953792609A">Creating and setting the connection field into the sdpDocument</xref> </p> </li> |
|
23 <li id="GUID-B54A2924-3AAC-5E1B-9A0B-145A532E9306"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-0C8C6767-7D0D-5211-88A1-E07FABFC2EDB">Defining the session part attribute and direction-attribute</xref> </p> </li> |
|
24 <li id="GUID-D35AFF85-8E2D-5352-BE58-E755F3FF7D53"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-7835F2BC-6D44-58D7-A662-72B636F31154">Creating the first media field</xref> </p> </li> |
|
25 <li id="GUID-86DD7BAC-9C2B-5A23-8B7B-8A1FE7047CC6"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-D991055C-4847-5A92-BA72-18917231C00E">Creating the second media field</xref> </p> </li> |
|
26 <li id="GUID-00D37100-7CB9-5A7A-874A-325B89E59A8F"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-F8B6AE3F-DD42-5318-9184-C7DE92B7068A">Assigning the media fields to the CSdpDocument object</xref> </p> </li> |
|
27 <li id="GUID-1785FB44-679F-5C03-8B5B-44A2F5B979D0"><p> <xref href="GUID-6F40A921-83A9-5268-A9A6-80750CD5823D.dita#GUID-6F40A921-83A9-5268-A9A6-80750CD5823D/GUID-8F23A065-184D-5725-86FC-AC5909B401BB">Deleting the sdpDocument and closing the SdpCodecStringPool</xref> </p> </li> |
|
28 </ul> |
|
29 <section id="GUID-5184D372-53E1-5872-9DC0-63E004232D6D"><title> Creating an |
|
30 SDP description</title> <ol id="GUID-9274DB5E-2266-5CBC-94BE-A140D1AA5B8E"> |
|
31 <li id="GUID-1D695593-6D60-5FB6-9D2B-EAF58D9D1451"><p>Open the String Pool </p> </li> |
|
32 <li id="GUID-DF565227-6809-578B-9C75-A5D06DF9DC02"><p>Access the predefined |
|
33 SDP constants in the string table </p> </li> |
|
34 <li id="GUID-44F46943-DCBA-5E12-B68D-A19DBF6DBBF7"><p>Close the String Pool |
|
35 after you finish with the SDP description </p> </li> |
|
36 </ol> <codeblock id="GUID-AC697A6F-FA2A-5B00-8004-DDCCEB82ADE1" xml:space="preserve">SdpCodecStringPool::OpenL(); |
|
37 RStringPool pool = SdpCodecStringPool::StringPoolL(); |
|
38 </codeblock> </section> |
|
39 <section id="GUID-CD67F58C-5059-50DA-B275-CC07EC5E93EF"><title> Creating a |
|
40 CSdpDocument object</title> <p>The following code snippet shows how to create |
|
41 the <xref href="GUID-FF6D4EAD-3AAE-3843-8A9C-7C92426FC29F.dita"><apiname>CSdpDocument</apiname></xref> object. This includes all SDP fields in |
|
42 the structural format: </p> <codeblock id="GUID-6A6F8797-0DB3-5FA3-9AEC-F688B998755B" xml:space="preserve">CSdpDocument* sdpDocument = CSdpDocument::NewLC();</codeblock> </section> |
|
43 <section id="GUID-35A2A9E8-8AE4-55EA-9DE3-C6F056A3B497"><title>Defining the |
|
44 session name field for the SDP description</title> <p>The following code snippet |
|
45 shows how to define the session name field for the SDP description: </p> <codeblock id="GUID-14984CDB-2868-5857-9E47-96E280524E2A" xml:space="preserve">sdpDocument->SetSessionNameL(_L8("SipSession"));</codeblock> </section> |
|
46 <section id="GUID-6D04653E-711E-53B3-8DC6-9A35EDE98173"><title>Creating an |
|
47 instance of the Origin field class </title> <p>The following code snippet |
|
48 shows how to create an instance of the Origin field class and set into the |
|
49 SDP description: </p> <codeblock id="GUID-BB71093E-DA1F-5BE8-A7A1-7D1BD51AC2AC" xml:space="preserve">TInt64 sessionId( TUint( 2890844526 ) ); |
|
50 TInt64 sessionVersion( TUint( 2890842807 ) ); |
|
51 TInetAddr address; |
|
52 const TUint32 KInetAddr = INET_ADDR(10,47,16,5); |
|
53 address.SetAddress( KInetAddr ); |
|
54 CSdpOriginField* originfield = CSdpOriginField::NewL(_L8("username"), sessionId, sessionversion, address); |
|
55 sdpDocument->SetOriginField(originfield); |
|
56 </codeblock> </section> |
|
57 <section id="GUID-63EE5D34-4AD2-5FC5-8D4C-E4DDEBE4D546"><title>Fetching the |
|
58 network type and the address type</title><p>The following code snippet shows |
|
59 how to fetch the predefined network type and the address type for the connection |
|
60 field from the String Pool:</p><codeblock xml:space="preserve">RStringF netType = pool.StringF( SdpCodecStringConstants::ENetType, SdpCodecStringConstants::Table );RStringF addressTypeIP4 = pool.StringF( SdpCodecStringConstants::EAddressTypeIP4, SdpCodecStringConstants::Table ); |
|
61 </codeblock> </section> |
|
62 <section id="GUID-4CE0F919-97DC-5A4B-81B1-44953792609A"><title>Creating |
|
63 and setting the connection field into the sdpDocument</title> <p>The following |
|
64 code snippet shows how to create the connection field and set the SDP parameters |
|
65 of the SIP message into the SDP description: </p> <codeblock id="GUID-C95DB654-C03B-5FAA-B21A-AD7AC7E45117" xml:space="preserve">_LIT8( KAddress, "10.47.16.5" ); |
|
66 CSdpConnectionField* connectionfield = CSdpConnectionField::NewL( netType, addressTypeIP4, KAddress ); |
|
67 sdpDocument->SetConnectionField(connectionfield); |
|
68 </codeblock> </section> |
|
69 <section id="GUID-0C8C6767-7D0D-5211-88A1-E07FABFC2EDB"><title>Defining the |
|
70 session part attribute and direction-attribute</title> <p>The following code |
|
71 snippet shows how to define the session part attribute for the SDP description. |
|
72 The direction-attribute is not one of the predefined attributes in the string |
|
73 table, it must be defined dynamically to the String Pool. </p> <codeblock id="GUID-83943165-3D45-5D50-B4D8-B6F3471CF623" xml:space="preserve">_LIT8(KSDPAttributeDirectionBoth,"both"); |
|
74 RStringF modifier = pool.OpenFStringL(_L8("direction")); |
|
75 CleanupClosePushL(modifier); |
|
76 CSdpAttributeField* attrField = CSdpAttributeField::NewL(modifier, KSDPAttributeDirectionBoth); |
|
77 User::LeaveIfError((sdpDocument->AttributeFields()).Append(attrField)); |
|
78 CleanupStack::PopAndDestroy(); |
|
79 </codeblock> </section> |
|
80 <section id="GUID-7835F2BC-6D44-58D7-A662-72B636F31154"><title> Creating the |
|
81 first media field</title> <p>The following code snippet shows how to create |
|
82 the first media field: </p> <codeblock id="GUID-5EC0673E-BE80-522E-BD8C-1A258BCF25E3" xml:space="preserve">RStringF mediaVideo = pool.StringF( SdpCodecStringConstants::EMediaVideo, SdpCodecStringPool::StringTableL()); |
|
83 RStringF protocol = pool.StringF(SdpCodecStringConstants::EProtocolRtpAvp, SdpCodecStringPool::StringTableL()); |
|
84 CSdpMediaField* media1 = CSdpMediaField::NewLC(mediaVideo, 49152, protocol, _L8("96")); |
|
85 </codeblock> <p>Add the sendonly attribute (“a=sendonly”) to the first media |
|
86 field: </p> <codeblock id="GUID-30DCBB1C-E76A-5BBA-B8CE-CA34EDE86C51" xml:space="preserve">RStringF sendonlyAttr = iPool.StringF( SdpCodecStringConstants:: EAttributeSendonly, SdpCodecStringPool::StringTableL() ); |
|
87 CSdpAttributeField* attr1 = CSdpAttributeField::NewLC(sendonlyAttr, _L8("")); |
|
88 User::LeaveIfError((media1->AttributeFields()).Append(attr1)); |
|
89 CleanupStack::Pop(); //attr1 |
|
90 </codeblock> <p>Add the rtpmap attribute (“a=rtpmap:96 H263-2000/90000”) to |
|
91 the first media field and then add the rtpmap specific attribute (“a=ptime:15”): </p> <codeblock id="GUID-73BD605A-7C81-50A2-988C-17ABA6B0641B" xml:space="preserve">_LIT8( KEncodingName, "H263-2000" ); |
|
92 _LIT8( KClockRate, "90000" ); |
|
93 _LIT8( KEncodingParam, "" ); |
|
94 TSdpRtpmapValue rtpmapValue( KEncodingName(), KClockRate(), KEncodingParam() ); |
|
95 HBufC8* rtpmapBuf = rtpmapValue.EncodeL(); |
|
96 CleanupStack::PushL(rtpmapBuf); |
|
97 RStringF rtpmapStr = pool.StringF( SdpCodecStringConstants::EAttributeRtpmap, SdpCodecStringPool::StringTableL() ); |
|
98 CSdpFmtAttributeField* rtpmapAttribute = CSdpFmtAttributeField::NewLC(rtpmapStr, _L8("96"), *rtpmapBuf); |
|
99 User::LeaveIfError(media1->FormatAttributeFields().Append (rtpmapAttribute)); |
|
100 CleanupStack::Pop(); // rtpmapAttribute |
|
101 CleanupStack::PopAndDestroy(); // rtpmapBuf |
|
102 // add a rtpmap specific attribute |
|
103 RStringF ptimeAttrStr = iPool.StringF( SdpCodecStringConstants:: EAttributePtime, SdpCodecStringPool::StringTableL() ); |
|
104 CSdpAttributeField* ptimeAttr = CSdpAttributeField::NewLC(ptimeAttrStr, _L8("15")); |
|
105 ptimeAttr->AssignTo(*(media1->FormatAttributeFields())[0]); |
|
106 User::LeaveIfError(media1->AttributeFields().Append(ptimeAttr)); |
|
107 CleanupStack::Pop(); //ptimeAttr |
|
108 </codeblock> </section> |
|
109 <section id="GUID-D991055C-4847-5A92-BA72-18917231C00E"><title>Creating the |
|
110 second media field</title> <p>The following code snippet shows how to create |
|
111 the second media field: </p> <codeblock id="GUID-9B5EAFE9-66DD-57A7-8AD3-78233430ED53" xml:space="preserve">RStringF mediaAudio = pool.StringF( SdpCodecStringConstants:: EMediaAudio, SdpCodecStringPool::StringTableL()); |
|
112 CSdpMediaField* media2 = CSdpMediaField::NewLC(mediaAudio, 57344, protocol, _L8("97")); |
|
113 </codeblock> <p>Create the sendonly attribute for the second media field: </p> <codeblock id="GUID-2561B0AD-A8DA-56B0-84E2-833A22F9BE4E" xml:space="preserve">CSdpAttributeField* attr2 = CSdpAttributeField::NewLC(sendonlyAttr, |
|
114 _L8("")); |
|
115 User::LeaveIfError((media2->AttributeFields()).Append(attr2)); |
|
116 CleanupStack::Pop(); |
|
117 </codeblock> <p>Create the rtpmap attribute (“a=rtpmap:97 AMR/8000”) for the |
|
118 second media field: </p> <codeblock id="GUID-18186488-A9C8-5B7A-B3FF-5424C1C4DBD9" xml:space="preserve">_LIT8( KEncodingName1, "AMR" ); |
|
119 _LIT8( KClockRate1, "8000" ); |
|
120 TSdpRtpmapValue rtpmapValue1( KEncodingName1(), KClockRate1(), KEncodingParam() ); |
|
121 HBufC8* rtpmapBuf1 = rtpmapValue1.EncodeL(); |
|
122 CleanupStack::PushL(rtpmapBuf1); |
|
123 CSdpFmtAttributeField* rtpmapAttribute1 = CSdpFmtAttributeField::NewLC(rtpmapStr, _L8("97"), *rtpmapBuf1); |
|
124 User::LeaveIfError(media2->FormatAttributeFields().Append (rtpmapAttribute1)); |
|
125 CleanupStack::Pop(); // rtpmapAttribute1 |
|
126 CleanupStack::PopAndDestroy(); //rtpmapBuf1 |
|
127 </codeblock> </section> |
|
128 <section id="GUID-F8B6AE3F-DD42-5318-9184-C7DE92B7068A"><title>Assigning the |
|
129 media fields to the CSdpDocument object </title> <p>The following code snippet |
|
130 shows how to assign the media fields to the <xref href="GUID-FF6D4EAD-3AAE-3843-8A9C-7C92426FC29F.dita"><apiname>CSdpDocument</apiname></xref> object |
|
131 and then remove the buffers from the cleanup stack: </p> <codeblock id="GUID-44BD57DA-85CD-554A-8801-86F7F47A7D41" xml:space="preserve">User::LeaveIfError(doc->MediaFields().Append(media1)); |
|
132 User::LeaveIfError(doc->MediaFields().Append(media2)); |
|
133 CleanupStack::Pop(); //media2 |
|
134 CleanupStack::Pop(); //media1 |
|
135 </codeblock> </section> |
|
136 <section id="GUID-8F23A065-184D-5725-86FC-AC5909B401BB"><title>Deleting the |
|
137 sdpDocument and closing the SdpCodecStringPool</title> <p>To close the String |
|
138 Pool the <xref href="GUID-FF6D4EAD-3AAE-3843-8A9C-7C92426FC29F.dita"><apiname>CSdpDocument</apiname></xref> object must be removed and deleted |
|
139 from the cleanup stack. The following code snippet shows how to remove and |
|
140 delete the <xref href="GUID-FF6D4EAD-3AAE-3843-8A9C-7C92426FC29F.dita"><apiname>CSdpDocument</apiname></xref> object from the cleanup stack and |
|
141 close the String Pool: </p> <codeblock id="GUID-2037F164-73C9-5DC0-95BF-F05E778BF4E1" xml:space="preserve">CleanupStack::PopAndDestroy(); //sdpDocument |
|
142 SdpCodecStringPool::Close(); |
|
143 </codeblock> <p>The SDP description created in the preceding example has the |
|
144 following fields: </p> <codeblock id="GUID-EC361C3C-02D4-5130-AD1B-4C12F1985A06" xml:space="preserve">v=0 |
|
145 o=username 2890844526 2890842807 IN IP4 10.47.16.5 |
|
146 s=SipSession |
|
147 c=IN IP4 10.47.16.5 |
|
148 t=0 0 |
|
149 a=direction:both |
|
150 m=video 49152 RTP/AVP 96 |
|
151 a=sendonly |
|
152 a=rtpmap:96 H263-2000/90000 |
|
153 m=audio 57344 RTP/AVP 97 |
|
154 a=sendonly |
|
155 a=rtpmap:97 AMR/8000 |
|
156 </codeblock> </section> |
|
157 </conbody></concept> |