vtengines/videoteleng/Src/State/CVtEngDtmfBuffered.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Buffered state of DTMF sending.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CVtEngDtmfState.h"
       
    22 #include    "VtEngPanic.h"
       
    23 #include    <cvtlogger.h>
       
    24 
       
    25 // CONSTANTS
       
    26 const TInt KVtEngDtmfToneBufferSize = 2;
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CVtEngDtmfBuffered::NewL
       
    32 // 
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CVtEngDtmfState* CVtEngDtmfBuffered::NewL( 
       
    36     MVtEngDtmfHandler& aDtmfHandler,
       
    37     MVtH324ConfigCommand& aH324Config )
       
    38     {
       
    39     CVtEngDtmfBuffered* self = new ( ELeave ) 
       
    40         CVtEngDtmfBuffered( aDtmfHandler, aH324Config );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop(); // self
       
    44     return self;
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CVtEngDtmfBuffered::~CVtEngDtmfBuffered
       
    49 // 
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CVtEngDtmfBuffered::~CVtEngDtmfBuffered()
       
    53     {
       
    54     delete iTones;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CVtEngDtmfBuffered::SendDtmfL
       
    59 // 
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CVtEngDtmfBuffered::SendDtmfL( const TVtEngDtmfTone& aTone )
       
    63     {
       
    64     // just add to buffer and wait for completion of pending send operation.
       
    65     iTones->AppendL( aTone );
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CVtEngDtmfBuffered::DtmfSendCompleteL
       
    70 // 
       
    71 // PSEUDO CODE:
       
    72 // deallocate Protocol dtmf instance
       
    73 // if ( previous_sending_OK )
       
    74 //     if ( tones_in_buffer > 1 )
       
    75 //         next_state = buffered
       
    76 //     else
       
    77 //         next_state = sending
       
    78 //     endif
       
    79 //     send tone from buffer and change state
       
    80 // endif
       
    81 // if ( previous_sending_FAIL or new_sending_FAIL )
       
    82 //     reset buffer 
       
    83 //     next_state = idle
       
    84 // endif
       
    85 //
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CVtEngDtmfBuffered::DtmfSendCompleteL( TInt aError )
       
    89     {
       
    90     __VTPRINTENTER( "DtmfStateBuffered.DtmfSendCompleteL" )
       
    91     CVtEngDtmfState::DtmfSendCompleteL( aError );
       
    92     const TInt count( iTones->Count() );
       
    93     __VTPRINT2( DEBUG_MEDIA , "DtmfStateBuffered.Send bufSize=%d", count )
       
    94 
       
    95     TInt index( KErrNone );
       
    96     if ( count && aError == KErrNone )
       
    97         {
       
    98         __VTPRINT2( DEBUG_MEDIA , "DtmfStateBuffered cnt=%d", count )
       
    99         const TVtEngDtmfTone& tone = iTones->At( index );
       
   100         MVtEngDtmfHandler::TVtEngDtmfState nextState = ( count > 1 ) ?
       
   101             MVtEngDtmfHandler::EVtDtmfStateBuffered :
       
   102             MVtEngDtmfHandler::EVtDtmfStateSending;
       
   103         TRAP( aError, DoSendAndActivateStateL( tone, nextState ) );
       
   104         iTones->Delete( index );
       
   105         }
       
   106     
       
   107     if ( aError != KErrNone )
       
   108         {
       
   109         __VTPRINT2( DEBUG_MEDIA , "DtmfStateBuffered.failed=%d", aError )
       
   110         // if failed clear DTMF buffer and go to dtmf idle state
       
   111         iTones->Reset();
       
   112         iDtmfHandler.ActivateState( MVtEngDtmfHandler::EVtDtmfStateIdle );
       
   113         }
       
   114     __VTPRINTEXIT( "DtmfStateBuffered.DtmfSendCompleteL" )
       
   115     }
       
   116 
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CVtEngDtmfBuffered::CVtEngDtmfBuffered
       
   120 // 
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CVtEngDtmfBuffered::CVtEngDtmfBuffered( 
       
   124     MVtEngDtmfHandler& aDtmfHandler,
       
   125     MVtH324ConfigCommand& aH324Config ) 
       
   126     : CVtEngDtmfState( aDtmfHandler, aH324Config)
       
   127     {
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CVtEngDtmfBuffered::ConstructL
       
   132 // 
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CVtEngDtmfBuffered::ConstructL()
       
   136     {
       
   137     iTones = new ( ELeave ) 
       
   138         CArrayFixFlat<TVtEngDtmfTone>( KVtEngDtmfToneBufferSize );
       
   139     }
       
   140 
       
   141 //  End of File