|
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : SdpBandwidthField.h |
|
16 * Part of : SDP Codec |
|
17 * Interface : SDK API, SDP Codec API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSDPBANDWIDTHFIELD_H |
|
25 #define CSDPBANDWIDTHFIELD_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32base.h> |
|
29 #include <stringpool.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class RReadStream; |
|
33 class RWriteStream; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * @publishedAll |
|
38 * @released |
|
39 * |
|
40 * This class encapsulates the bandwidth field of |
|
41 * the Session Description Protocol. |
|
42 * |
|
43 * The normative reference for correct formatting and values is |
|
44 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in |
|
45 * member documentation. The implementation supports this normative |
|
46 * reference, but does not enforce it fully. |
|
47 * |
|
48 * @lib sdpcodec.lib |
|
49 */ |
|
50 class CSdpBandwidthField : public CBase |
|
51 { |
|
52 public:// Constructors and destructor |
|
53 /** |
|
54 * Constructs a new bandwidth field. |
|
55 * |
|
56 * @param aText A string containing a correctly |
|
57 * formatted field value terminated by a CRLF. |
|
58 * @return a new instance. |
|
59 */ |
|
60 IMPORT_C static CSdpBandwidthField* DecodeL(const TDesC8& aText); |
|
61 |
|
62 /** |
|
63 * Constructs a new bandwidth field and adds the pointer to the |
|
64 * cleanup stack. |
|
65 * |
|
66 * @param aText A string containing a correctly |
|
67 * formatted field value terminated by a CRLF. |
|
68 * @return a new instance. |
|
69 */ |
|
70 IMPORT_C static CSdpBandwidthField* DecodeLC(const TDesC8& aText); |
|
71 |
|
72 /** |
|
73 * Constructs a new bandwidth field. |
|
74 * |
|
75 * @param aModifier Bandwidth modifier. |
|
76 * @param aValue Bandwidth value. |
|
77 * @return a new instance. |
|
78 */ |
|
79 IMPORT_C static CSdpBandwidthField* NewL(RStringF aModifier, |
|
80 TUint32 aValue); |
|
81 |
|
82 /** |
|
83 * Constructs a new bandwidth field and adds the pointer to the |
|
84 * cleanup stack. |
|
85 * |
|
86 * @param aModifier Bandwidth modifier. |
|
87 * @param aValue Bandwidth value. |
|
88 * @return a new instance. |
|
89 */ |
|
90 IMPORT_C static CSdpBandwidthField* NewLC(RStringF aModifier, |
|
91 TUint32 aValue); |
|
92 |
|
93 |
|
94 /** |
|
95 * Deletes the resources held by the instance. |
|
96 */ |
|
97 IMPORT_C ~CSdpBandwidthField(); |
|
98 |
|
99 public: // New functions |
|
100 /** |
|
101 * Outputs the field formatted according to SDP syntax and including |
|
102 * the terminating CRLF. |
|
103 * |
|
104 * @param aStream Stream used for output. On return |
|
105 * the stream includes correctly formatted bandwidth field. |
|
106 */ |
|
107 IMPORT_C void EncodeL(RWriteStream& aStream) const; |
|
108 |
|
109 /** |
|
110 * Creates a new instance that is equal to the target. |
|
111 * |
|
112 * @return a new instance. |
|
113 */ |
|
114 IMPORT_C CSdpBandwidthField * CloneL() const; |
|
115 |
|
116 /** |
|
117 * Compares this instance to another for equality. |
|
118 * |
|
119 * @param aObj The instance to compare to. |
|
120 * @return ETrue if equal, EFalse if not. |
|
121 */ |
|
122 IMPORT_C TBool operator == (const CSdpBandwidthField& aObj) const; |
|
123 |
|
124 /** |
|
125 * Gets the bandwidth modifier. |
|
126 * |
|
127 * @return The modifier that can be pre-defined in the |
|
128 * SDP string table or defined by the user. |
|
129 */ |
|
130 IMPORT_C RStringF Modifier() const; |
|
131 |
|
132 /** |
|
133 * Sets the bandwidth modifier. |
|
134 * |
|
135 * @param aModifier A valid bandwidth modifier name. |
|
136 */ |
|
137 IMPORT_C void SetModifier(RStringF aModifier); |
|
138 |
|
139 /** |
|
140 * Gets the bandwidth value. |
|
141 * |
|
142 * @return The value. |
|
143 */ |
|
144 IMPORT_C TUint32 Value() const; |
|
145 |
|
146 /** |
|
147 * Sets the bandwidth value. |
|
148 * |
|
149 * @param aValue The Value. |
|
150 */ |
|
151 IMPORT_C void SetValue(TUint32 aValue); |
|
152 |
|
153 public: |
|
154 /** |
|
155 * Externalize the instance in a memory optimized format. |
|
156 * |
|
157 * @param aStream The stream used for externalization. |
|
158 */ |
|
159 void ExternalizeL(RWriteStream& aStream) const; |
|
160 |
|
161 /** |
|
162 * Create a new instance from value created with ExternalizeL(). |
|
163 * |
|
164 * @param aStream The stream used for internalization. |
|
165 * @return The new instance. |
|
166 */ |
|
167 static CSdpBandwidthField* InternalizeL(RReadStream& aStream); |
|
168 |
|
169 private: |
|
170 CSdpBandwidthField(); |
|
171 void ConstructL(const TDesC8& aText); |
|
172 void ConstructL(RStringF aModifier, TUint32 aValue); |
|
173 void ConstructL(const TDesC8& aModifier, TUint32 aValue); |
|
174 |
|
175 /** |
|
176 * Copies given modifier to iModifier. If aModifier is none of |
|
177 * predefined ones, new modifier is added to stringPool. |
|
178 * |
|
179 * @param aModifier Given modifier |
|
180 */ |
|
181 void CopyModifierL(const TDesC8& aModifier); |
|
182 |
|
183 private: // Data |
|
184 RStringF iModifier; |
|
185 TUint32 iValue; |
|
186 RStringPool iStringPool; |
|
187 }; |
|
188 |
|
189 #endif // CSDPBANDWIDTHFIELD_H |