|
1 /* |
|
2 * Copyright (c) 2002 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 * For checking the validity of Smart messaging ringing tone and for |
|
16 * ripping the ringing tone title from binary data. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __RINGBCTONECONVERT_H |
|
22 #define __RINGBCTONECONVERT_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "NsmRingTone.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 NONSHARABLE_STRUCT( TInstruction ) |
|
30 { |
|
31 TInt iValue; |
|
32 TInt iDuration; |
|
33 TInt iDurspecifier; |
|
34 TInt iScale; |
|
35 TInt iStyle; |
|
36 }; |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 NONSHARABLE_STRUCT( TCompData ) |
|
41 { |
|
42 TInt iTempo; |
|
43 CArrayFix<TInstruction>* iSongData; |
|
44 TInt iSongLength; |
|
45 TBuf<KrtSongTitleTextLength> iSongTitle; |
|
46 }; |
|
47 |
|
48 // CLASS DECLARATION |
|
49 NONSHARABLE_CLASS( RingBCNSMConverter ) : public CBase |
|
50 { |
|
51 public: // New functions |
|
52 |
|
53 /** |
|
54 * Creates an instance of CRingBCNSMConverter and returns it. |
|
55 */ |
|
56 static RingBCNSMConverter* NewL(); |
|
57 |
|
58 protected: |
|
59 /** |
|
60 * Second-phase constructor. |
|
61 */ |
|
62 void ConstructL(); |
|
63 |
|
64 /** |
|
65 * Default C++ constructor. |
|
66 */ |
|
67 RingBCNSMConverter(); |
|
68 |
|
69 public: |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 ~RingBCNSMConverter(); |
|
74 |
|
75 public: // New methods |
|
76 |
|
77 /** |
|
78 * Converts a Nokia Smart Messaging stream into TCompData. |
|
79 * |
|
80 * Smart Messaging: <ringing-tone-programming-language>::=<command>+ |
|
81 * <command>::= |
|
82 * <command-length><command-part>+ | |
|
83 * <command-end> |
|
84 * <command-length>::='binary[00000001..11111111], indicates |
|
85 * how many command parts there are in the command.' |
|
86 * <command-end>::='binary[00000000]. This indicates the end |
|
87 * of the ringing tone programming language.' |
|
88 |
|
89 * @param aFileData The NSM stream. |
|
90 * @return The song. |
|
91 */ |
|
92 TCompData* ConvertNsmToCompDataL( const TDesC8& aFileData ); |
|
93 |
|
94 /** |
|
95 * Sets the title of the song. |
|
96 * |
|
97 * @param aFileName The new title of the song. |
|
98 * @return Error code |
|
99 */ |
|
100 void SetTitle( const TDesC& aFileName ); |
|
101 |
|
102 /** |
|
103 * Returns a pointer to the title of the ring tone. |
|
104 * |
|
105 * Usage: |
|
106 * 1) Create converter(converter = CRingBCNSMConverter::NewL()) |
|
107 * 2) Call TitleL function to get title pointer(title = converter->TitleL(aFileData)) |
|
108 * 3) Use title pointer however necessary |
|
109 * |
|
110 * @param aFileData A pointer to the raw file data. |
|
111 * @return The title as a HBufC. The ownership is |
|
112 * transferred and it is left in cleanup stack. |
|
113 * |
|
114 **/ |
|
115 HBufC* TitleLC(TPtr8& aFileData); |
|
116 |
|
117 /** |
|
118 * Check if a NSM stream is a valid ringtone. |
|
119 * |
|
120 * Usage: |
|
121 * 1) Create converter(converter = CRingBCNSMConverter::NewL()) |
|
122 * 2) Call function(booleanValue = converter->IsRingToneMimeTypeL(aFileData)) |
|
123 * |
|
124 * @param aFileData A pointer to the raw file data. |
|
125 * @return ETrue if the tune is a ring tone, EFalse otherwise. |
|
126 * |
|
127 **/ |
|
128 TBool IsRingToneMimeTypeL(TPtr8& aFileData); |
|
129 |
|
130 private: |
|
131 |
|
132 struct TNsmRTPatterns |
|
133 { |
|
134 TInt iStart; |
|
135 TInt iEnd; |
|
136 }; |
|
137 |
|
138 /** |
|
139 * Description: This function processes Nokia Smart Messaging Ringing Tone |
|
140 * <command-part> to generate Composer data. |
|
141 * |
|
142 * Smart Messaging: <command-part>::= |
|
143 * <ringing-tone-programming> | |
|
144 * <unicode> | |
|
145 * <cancel-command><cancel-command-specifier> | |
|
146 * <sound><sound-command-specifier> |
|
147 * |
|
148 * If necessary, filler bits are aded to ensure that |
|
149 * <command-part> is always octet-aligned. |
|
150 * |
|
151 * The Ringing Tone programming requires that the order of |
|
152 * the command parts is the following: <ringing-tone- |
|
153 * programming>, [<unicode>,] <sound>. |
|
154 */ |
|
155 void ProcessNsmRingToneCommandPartL(); |
|
156 |
|
157 /** |
|
158 * Description: This function processes Nokia Smart Messaging Ringing Tone |
|
159 * <sound-command-specifier> to generate Composer data. |
|
160 * |
|
161 * Smart Messaging: <sound-command-specifier>::= |
|
162 * <basic-song-type><basic-song> | |
|
163 * <temporary-song-type><temporary-song> | |
|
164 * <midi-song-type><midi-song> | |
|
165 * <digitized-song-type><digitized-song> |
|
166 */ |
|
167 void ProcessNsmRingToneSoundSpecL(); |
|
168 |
|
169 /** |
|
170 * Description: This function processes Nokia Smart Messaging Ringing Tone |
|
171 * <song-title> |
|
172 * |
|
173 * Smart Messaging: <song-title>::=<text-length><text> |
|
174 * <text>::=<default-char>+ | 'Uincode disabled' |
|
175 * <ISO-10646-char>+ 'Uincode enabled' |
|
176 * <text-length>::='binary[0000..1111]; Indicating how many |
|
177 * characters are used for the following text.' |
|
178 */ |
|
179 void ProcessNsmRingToneSongTitleL(); |
|
180 |
|
181 /** |
|
182 * Description: This function processes Nokia Smart Messaging Ringing Tone |
|
183 * <temporary-song> to generate Composer data. |
|
184 * |
|
185 * Smart Messaging: <temporary-song>::=<song-sequence-length><song-sequence> |
|
186 * <song-sequence-length>::='binary[00000000..11111111]; |
|
187 * Indicates how many song patterns follow |
|
188 * <song-sequence>::=<song-pattern>+ |
|
189 * <song-pattern>::= |
|
190 * <pattern-header> | |
|
191 * <pattern-header><pattern-instruction>+ |
|
192 * <pattern-header>::= |
|
193 * <pattern-header-id><pattern-id><loop-value><pattern-specifier> |
|
194 * <loop-value>::='binary[0000..1111]; Indicates how many |
|
195 * times the pattern should be repeated. Value zero |
|
196 * means no repeat. Value binary 1111 means infinite. |
|
197 * <pattern-spacifier>::= |
|
198 * <already-defined-pattern> | <length-of-new-pattern> |
|
199 * <already-defined-pattern::='binary[00000000]; Indicates that |
|
200 * an already defined pattern is used again.' |
|
201 * <length-of-the-new-pattern>::='binary[00000001..11111111]; |
|
202 * Indicates how many pattern instructions there are |
|
203 * in the song pattern. |
|
204 */ |
|
205 void ProcessNsmRingToneSongL(); |
|
206 |
|
207 /** |
|
208 * Description: This function processes Nokia Smart Messaging Ringing Tone |
|
209 * <pattern-instruction> to generate Composer data. |
|
210 * |
|
211 * Smart Messaging: <pattern-instruction>::= |
|
212 * <note-instruction> | <scale-instruction> | |
|
213 * <style-instruction> | <tempo-instruction> | |
|
214 * <volume-instruction> |
|
215 * <scale-intruction>::=<scale-instruction-id><scale-value> |
|
216 * <style-intruction>::=<style-instruction-id><style-value> |
|
217 * <tempo-intruction>::=<tempo-instruction-id><tempo-value> |
|
218 * <volume-intruction>::=<volume-instruction-id><volume-value> |
|
219 */ |
|
220 void ProcessNsmRingTonePatternInstructionL(); |
|
221 |
|
222 /** |
|
223 * Description: This function forms a composer symbol from the pattern |
|
224 * instructions and places it into the CompData structure. |
|
225 * |
|
226 * Smart Messaging: <note-instruction>::=<note-instruction-id><note-value> |
|
227 * <note-duration><note-duration-specifier> |
|
228 */ |
|
229 void ProcessNsmRingToneNoteInstructionL(TInt aScale, TInt aStyle); |
|
230 |
|
231 /** |
|
232 * This function extracts the specified number of bits from |
|
233 * the bit stream(returned int will contain both the instruction |
|
234 * bits and the data bits). |
|
235 * |
|
236 * @param aNumBits The number of bits to get. |
|
237 * @return The value. |
|
238 */ |
|
239 TInt GetBits(TInt aNumBits); |
|
240 |
|
241 /** |
|
242 */ |
|
243 void ResetForCompData(); |
|
244 |
|
245 private: // Data |
|
246 |
|
247 /// The data being converted from an NSM stream. |
|
248 TPtrC8 iReceivedNsmRTData; |
|
249 |
|
250 /// The flags associated with an NSM stream. |
|
251 TInt iNsmRTFlags; |
|
252 |
|
253 /// The current position in the stream. |
|
254 TInt iNsmPosition; |
|
255 |
|
256 /// The current bit number in the NSM stream. |
|
257 TInt iNsmPositionBit; |
|
258 |
|
259 /// Patterns of NSM data. |
|
260 TFixedArray<TNsmRTPatterns,4> iNsmRTPatterns; |
|
261 |
|
262 /// The default scale of a tone. |
|
263 TInt iScale; |
|
264 |
|
265 /// The default style of a tone. |
|
266 TInt iStyle; |
|
267 |
|
268 /// The song data created. Owns. |
|
269 TCompData iCompData; |
|
270 |
|
271 /// The song data received for conversion. Refs. |
|
272 TCompData* iReceivedCompData; |
|
273 |
|
274 /// The position in the song data. |
|
275 TInt iCompDataPosition; |
|
276 |
|
277 /// If ETrue, the song data cannot be loaded to Composer. |
|
278 TBool iReadOnly; |
|
279 }; |
|
280 #endif //__RINGBCTONECONVERT_H |