mmserv/tms/tmscallserver/src/tmsipcalluplinkds.cpp
changeset 31 8dfd592727cb
parent 14 80975da52420
child 33 5e8b14bae8c3
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
    29 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    30 // TMSIPUplink::TMSIPUplink
    30 // TMSIPUplink::TMSIPUplink
    31 // Standard Constructor
    31 // Standard Constructor
    32 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    33 //
    33 //
    34 TMSIPUplink::TMSIPUplink()
    34 TMSIPUplink::TMSIPUplink(TMSIPDevSoundObserver& observer) :
       
    35     TMSIPCallStreamBase(observer)
    35     {
    36     {
    36     }
    37     }
    37 
    38 
    38 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    39 // TMSIPUplink::~TMSIPUplink
    40 // TMSIPUplink::~TMSIPUplink
    57 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    58 // TMSIPUplink::NewL
    59 // TMSIPUplink::NewL
    59 // Symbian two-phase constructor
    60 // Symbian two-phase constructor
    60 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    61 //
    62 //
    62 TMSIPUplink* TMSIPUplink::NewL(const guint32 codecID,
    63 TMSIPUplink* TMSIPUplink::NewL(TMSIPDevSoundObserver& observer,
    63         const TMMFPrioritySettings priority)
    64         const guint32 codecID, const TMMFPrioritySettings priority,
    64     {
    65         const gint retrytime)
    65     TMSIPUplink* self = new (ELeave) TMSIPUplink();
    66     {
       
    67     TMSIPUplink* self = new (ELeave) TMSIPUplink(observer);
    66     CleanupStack::PushL(self);
    68     CleanupStack::PushL(self);
    67     self->ConstructL(codecID, priority);
    69     self->ConstructL(codecID, priority, retrytime);
    68     CleanupStack::Pop(self);
    70     CleanupStack::Pop(self);
    69     return self;
    71     return self;
    70     }
    72     }
    71 
    73 
    72 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    73 // TMSIPUplink::ConstructL
    75 // TMSIPUplink::ConstructL
    74 // Part two of Symbian two phase construction
    76 // Part two of Symbian two phase construction
    75 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    76 //
    78 //
    77 void TMSIPUplink::ConstructL(const guint32 codecID,
    79 void TMSIPUplink::ConstructL(const guint32 codecID,
    78         const TMMFPrioritySettings priority)
    80         const TMMFPrioritySettings priority, const gint /*retrytime*/)
    79     {
    81     {
    80     TRACE_PRN_FN_ENT;
    82     TRACE_PRN_FN_ENT;
    81 
       
    82     iCodecID = codecID;
    83     iCodecID = codecID;
    83     iPriority = priority;
    84     iPriority = priority;
    84 
    85 
    85     // Client must set these before querying!
    86     // Client must set these before querying!
    86     iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW;
    87     iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW;
    87     iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME;
    88     iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME;
    88 
       
    89     TRAPD(err, InitDevSoundL(EMMFStateRecording, priority));
    89     TRAPD(err, InitDevSoundL(EMMFStateRecording, priority));
    90     if (err != TMS_RESULT_SUCCESS)
    90     if (err != TMS_RESULT_SUCCESS)
    91         {
    91         {
    92         User::Leave(err);
    92         User::Leave(err);
    93         }
    93         }
    94 
    94 
    95     iMaxBufLen = ConfigureMedia(iCodecID);
    95     iMaxBufLen = ConfigureMedia(iCodecID);
    96 
       
    97     TRACE_PRN_FN_EXT;
    96     TRACE_PRN_FN_EXT;
    98     }
    97     }
    99 
    98 
   100 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   101 // TMSIPUplink::Start
   100 // TMSIPUplink::Start
   102 //
   101 //
   103 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   104 //
   103 //
   105 void TMSIPUplink::Start()
   104 void TMSIPUplink::Start(const gint /*retrytime*/)
   106     {
   105     {
   107     TRACE_PRN_FN_ENT;
   106     TRACE_PRN_FN_ENT;
   108 
   107 
   109     gint err = TMS_RESULT_ILLEGAL_OPERATION;
   108     gint err = TMS_RESULT_ILLEGAL_OPERATION;
   110     iWriteDataXferHndlToClient = FALSE;
   109     iWriteDataXferHndlToClient = FALSE;
   114         TRAP(err, iDevSound->RecordInitL());
   113         TRAP(err, iDevSound->RecordInitL());
   115         TRACE_PRN_IF_ERR(err);
   114         TRACE_PRN_IF_ERR(err);
   116 
   115 
   117         if (err != TMS_RESULT_SUCCESS)
   116         if (err != TMS_RESULT_SUCCESS)
   118             {
   117             {
   119             //TODO: Notify main thread
       
   120             iStatus = EReady;
   118             iStatus = EReady;
   121             }
   119             iObserver.UplinkStarted(err);
   122 #ifdef _DEBUG
   120             }
   123         else
   121         }
   124             {
       
   125             iSamplesRecCount = 0;
       
   126             }
       
   127 #endif
       
   128         }
       
   129 
       
   130     TRACE_PRN_FN_EXT;
   122     TRACE_PRN_FN_EXT;
   131     }
   123     }
   132 
   124 
   133 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   134 // TMSIPUplink::Stop
   126 // TMSIPUplink::Stop
   142     if (iStatus == EStreaming && iDevSound)
   134     if (iStatus == EStreaming && iDevSound)
   143         {
   135         {
   144         iDevSound->Stop();
   136         iDevSound->Stop();
   145         iStatus = EReady;
   137         iStatus = EReady;
   146         }
   138         }
   147     else
       
   148         {
       
   149         //TODO: Notify main thread
       
   150         }
       
   151     TRACE_PRN_FN_EXT;
   139     TRACE_PRN_FN_EXT;
   152     }
   140     }
   153 
   141 
   154 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   155 // TMSIPUplink::BufferToBeEmptied
   143 // TMSIPUplink::BufferToBeEmptied
   156 // From MDevSoundObserver
   144 // From MDevSoundObserver
   157 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   158 //
   146 //
   159 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer)
   147 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer)
   160     {
   148     {
   161     iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer);
   149     iDevSoundBufPtr = static_cast<CMMFDataBuffer*> (aBuffer);
   162     TDes8& data = iDevSoundBufPtr->Data();
   150     TDes8& data = iDevSoundBufPtr->Data();
   163 
       
   164     iBufLen = iDevSoundBufPtr->BufferSize();
   151     iBufLen = iDevSoundBufPtr->BufferSize();
   165     TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen);
   152     TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen);
   166 
   153 
   167     // Adjust/create RChunk if necessary
   154     // Adjust/create RChunk if necessary
   168     gint err = DoChunk(iBufLen, iMsgBuffer);
   155     gint err = DoChunk(iBufLen, iMsgBuffer);
   351         else
   338         else
   352             {
   339             {
   353             status = TMS_RESULT_ILLEGAL_OPERATION;
   340             status = TMS_RESULT_ILLEGAL_OPERATION;
   354             }
   341             }
   355         }
   342         }
   356 
       
   357     return status;
   343     return status;
   358     }
   344     }
   359 
   345 
   360 // -----------------------------------------------------------------------------
   346 // -----------------------------------------------------------------------------
   361 // TMSIPUplink::SetIlbcCodecMode
   347 // TMSIPUplink::SetIlbcCodecMode
   384                         CIlbcEncoderIntfc::E30msFrame);
   370                         CIlbcEncoderIntfc::E30msFrame);
   385                 TRACE_PRN_N(_L("TMS->UPL: SetIlbcCodecMode [30ms Frame]"));
   371                 TRACE_PRN_N(_L("TMS->UPL: SetIlbcCodecMode [30ms Frame]"));
   386                 }
   372                 }
   387             }
   373             }
   388         }
   374         }
   389 
       
   390     TRACE_PRN_IF_ERR(err);
   375     TRACE_PRN_IF_ERR(err);
   391     return err;
   376     return err;
   392     }
   377     }
   393 
   378 
   394 // -----------------------------------------------------------------------------
   379 // -----------------------------------------------------------------------------
   431                         CG711EncoderIntfc::EEncULaw);
   416                         CG711EncoderIntfc::EEncULaw);
   432                 TRACE_PRN_N(_L("TMS->UPL: SetG711CodecMode [uLaw]"));
   417                 TRACE_PRN_N(_L("TMS->UPL: SetG711CodecMode [uLaw]"));
   433                 }
   418                 }
   434             }
   419             }
   435         }
   420         }
   436 
       
   437     TRACE_PRN_IF_ERR(err);
   421     TRACE_PRN_IF_ERR(err);
   438     return err;
   422     return err;
   439     }
   423     }
   440 
   424 
   441 // -----------------------------------------------------------------------------
   425 // -----------------------------------------------------------------------------
   463 
   447 
   464     if (iSpeechEncoderConfig)
   448     if (iSpeechEncoderConfig)
   465         {
   449         {
   466         err = iSpeechEncoderConfig->GetSupportedBitrates(bitrates);
   450         err = iSpeechEncoderConfig->GetSupportedBitrates(bitrates);
   467         }
   451         }
   468 
       
   469     TRACE_PRN_IF_ERR(err);
   452     TRACE_PRN_IF_ERR(err);
   470     return err;
   453     return err;
   471     }
   454     }
   472 
   455 
   473 // -----------------------------------------------------------------------------
   456 // -----------------------------------------------------------------------------
   482     if (iSpeechEncoderConfig)
   465     if (iSpeechEncoderConfig)
   483         {
   466         {
   484         err = iSpeechEncoderConfig->SetBitrate(bitrate);
   467         err = iSpeechEncoderConfig->SetBitrate(bitrate);
   485         TRACE_PRN_N1(_L("TMS->UPL: SetBitrate [%d]"), bitrate);
   468         TRACE_PRN_N1(_L("TMS->UPL: SetBitrate [%d]"), bitrate);
   486         }
   469         }
   487 
       
   488     TRACE_PRN_IF_ERR(err);
   470     TRACE_PRN_IF_ERR(err);
   489     return err;
   471     return err;
   490     }
   472     }
   491 
   473 
   492 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   501     if (iSpeechEncoderConfig)
   483     if (iSpeechEncoderConfig)
   502         {
   484         {
   503         err = iSpeechEncoderConfig->GetBitrate(bitrate);
   485         err = iSpeechEncoderConfig->GetBitrate(bitrate);
   504         TRACE_PRN_N1(_L("TMS->UPL: GetBitrate [%d]"), bitrate);
   486         TRACE_PRN_N1(_L("TMS->UPL: GetBitrate [%d]"), bitrate);
   505         }
   487         }
   506 
       
   507     TRACE_PRN_IF_ERR(err);
   488     TRACE_PRN_IF_ERR(err);
   508     return err;
   489     return err;
   509     }
   490     }
   510 
   491 
   511 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   632 //
   613 //
   633 void TMSIPUplink::InitializeComplete(TInt aError)
   614 void TMSIPUplink::InitializeComplete(TInt aError)
   634     {
   615     {
   635     TRACE_PRN_FN_ENT;
   616     TRACE_PRN_FN_ENT;
   636 
   617 
   637     gint err = aError;
   618     gint status = aError;
   638 
   619 
   639     if (err == TMS_RESULT_SUCCESS && iDevSound)
   620     if (status == TMS_RESULT_SUCCESS && iDevSound)
   640         {
   621         {
   641         TMMFCapabilities conf;
   622         TMMFCapabilities conf;
   642         conf = iDevSound->Config();
   623         conf = iDevSound->Config();
   643         conf.iRate = EMMFSampleRate8000Hz;
   624         conf.iRate = EMMFSampleRate8000Hz;
   644         conf.iChannels = EMMFMono;
   625         conf.iChannels = EMMFMono;
   645         TRAP(err, iDevSound->SetConfigL(conf));
   626         TRAP(status, iDevSound->SetConfigL(conf));
   646         if (err == TMS_RESULT_SUCCESS)
   627         if (status == TMS_RESULT_SUCCESS)
   647             {
   628             {
   648             // We are ready to stream even in case of CI setting failure
   629             // We are ready to stream even in case of CI setting failure
   649             iStatus = EReady;
   630             iStatus = EReady;
   650             iMaxGain = iDevSound->MaxGain();
   631             iMaxGain = iDevSound->MaxGain();
   651             }
   632             }
   652 
   633 
   653         // Init Custom Interface API to the Encoder
   634         // Init Custom Interface API to the Encoder. Any return error can
   654         err = SetCodecCi();
   635         // be ignored as codec can still run in the default mode even if not
   655         if (err != TMS_RESULT_SUCCESS)
   636         // fully configured.
   656             {
   637         SetCodecCi();
   657             // DEBUG only
   638         }
   658             // Can ignore error - although encoder is not fully configured but
   639 
   659             // it can still run in the default mode.
   640     iObserver.UplinkInitCompleted(status);
   660             TRACE_PRN_IF_ERR(err);
   641     TRACE_PRN_IF_ERR(status);
   661             }
       
   662         }
       
   663 
       
   664     // TODO: Notify client
       
   665 
       
   666     TRACE_PRN_IF_ERR(err);
       
   667     TRACE_PRN_FN_EXT;
   642     TRACE_PRN_FN_EXT;
   668     }
   643     }
   669 
   644 
   670 // -----------------------------------------------------------------------------
   645 // -----------------------------------------------------------------------------
   671 // TMSIPUplink::RecordError
   646 // TMSIPUplink::RecordError
   672 // From MDevSoundObserver
   647 // From MDevSoundObserver
   673 // Recording error is send to the main thread.
   648 // Recording error is send to the main thread.
   674 // The state of recorder is rolled back to EReady.
   649 // The state of recorder is rolled back to EReady.
   675 // -----------------------------------------------------------------------------
   650 // -----------------------------------------------------------------------------
   676 //
   651 //
   677 void TMSIPUplink::RecordError(TInt /*aError*/)
   652 void TMSIPUplink::RecordError(TInt aError)
   678     {
   653     {
   679     //TRACE_PRN_IF_ERR(aError);
       
   680 
       
   681 #ifdef _DEBUG
       
   682     iSamplesRecCount = 0;
       
   683 #endif
       
   684     iStatus = EReady;
   654     iStatus = EReady;
   685 
   655     iObserver.UplinkStarted(aError);
   686     // TODO: Notify client
   656     TRACE_PRN_IF_ERR(aError);
   687     }
   657     }
   688 
   658 
   689 // End of file
   659 // End of file
   690 
   660