2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpRepeatField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPREPEATFIELD_H
25 #define CSDPREPEATFIELD_H
29 #include <stringpool.h>
30 #include <sdptypedtime.h>
32 // FORWARD DECLARATIONS
41 * This class encapsulates the repeat times field of the
42 * Session Description Protocol.
44 * The normative reference for correct formatting and values is
45 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
46 * member documentation. The implementation supports this normative
47 * reference, but does not enforce it fully.
51 class CSdpRepeatField : public CBase
53 public: // Constructors and destructor
55 * Constructs a new repeat times field.
57 * @param aText A string containing a correctly
58 * formatted field value terminated by a CRLF.
59 * @return a new instance.
61 IMPORT_C static CSdpRepeatField* DecodeL(const TDesC8& aText);
64 * Constructs a new repeat times field and adds the pointer to the
67 * @param aText A string containing a correctly
68 * formatted field value terminated by a CRLF.
69 * @return a new instance.
71 IMPORT_C static CSdpRepeatField* DecodeLC(const TDesC8& aText);
74 * Constructs a new repeat times field.
76 * @param aRepeatInterval Repeat interval value
78 * @param aActiveDuration Active duration.
79 * @param aOffsets At least one time offset.
80 * @return a new instance.
82 IMPORT_C static CSdpRepeatField* NewL(
83 const TSdpTypedTime aRepeatInterval,
84 const TSdpTypedTime aActiveDuration,
85 const RArray<TSdpTypedTime>& aOffsets);
88 * Constructs a new repeat times field and adds the pointer to the
91 * @param aRepeatInterval Repeat interval value
93 * @param aActiveDuration Active duration.
94 * @param aOffsets At least one time offset.
95 * @return a new instance.
97 IMPORT_C static CSdpRepeatField* NewLC(
98 const TSdpTypedTime aRepeatInterval,
99 const TSdpTypedTime aActiveDuration,
100 const RArray<TSdpTypedTime>& aOffsets);
103 * Deletes the resources held by the instance.
105 IMPORT_C ~CSdpRepeatField();
107 public: // New functions
109 * Outputs the field formatted according to SDP syntax and including
110 * the terminating CRLF.
112 * @param aStream Stream used for output. On return
113 * the stream includes correctly formatted repeat field.
115 IMPORT_C void EncodeL(RWriteStream& aStream) const;
118 * Creates a new instance that is equal to the target.
120 * @return a new instance.
122 IMPORT_C CSdpRepeatField * CloneL() const;
125 * Compares this instance to another for equality.
127 * @param aObj The instance to compare to.
128 * @return ETrue if equal, EFalse if not.
130 IMPORT_C TBool operator == (const CSdpRepeatField & aObj) const;
133 * Gets the repeat interval.
135 * @return The repeat interval.
137 IMPORT_C const TSdpTypedTime RepeatInterval() const;
140 * Sets the repeat interval.
142 * @param aValue Repeat interval value greater than zero.
143 * @leave KErrSdpCodecRepeatField if aValue is not positive integer
146 IMPORT_C void SetRepeatIntervalL(const TSdpTypedTime aValue);
149 * Gets the active duration..
151 * @return The active duration.
153 IMPORT_C const TSdpTypedTime ActiveDuration() const;
156 * Sets the active duration.
158 * @param Active duration.
160 IMPORT_C void SetActiveDuration(const TSdpTypedTime aValue);
163 * Gets the array of time offsets.
164 * This array is used directly for element insertion and removal.
166 * @return The offsets.
168 IMPORT_C const RArray<TSdpTypedTime>& TimeOffsets() const;
171 * Sets the time offsets.
173 * @param aOffsets At least one time offset.
175 IMPORT_C void SetTimeOffsetsL(const RArray<TSdpTypedTime>& aValue);
179 * Externalizes the object to stream
181 * @param aStream Stream where the object's state will be stored
183 void ExternalizeL(RWriteStream& aStream) const;
186 * Creates object from the stream data
188 * @param aStream Stream where the object's state will be read
189 * @return Initialized object
191 static CSdpRepeatField* InternalizeL(RReadStream& aStream);
194 CSdpRepeatField(const TSdpTypedTime aRepeatInterval,
195 const TSdpTypedTime aActiveDuration);
197 void ConstructL(const TDesC8& aText);
198 void ConstructL(const RArray<TSdpTypedTime>& aOffsets);
203 TSdpTypedTime iRepeatInterval;
204 TSdpTypedTime iActiveDuration;
205 RArray<TSdpTypedTime> iTimeOffsets;
207 void __DbgTestInvariant() const;
211 #endif // CSDPREPEATFIELD_H