harvesterplugins/media/video/src/videoplugin.cpp
changeset 2 208a4ba3894c
parent 0 ccd0fd43f247
child 13 0a2ec6860a93
equal deleted inserted replaced
0:ccd0fd43f247 2:208a4ba3894c
    29 #include "cpixmediavideodoc.h"
    29 #include "cpixmediavideodoc.h"
    30 #include "cpixindexerutils.h"
    30 #include "cpixindexerutils.h"
    31 #include "mmcmonitor.h"
    31 #include "mmcmonitor.h"
    32 #include "cpixmdedbmanager.h"
    32 #include "cpixmdedbmanager.h"
    33 #include "mdsitementity.h"
    33 #include "mdsitementity.h"
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "videopluginTraces.h"
       
    37 #endif
       
    38 
    34 
    39 
    35 //Constants
    40 //Constants
    36 _LIT(KPathTrailer, "\\root\\media\\video");
    41 _LIT(KPathTrailer, "\\root\\media\\video");
    37 #define MEDIA_QBASEAPPCLASS   "@0:root media video"
    42 #define MEDIA_QBASEAPPCLASS   "@0:root media video"
    38 #define LMEDIA_QBASEAPPCLASS  L"@0:root media video"
    43 #define LMEDIA_QBASEAPPCLASS  L"@0:root media video"
    74     delete iMdsItem;
    79     delete iMdsItem;
    75     }
    80     }
    76 
    81 
    77 void CVideoPlugin::StartPluginL()
    82 void CVideoPlugin::StartPluginL()
    78     {
    83     {
       
    84     OstTraceFunctionEntry0( CVIDEOPLUGIN_STARTPLUGINL_ENTRY );
    79     //Define the basic application class 
    85     //Define the basic application class 
    80     CPIXLOGSTRING("CVideoPlugin::StartPluginL");
    86     CPIXLOGSTRING("CVideoPlugin::StartPluginL");
    81     iIndexerUtil = CCPixIndexerUtils::NewL( iSearchSession );
    87     iIndexerUtil = CCPixIndexerUtils::NewL( iSearchSession );
    82     TBuf<KMaxFileName> databasePathTemp;
    88     TBuf<KMaxFileName> databasePathTemp;
    83     databasePathTemp.Append( KPathTrailer );
    89     databasePathTemp.Append( KPathTrailer );
    97     // Start harvester for this plugin
   103     // Start harvester for this plugin
    98     iObserver->AddHarvestingQueue(this, _L(MEDIA_QBASEAPPCLASS) );
   104     iObserver->AddHarvestingQueue(this, _L(MEDIA_QBASEAPPCLASS) );
    99     TUid uidOfPlugin = {0x20029ABA};
   105     TUid uidOfPlugin = {0x20029ABA};
   100     iDBManager = CCPIXMDEDbManager::NewL(uidOfPlugin);
   106     iDBManager = CCPIXMDEDbManager::NewL(uidOfPlugin);
   101     iMdsItem = CMDSEntity::NewL();
   107     iMdsItem = CMDSEntity::NewL();
       
   108     OstTraceFunctionExit0( CVIDEOPLUGIN_STARTPLUGINL_EXIT );
   102     }
   109     }
   103 
   110 
   104 void CVideoPlugin::StartHarvestingL( const TDesC& /*aMedia*/ )
   111 void CVideoPlugin::StartHarvestingL( const TDesC& /*aMedia*/ )
   105     {
   112     {
       
   113     OstTraceFunctionEntry0( CVIDEOPLUGIN_STARTHARVESTINGL_ENTRY );
   106     CPIXLOGSTRING("CVideoPlugin::StartHarvestingL");
   114     CPIXLOGSTRING("CVideoPlugin::StartHarvestingL");
   107     iDBManager->ResetL();
   115     iDBManager->ResetL();
   108     iIndexerUtil->ResetAllL();
   116     iIndexerUtil->ResetAllL();
   109     //start video harvesting
   117     //start video harvesting
   110 #ifdef __PERFORMANCE_DATA
   118 #ifdef __PERFORMANCE_DATA
   111     iStartTime.UniversalTime();
   119     iStartTime.UniversalTime();
   112 #endif
   120 #endif
   113     iMdeHarvester->DoHarvesetL( MdeConstants::Video::KVideoObject );      
   121     iMdeHarvester->DoHarvesetL( MdeConstants::Video::KVideoObject );      
       
   122     OstTraceFunctionExit0( CVIDEOPLUGIN_STARTHARVESTINGL_EXIT );
   114     }
   123     }
   115 
   124 
   116 void CVideoPlugin::HarvestingCompletedL()
   125 void CVideoPlugin::HarvestingCompletedL()
   117     {
   126     {
       
   127     OstTraceFunctionEntry0( CVIDEOPLUGIN_HARVESTINGCOMPLETEDL_ENTRY );
   118     CPIXLOGSTRING("CVideoPlugin::HarvestingCompletedL");
   128     CPIXLOGSTRING("CVideoPlugin::HarvestingCompletedL");
   119 #ifdef __PERFORMANCE_DATA
   129 #ifdef __PERFORMANCE_DATA
   120     UpdatePerformaceDataL();
   130     UpdatePerformaceDataL();
   121 #endif
   131 #endif
   122     iObserver->HarvestingCompleted(this, _L(MEDIA_QBASEAPPCLASS), KErrNone);    
   132     iObserver->HarvestingCompleted(this, _L(MEDIA_QBASEAPPCLASS), KErrNone);    
       
   133     OstTraceFunctionExit0( CVIDEOPLUGIN_HARVESTINGCOMPLETEDL_EXIT );
   123     }
   134     }
   124 
   135 
   125 //handle MMC event for the Drive
   136 //handle MMC event for the Drive
   126 void CVideoPlugin::HandleMMCEventL(const TDriveNumber aDrive,const TBool aMMCInsertRemoval)
   137 void CVideoPlugin::HandleMMCEventL(const TDriveNumber aDrive,const TBool aMMCInsertRemoval)
   127     {
   138     {
   142     }
   153     }
   143 
   154 
   144 void CVideoPlugin::HandleMdeItemL( TItemId aObjId, TCPixActionType aActionType)
   155 void CVideoPlugin::HandleMdeItemL( TItemId aObjId, TCPixActionType aActionType)
   145     {
   156     {
   146     //Get the object from object utils and get the CPIX document and add delete or update
   157     //Get the object from object utils and get the CPIX document and add delete or update
       
   158     OstTrace1( TRACE_NORMAL, CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL;aObjId=%d", aObjId );
   147     CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): aObjId = %d ", aObjId );
   159     CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): aObjId = %d ", aObjId );
   148     // creating CSearchDocument object with unique ID for this application
   160     // creating CSearchDocument object with unique ID for this application
   149     TBuf<KMaxFileName> docid_str;
   161     TBuf<KMaxFileName> docid_str;
   150     if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction )
   162     if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction )
   151         {
   163         {
   152         //To Improve performance check here only before Getobject if it is Add event
   164         //To Improve performance check here only before Getobject if it is Add event
   153         //and we already have in our database just return in case of update move forward
   165         //and we already have in our database just return in case of update move forward
   154         if(iDBManager->IsAlreadyExistL(aObjId) && aActionType == ECPixAddAction)//Avoid reharvesting
   166         if(iDBManager->IsAlreadyExistL(aObjId) && aActionType == ECPixAddAction)//Avoid reharvesting
   155            {
   167            {
       
   168            OstTrace0( TRACE_NORMAL, DUP1_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Already harvested returning" );
   156            CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Already harvested returning");
   169            CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Already harvested returning");
   157            return;
   170            return;
   158            }
   171            }
   159         CMdEObject& object= iMdsUtils->GetObjectL( aObjId,MdeConstants::Video::KVideoObject );        
   172         CMdEObject& object= iMdsUtils->GetObjectL( aObjId,MdeConstants::Video::KVideoObject );        
   160         CMdENamespaceDef& defaultNamespaceDef = iMdsUtils->GetSession()->GetDefaultNamespaceDefL();        
   173         CMdENamespaceDef& defaultNamespaceDef = iMdsUtils->GetSession()->GetDefaultNamespaceDefL();        
   163         iIndexer = iIndexerUtil->GetIndexerFromMediaId(object.MediaId());
   176         iIndexer = iIndexerUtil->GetIndexerFromMediaId(object.MediaId());
   164         
   177         
   165         if (!iIndexer)
   178         if (!iIndexer)
   166             {
   179             {
   167             delete index_item;
   180             delete index_item;
       
   181             OstTrace0( TRACE_NORMAL, DUP2_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Indexer not found" );
   168             CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Indexer not found");
   182             CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Indexer not found");
   169             return;
   183             return;
   170             }
   184             }
   171         // Send for indexing
   185         // Send for indexing
   172         if (aActionType == ECPixAddAction)
   186         if (aActionType == ECPixAddAction)
   173             {
   187             {
   174 #ifdef __PERFORMANCE_DATA
   188 #ifdef __PERFORMANCE_DATA
   175             ++count;
   189             ++count;
   176 #endif
   190 #endif
       
   191             OstTrace0( TRACE_NORMAL, DUP3_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Indexer found calling AddL" );
   177             CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Indexer found calling AddL");
   192             CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Indexer found calling AddL");
   178             //First check if it already exist in database
   193             //First check if it already exist in database
   179             TRAPD(err, iIndexer->UpdateL(*index_item)); //Always Update to avoid reharvesting
   194             TRAPD(err, iIndexer->UpdateL(*index_item)); //Always Update to avoid reharvesting
   180             if (err == KErrNone)
   195             if (err == KErrNone)
   181                 {
   196                 {
   185                 iMdsItem->SetUri(iVideoDocument->GetUri());//Use the Absolute URI
   200                 iMdsItem->SetUri(iVideoDocument->GetUri());//Use the Absolute URI
   186                 TDriveNumber drive;
   201                 TDriveNumber drive;
   187                 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   202                 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   188                 iMdsItem->SetDrive(drive);
   203                 iMdsItem->SetDrive(drive);
   189                 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB
   204                 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB
       
   205                 OstTrace0( TRACE_NORMAL, DUP4_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Added." );
   190                 CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Added.");
   206                 CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Added.");
   191                 }
   207                 }
   192             else
   208             else
   193                 {
   209                 {
       
   210                 OstTrace1( TRACE_NORMAL, DUP5_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL;Error %d in adding", err );
   194                 CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in adding.", err);
   211                 CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in adding.", err);
   195                 }           
   212                 }           
   196             }
   213             }
   197         else if (aActionType == ECPixUpdateAction)
   214         else if (aActionType == ECPixUpdateAction)
   198             {
   215             {
   209                 if(iMdsItem->GetPath().Compare(object.Uri()) != 0)
   226                 if(iMdsItem->GetPath().Compare(object.Uri()) != 0)
   210                     {
   227                     {
   211                     CCPixIndexer *tempIndexer;                
   228                     CCPixIndexer *tempIndexer;                
   212                     tempIndexer = iIndexerUtil->GetIndexerFromDrive(iMdsItem->DriveNumber());
   229                     tempIndexer = iIndexerUtil->GetIndexerFromDrive(iMdsItem->DriveNumber());
   213                     tempIndexer->DeleteL(iMdsItem->Uri());
   230                     tempIndexer->DeleteL(iMdsItem->Uri());
       
   231                     OstTrace0( TRACE_NORMAL, DUP6_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Deleted existing URI for update" );
   214                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Deleted existing URI for update");
   232                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Deleted existing URI for update");
   215                     }
   233                     }
   216                 TRAPD(error, iIndexer->UpdateL(*index_item));
   234                 TRAPD(error, iIndexer->UpdateL(*index_item));
   217                 if (error == KErrNone)
   235                 if (error == KErrNone)
   218                     {
   236                     {
   220                     iMdsItem->Reset();//reset existing values
   238                     iMdsItem->Reset();//reset existing values
   221                     TDriveNumber drive;
   239                     TDriveNumber drive;
   222                     iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   240                     iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   223                     iMdsItem->Set(aObjId,iVideoDocument->GetUri(),drive);
   241                     iMdsItem->Set(aObjId,iVideoDocument->GetUri(),drive);
   224                     iDBManager->UpdateL(aObjId,*iMdsItem);//Add to SyncDB
   242                     iDBManager->UpdateL(aObjId,*iMdsItem);//Add to SyncDB
       
   243                     OstTrace0( TRACE_NORMAL, DUP7_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Updated." );
   225                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Updated.");
   244                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Updated.");
   226                     }
   245                     }
   227                 else
   246                 else
   228                     {
   247                     {
       
   248                     OstTrace1( TRACE_NORMAL, DUP8_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL;Error %d in updating", err );
   229                     CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in updating.", error);
   249                     CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in updating.", error);
   230                     }   
   250                     }   
   231                 }
   251                 }
   232             //If a media item is added when downloading or streaming begins, add event is surpassed
   252             //If a media item is added when downloading or streaming begins, add event is surpassed
   233             //by update or delete event because of delay introduced on monitered object by objectqueue manager
   253             //by update or delete event because of delay introduced on monitered object by objectqueue manager
   243                     iMdsItem->SetUri(iVideoDocument->GetUri());//Use the Absolute URI
   263                     iMdsItem->SetUri(iVideoDocument->GetUri());//Use the Absolute URI
   244                     TDriveNumber drive;
   264                     TDriveNumber drive;
   245                     iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   265                     iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive);
   246                     iMdsItem->SetDrive(drive);
   266                     iMdsItem->SetDrive(drive);
   247                     iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB
   267                     iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB
       
   268                     OstTrace0( TRACE_NORMAL, DUP9_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Added Item before Update." );
   248                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Added Item before Update.");
   269                     CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Added Item before Update.");
   249                     }
   270                     }
   250                 }                    
   271                 }                    
   251             }
   272             }
   252         delete index_item;
   273         delete index_item;
   265                     {
   286                     {
   266                     docid_str.Copy(iMdsItem->Uri());
   287                     docid_str.Copy(iMdsItem->Uri());
   267                     TRAPD(err, iIndexer->DeleteL(docid_str));//Delete it
   288                     TRAPD(err, iIndexer->DeleteL(docid_str));//Delete it
   268                     if (err == KErrNone)
   289                     if (err == KErrNone)
   269                         {
   290                         {
       
   291                         OstTrace0( TRACE_NORMAL, DUP10_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL(): Deleted." );
   270                         CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Deleted.");
   292                         CPIXLOGSTRING("CVideoPlugin::HandleMdeItemL(): Deleted.");
   271                         }
   293                         }
   272                     else
   294                     else
   273                         {
   295                         {
       
   296                         OstTrace1( TRACE_NORMAL, DUP11_CVIDEOPLUGIN_HANDLEMDEITEML, "CVideoPlugin::HandleMdeItemL;Error %d in deleting", err );
   274                         CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in deleting.", err);
   297                         CPIXLOGSTRING2("CVideoPlugin::HandleMdeItemL(): Error %d in deleting.", err);
   275                         }
   298                         }
   276                     }
   299                     }
   277                 //delete entry from database
   300                 //delete entry from database
   278                 iDBManager->RemoveL(iMdsItem->Key());
   301                 iDBManager->RemoveL(iMdsItem->Key());