mobilemessaging/msgmedia/src/MsgAudioInfo.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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 *           Messaging Audio info class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // ========== INCLUDE FILES ================================
       
    22 
       
    23 #include <e32std.h>
       
    24 
       
    25 #include <mdaaudiosampleplayer.h> // MMdaAudioPlayerCallback & CMdaAudioPlayerUtility
       
    26 
       
    27 #include "MsgAudioInfo.h"
       
    28 #include "MsgMediaInfo.h"
       
    29 #include "MsgMedia.hrh"
       
    30 
       
    31 
       
    32 // ========== EXTERNAL DATA STRUCTURES =====================
       
    33 
       
    34 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    35 
       
    36 // ========== CONSTANTS ====================================
       
    37 
       
    38 // ========== MACROS =======================================
       
    39 
       
    40 // ========== LOCAL CONSTANTS AND MACROS ===================
       
    41 
       
    42 // ========== MODULE DATA STRUCTURES =======================
       
    43 
       
    44 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
    45 
       
    46 // ========== LOCAL FUNCTIONS ==============================
       
    47 
       
    48 // ========== MEMBER FUNCTIONS =============================
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CMsgAudioInfo::NewL
       
    52 //
       
    53 // Factory method.
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CMsgAudioInfo* CMsgAudioInfo::NewL( RFile& aFile, 
       
    57                                    TDataType& aMimeType )
       
    58     {
       
    59     CMsgAudioInfo* self = new ( ELeave ) CMsgAudioInfo( aMimeType );
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL( aFile );
       
    62     CleanupStack::Pop( self );
       
    63     return self;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CMsgAudioInfo::CMsgAudioInfo
       
    68 //
       
    69 // Constructor.
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 CMsgAudioInfo::CMsgAudioInfo( TDataType& aMimeType ) :
       
    73     CMsgMediaInfo( aMimeType, EMsgMediaAudio )
       
    74     {
       
    75     }
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CMsgAudioInfo::CMsgAudioInfo
       
    80 //
       
    81 // Destructor.
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 CMsgAudioInfo::~CMsgAudioInfo()
       
    85     {
       
    86     delete iAudioUtil;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CMsgAudioInfo::ConstructL
       
    91 //
       
    92 // 2nd phase constructor.
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 void CMsgAudioInfo::ConstructL( RFile& aFile )
       
    96     {
       
    97     CMsgMediaInfo::ConstructL( aFile );
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CMsgAudioInfo::ResolveAudioInfoL
       
   102 //
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void CMsgAudioInfo::ResolveAudioInfoL( RFile& aFile )
       
   106     {
       
   107     if ( !iAudioUtil )
       
   108         {
       
   109         iAudioUtil = CMdaAudioPlayerUtility::NewL( *this );
       
   110         }
       
   111     iAudioUtil->OpenFileL( aFile );
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // Callbacks from CMdaAudioPlayerUtility
       
   116 //
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CMsgAudioInfo::MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration )
       
   120     {
       
   121     if ( !aError )
       
   122         {
       
   123         iDuration = I64INT( aDuration.Int64() / 1000 );
       
   124         iState = EAudioStateReady;
       
   125         iParsed = ETrue;
       
   126         }
       
   127     CompleteSelf( aError );
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CMsgAudioInfo::DoCancel
       
   132 // 
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CMsgAudioInfo::DoCancel()
       
   136     {
       
   137     CMsgMediaInfo::DoCancel();
       
   138     delete iAudioUtil;
       
   139     iAudioUtil = NULL;
       
   140     iState = EAudioStateIdle;
       
   141     }
       
   142         
       
   143 // -----------------------------------------------------------------------------
       
   144 // CMsgAudioInfo::RunL
       
   145 // 
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void CMsgAudioInfo::RunL()
       
   149     {
       
   150     iParseError = iStatus.Int();
       
   151     if ( iParseError )
       
   152         {
       
   153         iState = EAudioStateReady;
       
   154         }
       
   155     switch ( iState )
       
   156         {
       
   157         case EAudioStateIdle:
       
   158             {
       
   159             FreezeRights();
       
   160             ResolveAudioInfoL( iFile );
       
   161             break;
       
   162             }
       
   163         case EAudioStateReady:
       
   164         default:
       
   165             {
       
   166             delete iAudioUtil;
       
   167             iAudioUtil = NULL;
       
   168             CompleteObserver();
       
   169             iState = EAudioStateIdle;
       
   170             break;
       
   171             }
       
   172         }
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // Callbacks from CMdaAudioPlayerUtility
       
   177 //
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 void CMsgAudioInfo::MapcPlayComplete( TInt /*aError*/ )
       
   181     {
       
   182     // Empty
       
   183     }