mmserv/voipaudioservices/VoIPServer/inc/VoIPServerSession.h
changeset 0 71ca22bcf22a
child 28 ebf79c79991a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2007-2008 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:  Definition of VoIP server session class.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef __VOIPSERVERSESSION_H
       
    19 #define __VOIPSERVERSESSION_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32msgqueue.h>
       
    23 #include <mdaaudiosampleplayer.h>
       
    24 #include <sounddevice.h>
       
    25 #include "VoIPServerAO.h"
       
    26 #include "VoIPSharedData.h"
       
    27 #include "VoIPAudioClientServer.h"
       
    28 #include "VoIPServer.h"
       
    29 #include "VoIPAudioSession.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CVoIPAudioServerThread;
       
    33 class MProEngEngine;
       
    34 class MProEngProfile;
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 //  Class Name:  CVoIPAudioServerSession
       
    38 //
       
    39 //  VoIP server session class.
       
    40 // -----------------------------------------------------------------------------
       
    41 class CVoIPAudioServerSession : public CSession2,
       
    42                                 public MThreadComObserver,
       
    43                                 public MDevSoundObserver,
       
    44                                 public MMdaAudioPlayerCallback
       
    45     {
       
    46     // Each session is designated as one of these types
       
    47     enum TSessionType
       
    48         {
       
    49         ENone,
       
    50         EQueryDec,
       
    51         EQueryEnc,
       
    52         EDnlink,
       
    53         EUplink,
       
    54         ERingTone
       
    55         };
       
    56 
       
    57 public:
       
    58     // Constractor
       
    59     static CVoIPAudioServerSession* NewL(CVoIPAudioServer &aServer);
       
    60 
       
    61     // Destructor
       
    62     ~CVoIPAudioServerSession();
       
    63 
       
    64     /**
       
    65      * ?description
       
    66      * @since S60 v5.0
       
    67      * @param const RMessage2&
       
    68      * @return void
       
    69      */
       
    70     void SetPriorityL(const RMessage2& aMessage);
       
    71 
       
    72     /**
       
    73      * ?description
       
    74      * @since S60 v5.0
       
    75      * @param const RMessage2&
       
    76      * @return void
       
    77      */
       
    78     void GetCodecsCountL(const RMessage2& aMessage);
       
    79 
       
    80     /**
       
    81      * ?description
       
    82      * @since S60 v5.0
       
    83      * @param const RMessage2&
       
    84      * @return void
       
    85      */
       
    86     void GetSupportedCodecsL(const RMessage2& aMessage);
       
    87 
       
    88     /**
       
    89      * ?description
       
    90      * @since S60 v5.0
       
    91      * @param const RMessage2&
       
    92      * @return void
       
    93      */
       
    94     void OpenDownlinkL(const RMessage2& aMessage);
       
    95 
       
    96     /**
       
    97      * ?description
       
    98      * @since S60 v5.0
       
    99      * @param const RMessage2&
       
   100      * @return void
       
   101      */
       
   102     void OpenUplinkL(const RMessage2& aMessage);
       
   103 
       
   104     /**
       
   105      * ?description
       
   106      * @since S60 v5.0
       
   107      * @param RMessage2&
       
   108      * @return void
       
   109      */
       
   110     void SetFormatL(const RMessage2& aMessage);
       
   111 
       
   112     /**
       
   113      * ?description
       
   114      * @since S60 v5.0
       
   115      * @param none
       
   116      * @return void
       
   117      */
       
   118     void StartDownlink();
       
   119 
       
   120     /**
       
   121      * ?description
       
   122      * @since S60 v5.0
       
   123      * @param none
       
   124      * @return void
       
   125      */
       
   126     void StartUplink();
       
   127 
       
   128     /**
       
   129      * ?description
       
   130      * @since S60 v5.0
       
   131      * @param none
       
   132      * @return void
       
   133      */
       
   134     void StopDownlink();
       
   135 
       
   136     /**
       
   137      * ?description
       
   138      * @since S60 v5.0
       
   139      * @param none
       
   140      * @return void
       
   141      */
       
   142     void StopUplink();
       
   143 
       
   144     /**
       
   145      * ?description
       
   146      * @since S60 v5.0
       
   147      * @param none
       
   148      * @return void
       
   149      */
       
   150     void CloseDownlink();
       
   151 
       
   152     /**
       
   153      * ?description
       
   154      * @since S60 v5.0
       
   155      * @param none
       
   156      * @return void
       
   157      */
       
   158     void CloseUplink();
       
   159 
       
   160     /**
       
   161      * ?description
       
   162      * @since S60 v5.0
       
   163      * @param RMessage2&
       
   164      * @return void
       
   165      */
       
   166     void GetMaxVolumeL(const RMessage2& aMessage);
       
   167 
       
   168     /**
       
   169      * ?description
       
   170      * @since S60 v5.0
       
   171      * @param RMessage2&
       
   172      * @return void
       
   173      */
       
   174     void GetVolume(const RMessage2& aMessage);
       
   175 
       
   176     /**
       
   177      * ?description
       
   178      * @since S60 v5.0
       
   179      * @param RMessage2&
       
   180      * @return void
       
   181      */
       
   182     void SetVolume(const RMessage2& aMessage);
       
   183 
       
   184     /**
       
   185      * ?description
       
   186      * @since S60 v5.0
       
   187      * @param RMessage2&
       
   188      * @return void
       
   189      */
       
   190     void GetMaxGainL(const RMessage2& aMessage);
       
   191 
       
   192     /**
       
   193      * ?description
       
   194      * @since S60 v5.0
       
   195      * @param RMessage2&
       
   196      * @return void
       
   197      */
       
   198     void GetGain(const RMessage2& aMessage);
       
   199 
       
   200     /**
       
   201      * ?description
       
   202      * @since S60 v5.0
       
   203      * @param RMessage2&
       
   204      * @return void
       
   205      */
       
   206     void SetGain(const RMessage2& aMessage);
       
   207 
       
   208     /**
       
   209      * ?description
       
   210      * @since S60 v5.0
       
   211      * @param RMessage2&
       
   212      * @return void
       
   213      */
       
   214     void SetAudioDeviceL(const RMessage2& aMessage);
       
   215 
       
   216     /**
       
   217      * ?description
       
   218      * @since S60 v5.0
       
   219      * @param RMessage2&
       
   220      * @return void
       
   221      */
       
   222     void GetAudioDevice(const RMessage2& aMessage);
       
   223 
       
   224     /**
       
   225      * ?description
       
   226      * @since S60 v5.0
       
   227      * @param RMessage2&
       
   228      * @return void
       
   229      */
       
   230     void BufferFilledL(const RMessage2& aMessage);
       
   231 
       
   232     /**
       
   233      * ?description
       
   234      * @since S60 v5.0
       
   235      * @param RMessage2&
       
   236      * @return void
       
   237      */
       
   238     void BufferEmptiedL(const RMessage2& aMessage);
       
   239 
       
   240     /**
       
   241      * ?description
       
   242      * @since S60 v5.0
       
   243      * @param RThread&
       
   244      * @param TUserCommand
       
   245      * @return void
       
   246      */
       
   247     void SendCmd(RThread& aThread, TUserCommand aCmd);
       
   248 
       
   249     /**
       
   250      * ?description
       
   251      * @since S60 v5.0
       
   252      * @param RMessage2&
       
   253      * @return void
       
   254      */
       
   255     void SetIlbcCodecModeL(const RMessage2& aMessage);
       
   256 
       
   257     /**
       
   258      * ?description
       
   259      * @since S60 v5.0
       
   260      * @param RMessage2&
       
   261      * @return void
       
   262      */
       
   263     void GetIlbcCodecMode(const RMessage2& aMessage);
       
   264 
       
   265     /**
       
   266      * ?description
       
   267      * @since S60 v5.0
       
   268      * @param RMessage2&
       
   269      * @return void
       
   270      */
       
   271     void SetG711CodecModeL(const RMessage2& aMessage);
       
   272 
       
   273     /**
       
   274      * ?description
       
   275      * @since S60 v5.0
       
   276      * @param RMessage2&
       
   277      * @return void
       
   278      */
       
   279     void GetG711CodecMode(const RMessage2& aMessage);
       
   280 
       
   281     /**
       
   282      * ?description
       
   283      * @since S60 v5.0
       
   284      * @param RMessage2&
       
   285      * @return void
       
   286      */
       
   287     void GetSupportedBitratesCount(const RMessage2& aMessage);
       
   288 
       
   289     /**
       
   290      * ?description
       
   291      * @since S60 v5.0
       
   292      * @param RMessage2&
       
   293      * @return void
       
   294      */
       
   295     void GetSupportedBitratesL(const RMessage2& aMessage);
       
   296 
       
   297     /**
       
   298      * ?description
       
   299      * @since S60 v5.0
       
   300      * @param RMessage2&
       
   301      * @return void
       
   302      */
       
   303     void SetBitrate(const RMessage2& aMessage);
       
   304 
       
   305     /**
       
   306      * ?description
       
   307      * @since S60 v5.0
       
   308      * @param RMessage2&
       
   309      * @return void
       
   310      */
       
   311     void GetBitrate(const RMessage2& aMessage);
       
   312 
       
   313     /**
       
   314      * ?description
       
   315      * @since S60 v5.0
       
   316      * @param RMessage2&
       
   317      * @return void
       
   318      */
       
   319     void FrameModeRqrdForEC(const RMessage2& aMessage);
       
   320 
       
   321     /**
       
   322      * ?description
       
   323      * @since S60 v5.0
       
   324      * @param RMessage2&
       
   325      * @return void
       
   326      */
       
   327     void SetFrameMode(const RMessage2& aMessage);
       
   328 
       
   329     /**
       
   330      * ?description
       
   331      * @since S60 v5.0
       
   332      * @param RMessage2&
       
   333      * @return void
       
   334      */
       
   335     void GetFrameMode(const RMessage2& aMessage);
       
   336 
       
   337     /**
       
   338      * ?description
       
   339      * @since S60 v5.0
       
   340      * @param none
       
   341      * @return void
       
   342      */
       
   343     void ConcealErrorForNextBuffer();
       
   344 
       
   345     /**
       
   346      * ?description
       
   347      * @since S60 v5.0
       
   348      * @param RMessage2&
       
   349      * @return void
       
   350      */
       
   351     void SetVad(const RMessage2& aMessage);
       
   352 
       
   353     /**
       
   354      * ?description
       
   355      * @since S60 v5.0
       
   356      * @param RMessage2&
       
   357      * @return void
       
   358      */
       
   359     void GetVad(const RMessage2& aMessage);
       
   360 
       
   361     /**
       
   362      * ?description
       
   363      * @since S60 v5.0
       
   364      * @param RMessage2&
       
   365      * @return void
       
   366      */
       
   367     void SetCng(const RMessage2& aMessage);
       
   368 
       
   369     /**
       
   370      * ?description
       
   371      * @since S60 v5.0
       
   372      * @param RMessage2&
       
   373      * @return void
       
   374      */
       
   375     void GetCng(const RMessage2& aMessage);
       
   376 
       
   377     /**
       
   378      * ?description
       
   379      * @since S60 v5.0
       
   380      * @param RMessage2&
       
   381      * @return void
       
   382      */
       
   383     void SetPlc(const RMessage2& aMessage);
       
   384 
       
   385     /**
       
   386      * ?description
       
   387      * @since S60 v5.0
       
   388      * @param RMessage2&
       
   389      * @return void
       
   390      */
       
   391     void GetPlc(const RMessage2& aMessage);
       
   392 
       
   393     /**
       
   394      * ?description
       
   395      * @since S60 v5.0
       
   396      * @param none
       
   397      * @return void
       
   398      */
       
   399     void BadLsfNextBuffer();
       
   400 
       
   401     /**
       
   402      * ?description
       
   403      * @since S60 v5.0
       
   404      * @param RMessage2&
       
   405      * @return void
       
   406      */
       
   407     void ConfigureJitterBufferL(const RMessage2& aMessage);
       
   408 
       
   409     /**
       
   410      * ?description
       
   411      * @since S60 v5.0
       
   412      * @param RMessage2&
       
   413      * @return void
       
   414      */
       
   415     void ResetJitterBuffer(const RMessage2& aMessage);
       
   416 
       
   417     /**
       
   418      * ?description
       
   419      * @since S60 v5.0
       
   420      * @param none
       
   421      * @return void
       
   422      */
       
   423     void JBDelayDown();
       
   424 
       
   425     /**
       
   426      * ?description
       
   427      * @since S60 v5.0
       
   428      * @param none
       
   429      * @return void
       
   430      */
       
   431     void JBDelayUp();
       
   432 
       
   433     /**
       
   434      * ?description
       
   435      * @since S60 v5.0
       
   436      * @param none
       
   437      * @return void
       
   438      */
       
   439     void OpenDTMFTonePlayerL();
       
   440 
       
   441     /**
       
   442      * ?description
       
   443      * @since S60 v5.0
       
   444      * @param RMessage2&
       
   445      * @return void
       
   446      */
       
   447     void PlayDTMFToneL(const RMessage2& aMessage);
       
   448 
       
   449     /**
       
   450      * ?description
       
   451      *
       
   452      * @since S60 v5.0
       
   453      * @param none
       
   454      * @return void
       
   455      */
       
   456     void StopDTMFTonePlay();
       
   457 
       
   458     /**
       
   459      * ?description
       
   460      *
       
   461      * @since S60 v5.0
       
   462      * @param none
       
   463      * @return void
       
   464      */
       
   465     void CloseDTMFTonePlayer();
       
   466 
       
   467     /**
       
   468      * ?description
       
   469      *
       
   470      * @since S60 v5.0
       
   471      * @param const RMessage2&
       
   472      * @return void
       
   473      */
       
   474     void OpenRingTonePlayerFromFileL(const RMessage2& aMessage);
       
   475 
       
   476     /**
       
   477      * ?description
       
   478      *
       
   479      * @since S60 v5.0
       
   480      * @param const RMessage2&
       
   481      * @return void
       
   482      */
       
   483     void OpenRingTonePlayerFromRFileL(const RMessage2& aMessage);
       
   484 
       
   485     /**
       
   486      * ?description
       
   487      *
       
   488      * @since S60 v5.0
       
   489      * @param none
       
   490      * @return void
       
   491      */
       
   492     void OpenRingTonePlayerFromProfileL();
       
   493 
       
   494     /**
       
   495      * ?description
       
   496      *
       
   497      * @since S60 v5.0
       
   498      * @param const RMessage2&
       
   499      * @return void
       
   500      */
       
   501     void OpenRingTonePlayerFromDesL(const RMessage2& aMessage);
       
   502 
       
   503     /**
       
   504      * ?description
       
   505      *
       
   506      * @since S60 v5.0
       
   507      * @param none
       
   508      * @return void
       
   509      */
       
   510     void PlayRingTone();
       
   511 
       
   512     /**
       
   513      * ?description
       
   514      *
       
   515      * @since S60 v5.0
       
   516      * @param none
       
   517      * @return void
       
   518      */
       
   519     void PauseRingTone();
       
   520 
       
   521     /**
       
   522      * ?description
       
   523      *
       
   524      * @since S60 v5.0
       
   525      * @param none
       
   526      * @return void
       
   527      */
       
   528     void ResumeRingTone();
       
   529 
       
   530     /**
       
   531      * ?description
       
   532      *
       
   533      * @since S60 v5.0
       
   534      * @param none
       
   535      * @return void
       
   536      */
       
   537     void StopRingTone();
       
   538 
       
   539     /**
       
   540      * ?description
       
   541      *
       
   542      * @since S60 v5.0
       
   543      * @param none
       
   544      * @return void
       
   545      */
       
   546     void CloseRingTonePlayer();
       
   547 
       
   548     /**
       
   549      * ?description
       
   550      *
       
   551      * @since S60 v5.0
       
   552      * @param TInt
       
   553      * @return void
       
   554      */
       
   555     void InitRingTonePlayerL();
       
   556 
       
   557     // CALLBACKS
       
   558 
       
   559     // From MMdaAudioPlayerCallback
       
   560 
       
   561     /**
       
   562      * ?description
       
   563      * @since S60 v5.0
       
   564      * @param TInt
       
   565      * @param const TTimeIntervalMicroSeconds&
       
   566      * @return void
       
   567      */
       
   568     virtual void MapcInitComplete(TInt aError,
       
   569             const TTimeIntervalMicroSeconds& aDuration);
       
   570 
       
   571     /**
       
   572      * ?description
       
   573      * @since S60 v5.0
       
   574      * @param TInt
       
   575      * @return void
       
   576      */
       
   577     virtual void MapcPlayComplete(TInt aError);
       
   578 
       
   579     // From MThreadComObserver
       
   580 
       
   581     /**
       
   582      * ?description
       
   583      * @since S60 v5.0
       
   584      * @param TExcType
       
   585      * @return void
       
   586      */
       
   587     virtual void DoHandleCmd(TExcType aExc, TInt aError);
       
   588 
       
   589     /**
       
   590      * ?description
       
   591      * @since S60 v5.0
       
   592      * @param TInt
       
   593      * @return void
       
   594      */
       
   595     virtual void DoHandleError(TInt aError);
       
   596 
       
   597     // From MDevSoundObserver
       
   598     virtual void InitializeComplete(TInt aError);
       
   599     virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
       
   600     virtual void RecordError(TInt aError);
       
   601     virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
       
   602     virtual void PlayError(TInt aError);
       
   603     virtual void ToneFinished(TInt /*aError*/);
       
   604     virtual void ConvertError(TInt /*aError*/) {}
       
   605     virtual void DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/) {}
       
   606     virtual void SendEventToClient(const TMMFEvent& /*aEvent*/) {}
       
   607 
       
   608 private:
       
   609 
       
   610     // Symbian constructors
       
   611     void ConstructL();
       
   612     CVoIPAudioServerSession(CVoIPAudioServer& aServer);
       
   613 
       
   614     // Client-server message handlers
       
   615     void ServiceL(const RMessage2& aMessage);
       
   616     void DispatchMessageL(const RMessage2& aMessage);
       
   617 
       
   618     void SendCmdToThread(const TInt aCommand, const TInt aStatus = KErrNone);
       
   619     void NotifyClient(const TInt aCommand, const TInt aStatus = KErrNone,
       
   620             const TInt64 aInt64 = TInt64(0));
       
   621     void NotifyDtmfClient(const TInt aCommand, const TInt aStatus = KErrNone);
       
   622 
       
   623     // Handlers of request complete events from the work threads
       
   624     void DownlinkInitComplete(TInt aError);
       
   625     void UplinkInitComplete(TInt aError);
       
   626     void GetVolumeComplete(TInt aError);
       
   627     void GetGainComplete(TInt aError);
       
   628     void GetAudioDeviceComplete(TInt aError);
       
   629     void GetSupportedBitratesComplete(TInt aError);
       
   630     void GetBitrateComplete(TInt aError);
       
   631     void GetG711CodecModeComplete(TInt aError);
       
   632     void GetIlbcCodecModeComplete(TInt aError);
       
   633     void GetFrameModeComplete(TInt aError);
       
   634     void GetFrameModeReqForECComplete(TInt aError);
       
   635     void GetVadComplete(TInt aError);
       
   636     void GetCngComplete(TInt aError);
       
   637     void GetPlcComplete(TInt aError);
       
   638 
       
   639     //void DetermineG711FrameRateL();
       
   640     void ReleaseQueuedMessage(TInt aError, TUint aFrmSize = 0);
       
   641 
       
   642 private:
       
   643     //data members
       
   644 
       
   645     CVoIPAudioServer& iVoIPServer;
       
   646     RThread iThread;
       
   647     TSharedData iShared;
       
   648 
       
   649     // Message queue for communication back to the client side
       
   650     RMsgQueue<TVoIPMsgBuf> iMsgComQueue;
       
   651     RMsgQueue<TVoIPMsgBuf> iMsgComQueueDtmf;
       
   652 
       
   653     // Message queue for communication between server threads
       
   654     RMsgQueue<TVoIPMsgBuf> iITCMsgComQueue;
       
   655 
       
   656     TVoIPMsgBuf iMsgBuffer;
       
   657     TMMFPrioritySettings iPriority;
       
   658 
       
   659     // Msg queued until called back from the DL/UL thread
       
   660     RMessage2 iMessage;
       
   661     TBool iMsgQueued;
       
   662 
       
   663     TInt iMaxVolume;
       
   664     TInt iMaxGain;
       
   665     RArray<TUint> iBitrateArray;
       
   666     RArray<TFourCC> iCodecsUp;
       
   667     RArray<TFourCC> iCodecsDn;
       
   668     TInt iCodecsCountUp;
       
   669     TInt iCodecsCountDn;
       
   670     CVoIPServerAO* iAO; // ITC back with this thread
       
   671     TSessionType iSessionType;
       
   672 
       
   673     CMMFDevSound* iDevSound; // To get supported codecs
       
   674     CMMFDevSound* iDTMFTonePlayer;
       
   675     TBool iDTMFTonePlayerInitRequest;
       
   676     TBool iDevSoundInitRequest;
       
   677     TTimeIntervalMicroSeconds32 iToneLenOn;
       
   678     TTimeIntervalMicroSeconds32 iToneLenOff;
       
   679     TTimeIntervalMicroSeconds32 iToneLenPause;
       
   680 
       
   681     CMdaAudioPlayerUtility* iRingTonePlayer;
       
   682     HBufC8* iToneBuf;
       
   683     };
       
   684 
       
   685 #endif //__VOIPSERVERSESSION_H
       
   686 
       
   687 // End of file