mmmw_plat/enhanced_media_client_api/tsrc/EnhanMediaTestClass/src/EnhanMediaTestCallbacks.cpp
changeset 0 71ca22bcf22a
child 16 43d09473c595
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  EMC Api Test App
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "EnhanMediaTestClass.h"
       
    22 #include "debug.h"
       
    23 #include <StreamControlObserver.h>
       
    24 #include <SourceControlObserver.h>
       
    25 
       
    26 
       
    27 using namespace multimedia;
       
    28 
       
    29 using multimedia::MSourceControlObserver;
       
    30 using multimedia::MStreamControlObserver;
       
    31 
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 /************************************************************************************************************/
       
    37 
       
    38 void CEnhanMediaTestClass::Event( MControl* aControl, TUint aEventType, TAny* aEventObject )
       
    39 	{
       
    40 	TInt controlTy;
       
    41    // TControlType controlType;
       
    42     controlTy = aControl->ControlType();
       
    43     RDebug::Print(_L("CEnhanMediaTestClass::Event [%d]"),controlTy);
       
    44 	switch ( controlTy )
       
    45 		{
       
    46 		case EStreamControl:
       
    47 			    {
       
    48 		    	switch (aEventType)
       
    49 			        {
       
    50 			        case MStreamControlObserver::KStateChangedEvent:
       
    51 			            {
       
    52 			            MStreamControl* control1 = (MStreamControl*)(aControl);
       
    53 			            RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged"));
       
    54 			            switch(control1->GetState())
       
    55 			                {
       
    56 			                case MStreamControl::CLOSED:
       
    57 								RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Closed]"));
       
    58 			                    break;
       
    59 			                case MStreamControl::INITIALIZED:
       
    60 							    {
       
    61 					            iLog->Log(_L("CEnhanMediaTestClass::Event:EStateChanged[Opened]"));
       
    62 							    RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Opened]"));
       
    63 							    }
       
    64 			                    break;
       
    65 			                case MStreamControl::PRIMED:
       
    66 			                	{
       
    67 					            iLog->Log(_L("CEnhanMediaTestClass::Event:EStateChanged[Primed]"));
       
    68 			                	RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Primed]"));
       
    69 			                	}
       
    70 							    break;
       
    71 			                case MStreamControl::EXECUTING:
       
    72 			                	RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Playing]"));
       
    73 			                    break;
       
    74 			                case MStreamControl::BUFFERING:
       
    75 			                	RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Buffering]"));
       
    76 			                    break;
       
    77 			                case MStreamControl::PAUSED:
       
    78 							    RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Paused]"));
       
    79 			                    break;
       
    80 			                default:
       
    81 			                    break;
       
    82 			                };
       
    83 			            }
       
    84 			            break;
       
    85 
       
    86 			        case MStreamControlObserver::KDurationChangedEvent:
       
    87 			        	RDebug::Print(_L("CEnhanMediaTestClass::Event:KDurationChangedEvent"));
       
    88 			            break;
       
    89 					};
       
    90 				}
       
    91         		break;
       
    92 
       
    93         case ESourceControl:
       
    94  			    {
       
    95  			    switch (aEventType)
       
    96 			        {
       
    97 			        case MSourceControlObserver::KPercentageDownloadedChangedEvent:
       
    98 			        	{
       
    99 			        	TUint percent;
       
   100 			        	MProgDLSource* control1 = (MProgDLSource*)(aControl);
       
   101 			        	control1->GetPercentageBuffered(percent);
       
   102 			            iLog->Log(_L("KPercentageDownloadedChangedEvent"));
       
   103 			        	}
       
   104 			            break;
       
   105 			        case MSourceControlObserver::KBufferingTypesSupportChangedEvent:
       
   106 			        	{
       
   107 			            iLog->Log(_L("KBufferingTypesSupportChangedEvent"));
       
   108 			        	}
       
   109 			            break;
       
   110 			        case MSourceControlObserver::KBufferProcessedEvent:
       
   111 			        	{
       
   112 			            MBufferProcessedEvent* evt = (MBufferProcessedEvent*)aEventObject;
       
   113 			            RDebug::Print(_L("CEnhanMediaTestClass::Event:EBufferProcessed[AudioBuffer[0x%x]Reason[%d]]") , evt->GetDataBuffer(), evt->GetErrorCode() );
       
   114 			            iLog->Log(_L("CEnhanMediaTestClass::Event:EBufferProcessed[AudioBuffer[0x%x]Reason[%d]]") , evt->GetDataBuffer(), evt->GetErrorCode() );
       
   115 			        	}
       
   116 			            break;
       
   117 			        case MSourceControlObserver::KBitRateChangedEvent:
       
   118 			        	{
       
   119 		            	TUint rate;
       
   120 			            iMFileSource->GetBitRate(rate);
       
   121 			            RDebug::Print(_L("CEnhanMediaTestClass::Event:BitRateChanged[%d]"),rate);
       
   122 			            iLog->Log(_L("CEnhanMediaTestClass::Event:BitRateChanged[%d]"),rate);
       
   123 			        	}
       
   124 			            break;
       
   125 			        case MSourceControlObserver::KDownloadStatusChangedEvent:
       
   126 			            {
       
   127 			            MProgDLSource* control1 = (MProgDLSource*)(aControl);
       
   128 			            RDebug::Print(_L("CMPlayerAudioUIController::Event:DownloadStatus[%d]"),control1->GetDownloadStatus());
       
   129 			            iLog->Log(_L("CMPlayerAudioUIController::Event:DownloadStatus[%d]"),control1->GetDownloadStatus());
       
   130 			            switch(control1->GetDownloadStatus())
       
   131 			            	{
       
   132 
       
   133 			            	case MProgDLSource::EConnecting:
       
   134 			            	    {
       
   135 			            	    RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [connecting]"));
       
   136 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [connecting]"));
       
   137 			            	    }
       
   138 			            	    break;
       
   139 
       
   140 			            	case MProgDLSource::EStarted:
       
   141 			            		{
       
   142 			            		RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [started]"));
       
   143 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [started]"));
       
   144 			            		}
       
   145 			            	    break;
       
   146 
       
   147 			            	case MProgDLSource::EPaused:
       
   148 			            		{
       
   149 			            	    RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [paused]"));
       
   150 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [paused]"));
       
   151 			            		}
       
   152 			            	    break;
       
   153 
       
   154 			            	case MProgDLSource::EDeleted:
       
   155 			            		{
       
   156 			            	    RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [deleted]"));
       
   157 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [deleted]"));
       
   158 			            		}
       
   159 			                    break;
       
   160 			            	case MProgDLSource::ECompleted:
       
   161 			            		{
       
   162 			            	    RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [completed]"));
       
   163 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [completed]"));
       
   164 			            		}
       
   165 			            	    break;
       
   166 			   	            case MProgDLSource::EFailed:
       
   167 			                    {
       
   168 			        	        RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [failed]"));
       
   169 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [failed]"));
       
   170 			                    break;
       
   171 			                    }
       
   172 			    	        case MProgDLSource::EUnknown:
       
   173 			        	        {
       
   174 			        	        RDebug::Print(_L("CEnhanMediaTestClass::Event:DownloadStatus [EUnknown]"));
       
   175 					            iLog->Log(_L("CEnhanMediaTestClass::Event:DownloadStatus [EUnknown]"));
       
   176 			        	        }
       
   177 			        	        break;
       
   178 			            	default:
       
   179 			            	  break;
       
   180 			            	}
       
   181 			            }
       
   182 			            break;
       
   183 
       
   184 			        case MSourceControlObserver::KFileMoveCompleteEvent:
       
   185 			            {
       
   186 				            RDebug::Print(_L("CEnhanMediaTestClass::Event:KFileMoveCompleteEvent"));
       
   187 				            iLog->Log(_L("CEnhanMediaTestClass::Event:KFileMoveCompleteEvent"));
       
   188 			            }
       
   189 			            break;
       
   190 
       
   191 
       
   192 			        };
       
   193 			    }
       
   194        			break;
       
   195 
       
   196        case ESinkControl:
       
   197 			    {
       
   198                 TUid controlUid = aControl->Type();
       
   199 	            iLog->Log(_L("CEnhanMediaTestClass::Event Sink[%x] Event[%d]"),controlUid, aEventType);
       
   200                 RDebug::Print(_L("CEnhanMediaTestClass::Event Sink[%x] Event[%d]"),controlUid, aEventType);
       
   201 			    }
       
   202                 break;
       
   203 
       
   204         case EEffectControl:
       
   205 			    {
       
   206                 TUid controlUid = aControl->Type();
       
   207 	            iLog->Log(_L("CEnhanMediaTestClass::Event Effect[%x] Event[%d]"),controlUid, aEventType);
       
   208                 RDebug::Print(_L("CEnhanMediaTestClass::Event Effect[%x] Event[%d]"),controlUid, aEventType);
       
   209 			    }
       
   210 			    break;
       
   211         default:
       
   212             break;
       
   213 		};
       
   214 	}
       
   215 
       
   216 
       
   217 void CEnhanMediaTestClass::HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent )
       
   218     {
       
   219     RDebug::Print(_L("HandleDMgrEventL DownloadState[%d] ProgressState[%d]"),aEvent.iDownloadState,aEvent.iProgressState);
       
   220     iLog->Log(_L("HandleDMgrEventL DownloadState[%d] ProgressState[%d]"),aEvent.iDownloadState,aEvent.iProgressState);
       
   221 
       
   222     TInt32 downloadSize = 0;
       
   223     TInt32 length = 0;
       
   224     TInt status = aDownload.GetIntAttribute(EDlAttrDownloadedSize, downloadSize);
       
   225     status = aDownload.GetIntAttribute(EDlAttrLength, length);
       
   226 
       
   227 
       
   228     TInt percentageDL = (downloadSize*100/length);
       
   229 
       
   230     if(percentageDL > 8 && iActive->IsStarted())
       
   231         {
       
   232         iActive->AsyncStop();
       
   233         }
       
   234 
       
   235     //iLog->Log(_L("iMProgDLSource->GetDownloadingRate = [%d]"),rate);
       
   236    // RDebug::Print(_L("CEnhanMediaTestClass::Event:EStateChanged[Opened]"));
       
   237 
       
   238 
       
   239     if(aEvent.iDownloadState == EHttpDlPaused)
       
   240         {
       
   241         iDownload->Start();
       
   242         }
       
   243 
       
   244     if(aEvent.iDownloadState == EHttpDlCreated)
       
   245         {
       
   246         iLog->Log(_L("EHttpDlCreated"));
       
   247         }
       
   248 
       
   249     if(aEvent.iDownloadState == EHttpDlInprogress)
       
   250         {
       
   251         iLog->Log(_L("EHttpDlInprogress "));
       
   252         }
       
   253     if(aEvent.iDownloadState == EHttpDlPaused)
       
   254         {
       
   255         iLog->Log(_L("EHttpDlPaused "));
       
   256         }
       
   257     if(aEvent.iDownloadState == EHttpDlCompleted)
       
   258         {
       
   259         iLog->Log(_L("EHttpDlCompleted "));
       
   260         }
       
   261     if(aEvent.iDownloadState == EHttpDlFailed)
       
   262         {
       
   263         iLog->Log(_L("EHttpDlFailed "));
       
   264         }
       
   265     }
       
   266 // End of File