mmfenh/enhancedmediaclient/Client/src/Components/StreamControl/ClientStreamControl.cpp
branchRCL_3
changeset 8 e35735ece90c
parent 0 71ca22bcf22a
child 16 43d09473c595
equal deleted inserted replaced
7:709f89d8c047 8:e35735ece90c
   209 
   209 
   210 TInt CStreamControl::RemoveEffect(MEffectControl& aEffect)
   210 TInt CStreamControl::RemoveEffect(MEffectControl& aEffect)
   211     {
   211     {
   212     TInt status(KErrNotReady);
   212     TInt status(KErrNotReady);
   213     // Get the observer from effect
   213     // Get the observer from effect
   214     CEffectControlBase* effectBase =
   214     if(&aEffect)
       
   215        {
       
   216        CEffectControlBase* effectBase =
   215             dynamic_cast<CEffectControlBase*>(&aEffect);
   217             dynamic_cast<CEffectControlBase*>(&aEffect);
   216 
   218 
   217     // Remove the effect from the array
   219     // Remove the effect from the array
   218     TInt index(KErrNotFound);
   220     TInt index(KErrNotFound);
   219     index = iAssociatedEffects.Find(effectBase);
   221     if(effectBase)
       
   222        {
       
   223        index = iAssociatedEffects.Find(effectBase);
       
   224         
   220     if (index != KErrNotFound)
   225     if (index != KErrNotFound)
   221         {
   226         {
   222         MControlObserver* observer;
   227         MControlObserver* observer;
   223         status = effectBase->GetControlObserver(observer);
   228         status = effectBase->GetControlObserver(observer);
   224         RETURN_IF_ERROR( status );
   229         RETURN_IF_ERROR( status );
   227         RETURN_IF_ERROR( status );
   232         RETURN_IF_ERROR( status );
   228 
   233 
   229         iAssociatedEffects.Remove(index);
   234         iAssociatedEffects.Remove(index);
   230         status = effectBase->RemovedFromStreamControl(*this);
   235         status = effectBase->RemovedFromStreamControl(*this);
   231         RETURN_IF_ERROR( status );
   236         RETURN_IF_ERROR( status );
   232         }
   237          }
   233 
   238         }
   234     return status;
   239        }
       
   240     return status;
       
   241         
   235     }
   242     }
   236 
   243 
   237 TInt CStreamControl::AddEffect(MEffectControl& aEffect)
   244 TInt CStreamControl::AddEffect(MEffectControl& aEffect)
   238     {
   245     {
   239     TInt status(KErrNotReady);
   246     TInt status(KErrNotReady);
   523 
   530 
   524     // Signal the source that server side source is unloaded
   531     // Signal the source that server side source is unloaded
   525     if (iSourceControl)
   532     if (iSourceControl)
   526         {
   533         {
   527         CSourceBase* sourcebase = dynamic_cast<CSourceBase*>(iSourceControl);
   534         CSourceBase* sourcebase = dynamic_cast<CSourceBase*>(iSourceControl);
   528         sourcebase->ServerSourceDeleted();
   535         if (sourcebase)
       
   536             sourcebase->ServerSourceDeleted();
       
   537         else
       
   538             return status;
   529         }
   539         }
   530 
   540 
   531     SetStreamState(EStreamClosed, KErrNone);
   541     SetStreamState(EStreamClosed, KErrNone);
   532     status = KErrNone;
   542     status = KErrNone;
   533     return status;
   543     return status;
   625 
   635 
   626             // The same sequence occurs in Close() also. May be move this a
   636             // The same sequence occurs in Close() also. May be move this a
   627             // seperate function and call function here...
   637             // seperate function and call function here...
   628 
   638 
   629             // Signal the source that server side source is unloaded
   639             // Signal the source that server side source is unloaded
       
   640         if (iSourceControl)
       
   641             {
   630             CSourceBase* sourcebase =
   642             CSourceBase* sourcebase =
   631                     dynamic_cast<CSourceBase*>(iSourceControl);
   643                     dynamic_cast<CSourceBase*>(iSourceControl);
   632             sourcebase->ServerSourceDeleted();
   644              if (sourcebase)
   633 
   645                  sourcebase->ServerSourceDeleted();
       
   646             }
   634             if (iControllerEventMonitor)
   647             if (iControllerEventMonitor)
   635                 {
   648                 {
   636                 iControllerEventMonitor->Cancel();
   649                 iControllerEventMonitor->Cancel();
   637                 }
   650                 }
   638 
   651 
   664                 }
   677                 }
   665 
   678 
   666             // Save the uid of controller loaded.
   679             // Save the uid of controller loaded.
   667             iControllerUid = aControllerUid;
   680             iControllerUid = aControllerUid;
   668             // Signal the source that server side source is loaded
   681             // Signal the source that server side source is loaded
   669             CSourceBase* sourcebase =
   682             if (iSourceControl)
       
   683                 {
       
   684                 CSourceBase* sourcebase =
   670                     dynamic_cast<CSourceBase*>(iSourceControl);
   685                     dynamic_cast<CSourceBase*>(iSourceControl);
   671             sourcebase->ServerSourceCreated( *iCMCustomCommand,
   686                if (sourcebase)
       
   687                    sourcebase->ServerSourceCreated( *iCMCustomCommand,
   672                     *aSourceHandle);
   688                     *aSourceHandle);
   673 
   689               else
       
   690                  {
       
   691                  SetStreamState(EStreamClosed, aError);
       
   692                  }
       
   693                 }
   674             if (iStreamState == EStreamOpening)
   694             if (iStreamState == EStreamOpening)
   675                 {
   695                 {
   676                 iPrimeController = ETrue;
   696                 iPrimeController = ETrue;
   677                 SetStreamState(EStreamOpened, KErrNone);
   697                 SetStreamState(EStreamOpened, KErrNone);
   678                 //FIX ME we need to do this even when the controller is closed
   698                 //FIX ME we need to do this even when the controller is closed
   697             *iControllerEventMonitor, aMode);
   717             *iControllerEventMonitor, aMode);
   698     }
   718     }
   699 
   719 
   700 TInt CStreamControl::LaunchController()
   720 TInt CStreamControl::LaunchController()
   701     {
   721     {
   702     TInt status(KErrNone);
   722     TInt status(KErrNotReady);
   703     // KUidMediaTypeAudio need to be part of source
   723     // KUidMediaTypeAudio need to be part of source
   704     ConfigureControllerLoader(KUidMediaTypeAudio,
   724     ConfigureControllerLoader(KUidMediaTypeAudio,
   705             CMMFFindAndOpenController::EPlayback);
   725             CMMFFindAndOpenController::EPlayback);
   706     // if Streaming case
   726     // if Streaming case
   707 
   727 
   708     if (!iSourceControl || !iSinkControl)
   728     if (!iSourceControl || !iSinkControl)
   709         return KErrNotReady;
   729         return KErrNotReady;
   710 
   730    CSourceBase *sourceBase=(dynamic_cast<CSourceBase*>(iSourceControl));
   711     TUid sourceUID = (dynamic_cast<CSourceBase*>(iSourceControl))->GetSourceUid();
   731    TUid sourceUID ;
   712     TUid sinkUID = (dynamic_cast<CSinkBase*>(iSinkControl))->GetSinkUid();
   732 
       
   733    if (sourceBase)
       
   734       {
       
   735        sourceUID = sourceBase->GetSourceUid();
       
   736       }
       
   737    else
       
   738        {
       
   739        return KErrNotReady;
       
   740        }
       
   741 
       
   742    CSinkBase *sinkBase=(dynamic_cast<CSinkBase*>(iSinkControl));
       
   743    TUid sinkUID;
       
   744 
       
   745    if(sinkBase)
       
   746       sinkUID = sinkBase ->GetSinkUid();
       
   747    else
       
   748       return KErrNotReady;
   713 
   749 
   714     if (iSourceControl->Type() == KDataBufferSourceControl)
   750     if (iSourceControl->Type() == KDataBufferSourceControl)
   715         {
   751         {
   716         MDataBufferSource* streamingSource =
   752         MDataBufferSource* streamingSource =
   717                 static_cast<MDataBufferSource*>(iSourceControl);
   753                 static_cast<MDataBufferSource*>(iSourceControl);
   753             TInt err = progDLSource->FileName(fileNamePtr);
   789             TInt err = progDLSource->FileName(fileNamePtr);
   754 
   790 
   755             HBufC8* mimeType = HBufC8::NewLC(KMaxMimeLength);
   791             HBufC8* mimeType = HBufC8::NewLC(KMaxMimeLength);
   756             TPtr8 mimeTypePtr = mimeType->Des();
   792             TPtr8 mimeTypePtr = mimeType->Des();
   757 
   793 
   758             TInt status = iSourceControl->GetMimeType(mimeTypePtr);
   794             status = iSourceControl->GetMimeType(mimeTypePtr);
   759 
   795 
   760             iFindAndOpenController->ConfigureSourceSink(
   796             iFindAndOpenController->ConfigureSourceSink(
   761                     TMMFileSource(fileNamePtr,
   797                     TMMFileSource(fileNamePtr,
   762                             ContentAccess::KDefaultContentObject,
   798                             ContentAccess::KDefaultContentObject,
   763                             ContentAccess::EPlay),
   799                             ContentAccess::EPlay),
   804         fileNamePtr1.Copy(fileNamePtr);
   840         fileNamePtr1.Copy(fileNamePtr);
   805 
   841 
   806         HBufC8* mimeType = HBufC8::NewLC(KMaxMimeLength);
   842         HBufC8* mimeType = HBufC8::NewLC(KMaxMimeLength);
   807         TPtr8 mimeTypePtr = mimeType->Des();
   843         TPtr8 mimeTypePtr = mimeType->Des();
   808 
   844 
   809         TInt status = iSourceControl->GetMimeType(mimeTypePtr);
   845         status = iSourceControl->GetMimeType(mimeTypePtr);
   810 
   846 
   811         iFindAndOpenController->ConfigureSourceSink(
   847         iFindAndOpenController->ConfigureSourceSink(
   812                 CMMFFindAndOpenController::TSourceSink(sourceUID,
   848                 CMMFFindAndOpenController::TSourceSink(sourceUID,
   813                         fileNamePtr1),
   849                         fileNamePtr1),
   814                 CMMFFindAndOpenController::TSourceSink(sinkUID));
   850                 CMMFFindAndOpenController::TSourceSink(sinkUID));