1 /* |
|
2 * Copyright (c) 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: RTP clip metaheader write/read functionalities.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CRTPMETAHEADER_H |
|
21 #define CRTPMETAHEADER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <ipvideo/CRtpUtil.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KStringLengthBytes( 1 ); |
|
29 const TInt KMaxMetaHeaderLength( 2048 ); |
|
30 const TInt KMetaLengthPoint( 0 ); |
|
31 const TInt KAttributesPoint( KMetaLengthPoint + KIntegerBytes ); // 4 |
|
32 const TInt KPlayCountPoint( KAttributesPoint + KIntegerBytes ); // 8 |
|
33 const TInt KPlaySpotPoint( KPlayCountPoint + KIntegerBytes ); // 12 |
|
34 const TInt KReservedPoint1( KPlaySpotPoint + KIntegerBytes ); // 16 |
|
35 const TInt KReservedPoint2( KReservedPoint1 + KIntegerBytes ); // 20 |
|
36 const TInt KReservedPoint3( KReservedPoint2 + KIntegerBytes ); // 24 |
|
37 const TInt KReservedPoint4( KReservedPoint3 + KIntegerBytes ); // 28 |
|
38 const TInt KStartTimePoint( KReservedPoint4 + KIntegerBytes ); // 32 |
|
39 const TInt KEndTimePoint( KStartTimePoint + 2 * KIntegerBytes ); // 40 |
|
40 const TInt KDurationPoint( KEndTimePoint + 2 * KIntegerBytes ); // 48 |
|
41 const TInt KSeekArrayPoint( KDurationPoint + KIntegerBytes ); // 52 |
|
42 const TInt KUserIdPoint( KSeekArrayPoint + KIntegerBytes ); // 56 |
|
43 const TInt KDeviceInfoPoint( KUserIdPoint + KStringLengthBytes + // 72 |
|
44 KUserIdLength ); |
|
45 // Metaheader attributes |
|
46 const TInt KOngoingFlagShift( 0 ); |
|
47 const TInt KCompletedFlagShift( 1 ); |
|
48 const TInt KProtectedFlagShift( 2 ); |
|
49 const TInt KFailedFlagShift( 3 ); |
|
50 const TInt KVersionFieldShift( 4 ); |
|
51 const TInt KQualityFieldShift( 8 ); |
|
52 const TInt KPostRuleFieldShift( 16 ); |
|
53 const TInt KParentalFieldShift( 24 ); |
|
54 |
|
55 // MACROS |
|
56 // None |
|
57 |
|
58 // DATA TYPES |
|
59 // None |
|
60 |
|
61 // FORWARD DECLARATIONS |
|
62 // None |
|
63 |
|
64 // CLASS DECLARATION |
|
65 |
|
66 /** |
|
67 * Meta header handling for RTP file format. |
|
68 * |
|
69 * @lib CommonRecordingEngine.lib |
|
70 * @since Series 60 3.0 |
|
71 */ |
|
72 class CRtpMetaHeader : public CBase |
|
73 { |
|
74 |
|
75 public: // Enumeration |
|
76 |
|
77 // Defines mode |
|
78 enum TMetaMode |
|
79 { |
|
80 EMetaRead = 200, |
|
81 EMetaWrite, |
|
82 EMetaUpdate |
|
83 }; |
|
84 |
|
85 public: // Data types |
|
86 |
|
87 // Defines clip attributes struct |
|
88 class SAttributes |
|
89 { |
|
90 public: // Data |
|
91 |
|
92 /** |
|
93 * Recording ongoing. |
|
94 */ |
|
95 TBool iOngoing; |
|
96 |
|
97 /** |
|
98 * Recording completed. |
|
99 */ |
|
100 TBool iCompleted; |
|
101 |
|
102 /** |
|
103 * Clip protected. |
|
104 */ |
|
105 TBool iProtected; |
|
106 |
|
107 /** |
|
108 * Recording failed. |
|
109 */ |
|
110 TBool iFailed; |
|
111 |
|
112 /** |
|
113 * Clip version. |
|
114 */ |
|
115 TUint8 iVersion; |
|
116 |
|
117 /** |
|
118 * Clip quality. |
|
119 */ |
|
120 TUint8 iQuality; |
|
121 |
|
122 /** |
|
123 * Clip's post accuisition rule. |
|
124 */ |
|
125 TUint8 iPostRule; |
|
126 |
|
127 /** |
|
128 * Parental rate. |
|
129 */ |
|
130 TUint8 iParental; |
|
131 |
|
132 /** |
|
133 * Viewed counter. |
|
134 */ |
|
135 TInt iPlayCount; |
|
136 |
|
137 /** |
|
138 * Point where vieving stopped. |
|
139 */ |
|
140 TInt iPlaySpot; |
|
141 |
|
142 }; |
|
143 |
|
144 public: // Constructors and destructor |
|
145 |
|
146 /** |
|
147 * Two-phased constructor. |
|
148 * @param aFile a reference to file operations. |
|
149 * @param aMode a meta data read or write mode. |
|
150 */ |
|
151 static CRtpMetaHeader* NewL( RFile& aFile, |
|
152 const TMetaMode& aMode ); |
|
153 |
|
154 /** |
|
155 * Two-phased constructor. |
|
156 * @param aFile a reference to file operations. |
|
157 * @param aMode a meta data read or write mode. |
|
158 */ |
|
159 static CRtpMetaHeader* NewLC( RFile& aFile, |
|
160 const TMetaMode& aMode ); |
|
161 |
|
162 /** |
|
163 * Destructor. |
|
164 */ |
|
165 virtual ~CRtpMetaHeader(); |
|
166 |
|
167 public: // New functions |
|
168 |
|
169 /** |
|
170 * Getter for seek header point. |
|
171 * @since Series 60 3.0 |
|
172 * @return seek header point. |
|
173 */ |
|
174 TInt SeekHeaderPoint(); |
|
175 |
|
176 /** |
|
177 * Writes whole meta header to the clip. |
|
178 * Note, need use only with node: EMetaWrite. |
|
179 * @since Series 60 3.0 |
|
180 * @return None. |
|
181 */ |
|
182 void CommitL(); |
|
183 |
|
184 /** |
|
185 * Writes clip's attributes of meta data header to a file. |
|
186 * @since Series 60 3.0 |
|
187 * @param aAtt a struct of attributes to write. |
|
188 * @return None. |
|
189 */ |
|
190 void WriteAttributesL( const SAttributes& aAtt ); |
|
191 |
|
192 /** |
|
193 * Writes start date/time to meta data header of the clip. |
|
194 * @since Series 60 3.0 |
|
195 * @param aTime a date/time value to write |
|
196 * @return None. |
|
197 */ |
|
198 void WriteStartTimeL( const TTime& aTime ); |
|
199 |
|
200 /** |
|
201 * Writes start date/time to meta data header of the clip. |
|
202 * @since Series 60 3.0 |
|
203 * @param aTime a date/time value to write |
|
204 * @return None. |
|
205 */ |
|
206 void WriteEndTimeL( const TTime& aTime ); |
|
207 |
|
208 /** |
|
209 * Writes duration to meta data header of the clip. |
|
210 * @since Series 60 3.0 |
|
211 * @param aDuration a duration value to write |
|
212 * @return None. |
|
213 */ |
|
214 void WriteDurationL( const TInt aDuration ); |
|
215 |
|
216 /** |
|
217 * Writes seek array point to meta data header of the clip. |
|
218 * @since Series 60 3.0 |
|
219 * @param aPoint a value to write |
|
220 * @return None. |
|
221 */ |
|
222 void WriteSeekArrayPointL( const TInt aPoint ); |
|
223 |
|
224 /** |
|
225 * Writes device info to meta data header of the clip. |
|
226 * @since Series 60 3.0 |
|
227 * @param aId a id to write |
|
228 * @return None. |
|
229 */ |
|
230 void WriteUserIdL( const TDesC& aId ); |
|
231 |
|
232 /** |
|
233 * Writes device info to meta data header of the clip. |
|
234 * @since Series 60 3.0 |
|
235 * @param aInfo a device info to write |
|
236 * @return None. |
|
237 */ |
|
238 void WriteDeviceInfoL( const TDesC& aInfo ); |
|
239 |
|
240 /** |
|
241 * Writes ESG to meta data header of the clip. |
|
242 * @since Series 60 3.0 |
|
243 * @param aService a name of the service |
|
244 * @param aProgram a name of the program |
|
245 * @return None. |
|
246 */ |
|
247 void WriteEsgDataL( const TDesC& aService, |
|
248 const TDesC& aProgram ); |
|
249 |
|
250 /** |
|
251 * Writes SRTP data to meta data header of the clip. |
|
252 * @since Series 60 3.0 |
|
253 * @param aSrtpData a SRTP data to write. |
|
254 * @return None. |
|
255 */ |
|
256 void WriteSrtpDataL( const TDesC8& aSrtpData ); |
|
257 |
|
258 /** |
|
259 * Writes SDP file data to meta data header of the clip. |
|
260 * @since Series 60 3.0 |
|
261 * @param aSdpData a SDP file data. |
|
262 * @return None. |
|
263 */ |
|
264 void WriteSdpDataL( const TDesC8& aSdpData ); |
|
265 |
|
266 /** |
|
267 * Reads clip's attributes of meta data header from a file. |
|
268 * @since Series 60 3.0 |
|
269 * @param aAtt a struct of attributes to read. |
|
270 * @return None. |
|
271 */ |
|
272 void ReadAttributesL( SAttributes& aAtt ); |
|
273 |
|
274 /** |
|
275 * Reads start date/time of meta data header from the clip. |
|
276 * @since Series 60 3.0 |
|
277 * @param aTime a readed date/time value |
|
278 * @return None. |
|
279 */ |
|
280 void ReadStartTimeL( TTime& aTime ); |
|
281 |
|
282 /** |
|
283 * Reads end date/time of meta data header from the clip. |
|
284 * @since Series 60 3.0 |
|
285 * @param aTime a readed date/time value |
|
286 * @return None. |
|
287 */ |
|
288 void ReadEndTimeL( TTime& aTime ); |
|
289 |
|
290 /** |
|
291 * Reads duration in seconds of meta data header from the clip. |
|
292 * @since Series 60 3.0 |
|
293 * @param aDuration a readed duration value |
|
294 * @return None. |
|
295 */ |
|
296 void ReadDurationL( TInt& aDuration ); |
|
297 |
|
298 /** |
|
299 * Reads seek array point of meta data header from the clip. |
|
300 * @since Series 60 3.0 |
|
301 * @param aPoint a readed seek array point value |
|
302 * @return None. |
|
303 */ |
|
304 void ReadSeekArrayPointL( TInt& aPoint ); |
|
305 |
|
306 /** |
|
307 * Reads user id of meta data header from the clip. |
|
308 * @since Series 60 3.0 |
|
309 * @param a buffer for info to read |
|
310 * @return None. |
|
311 */ |
|
312 void ReadUserIdL( TDes& aId ); |
|
313 |
|
314 /** |
|
315 * Reads device info of meta data header from the clip. |
|
316 * @since Series 60 3.0 |
|
317 * @param a buffer for info to read |
|
318 * @return None. |
|
319 */ |
|
320 void ReadDeviceInfoL( TDes& aInfo ); |
|
321 |
|
322 /** |
|
323 * Reads ESG of meta data header from the clip. |
|
324 * @since Series 60 3.0 |
|
325 * @param a buffer for service name to read |
|
326 * @param a buffer for program name to read |
|
327 * @return None. |
|
328 */ |
|
329 void ReadEsgDataL( TDes& aService, TDes& aProgram ); |
|
330 |
|
331 /** |
|
332 * Reads SRTP data of meta data header from the clip. |
|
333 * @since Series 60 3.0 |
|
334 * @return pointer to readed SRTP data. |
|
335 */ |
|
336 HBufC8* ReadSrtpDataL(); |
|
337 |
|
338 /** |
|
339 * Reads SDP file data of meta data header from the clip. |
|
340 * @since Series 60 3.0 |
|
341 * @return pointer to readed SDP file data. |
|
342 */ |
|
343 HBufC8* ReadSdpDataL(); |
|
344 |
|
345 private: // Constructors and destructor |
|
346 |
|
347 /** |
|
348 * C++ default constructor. |
|
349 * @param aFile a reference to file operations |
|
350 * @param aMode a meta data read or write mode |
|
351 */ |
|
352 CRtpMetaHeader( RFile& aFile, |
|
353 const TMetaMode& aMode ); |
|
354 |
|
355 /** |
|
356 * Symbian 2nd phase constructor can leave and is private by default. |
|
357 */ |
|
358 void ConstructL(); |
|
359 |
|
360 private: // New functions |
|
361 |
|
362 /** |
|
363 * Writes any string with one byte len info to meta header. |
|
364 * @since Series 60 3.0 |
|
365 * @param aPosition a position to write |
|
366 * @param aData a data to write |
|
367 * @return None. |
|
368 */ |
|
369 void WriteStringDataL( const TInt aPosition, |
|
370 const TDesC& aData ); |
|
371 |
|
372 /** |
|
373 * Reads any string with one byte len info from meta header. |
|
374 * @since Series 60 3.0 |
|
375 * @param aPosition a position from to read |
|
376 * @param aData a data to read |
|
377 * @return None. |
|
378 */ |
|
379 void ReadStringDataL( const TInt aPosition, |
|
380 TDes& aData ); |
|
381 |
|
382 /** |
|
383 * Writes time info to meta data header of the clip. |
|
384 * @since Series 60 3.0 |
|
385 * @param aPosition a position to append |
|
386 * @param aTime a time value to write |
|
387 * @return None. |
|
388 */ |
|
389 void AddTimeL( const TInt aPosition, |
|
390 const TTime& aTime ); |
|
391 |
|
392 /** |
|
393 * Reads time info of meta data header from the clip. |
|
394 * @since Series 60 3.0 |
|
395 * @param aPosition a position to read |
|
396 * @param aTime a readed time value |
|
397 * @return None. |
|
398 */ |
|
399 void GetTimeL( const TInt aPosition, |
|
400 TTime& aTime ); |
|
401 |
|
402 /** |
|
403 * Adds intehger data to meta buffer. |
|
404 * @since Series 60 3.0 |
|
405 * @param aPosition a position to add |
|
406 * @param aValue a integer value to add |
|
407 * @return None. |
|
408 */ |
|
409 void AddIntegerL( const TInt aPosition, |
|
410 const TInt aValue ); |
|
411 |
|
412 /** |
|
413 * Adds new data to meta buffer. |
|
414 * @since Series 60 3.0 |
|
415 * @param aPosition a position to add |
|
416 * @param aData a data to append |
|
417 * @return None. |
|
418 */ |
|
419 void AddDataL( const TInt aPosition, |
|
420 const TDesC8& aData ); |
|
421 |
|
422 /** |
|
423 * Reads 32 bits (TInt) from a file from certain position. |
|
424 * @since Series 60 3.0 |
|
425 * @param aPosition a position from to read |
|
426 * @param aValue a value to update |
|
427 * @return None. |
|
428 */ |
|
429 void ReadTintFromFileL( const TInt& aPosition, |
|
430 TInt& aValue ); |
|
431 |
|
432 private: // Data |
|
433 |
|
434 /** |
|
435 * File operations. |
|
436 */ |
|
437 RFile& iFile; |
|
438 |
|
439 /** |
|
440 * Mode. |
|
441 */ |
|
442 TMetaMode iMode; |
|
443 |
|
444 /** |
|
445 * File data buffer. |
|
446 */ |
|
447 HBufC8* iMetaData; |
|
448 |
|
449 /** |
|
450 * File data buffer pointer. |
|
451 */ |
|
452 TPtr8 iDataPtr; |
|
453 |
|
454 /** |
|
455 * ESG data point. |
|
456 */ |
|
457 TInt iEsgDataPoint; |
|
458 |
|
459 /** |
|
460 * SRTP data point. |
|
461 */ |
|
462 TInt iSrtpDataPoint; |
|
463 |
|
464 /** |
|
465 * SDP file data point. |
|
466 */ |
|
467 TInt iSdpDataPoint; |
|
468 |
|
469 /** |
|
470 * Meta total length. |
|
471 */ |
|
472 TInt iMetaTotal; |
|
473 |
|
474 }; |
|
475 |
|
476 #endif // CRTPMETAHEADER_H |
|
477 |
|
478 // End of File |
|