javauis/mmapi_akn/baseline/src.mmf/cmmamanager.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     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:  This class uses player factories to generate different players
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include <jdebug.h>
       
    21 #include <ECam.h>
       
    22 
       
    23 #include "CMMAManager.h"
       
    24 #include "CMMAAudioPlayerFactory.h"
       
    25 #include "CMMAVideoPlayerFactory.h"
       
    26 #include "CMMAAudioRecorderFactory.h"
       
    27 #include "CMMACameraPlayerFactory.h"
       
    28 #include "CMMAMidiPlayerFactory.h"
       
    29 #include "CMMAVideoUrlPlayerFactory.h"
       
    30 #include "CMMAAudioStreamPlayerFactory.h"
       
    31 #include "CMMAAnimationPlayerFactory.h"
       
    32 
       
    33 #ifdef RD_JAVA_OMA_DRM_V2
       
    34 #include "CMMADRMPlayerFactory.h"
       
    35 #endif // RD_JAVA_OMA_DRM_V2
       
    36 
       
    37 CMMAManager::~CMMAManager()
       
    38 {
       
    39     iPlayerFactories.ResetAndDestroy();
       
    40     iPlayerFactories.Close();
       
    41 }
       
    42 
       
    43 CMMAManager::CMMAManager()
       
    44 {
       
    45 }
       
    46 
       
    47 void CMMAManager::ConstructL(TInt aMIDletSuiteID)
       
    48 {
       
    49     DEBUG("MMA::CMMAManager::ConstructL +");
       
    50     //
       
    51     // Create and insert known player factories
       
    52     //
       
    53 
       
    54     CMMAVideoUrlPlayerFactory* videoUrlPlayerFactory = CMMAVideoUrlPlayerFactory::NewLC();
       
    55     AddPlayerFactoryL(videoUrlPlayerFactory);
       
    56     CleanupStack::Pop(); // videoUrlPlayerFactory
       
    57 
       
    58     CMMAMIDIPlayerFactory* midiPlayerFactory = CMMAMIDIPlayerFactory::NewLC();
       
    59     AddPlayerFactoryL(midiPlayerFactory);
       
    60     CleanupStack::Pop(); // midiPlayerFactory
       
    61 
       
    62     CMMAVideoPlayerFactory* videoPlayerFactory = CMMAVideoPlayerFactory::NewLC();
       
    63     AddPlayerFactoryL(videoPlayerFactory);
       
    64     CleanupStack::Pop(); // videoPlayerFactory
       
    65 
       
    66     CMMAAudioStreamPlayerFactory* audioStreamPlayerFactory =
       
    67         CMMAAudioStreamPlayerFactory::NewLC();
       
    68     AddPlayerFactoryL(audioStreamPlayerFactory);
       
    69     CleanupStack::Pop(); // audioStreamPlayerFactory
       
    70 
       
    71     CMMAAudioPlayerFactory* audioPlayerFactory = CMMAAudioPlayerFactory::NewLC();
       
    72     AddPlayerFactoryL(audioPlayerFactory);
       
    73     CleanupStack::Pop(); // audioPlayerFactory
       
    74 
       
    75     CMMAAudioRecorderFactory* audioRecorderFactory =
       
    76         CMMAAudioRecorderFactory::NewLC(aMIDletSuiteID);
       
    77     AddPlayerFactoryL(audioRecorderFactory);
       
    78     CleanupStack::Pop(); // audioRecorderFactory
       
    79 
       
    80     CMMAAnimationPlayerFactory* animationPlayerFactory =
       
    81         CMMAAnimationPlayerFactory::NewLC();
       
    82     AddPlayerFactoryL(animationPlayerFactory);
       
    83     CleanupStack::Pop(); // animationPlayerFactory
       
    84 
       
    85     // Add camera playerfactory only if there is a camera
       
    86     if (CCamera::CamerasAvailable() > 0)
       
    87     {
       
    88         CMMACameraPlayerFactory* cameraPlayerFactory =
       
    89             CMMACameraPlayerFactory::NewLC();
       
    90         AddPlayerFactoryL(cameraPlayerFactory);
       
    91         CleanupStack::Pop(); // cameraPlayerFactory
       
    92     }
       
    93 
       
    94 #ifdef RD_JAVA_OMA_DRM_V2
       
    95     CMMADRMPlayerFactory* drmPlayerFactory =
       
    96         CMMADRMPlayerFactory::NewLC(videoPlayerFactory);
       
    97     AddPlayerFactoryL(drmPlayerFactory);
       
    98     CleanupStack::Pop(); // drmPlayerFactory
       
    99 #endif // RD_JAVA_OMA_DRM_V2
       
   100 
       
   101     DEBUG("MMA::CMMAManager::ConstructL -");
       
   102 }
       
   103 
       
   104 void CMMAManager::StaticCreateManagerL(CMMAManager** aManager,
       
   105                                        TInt aMIDletSuiteID)
       
   106 {
       
   107     CMMAManager* self = new(ELeave) CMMAManager();
       
   108 
       
   109     CleanupStack::PushL(self);
       
   110     self->ConstructL(aMIDletSuiteID);
       
   111     CleanupStack::Pop();
       
   112 
       
   113     *aManager = self;
       
   114 }
       
   115 
       
   116 /**
       
   117  * Use factories to create a player from content type
       
   118  *
       
   119  */
       
   120 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC& aContentType)
       
   121 {
       
   122     // Try all factories, in order
       
   123     TInt factoryCount = iPlayerFactories.Count();
       
   124     for (TInt i = 0; i < factoryCount; i++)
       
   125     {
       
   126         CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aContentType);
       
   127         if (player)
       
   128         {
       
   129             return player;
       
   130         }
       
   131     }
       
   132     // No PlayerFactory accepted the content type
       
   133     return NULL;
       
   134 }
       
   135 
       
   136 /**
       
   137  * Use factories to create a player from locator
       
   138  *
       
   139  */
       
   140 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC& aProtocol,
       
   141                                        const TDesC& aMiddlePart,
       
   142                                        const TDesC& aParameters)
       
   143 {
       
   144     // Try all factories, in order
       
   145     TInt factoryCount = iPlayerFactories.Count();
       
   146     for (TInt i = 0; i < factoryCount; i++)
       
   147     {
       
   148         CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aProtocol,
       
   149                              aMiddlePart,
       
   150                              aParameters);
       
   151         if (player)
       
   152         {
       
   153             return player;
       
   154         }
       
   155     }
       
   156     // No PlayerFactory accepted the content type
       
   157     return NULL;
       
   158 }
       
   159 
       
   160 /**
       
   161  * Use factories to create a player from header data
       
   162  *
       
   163  */
       
   164 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC8& aHeaderData)
       
   165 {
       
   166     // Try all factories, in order
       
   167     TInt factoryCount = iPlayerFactories.Count();
       
   168     for (TInt i = 0; i < factoryCount; i++)
       
   169     {
       
   170         CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aHeaderData);
       
   171         if (player)
       
   172         {
       
   173             return player;
       
   174         }
       
   175     }
       
   176     // No PlayerFactory accepted the content type
       
   177     return NULL;
       
   178 }
       
   179 
       
   180 /**
       
   181  * From MMMAPlayerFactory. Get all supported protocols
       
   182  */
       
   183 void CMMAManager::GetSupportedProtocolsL(
       
   184     const TDesC& aContentType,
       
   185     CDesC16Array& aSupportedProtocols)
       
   186 {
       
   187     // Query supported protocols from all player factories
       
   188     for (TInt i = 0; i < iPlayerFactories.Count(); i++)
       
   189     {
       
   190         iPlayerFactories[ i ]->GetSupportedProtocolsL(aContentType,
       
   191                 aSupportedProtocols);
       
   192     }
       
   193 }
       
   194 
       
   195 /**
       
   196  * From MMMAPlayerFactory. Get all supported content types
       
   197  */
       
   198 void CMMAManager::GetSupportedContentTypesL(
       
   199     const TDesC& aProtocol,
       
   200     CDesC16Array& aContentTypes)
       
   201 {
       
   202     // Get all supported content types from PlayerFactories
       
   203     for (TInt i = 0; i < iPlayerFactories.Count(); i++)
       
   204     {
       
   205         iPlayerFactories[ i ]->GetSupportedContentTypesL(aProtocol,
       
   206                 aContentTypes);
       
   207     }
       
   208 }
       
   209 
       
   210 EXPORT_C void CMMAManager::AddPlayerFactoryL(MMMAPlayerFactory* aPlayerFactory)
       
   211 {
       
   212     User::LeaveIfError(iPlayerFactories.Append(aPlayerFactory));
       
   213 }
       
   214 
       
   215 //  END OF FILE