mmserv/voipaudioservices/VoIPIntfc/src/VoIPRingTonePlayerImpl.cpp
changeset 55 e267340986c9
parent 0 71ca22bcf22a
equal deleted inserted replaced
52:4ce423f34688 55:e267340986c9
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2007-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 
    17 
    19 #include <e32base.h>
    18 #include <e32base.h>
    20 #include "VoIPAudioSession.h"
    19 #include "VoIPAudioSession.h"
    21 #include "VoIPRingTonePlayerImpl.h"
    20 #include "VoIPRingTonePlayerImpl.h"
    22 
       
    23 // CONSTANTS
       
    24 //_LIT8(KMimetypeMP3, "audio/mpeg");
       
    25 
       
    26 
    21 
    27 // ---------------------------------------------------------------------------
    22 // ---------------------------------------------------------------------------
    28 // CRingTonePlayerImpl::NewL
    23 // CRingTonePlayerImpl::NewL
    29 // ---------------------------------------------------------------------------
    24 // ---------------------------------------------------------------------------
    30 //
    25 //
   117 //
   112 //
   118 // Plays ring tone from file handle
   113 // Plays ring tone from file handle
   119 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
   120 //
   115 //
   121 void CRingTonePlayerImpl::OpenL(MRingToneObserver& aObserver,
   116 void CRingTonePlayerImpl::OpenL(MRingToneObserver& aObserver,
   122                                 RFile& aFileHandle)
   117         RFile& aFileHandle)
   123     {
   118     {
   124     iObserver = &aObserver;
   119     iObserver = &aObserver;
   125     StartMsgQueueL();
   120     StartMsgQueueL();
   126     TInt err = iVoIPAudioSession.OpenRingTonePlayer(aFileHandle);
   121     TInt err = iVoIPAudioSession.OpenRingTonePlayer(aFileHandle);
   127     User::LeaveIfError(err);
   122     User::LeaveIfError(err);
   131 // CRingTonePlayerImpl::OpenL
   126 // CRingTonePlayerImpl::OpenL
   132 //
   127 //
   133 // Plays ring tone from a descriptor string based on its MIME type
   128 // Plays ring tone from a descriptor string based on its MIME type
   134 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   135 //
   130 //
   136 void CRingTonePlayerImpl::OpenL(MRingToneObserver& aObserver,
   131 void CRingTonePlayerImpl::OpenL(MRingToneObserver& aObserver, TPtr8 aDesTone,
   137                                 TPtr8 aDesTone,
   132         TPtr8 /*aMimeType*/)
   138                                 TPtr8 /*aMimeType*/)
       
   139     {
   133     {
   140     iObserver = &aObserver;
   134     iObserver = &aObserver;
   141     StartMsgQueueL();
   135     StartMsgQueueL();
   142 
   136 
   143     TInt size = aDesTone.Size();
   137     TInt size = aDesTone.Size();
   146         {
   140         {
   147         User::Leave(KErrArgument);
   141         User::Leave(KErrArgument);
   148         }
   142         }
   149     else
   143     else
   150         {
   144         {
   151 //        size += aMimeType.Size();
       
   152 
       
   153         HBufC8* tone = HBufC8::NewLC(size);
   145         HBufC8* tone = HBufC8::NewLC(size);
   154         TPtr8 ptr = tone->Des();
   146         TPtr8 ptr = tone->Des();
   155 /*
   147         ptr.Copy(aDesTone);
   156         if (aMimeType.Compare(KMimetypeMP3) == 0)
       
   157             {
       
   158             // MP3 requires mime header
       
   159             ptr.Copy(aMimeType);
       
   160             ptr.Append(aDesTone);
       
   161             }
       
   162         else
       
   163             {*/
       
   164             ptr.Copy(aDesTone);
       
   165 //            }
       
   166 
       
   167         TInt err = iVoIPAudioSession.OpenRingTonePlayer(*tone);
   148         TInt err = iVoIPAudioSession.OpenRingTonePlayer(*tone);
   168         CleanupStack::PopAndDestroy(tone);
   149         CleanupStack::PopAndDestroy(tone);
   169         User::LeaveIfError(err); //return error via trap mechanism
   150         User::LeaveIfError(err); //return error via trap mechanism
   170         }
   151         }
   171     }
   152     }
   227 void CRingTonePlayerImpl::StartMsgQueueL()
   208 void CRingTonePlayerImpl::StartMsgQueueL()
   228     {
   209     {
   229     if (iMsgComQueue.Handle() <= 0)
   210     if (iMsgComQueue.Handle() <= 0)
   230         {
   211         {
   231         TInt err = iMsgComQueue.CreateGlobal(KRingToneComQueue,
   212         TInt err = iMsgComQueue.CreateGlobal(KRingToneComQueue,
   232                                              KVoIPMsgComQSlots);
   213                 KVoIPMsgComQSlots);
   233         User::LeaveIfError(err);
   214         User::LeaveIfError(err);
   234         }
   215         }
   235 
   216 
   236     ReceiveMsgQComHandlerEventsL();
   217     ReceiveMsgQComHandlerEventsL();
   237     }
   218     }
   253         }
   234         }
   254 
   235 
   255     iMsgQComHandler->Start();
   236     iMsgQComHandler->Start();
   256     }
   237     }
   257 
   238 
   258 
       
   259 // ======== CALLBACK FUNCTIONS ========
   239 // ======== CALLBACK FUNCTIONS ========
   260 
   240 
   261 
   241 
   262 // ---------------------------------------------------------------------------
   242 // ---------------------------------------------------------------------------
   263 // CRingTonePlayerImpl::Event
   243 // CRingTonePlayerImpl::Event
   268 void CRingTonePlayerImpl::Event(TInt aEventType, TInt aError)
   248 void CRingTonePlayerImpl::Event(TInt aEventType, TInt aError)
   269     {
   249     {
   270     iObserver->Event(*this, aEventType, aError);
   250     iObserver->Event(*this, aEventType, aError);
   271     }
   251     }
   272 
   252 
   273 
       
   274 // End of file
   253 // End of file