javauis/mmapi_akn/baseline/src/cmmaaudiorecorderfactory.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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 is used for creating audio recorder
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include "cmmaaudiorecorderfactory.h"
       
    21 #include "cmmaaudiorecordcontrol.h"
       
    22 #include "cmmammfresolver.h"
       
    23 
       
    24 _LIT(KCaptureProtocol, "capture");
       
    25 _LIT(KAudioRecord, "audio");
       
    26 _LIT(KContentTypeAudioMp4NotIncluded, "audio/mp4");
       
    27 
       
    28 CMMAAudioRecorderFactory* CMMAAudioRecorderFactory::NewLC(TInt aMIDletSuiteID)
       
    29 {
       
    30     CMMAAudioRecorderFactory* pFactory =
       
    31         new(ELeave) CMMAAudioRecorderFactory(aMIDletSuiteID);
       
    32     CleanupStack::PushL(pFactory);
       
    33     return pFactory;
       
    34 }
       
    35 
       
    36 
       
    37 CMMAAudioRecorderFactory::CMMAAudioRecorderFactory(TInt aMIDletSuiteID)
       
    38 {
       
    39     iMIDletSuiteID = aMIDletSuiteID;
       
    40 }
       
    41 
       
    42 
       
    43 CMMAAudioRecorderFactory::~CMMAAudioRecorderFactory()
       
    44 {
       
    45     delete iSettings;
       
    46 }
       
    47 
       
    48 CMMAPlayer* CMMAAudioRecorderFactory::CreatePlayerL(const TDesC&)
       
    49 {
       
    50     // record player cannot be created from content-type, since this is used only
       
    51     // when we have also data
       
    52     return NULL;
       
    53 }
       
    54 
       
    55 
       
    56 CMMAPlayer* CMMAAudioRecorderFactory::CreatePlayerL(const TDesC8&)
       
    57 {
       
    58     // record player cannot be created with header data
       
    59     return NULL;
       
    60 }
       
    61 
       
    62 CMMAPlayer* CMMAAudioRecorderFactory::CreatePlayerL(
       
    63     CMMAMMFResolver* aResolver)
       
    64 {
       
    65     // settings ownership transferred to audiorecorder
       
    66     CMMAAudioSettings* tmpSettings = iSettings;
       
    67     iSettings = NULL;
       
    68     CMMAAudioRecorder* recorder = CMMAAudioRecorder::NewLC(aResolver,
       
    69                                   tmpSettings,
       
    70                                   iMIDletSuiteID);
       
    71 
       
    72 
       
    73 
       
    74     CMMAAudioRecordControl* audioRecordControl = CMMAAudioRecordControl::NewL(recorder);
       
    75     CleanupStack::PushL(audioRecordControl);
       
    76     recorder->AddControlL(audioRecordControl);
       
    77     CleanupStack::Pop(audioRecordControl);
       
    78 
       
    79     CleanupStack::Pop(recorder);
       
    80 
       
    81     return recorder;
       
    82 }
       
    83 
       
    84 
       
    85 void CMMAAudioRecorderFactory::MediaIdsL(RArray<TUid>& aMediaIds)
       
    86 {
       
    87     CleanupClosePushL(aMediaIds);
       
    88     User::LeaveIfError(aMediaIds.Append(KUidMediaTypeAudio));
       
    89     CleanupStack::Pop();
       
    90 }
       
    91 
       
    92 void CMMAAudioRecorderFactory::PreparePluginSelectionParametersL(
       
    93     CMMAMMFResolver* aResolver,
       
    94     CMMFFormatSelectionParameters* aFormatSelection)
       
    95 {
       
    96     aResolver->SetRequiredRecordFormatSupportL(*aFormatSelection);
       
    97 }
       
    98 
       
    99 CMMAPlayer* CMMAAudioRecorderFactory::CreatePlayerL(
       
   100     const TDesC& aProtocol,
       
   101     const TDesC& aMiddlePart,
       
   102     const TDesC& aParameters)
       
   103 {
       
   104     // check that locator is capture:://audio
       
   105     if ((aProtocol != KCaptureProtocol) ||
       
   106             (aMiddlePart != KAudioRecord))
       
   107     {
       
   108         return NULL;
       
   109     }
       
   110 
       
   111     // validate properties
       
   112     CMMAAudioSettings* settings =
       
   113         TMMAParameterValidator::ValidateAudioPropertiesL(aParameters);
       
   114     delete iSettings;
       
   115     iSettings = settings;
       
   116 
       
   117     // Find controller with content-type
       
   118     return CMMAMMFPlayerFactory::CreatePlayerL(*iSettings->iContentType);
       
   119 }
       
   120 
       
   121 void CMMAAudioRecorderFactory::GetSupportedProtocolsL(
       
   122     const TDesC& aContentType,
       
   123     CDesC16Array& aProtocolArray)
       
   124 {
       
   125     // Support for MP4 recording disabled: All features cannot
       
   126     // be supported for MP4 capture at the moment (e.g. pause)
       
   127     if (IsSupportedContentTypeL(aContentType) &&
       
   128             (aContentType != KContentTypeAudioMp4NotIncluded))
       
   129     {
       
   130         aProtocolArray.AppendL(KMMACaptureProtocol);
       
   131     }
       
   132 }
       
   133 
       
   134 void CMMAAudioRecorderFactory::GetSupportedContentTypesL(
       
   135     const TDesC& aProtocol,
       
   136     CDesC16Array& aMimeTypeArray)
       
   137 {
       
   138     // protocol is empty string all types must be returned.
       
   139     if (IsSupportedProtocolL(aProtocol) ||
       
   140             (aProtocol == KNullDesC))
       
   141     {
       
   142         // get supported types from MMF
       
   143         CMMAMMFPlayerFactory::GetSupportedContentTypesL(aProtocol,
       
   144                 aMimeTypeArray);
       
   145 
       
   146         // "audio/mp4" content type must not be supported
       
   147         // for capture protocol
       
   148         if (aProtocol == KCaptureProtocol)
       
   149         {
       
   150             TInt position(0);
       
   151             TInt err = aMimeTypeArray.Find(KContentTypeAudioMp4NotIncluded, position);
       
   152             if (err == KErrNone)
       
   153             {
       
   154                 aMimeTypeArray.Delete(position);
       
   155                 aMimeTypeArray.Compress();
       
   156             }
       
   157         }
       
   158     }
       
   159 }
       
   160 
       
   161 //  END OF FILE