mmmw_plat/voip_audio_services_api/tsrc/VoIPAudioServicesTestClass/src/VoIPAudioServicesTestClassBlocksCallbacks.cpp
changeset 55 e267340986c9
parent 0 71ca22bcf22a
equal deleted inserted replaced
52:4ce423f34688 55:e267340986c9
     1 /*
     1 /*
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: voip audio service -
    14  * Description: voip audio service -
    15 *
    15  *
    16 */
    16  */
    17 
       
    18 
       
    19 
    17 
    20 // INCLUDE FILES
    18 // INCLUDE FILES
    21 #include "VoIPAudioServicesTestClass.h"
    19 #include "VoIPAudioServicesTestClass.h"
    22 #include "debug.h"
    20 #include "debug.h"
    23 
    21 
    24 
    22 const TUint KLoopCount = 200;
    25 
       
    26 
       
    27 
       
    28 /************************************************************************************************************/
       
    29 
    23 
    30 // ----------------------------------------------------------------------------
    24 // ----------------------------------------------------------------------------
    31 // CVoIPAudioServicesTestClass::FillBuffer
    25 // CVoIPAudioServicesTestClass::FillBuffer
    32 //
    26 //
    33 // Callback from MVoIPDownlinkObserver
    27 // Callback from MVoIPDownlinkObserver
    34 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    35 //
    29 //
    36 void CVoIPAudioServicesTestClass::FillBuffer(const CVoIPAudioDownlinkStream& /*aSrc*/,
    30 void CVoIPAudioServicesTestClass::FillBuffer(
    37                                   CVoIPDataBuffer* aBuffer)
    31         const CVoIPAudioDownlinkStream& /*aSrc*/, CVoIPDataBuffer* aBuffer)
    38 {
    32     {
    39 
       
    40     iLog->Log(_L("CVoIPAudioServicesTestClass::FillBuffer"));
    33     iLog->Log(_L("CVoIPAudioServicesTestClass::FillBuffer"));
    41     ProcessEvent(EFillBuffer, KErrNone);
    34 
    42 
    35     if (!iJBIntfc)
    43     // In JB mode we will only receive FillBuffer callback once after
    36         {
    44     // ConfigureJB. We will simply reuse same buffer to send data to VAS.
    37         if (iPlayCounter++ < KLoopCount)
    45     aBuffer->GetPayloadPtr(iPlayBufPtr);
    38             {
    46     iPlayBufReady = ETrue; // always ready in JB mode
    39             aBuffer->GetPayloadPtr(iPlayBufPtr);
    47 
    40             iPlayBufReady = ETrue; // always ready in JB mode
    48 #ifndef __JITTER_BUFFER_TEST__
    41 
    49     // In JB mode, DoLoopback is only called when from EmptyBuffer
    42             if (iDnLinkStatus == EStreaming)
    50     if (iDnLinkStatus == EStreaming)
    43                 {
    51         {
    44                 if (iDnLinkCodec == EG729 && ((iPlayCounter == KLoopCount / 2)
    52         DoLoopback();
    45                         || (iPlayCounter == KLoopCount / 5)))
    53         }
    46                     {
    54 #endif  //__JITTER_BUFFER_TEST__
    47                     BadLsfNextBuffer();
    55 }
    48                     }
       
    49                 DoLoopback();
       
    50                 }
       
    51             }
       
    52         }
       
    53     else //JB case
       
    54         {
       
    55         // In JB mode we will only receive FillBuffer callback once after
       
    56         // ConfigureJB. We will simply reuse same buffer to send data to VAS.
       
    57         // The loopback play is controlled by the recorder side.
       
    58         aBuffer->GetPayloadPtr(iPlayBufPtr);
       
    59         iPlayBufReady = ETrue; // always ready in JB mode
       
    60         }
       
    61     }
    56 
    62 
    57 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    58 // CVoIPAudioServicesTestClass::Event
    64 // CVoIPAudioServicesTestClass::Event
    59 //
    65 //
    60 // Callback from MVoIPDownlinkObserver
    66 // Callback from MVoIPDownlinkObserver
    61 // ----------------------------------------------------------------------------
    67 // ----------------------------------------------------------------------------
    62 //
    68 //
    63 void CVoIPAudioServicesTestClass::Event(const CVoIPAudioDownlinkStream& /*aSrc*/,
    69 void CVoIPAudioServicesTestClass::Event(
    64                             TInt aEventType,
    70         const CVoIPAudioDownlinkStream& /*aSrc*/, TInt aEventType,
    65                             TInt aError)
    71         TInt aError)
    66 {
    72     {
    67     switch (aEventType)
    73     switch (aEventType)
    68         {
    74         {
    69         case MVoIPDownlinkObserver::KOpenComplete:
    75         case MVoIPDownlinkObserver::KOpenComplete:
    70             {
    76             {
    71             if (aError == KErrNone)
    77             if (aError == KErrNone)
    72                 {
    78                 {
    73                 // Now we can configure decoder and audio device
    79                 // Now we can configure decoder and audio device
    74                 iVoIPDnlink->GetMaxVolume(iMaxVolume);
    80                 iVoIPDnlink->GetMaxVolume(iMaxVolume);
    75                 iVoIPDnlink->SetVolume(iMaxVolume / 2);
    81                 iVoIPDnlink->SetVolume(iMaxVolume / 2);
    76                 //  ConfigureDecoder();
    82                 //  ConfigureDecoder();
    77 
       
    78 #ifdef __JITTER_BUFFER_TEST__
       
    79                 if (iDnLinkCodec != EPCM16)
       
    80                     {
       
    81                     ConfigureJB(); // will trigger FillBuffer callback
       
    82                     }
       
    83 #endif //__JITTER_BUFFER_TEST__
       
    84 
       
    85                 iDnLinkStatus = EReady;
    83                 iDnLinkStatus = EReady;
    86                 iLog->Log(_L("MVoIPDownlinkObserver::KOpenComplete: aError = %d"), aError);
    84                 iLog->Log(_L("MVoIPDownlinkObserver::KOpenComplete: aError = %d"),
       
    85                         aError);
    87                 ProcessEvent(EOpenDownlinkComplete, aError);
    86                 ProcessEvent(EOpenDownlinkComplete, aError);
    88                 }
    87                 }
    89 
       
    90             iLog->Log(_L("DNL Initialized: aError = %d"), aError);
    88             iLog->Log(_L("DNL Initialized: aError = %d"), aError);
    91             break;
    89             break;
    92             }
    90             }
    93         case MVoIPDownlinkObserver::KDownlinkClosed:
    91         case MVoIPDownlinkObserver::KDownlinkClosed:
    94             {
    92             {
    95             iDnLinkStatus = ENotReady;
    93             iDnLinkStatus = ENotReady;
    96             iLog->Log(_L("MVoIPDownlinkObserver::KDownlinkClosed: aError = %d"), aError);
    94             iLog->Log(_L("MVoIPDownlinkObserver::KDownlinkClosed: aError = %d"),
       
    95                     aError);
    97             ProcessEvent(EDownlinkClosed, aError);
    96             ProcessEvent(EDownlinkClosed, aError);
    98             break;
    97             break;
    99             }
    98             }
   100         case MVoIPDownlinkObserver::KDownlinkError:
    99         case MVoIPDownlinkObserver::KDownlinkError:
   101             {
   100             {
   102             iDnLinkStatus = EReady;
   101             iDnLinkStatus = EReady;
   103             iLog->Log(_L("DNL Error: aError = %d"), aError);
   102             iLog->Log(_L("DNL Error: aError = %d"), aError);
   104             break;
   103             ProcessEvent(EDownlinkError, aError);
   105             }
   104             break;
   106 /*        case KVoIPOpenDTMFComplete:
   105             }
   107             {
   106         default:
   108             DisplayText(_L("DTMF (DNL) Open"), aError);
   107             break;
   109             break;
   108         }
   110             }*/
   109     }
   111 /*
       
   112         case KVoIP_TEMP1:
       
   113             {
       
   114             DisplayText(_L("DTMF PLR Ready"), aError);
       
   115             break;
       
   116             }
       
   117         case KVoIP_TEMP2:
       
   118             {
       
   119             DisplayText(_L("DTMF PLR Ready"), aError);
       
   120             break;
       
   121             }
       
   122 */
       
   123         default:
       
   124             break;
       
   125         }
       
   126 }
       
   127 
   110 
   128 // ----------------------------------------------------------------------------
   111 // ----------------------------------------------------------------------------
   129 // CVoIPAudioServicesTestClass::EmptyBuffer
   112 // CVoIPAudioServicesTestClass::EmptyBuffer
   130 //
   113 //
   131 // Callback from MVoIPUplinkObserver
   114 // Callback from MVoIPUplinkObserver
   132 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   133 //
   116 //
   134 void CVoIPAudioServicesTestClass::EmptyBuffer(const CVoIPAudioUplinkStream& /*aSrc*/,
   117 void CVoIPAudioServicesTestClass::EmptyBuffer(
   135                                   CVoIPDataBuffer* aBuffer)
   118         const CVoIPAudioUplinkStream& /*aSrc*/, CVoIPDataBuffer* aBuffer)
   136 {
   119     {
   137     iLog->Log(_L("CVoIPAudioServicesTestClass::EmptyBuffer"));
   120     iLog->Log(_L("CVoIPAudioServicesTestClass::EmptyBuffer"));
   138     ProcessEvent(EEmptyBuffer, KErrNone);
   121 
   139 
   122     if (iRecCounter++ < KLoopCount)
   140     aBuffer->GetPayloadPtr(iRecBufPtr);
   123         {
   141     iRecBufReady = ETrue;
   124         aBuffer->GetPayloadPtr(iRecBufPtr);
   142 
   125         iRecBufReady = ETrue;
   143     if (iUpLinkStatus == EStreaming)
   126 
   144         {
   127         if (iUpLinkStatus == EStreaming)
   145         DoLoopback();
   128             {
   146       //  iVoIPUplink->BufferEmptied(aBuffer);
   129             if (iJBIntfc)
   147       //  iUpLinkStatus = EReady;
   130                 {
   148         }
   131                 DoJBLoopback();
   149 }
   132                 }
       
   133             else
       
   134                 {
       
   135                 DoLoopback();
       
   136                 }
       
   137             }
       
   138         }
       
   139     }
   150 
   140 
   151 // ----------------------------------------------------------------------------
   141 // ----------------------------------------------------------------------------
   152 // CVoIPAudioServicesTestClass::Event
   142 // CVoIPAudioServicesTestClass::Event
   153 //
   143 //
   154 // Callback from MVoIPUplinkObserver
   144 // Callback from MVoIPUplinkObserver
   155 // ----------------------------------------------------------------------------
   145 // ----------------------------------------------------------------------------
   156 //
   146 //
   157 void CVoIPAudioServicesTestClass::Event(const CVoIPAudioUplinkStream& /*aSrc*/,
   147 void CVoIPAudioServicesTestClass::Event(
   158                             TInt aEventType,
   148         const CVoIPAudioUplinkStream& /*aSrc*/, TInt aEventType, TInt aError)
   159                             TInt aError)
   149     {
   160 {
       
   161     switch (aEventType)
   150     switch (aEventType)
   162         {
   151         {
   163         case MVoIPUplinkObserver::KOpenComplete:
   152         case MVoIPUplinkObserver::KOpenComplete:
   164             {
   153             {
   165             if (aError == KErrNone)
   154             if (aError == KErrNone)
   166                 {
   155                 {
   167                 // Now we can configure encoder and audio device
   156                 // Now we can configure encoder and audio device
   168                 iVoIPUplink->GetMaxGain(iMaxGain);
   157                 iVoIPUplink->GetMaxGain(iMaxGain);
   169                 iVoIPUplink->SetGain(iMaxGain);
   158                 iVoIPUplink->SetGain(iMaxGain);
   170 
       
   171                 iUpLinkStatus = EReady;
   159                 iUpLinkStatus = EReady;
   172                 iLog->Log(_L("MVoIPUplinkObserver::KOpenComplete: aError = %d"), aError);
   160                 iLog->Log(_L("MVoIPUplinkObserver::KOpenComplete: aError = %d"),
       
   161                         aError);
   173                 ProcessEvent(EOpenUplinkComplete, aError);
   162                 ProcessEvent(EOpenUplinkComplete, aError);
   174                 }
   163                 }
   175 
       
   176             iLog->Log(_L("UPL Initialized: aError = %d"), aError);
   164             iLog->Log(_L("UPL Initialized: aError = %d"), aError);
   177             break;
   165             break;
   178             }
   166             }
   179         case MVoIPUplinkObserver::KUplinkClosed:
   167         case MVoIPUplinkObserver::KUplinkClosed:
   180             {
   168             {
   181             iUpLinkStatus = ENotReady;
   169             iUpLinkStatus = ENotReady;
   182             iLog->Log(_L("MVoIPUplinkObserver::KUplinkClosed: aError = %d"), aError);
   170             iLog->Log(_L("MVoIPUplinkObserver::KUplinkClosed: aError = %d"),
       
   171                     aError);
   183             ProcessEvent(EUplinkClosed, aError);
   172             ProcessEvent(EUplinkClosed, aError);
   184             break;
   173             break;
   185             }
   174             }
   186         case MVoIPUplinkObserver::KUplinkError:
   175         case MVoIPUplinkObserver::KUplinkError:
   187             {
   176             {
   188             iUpLinkStatus = EReady;
   177             iUpLinkStatus = EReady;
   189             iLog->Log(_L("UPL Error: aError = %d"), aError);
   178             iLog->Log(_L("UPL Error: aError = %d"), aError);
   190             break;
   179             ProcessEvent(EUplinkError, aError);
   191             }
   180             break;
   192 
   181             }
   193 // TODO: Move to MDTMFToneObserver::Event handler
   182         default:
   194 /*        case KVoIP_TEMP1:
   183             break;
   195             {
   184         }
   196             DisplayText(_L("DTMF PLR Ready"), aError);
   185     }
   197             break;
       
   198             }
       
   199         case KVoIP_TEMP2:
       
   200             {
       
   201             DisplayText(_L("DTMF PLR Ready"), aError);
       
   202             break;
       
   203             }
       
   204 */
       
   205         default:
       
   206             break;
       
   207         }
       
   208 }
       
   209 
   186 
   210 // ----------------------------------------------------------------------------
   187 // ----------------------------------------------------------------------------
   211 // CVoIPAudioServicesTestClass::Event
   188 // CVoIPAudioServicesTestClass::Event
   212 //
   189 //
   213 // Callback from MVoIPFormatObserver
   190 // Callback from MVoIPFormatObserver
   214 // ----------------------------------------------------------------------------
   191 // ----------------------------------------------------------------------------
   215 //
   192 //
   216 void CVoIPAudioServicesTestClass::Event(const CVoIPFormatIntfc& /*aSrc*/, TInt aEventType)
   193 void CVoIPAudioServicesTestClass::Event(const CVoIPFormatIntfc& /*aSrc*/,
   217 {
   194         TInt aEventType)
       
   195     {
   218     switch (aEventType)
   196     switch (aEventType)
   219         {
   197         {
   220         case MVoIPFormatObserver::KSilenceBegin:
   198         case MVoIPFormatObserver::KSilenceBegin:
   221         case MVoIPFormatObserver::KSilenceUpdate:
   199         case MVoIPFormatObserver::KSilenceUpdate:
   222         case MVoIPFormatObserver::KSilenceEnd:
   200         case MVoIPFormatObserver::KSilenceEnd:
   223         case MVoIPFormatObserver::KObserverEventMax:
   201         case MVoIPFormatObserver::KObserverEventMax:
   224         default:
   202         default:
   225             break;
   203             break;
   226         }
   204         }
   227 }
   205     }
   228 
   206 
   229 // ----------------------------------------------------------------------------
   207 // ----------------------------------------------------------------------------
   230 // CVoIPAudioServicesTestClass::Event
   208 // CVoIPAudioServicesTestClass::Event
   231 //
   209 //
   232 // Callback from MDTMFToneObserver
   210 // Callback from MDTMFToneObserver
   233 // ----------------------------------------------------------------------------
   211 // ----------------------------------------------------------------------------
   234 //
   212 //
   235 void CVoIPAudioServicesTestClass::Event(const CDTMFTonePlayer& /*aSrc*/,
   213 void CVoIPAudioServicesTestClass::Event(const CDTMFTonePlayer& /*aSrc*/,
   236                             TInt aEventType,
   214         TInt aEventType, TInt aError)
   237                             TInt aError)
   215     {
   238 {
       
   239     switch (aEventType)
   216     switch (aEventType)
   240         {
   217         {
   241         case MDTMFToneObserver::KOpenCompleteDNL:
   218         case MDTMFToneObserver::KOpenCompleteDNL:
   242             iLog->Log(_L("MDTMFToneObserver:KOpenCompleteDNL:DTMF DNL-PLR Ready: aError = %d"), aError);
   219             iLog->Log(
       
   220                     _L("MDTMFToneObserver:KOpenCompleteDNL:DTMF DNL-PLR Ready: aError = %d"),
       
   221                     aError);
   243             ProcessEvent(EOpenCompleteDNL, aError);
   222             ProcessEvent(EOpenCompleteDNL, aError);
   244             break;
   223             break;
   245         case MDTMFToneObserver::KOpenCompleteUPL:
   224         case MDTMFToneObserver::KOpenCompleteUPL:
   246             iLog->Log(_L("MDTMFToneObserver:KOpenCompleteUPL:DTMF UPL-PLR Ready: aError = %d"), aError);
   225             iLog->Log(
       
   226                     _L("MDTMFToneObserver:KOpenCompleteUPL:DTMF UPL-PLR Ready: aError = %d"),
       
   227                     aError);
   247             ProcessEvent(EOpenCompleteUPL, aError);
   228             ProcessEvent(EOpenCompleteUPL, aError);
   248             break;
   229             break;
   249         default:
   230         default:
   250             break;
   231             break;
   251         }
   232         }
   252 }
   233     }
   253 
   234 
   254 // ----------------------------------------------------------------------------
   235 // ----------------------------------------------------------------------------
   255 // CVoIPAudioServicesTestClass::Event
   236 // CVoIPAudioServicesTestClass::Event
   256 //
   237 //
   257 // Callback from MRingToneObserver
   238 // Callback from MRingToneObserver
   258 // ----------------------------------------------------------------------------
   239 // ----------------------------------------------------------------------------
   259 //
   240 //
   260 void CVoIPAudioServicesTestClass::Event(const CRingTonePlayer& /*aSrc*/,
   241 void CVoIPAudioServicesTestClass::Event(const CRingTonePlayer& /*aSrc*/,
   261                             TInt aEventType,
   242         TInt aEventType, TInt aError)
   262                             TInt aError)
   243     {
   263 {
       
   264     switch (aEventType)
   244     switch (aEventType)
   265         {
   245         {
   266         case MRingToneObserver::KOpenComplete:
   246         case MRingToneObserver::KOpenComplete:
   267             ProcessEvent(EOpenComplete, aError);
   247             ProcessEvent(EOpenComplete, aError);
   268             iLog->Log(_L("RT PLR Ready: error = %d"), aError);
   248             iLog->Log(_L("RT PLR Ready: error = %d"), aError);
   272             iLog->Log(_L("RT Play Complete: error = %d"), aError);
   252             iLog->Log(_L("RT Play Complete: error = %d"), aError);
   273             break;
   253             break;
   274         default:
   254         default:
   275             break;
   255             break;
   276         }
   256         }
   277 }
   257     }
   278 
   258 
   279 #ifdef __JITTER_BUFFER_TEST__
       
   280 // ----------------------------------------------------------------------------
   259 // ----------------------------------------------------------------------------
   281 // CVoIPAudioServicesTestClass::Event
   260 // CVoIPAudioServicesTestClass::Event
   282 //
   261 //
   283 // Callback from MVoIPJitterBufferObserver
   262 // Callback from MVoIPJitterBufferObserver
   284 // ----------------------------------------------------------------------------
   263 // ----------------------------------------------------------------------------
   285 //
   264 //
   286 void CVoIPAudioServicesTestClass::Event(const CVoIPJitterBufferIntfc& /*aSrc*/,
   265 void CVoIPAudioServicesTestClass::Event(
   287                             			TInt aEventType)
   266         const CVoIPJitterBufferIntfc& /*aSrc*/, TInt aEventType)
   288 {
   267     {
   289     switch (aEventType)
   268     switch (aEventType)
   290         {
   269         {
   291         // Reserved for future use
   270         // Reserved for future use
   292 		case MVoIPJitterBufferObserver::KJBReserved1:
   271         case MVoIPJitterBufferObserver::KJBReserved1:
   293 		case MVoIPJitterBufferObserver::KJBReserved2:
   272         case MVoIPJitterBufferObserver::KJBReserved2:
   294 		default:
   273         default:
   295             break;
   274             break;
   296         }
   275         }
   297 }
   276     }
   298 
       
   299 #endif //__JITTER_BUFFER_TEST__
       
   300