videoutils_plat/dvrengine_api/inc/ipvideo/CRtpFileBase.h
branchRCL_3
changeset 47 826cea16efd9
parent 45 798ee5f1972c
child 48 13a33d82ad98
equal deleted inserted replaced
45:798ee5f1972c 47:826cea16efd9
     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:    Base methods/variables for RTP file format recording.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CRTPFILEBASE_H
       
    21 #define CRTPFILEBASE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <ipvideo/CRtpUtil.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KCurrentClipVersion( 3 );
       
    29 const TInt KMinValidClipVersion( 2 );
       
    30 const TInt KSeekHeaderBytes( 3 * KIntegerBytes );
       
    31 const TInt KGroupHeaderBytes( 4 * KIntegerBytes );
       
    32 const TInt KPacketsCountBytes( 4 );
       
    33 const TInt KNormalRecGroupLength( 2000 ); // 2 s
       
    34 const TUint KSeekArrayInterval( 30000 );  // 30 s
       
    35 
       
    36 // MACROS
       
    37 // None
       
    38 
       
    39 // DATA TYPES
       
    40 // None
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 // None
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48 *  RTP format common functionalities.
       
    49 *
       
    50 *  @lib RtpClipHandler.lib
       
    51 *  @since Series 60 3.0
       
    52 */
       
    53 class CRtpFileBase : public CActive
       
    54     {
       
    55 
       
    56 public: // Data types
       
    57 
       
    58     // Time shift seek array
       
    59     class STimeShiftSeek 
       
    60         {
       
    61 
       
    62     public: // Data
       
    63 
       
    64         /**
       
    65         * Group time.
       
    66         */
       
    67         TUint iGroupTime;
       
    68         
       
    69         /**
       
    70         * File seek point.
       
    71         */
       
    72         TInt iSeekpoint;
       
    73 
       
    74         /**
       
    75         * File name index.
       
    76         */
       
    77         TInt iNameIndex;
       
    78         
       
    79         };
       
    80 
       
    81 
       
    82 public: // Constructors and destructor
       
    83     
       
    84     /**
       
    85     * Destructor.
       
    86     */
       
    87     virtual ~CRtpFileBase();
       
    88 
       
    89 protected: // Constructors and destructor
       
    90 
       
    91     /**
       
    92     * C++ default constructor.
       
    93     */
       
    94     CRtpFileBase();
       
    95 
       
    96     /**
       
    97     * Symbian 2nd phase constructor can leave and is private by default.
       
    98     */
       
    99     void ConstructL();
       
   100     
       
   101 protected: // Enumeration
       
   102 
       
   103     // Defines RTP file mode
       
   104     enum TRtpFileMode
       
   105         {
       
   106         EModeNone = KErrBadHandle,
       
   107         EModeNormal = KErrNone,
       
   108         EModeHandle,
       
   109         EModeTimeShift
       
   110         };
       
   111 
       
   112 public: // New functions
       
   113 
       
   114     /**
       
   115     * Deletes time shift files.
       
   116     * @since Series 60 3.0
       
   117     * @param aShiftSeek a reference to time shift seek array.
       
   118     * @return None.
       
   119     */
       
   120     void DeleteTimeShiftFiles( RArray<STimeShiftSeek>& aShiftSeek );
       
   121 
       
   122 protected: // New functions
       
   123 
       
   124     /**
       
   125     * Writes RTP seek header to a file.
       
   126     * @since Series 60 3.0
       
   127     * @return None.
       
   128     */
       
   129     void WriteSeekHeaderL();
       
   130 
       
   131     /**
       
   132     * Reads clip's seek header from a file.
       
   133     * @since Series 60 3.0
       
   134     * @return None.
       
   135     */
       
   136     void ReadSeekHeaderL();
       
   137 
       
   138     /**
       
   139     * Reads clip's group header from a file.
       
   140     * @since Series 60 3.0
       
   141     * @return None.
       
   142     */
       
   143     void ReadGroupHeaderL();
       
   144 
       
   145     /**
       
   146     * Updates group header variables from readed data.
       
   147     * @since Series 60 3.0
       
   148     * @param aDataPtr data from which header is updated.
       
   149     * @return None.
       
   150     */
       
   151     void UpdateGroupHeaderVariablesL( const TDesC8& aDataPtr );
       
   152 
       
   153     /**
       
   154     * Appends one group to the seek array.
       
   155     * @since Series 60 3.0
       
   156     * @param aTime a TS time of first packet in group.
       
   157     * @param aPoint a seek point in clip for group.
       
   158     * @return None.
       
   159     */
       
   160     void AppendSeekArrayL( const TUint aTime,
       
   161                            const TInt aPoint );
       
   162 
       
   163     /**
       
   164     * Saves seek array to the clip.
       
   165     * @since Series 60 3.0
       
   166     * @return None.
       
   167     */
       
   168     void SaveSeekArrayL();
       
   169 
       
   170     /**
       
   171     * Reads seek array from the clip.
       
   172     * @since Series 60 3.0
       
   173     * @param aPoint a seek array point in clip.
       
   174     * @return true if items in seek array, otherwise false.
       
   175     */
       
   176     TBool ReadSeekArrayL( const TInt aPoint );
       
   177 
       
   178     /**
       
   179     * Resets seek array.
       
   180     * @since Series 60 3.0
       
   181     * @return None.
       
   182     */
       
   183     inline void ResetSeekArray();
       
   184 
       
   185     /**
       
   186     * Writes variables to log file.
       
   187     * @since Series 60 3.0
       
   188     * @param aMethod a method which called this
       
   189     */
       
   190     void LogVariables( const TDesC& aMethod );
       
   191 
       
   192 private: // Functions from base classes
       
   193 
       
   194     /**
       
   195     * From CActive : Called when request completion event occurs.
       
   196     * @since Series 60 3.0
       
   197     * @return None.
       
   198     */
       
   199     virtual void RunL() = 0;
       
   200 
       
   201     /**
       
   202     * From CActive : Handles a leave occurring in the request
       
   203     *                completion event handler RunL().
       
   204     * @since Series 60 3.0
       
   205     * @param aError the leave code
       
   206     * @return status of run error handling
       
   207     */
       
   208     virtual TInt RunError( TInt aError ) = 0;
       
   209 
       
   210     /**
       
   211     * From CActive : Called when request completion event cancelled.
       
   212     * @since Series 60 3.0
       
   213     * @return None.
       
   214     */
       
   215     virtual void DoCancel() = 0;
       
   216 
       
   217 protected: // Data types
       
   218     
       
   219     // Defines seek struct
       
   220     class SSeek
       
   221         {
       
   222 
       
   223     public: // Data
       
   224 
       
   225         /**
       
   226         * Enlapsed time.
       
   227         */
       
   228         TUint iTime;
       
   229 
       
   230         /**
       
   231         * Point in clip.
       
   232         */
       
   233         TInt iPoint;
       
   234         
       
   235         };
       
   236 
       
   237 protected: // Data
       
   238     
       
   239     /**
       
   240     * Rtp file usage mode.
       
   241     */
       
   242     TRtpFileMode iMode;
       
   243     
       
   244     /**
       
   245     * Current group.
       
   246     */
       
   247     TInt iThisGroup;
       
   248     
       
   249     /**
       
   250     * Packet group counter (Seek header).
       
   251     */
       
   252     TInt iGroupsTotalCount;
       
   253     
       
   254     /**
       
   255     * First seek address (Seek header).
       
   256     */
       
   257     TInt iFirstSeekAddr;
       
   258     
       
   259     /**
       
   260     * Last seek address (Seek header).
       
   261     */
       
   262     TInt iLastSeekAddr;
       
   263     
       
   264     /**
       
   265     * Group total length (Group header).
       
   266     */
       
   267     TInt iGroupTotalLen;
       
   268     
       
   269     /**
       
   270     * Next group point (Group header).
       
   271     */
       
   272     TInt iNextGroupPoint;
       
   273     
       
   274     /**
       
   275     * Previous group point (Group header).
       
   276     */
       
   277     TInt iPrevGroupPoint;
       
   278     
       
   279     /**
       
   280     * Group time (Group header).
       
   281     */
       
   282     TUint iGroupTime;
       
   283     
       
   284     /**
       
   285     * Seek header point.
       
   286     */
       
   287     TInt iSeekHeaderPoint;
       
   288 
       
   289     /**
       
   290     * Current clip path.
       
   291     */
       
   292     HBufC* iCurrentPath;
       
   293     
       
   294     /**
       
   295     * Seek array.
       
   296     */
       
   297     CArrayFix<SSeek>* iSeekArray;
       
   298 
       
   299     /**
       
   300     * File data buffer pointer.
       
   301     */
       
   302     TPtr8 iDataPtr;
       
   303     
       
   304     /**
       
   305     * File server.
       
   306     */
       
   307     RFs iFs;
       
   308     
       
   309     /*
       
   310     * File operations.
       
   311     */
       
   312     RFile iFile;
       
   313     
       
   314   };
       
   315 
       
   316 #include <ipvideo/CRtpFileBase.inl>
       
   317 
       
   318 #endif // CRTPFILEBASE_H
       
   319 
       
   320 // End of File