|
1 /* |
|
2 * Copyright (c) 2004-2007 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 the License "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: Utilities to handle media content* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #include <e32base.h> |
|
21 #include "IptvDebug.h" |
|
22 #include "CIptvMediaContent.h" |
|
23 |
|
24 #ifdef _DEBUG |
|
25 const TInt KIptvMaxDebugPrint = 100; |
|
26 #endif |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // -------------------------------------------------------------------------- |
|
31 // CIptvMediaContent::NewL |
|
32 // Two-phased constructor. |
|
33 // -------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CIptvMediaContent* CIptvMediaContent::NewL() |
|
36 { |
|
37 CIptvMediaContent* self = new ( ELeave ) CIptvMediaContent(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CIptvMediaContent::~CIptvMediaContent |
|
43 // Destructor |
|
44 // -------------------------------------------------------------------------- |
|
45 // |
|
46 CIptvMediaContent::~CIptvMediaContent() |
|
47 { |
|
48 delete iMediaContentUrl; |
|
49 } |
|
50 |
|
51 // -------------------------------------------------------------------------- |
|
52 // CIptvMediaContent::CIptvMediaContent |
|
53 // C++ default constructor |
|
54 // -------------------------------------------------------------------------- |
|
55 // |
|
56 CIptvMediaContent::CIptvMediaContent() |
|
57 { |
|
58 } |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CIptvMediaContent::PrintL |
|
62 // -------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C void CIptvMediaContent::PrintL() |
|
65 { |
|
66 #ifdef _DEBUG |
|
67 |
|
68 IPTVLOGSTRING_LOW_LEVEL( "CIptvMediaContent::PrintL" ); |
|
69 |
|
70 TBuf<KIptvMaxDebugPrint> temp; |
|
71 TInt count = Min( KIptvMaxDebugPrint, iMediaContentUrl->Length() ); |
|
72 temp.Copy( iMediaContentUrl->Mid( 0, count ) ); |
|
73 |
|
74 IPTVLOGSTRING2_LOW_LEVEL("--- Url: %S", &temp); |
|
75 |
|
76 switch ( iDownloadType ) |
|
77 { |
|
78 case EIptvDownloadTypeStream: |
|
79 { |
|
80 IPTVLOGSTRING_LOW_LEVEL( |
|
81 "--- Download type: EIptvDownloadTypeStream" ); |
|
82 break; |
|
83 } |
|
84 |
|
85 case EIptvDownloadTypeImmediate: |
|
86 { |
|
87 IPTVLOGSTRING_LOW_LEVEL( |
|
88 "--- Download type: EIptvDownloadTypeImmediate" ); |
|
89 break; |
|
90 } |
|
91 |
|
92 case EIptvDownloadTypePostponed: |
|
93 { |
|
94 IPTVLOGSTRING_LOW_LEVEL( |
|
95 "--- Download type: EIptvDownloadTypePostponed" ); |
|
96 break; |
|
97 } |
|
98 |
|
99 case EIptvDownloadTypeScheduled: |
|
100 { |
|
101 IPTVLOGSTRING_LOW_LEVEL( |
|
102 "--- Download type: EIptvDownloadTypeScheduled" ); |
|
103 break; |
|
104 } |
|
105 |
|
106 default: |
|
107 { |
|
108 break; |
|
109 } |
|
110 } |
|
111 |
|
112 IPTVLOGSTRING2_LOW_LEVEL( "--- Filesize: %d", iFileSize ); |
|
113 IPTVLOGSTRING2_LOW_LEVEL( "--- Mime-type: %S", &iMimeType ); |
|
114 IPTVLOGSTRING2_LOW_LEVEL( "--- Medium: %S", &iMedium ); |
|
115 |
|
116 if ( iIsDefault ) |
|
117 { |
|
118 IPTVLOGSTRING_LOW_LEVEL( "--- Is default: ETrue" ); |
|
119 } |
|
120 else |
|
121 { |
|
122 IPTVLOGSTRING_LOW_LEVEL( "--- Is default: EFalse" ); |
|
123 } |
|
124 |
|
125 IPTVLOGSTRING2_LOW_LEVEL( "--- Bitrate: %d", iBitrate ); |
|
126 IPTVLOGSTRING2_LOW_LEVEL( "--- Framerate: %d", iFramerate ); |
|
127 IPTVLOGSTRING2_LOW_LEVEL( "--- Samplingrate: %d", iSamplingrate ); |
|
128 IPTVLOGSTRING2_LOW_LEVEL( "--- Duration: %d", iDuration ); |
|
129 IPTVLOGSTRING2_LOW_LEVEL( "--- Height: %d", iHeight ); |
|
130 IPTVLOGSTRING2_LOW_LEVEL( "--- Width: %d", iWidth ); |
|
131 IPTVLOGSTRING2_LOW_LEVEL( "--- Language: %S", &iLanguage ); |
|
132 |
|
133 switch ( iExpression ) |
|
134 { |
|
135 case EFull: |
|
136 { |
|
137 IPTVLOGSTRING_LOW_LEVEL("--- Expression: EFull"); |
|
138 break; |
|
139 } |
|
140 |
|
141 case ESample: |
|
142 { |
|
143 IPTVLOGSTRING_LOW_LEVEL("--- Expression: ESample"); |
|
144 break; |
|
145 } |
|
146 |
|
147 case ENonStop: |
|
148 { |
|
149 IPTVLOGSTRING_LOW_LEVEL("--- Expression: ENonStop"); |
|
150 break; |
|
151 } |
|
152 |
|
153 default: |
|
154 { |
|
155 break; |
|
156 } |
|
157 } |
|
158 |
|
159 IPTVLOGSTRING2_LOW_LEVEL( "--- Last position: %d", iLastPosition ); |
|
160 #endif |
|
161 } |
|
162 |
|
163 // -------------------------------------------------------------------------- |
|
164 // Externalize |
|
165 // -------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C void CIptvMediaContent::ExternalizeL( RWriteStream& aStream ) const |
|
168 { |
|
169 IPTVLOGSTRING_LOW_LEVEL( "CIptvMediaContent::ExternalizeL" ); |
|
170 |
|
171 // Content key |
|
172 aStream.WriteUint32L( iContentKey ); |
|
173 |
|
174 // Index |
|
175 aStream.WriteUint32L( iIndex ); |
|
176 |
|
177 // Download type |
|
178 aStream.WriteUint32L( iDownloadType ); |
|
179 |
|
180 // File id (Part of global file id (1/2) |
|
181 aStream.WriteUint32L( iFileId ); |
|
182 |
|
183 // Drive id (Part of global file id (2/2) |
|
184 aStream.WriteUint32L( iDriveId ); |
|
185 |
|
186 // Content URL (MRSS) |
|
187 if ( iMediaContentUrl ) |
|
188 { |
|
189 CIptvUtil::WriteDesToStreamL( *iMediaContentUrl, aStream ); |
|
190 } |
|
191 else |
|
192 { |
|
193 aStream.WriteUint32L( 0 ); |
|
194 } |
|
195 |
|
196 // File size (MRSS) |
|
197 aStream.WriteUint32L( iFileSize ); |
|
198 |
|
199 // Mime-type (MRSS |
|
200 CIptvUtil::WriteDesToStreamL( iMimeType, aStream ); |
|
201 |
|
202 // Medium (not used in client side) |
|
203 |
|
204 // iIsDefault (not used in client side) |
|
205 |
|
206 // Expression |
|
207 aStream.WriteUint32L( iExpression ); |
|
208 |
|
209 // Bitrate (not used in client side) |
|
210 |
|
211 // Framerate (not used in client side) |
|
212 |
|
213 // Samplingrate (not used in client side) |
|
214 |
|
215 // Duration |
|
216 aStream.WriteUint32L( iDuration ); |
|
217 |
|
218 // Height (Not used in client side) |
|
219 |
|
220 // Width (Not used in client side) |
|
221 |
|
222 // Language |
|
223 CIptvUtil::WriteDesToStreamL( iLanguage, aStream ); |
|
224 |
|
225 // Last position |
|
226 aStream.WriteUint32L( iLastPosition ); |
|
227 } |
|
228 |
|
229 // -------------------------------------------------------------------------- |
|
230 // Internalize |
|
231 // -------------------------------------------------------------------------- |
|
232 // |
|
233 EXPORT_C void CIptvMediaContent::InternalizeL( RReadStream& aStream ) |
|
234 { |
|
235 IPTVLOGSTRING_LOW_LEVEL( "CIptvMediaContent::InternalizeL" ); |
|
236 |
|
237 // Content key |
|
238 iContentKey = aStream.ReadUint32L(); |
|
239 |
|
240 // Index |
|
241 iIndex = aStream.ReadUint32L(); |
|
242 |
|
243 // Download type |
|
244 iDownloadType = aStream.ReadUint32L(); |
|
245 |
|
246 // File id (Part of global file id (1/2) |
|
247 iFileId = aStream.ReadUint32L(); |
|
248 |
|
249 // Drive id (Part of global file id (2/2) |
|
250 iDriveId = aStream.ReadUint32L(); |
|
251 |
|
252 // Content URL (MRSS) |
|
253 delete iMediaContentUrl; |
|
254 iMediaContentUrl = NULL; |
|
255 |
|
256 iMediaContentUrl = HBufC::NewL( KIptvEpgContentBrowserUrlMaxLength ); |
|
257 TPtr16 p = iMediaContentUrl->Des(); |
|
258 CIptvUtil::ReadDesFromStreamL( p, aStream ); |
|
259 iMediaContentUrl = |
|
260 iMediaContentUrl->ReAllocL( iMediaContentUrl->Length() ); |
|
261 |
|
262 // File size (MRSS) |
|
263 iFileSize = aStream.ReadUint32L(); |
|
264 |
|
265 // Mime-type (MRSS) |
|
266 CIptvUtil::ReadDesFromStreamL( iMimeType, aStream ); |
|
267 |
|
268 // Expression |
|
269 iExpression = aStream.ReadUint32L(); |
|
270 |
|
271 // Duration |
|
272 iDuration = aStream.ReadUint32L(); |
|
273 |
|
274 // Language |
|
275 CIptvUtil::ReadDesFromStreamL( iLanguage, aStream ); |
|
276 |
|
277 // Last position |
|
278 iLastPosition = aStream.ReadUint32L(); |
|
279 } |
|
280 |
|
281 // -------------------------------------------------------------------------- |
|
282 // Count externalized size |
|
283 // -------------------------------------------------------------------------- |
|
284 // |
|
285 EXPORT_C TUint32 CIptvMediaContent::CountExternalizeSize() |
|
286 { |
|
287 IPTVLOGSTRING_LOW_LEVEL( "CIptvMediaContent::CountExternalizeSize" ); |
|
288 |
|
289 TUint32 size = 0; |
|
290 |
|
291 size = |
|
292 // Content key |
|
293 4 + |
|
294 |
|
295 // Index |
|
296 4 + |
|
297 |
|
298 // Download type |
|
299 4 + |
|
300 |
|
301 // File id (Part of global file id (1/2) |
|
302 4 + |
|
303 |
|
304 // Drive id (Part of global file id (2/2) |
|
305 4 + |
|
306 |
|
307 // Content URL (MRSS) |
|
308 4 + ( iMediaContentUrl->Length() * 2 ) + |
|
309 |
|
310 // File size (MRSS) |
|
311 4 + |
|
312 |
|
313 // Mime-type (MRSS) |
|
314 4 + ( iMimeType.Length() * 2 ) + |
|
315 |
|
316 // Expression |
|
317 4 + |
|
318 |
|
319 // Duration |
|
320 4 + |
|
321 |
|
322 // Language |
|
323 4 + ( iLanguage.Length() * 2 ) + |
|
324 |
|
325 // Last position |
|
326 4; |
|
327 |
|
328 return size; |
|
329 } |
|
330 |
|
331 // -------------------------------------------------------------------------- |
|
332 // Set media content URL |
|
333 // -------------------------------------------------------------------------- |
|
334 // |
|
335 EXPORT_C void CIptvMediaContent::SetMediaContentUrlL( |
|
336 const TDesC& aMediaUrl ) |
|
337 { |
|
338 delete iMediaContentUrl; |
|
339 iMediaContentUrl = NULL; |
|
340 |
|
341 TInt actualLength = Min( KIptvCAContentUrlLength, aMediaUrl.Length() ); |
|
342 |
|
343 if ( actualLength > 0 ) |
|
344 { |
|
345 iMediaContentUrl = HBufC::NewL( actualLength ); |
|
346 TPtr16 ptr = iMediaContentUrl->Des(); |
|
347 ptr.Copy( aMediaUrl.Mid( 0, actualLength ) ); |
|
348 } |
|
349 } |
|
350 |
|
351 // -------------------------------------------------------------------------- |
|
352 // Get media content URL |
|
353 // -------------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C TPtrC CIptvMediaContent::GetMediaContentUrl() const |
|
356 { |
|
357 if ( iMediaContentUrl ) |
|
358 { |
|
359 return iMediaContentUrl->Des(); |
|
360 } |
|
361 |
|
362 return TPtrC(); |
|
363 } |