Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/mmfrec_8cpp-source.html
changeset 1 25a17d01db0c
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
       
     2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
       
     3 <title>TB10.1 Example Applications: examples/Multimedia/MmfRec/src/mmfrec.cpp Source File</title>
       
     4 <link href="doxygen.css" rel="stylesheet" type="text/css">
       
     5 <link href="tabs.css" rel="stylesheet" type="text/css">
       
     6 </head><body>
       
     7 <!-- Generated by Doxygen 1.5.3 -->
       
     8 <h1>examples/Multimedia/MmfRec/src/mmfrec.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
       
     9 <a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
       
    10 <a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
       
    11 <a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
       
    12 <a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
       
    13 <a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
       
    14 <a name="l00007"></a>00007 <span class="comment">//</span>
       
    15 <a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
       
    16 <a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
       
    17 <a name="l00010"></a>00010 <span class="comment">//</span>
       
    18 <a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
       
    19 <a name="l00012"></a>00012 <span class="comment">//</span>
       
    20 <a name="l00013"></a>00013 <span class="comment">// Description:</span>
       
    21 <a name="l00014"></a>00014 <span class="comment">//</span>
       
    22 <a name="l00015"></a>00015 
       
    23 <a name="l00016"></a>00016 <span class="preprocessor">#include &lt;e32base.h&gt;</span>
       
    24 <a name="l00017"></a>00017 <span class="preprocessor">#include &lt;e32cons.h&gt;</span>
       
    25 <a name="l00018"></a>00018 <span class="preprocessor">#include &lt;mdaaudiosampleeditor.h&gt;</span>
       
    26 <a name="l00019"></a>00019 <span class="preprocessor">#include &lt;bautils.h&gt;</span>
       
    27 <a name="l00020"></a>00020 <span class="preprocessor">#include &lt;ecom/ecom.h&gt;</span>
       
    28 <a name="l00021"></a>00021 <span class="preprocessor">#include "mmfrec.h"</span>
       
    29 <a name="l00022"></a>00022 
       
    30 <a name="l00023"></a>00023 _LIT(KFileNameFormat, <span class="stringliteral">"c:\\record%03d%S"</span>);
       
    31 <a name="l00024"></a>00024 
       
    32 <a name="l00025"></a>00025 <span class="keyword">const</span> TInt KRecordTimeMicros = 2000000; <span class="comment">//2s</span>
       
    33 <a name="l00026"></a>00026 
       
    34 <a name="l00027"></a>00027 TInt <a class="code" href="dbllist_8cpp.html#0f358e9c4355138f629b8c4f37310295">E32Main</a>()
       
    35 <a name="l00028"></a>00028         {
       
    36 <a name="l00029"></a>00029         __UHEAP_MARK;
       
    37 <a name="l00030"></a>00030 
       
    38 <a name="l00031"></a>00031         CTrapCleanup* cleanup=CTrapCleanup::New();
       
    39 <a name="l00032"></a>00032         TInt r=KErrNoMemory;
       
    40 <a name="l00033"></a>00033         <span class="keywordflow">if</span> (cleanup)
       
    41 <a name="l00034"></a>00034                 {
       
    42 <a name="l00035"></a>00035                 TRAP(r,<a class="code" href="circularbuffer_8cpp.html#5fb473d4ee18739183215b04dcad6e12">MainL</a>());
       
    43 <a name="l00036"></a>00036                 <span class="keyword">delete</span> cleanup;
       
    44 <a name="l00037"></a>00037                 }
       
    45 <a name="l00038"></a>00038         REComSession::FinalClose();
       
    46 <a name="l00039"></a>00039         __UHEAP_MARKEND;
       
    47 <a name="l00040"></a>00040 
       
    48 <a name="l00041"></a>00041         <span class="keywordflow">return</span> r;
       
    49 <a name="l00042"></a>00042         }
       
    50 <a name="l00043"></a>00043         
       
    51 <a name="l00044"></a>00044 <span class="keywordtype">void</span> <a class="code" href="circularbuffer_8cpp.html#5fb473d4ee18739183215b04dcad6e12">MainL</a>()
       
    52 <a name="l00045"></a>00045         {
       
    53 <a name="l00046"></a>00046         <span class="comment">// The recorder utility requires an active scheduler to be running in the thread before</span>
       
    54 <a name="l00047"></a>00047         <span class="comment">// it can be used. This would normally be done by the application framework</span>
       
    55 <a name="l00048"></a>00048         CActiveScheduler* s=<span class="keyword">new</span>(ELeave) CActiveScheduler;
       
    56 <a name="l00049"></a>00049         CleanupStack::PushL(s);
       
    57 <a name="l00050"></a>00050         CActiveScheduler::Install(s);
       
    58 <a name="l00051"></a>00051         
       
    59 <a name="l00052"></a>00052         <a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>* test = <a class="code" href="class_c_m_m_f_record_test.html#223fa583d02e766942f59002ac21646c">CMMFRecordTest::NewLC</a>();
       
    60 <a name="l00053"></a>00053         
       
    61 <a name="l00054"></a>00054         test-&gt;<a class="code" href="class_c_m_m_f_record_test.html#373448249ca3b5b645b915cab1f2ca46">Go</a>();
       
    62 <a name="l00055"></a>00055 
       
    63 <a name="l00056"></a>00056         CActiveScheduler::Start();
       
    64 <a name="l00057"></a>00057         CleanupStack::PopAndDestroy(2);
       
    65 <a name="l00058"></a>00058         }
       
    66 <a name="l00059"></a>00059         
       
    67 <a name="l00060"></a>00060 
       
    68 <a name="l00061"></a>00061 <span class="comment">//______________________________________________________________________________</span>
       
    69 <a name="l00062"></a>00062 <span class="comment">//                                              CMMFRecordTest</span>
       
    70 <a name="l00063"></a><a class="code" href="class_c_m_m_f_record_test.html#223fa583d02e766942f59002ac21646c">00063</a> <a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>* <a class="code" href="class_c_m_m_f_record_test.html#223fa583d02e766942f59002ac21646c">CMMFRecordTest::NewLC</a>()
       
    71 <a name="l00064"></a>00064         {
       
    72 <a name="l00065"></a>00065         <a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>* <span class="keyword">self</span> = <span class="keyword">new</span>(ELeave)<a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>();
       
    73 <a name="l00066"></a>00066         CleanupStack::PushL(<span class="keyword">self</span>);
       
    74 <a name="l00067"></a>00067         <span class="keyword">self</span>-&gt;ConstructL();
       
    75 <a name="l00068"></a>00068         <span class="keywordflow">return</span> <span class="keyword">self</span>;
       
    76 <a name="l00069"></a>00069         }
       
    77 <a name="l00070"></a>00070 
       
    78 <a name="l00071"></a><a class="code" href="class_c_m_m_f_record_test.html#83fee589eb410961d580b3e19931c43f">00071</a> <a class="code" href="class_c_m_m_f_record_test.html#83fee589eb410961d580b3e19931c43f">CMMFRecordTest::~CMMFRecordTest</a>()
       
    79 <a name="l00072"></a>00072         {
       
    80 <a name="l00073"></a>00073         <span class="keyword">delete</span> iRecorder;
       
    81 <a name="l00074"></a>00074         <span class="keyword">delete</span> iConsole;
       
    82 <a name="l00075"></a>00075         <span class="keyword">delete</span> iCallBack;
       
    83 <a name="l00076"></a>00076         <span class="keyword">delete</span> iTimer;
       
    84 <a name="l00077"></a>00077         iFs.Close();
       
    85 <a name="l00078"></a>00078         <span class="keywordflow">for</span> (TInt i=0; i&lt;iControllers.Count(); ++i)
       
    86 <a name="l00079"></a>00079                 {
       
    87 <a name="l00080"></a>00080                 <span class="keyword">delete</span> iControllers[i];
       
    88 <a name="l00081"></a>00081                 }
       
    89 <a name="l00082"></a>00082         iControllers.Close();
       
    90 <a name="l00083"></a>00083         }
       
    91 <a name="l00084"></a>00084         
       
    92 <a name="l00085"></a>00085 <span class="keywordtype">void</span> CMMFRecordTest::NextState(TState aState)
       
    93 <a name="l00086"></a>00086         {
       
    94 <a name="l00087"></a>00087         iState = aState;
       
    95 <a name="l00088"></a>00088         iCallBack-&gt;Set(iCbFn);
       
    96 <a name="l00089"></a>00089         iCallBack-&gt;CallBack();
       
    97 <a name="l00090"></a>00090         }
       
    98 <a name="l00091"></a>00091 
       
    99 <a name="l00092"></a><a class="code" href="class_c_m_m_f_record_test.html#373448249ca3b5b645b915cab1f2ca46">00092</a> <span class="keywordtype">void</span> <a class="code" href="class_c_m_m_f_record_test.html#373448249ca3b5b645b915cab1f2ca46">CMMFRecordTest::Go</a>()
       
   100 <a name="l00093"></a>00093         {
       
   101 <a name="l00094"></a>00094         NextState(ENone);
       
   102 <a name="l00095"></a>00095         }
       
   103 <a name="l00096"></a>00096 
       
   104 <a name="l00102"></a><a class="code" href="class_c_m_m_f_record_test.html#7d51322057936bba891cc6f375671e80">00102</a> <span class="keywordtype">void</span> <a class="code" href="class_c_m_m_f_record_test.html#7d51322057936bba891cc6f375671e80">CMMFRecordTest::MoscoStateChangeEvent</a>(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
       
   105 <a name="l00103"></a>00103         {
       
   106 <a name="l00104"></a>00104         
       
   107 <a name="l00105"></a>00105         __ASSERT_ALWAYS(aObject == iRecorder, User::Panic(_L(<span class="stringliteral">"Objects NotEqual"</span>),KErrNotFound));
       
   108 <a name="l00106"></a>00106         
       
   109 <a name="l00107"></a>00107         <span class="keywordflow">switch</span> (iState)
       
   110 <a name="l00108"></a>00108                 {
       
   111 <a name="l00109"></a>00109         <span class="keywordflow">case</span> EInitFile:
       
   112 <a name="l00110"></a>00110                 Printf(_L(<span class="stringliteral">"Initialising file:"</span>));
       
   113 <a name="l00111"></a>00111                 <span class="keywordflow">break</span>;
       
   114 <a name="l00112"></a>00112         <span class="keywordflow">case</span> EInitDesc:
       
   115 <a name="l00113"></a>00113                 Printf(_L(<span class="stringliteral">"Initialising des:"</span>));
       
   116 <a name="l00114"></a>00114                 <span class="keywordflow">break</span>;
       
   117 <a name="l00115"></a>00115         <span class="keywordflow">case</span> ENone:
       
   118 <a name="l00116"></a>00116         <span class="keywordflow">case</span> EDoOpenFile:
       
   119 <a name="l00117"></a>00117         <span class="keywordflow">case</span> ERecordFile:
       
   120 <a name="l00118"></a>00118         <span class="keywordflow">case</span> EDoOpenDesc:
       
   121 <a name="l00119"></a>00119         <span class="keywordflow">case</span> ERecordDesc:
       
   122 <a name="l00120"></a>00120         <span class="keywordflow">case</span> ENext:
       
   123 <a name="l00121"></a>00121         <span class="keywordflow">case</span> EDone:
       
   124 <a name="l00122"></a>00122         <span class="keywordflow">default</span>:
       
   125 <a name="l00123"></a>00123                         <span class="keywordflow">break</span>;
       
   126 <a name="l00124"></a>00124                 }
       
   127 <a name="l00125"></a>00125 
       
   128 <a name="l00126"></a>00126         Printf(_L(<span class="stringliteral">"MoscoStateChangeEvent(%d, %d, %d)"</span>), aPreviousState, aCurrentState, aErrorCode);     
       
   129 <a name="l00127"></a>00127 
       
   130 <a name="l00128"></a>00128         TTimeIntervalMicroSeconds32 delay(KRecordTimeMicros);
       
   131 <a name="l00129"></a>00129 
       
   132 <a name="l00130"></a>00130         <span class="keywordflow">switch</span> (iState)
       
   133 <a name="l00131"></a>00131                 {
       
   134 <a name="l00132"></a>00132         <span class="keywordflow">case</span> EInitFile:
       
   135 <a name="l00133"></a>00133                 <span class="keywordflow">if</span> (aErrorCode == KErrNone)
       
   136 <a name="l00134"></a>00134                         { <span class="comment">// file was opened successfully</span>
       
   137 <a name="l00135"></a>00135                         Printf(_L(<span class="stringliteral">"call: RecordL() (to file)"</span>));
       
   138 <a name="l00136"></a>00136                         iState = ERecordFile;
       
   139 <a name="l00137"></a>00137                         TRAPD(err,iRecorder-&gt;RecordL());
       
   140 <a name="l00138"></a>00138                         <span class="keywordflow">if</span>(err)
       
   141 <a name="l00139"></a>00139                                 {
       
   142 <a name="l00140"></a>00140                                 <span class="keywordflow">return</span>;
       
   143 <a name="l00141"></a>00141                                 }
       
   144 <a name="l00142"></a>00142                         iTimer-&gt;Start(delay, delay, iCbFn);
       
   145 <a name="l00143"></a>00143                         }
       
   146 <a name="l00144"></a>00144                 <span class="keywordflow">else</span>
       
   147 <a name="l00145"></a>00145                         {
       
   148 <a name="l00146"></a>00146                         Printf(_L(<span class="stringliteral">"OpenFile failed with error %d"</span>), aErrorCode);
       
   149 <a name="l00147"></a>00147                         <span class="comment">// move onto next stage: record to descriptor</span>
       
   150 <a name="l00148"></a>00148                         NextState(EDoOpenDesc);
       
   151 <a name="l00149"></a>00149                         }
       
   152 <a name="l00150"></a>00150                 <span class="keywordflow">break</span>;
       
   153 <a name="l00151"></a>00151         <span class="keywordflow">case</span> EInitDesc:
       
   154 <a name="l00152"></a>00152                 <span class="keywordflow">if</span> (aErrorCode == KErrNone)
       
   155 <a name="l00153"></a>00153                         {
       
   156 <a name="l00154"></a>00154                         Printf(_L(<span class="stringliteral">"call: RecordL() (to des)"</span>));
       
   157 <a name="l00155"></a>00155                         iState = ERecordDesc;
       
   158 <a name="l00156"></a>00156                         TRAPD(err,iRecorder-&gt;RecordL());
       
   159 <a name="l00157"></a>00157                         <span class="keywordflow">if</span>(err)
       
   160 <a name="l00158"></a>00158                                 {
       
   161 <a name="l00159"></a>00159                                 <span class="keywordflow">return</span>;
       
   162 <a name="l00160"></a>00160                                 }
       
   163 <a name="l00161"></a>00161                         iTimer-&gt;Start(delay, delay, iCbFn);
       
   164 <a name="l00162"></a>00162                         }
       
   165 <a name="l00163"></a>00163                 <span class="keywordflow">else</span>
       
   166 <a name="l00164"></a>00164                         {
       
   167 <a name="l00165"></a>00165                         Printf(_L(<span class="stringliteral">"OpenDesc failed with error %d"</span>), aErrorCode);
       
   168 <a name="l00166"></a>00166                         <span class="comment">// move onto next stage: try next format</span>
       
   169 <a name="l00167"></a>00167                         NextState(ENext);
       
   170 <a name="l00168"></a>00168                         }                       
       
   171 <a name="l00169"></a>00169                 <span class="keywordflow">break</span>;
       
   172 <a name="l00170"></a>00170         <span class="keywordflow">case</span> ERecordFile:
       
   173 <a name="l00171"></a>00171                 <span class="comment">// an error has occurred during recording. Stop the recording and move onto the next test.</span>
       
   174 <a name="l00172"></a>00172                 <span class="keywordflow">if</span> (aCurrentState!=CMdaAudioClipUtility::ERecording)
       
   175 <a name="l00173"></a>00173                         {
       
   176 <a name="l00174"></a>00174                         iTimer-&gt;Cancel();
       
   177 <a name="l00175"></a>00175                         Printf(_L(<span class="stringliteral">"call: Stop()"</span>));
       
   178 <a name="l00176"></a>00176                         iRecorder-&gt;Stop();
       
   179 <a name="l00177"></a>00177                         NextState(EDoOpenDesc);
       
   180 <a name="l00178"></a>00178                         }
       
   181 <a name="l00179"></a>00179                 <span class="keywordflow">break</span>;
       
   182 <a name="l00180"></a>00180         <span class="keywordflow">case</span> ERecordDesc:
       
   183 <a name="l00181"></a>00181                 <span class="comment">// an error has occurred during recording. Stop the recording and move onto the next test.</span>
       
   184 <a name="l00182"></a>00182                 <span class="keywordflow">if</span> (aCurrentState!=CMdaAudioClipUtility::ERecording)
       
   185 <a name="l00183"></a>00183                         {
       
   186 <a name="l00184"></a>00184                         iTimer-&gt;Cancel();
       
   187 <a name="l00185"></a>00185                         Printf(_L(<span class="stringliteral">"call: Stop()"</span>));
       
   188 <a name="l00186"></a>00186                         iRecorder-&gt;Stop();
       
   189 <a name="l00187"></a>00187                         NextState(ENext);
       
   190 <a name="l00188"></a>00188                         }
       
   191 <a name="l00189"></a>00189                 <span class="keywordflow">break</span>;
       
   192 <a name="l00190"></a>00190         <span class="keywordflow">case</span> ENone:
       
   193 <a name="l00191"></a>00191         <span class="keywordflow">case</span> EDoOpenFile:
       
   194 <a name="l00192"></a>00192         <span class="keywordflow">case</span> EDoOpenDesc:
       
   195 <a name="l00193"></a>00193         <span class="keywordflow">case</span> ENext:
       
   196 <a name="l00194"></a>00194         <span class="keywordflow">case</span> EDone:
       
   197 <a name="l00195"></a>00195         <span class="keywordflow">default</span>:
       
   198 <a name="l00196"></a>00196                         <span class="keywordflow">break</span>;
       
   199 <a name="l00197"></a>00197         
       
   200 <a name="l00198"></a>00198                 }
       
   201 <a name="l00199"></a>00199         }
       
   202 <a name="l00200"></a>00200         
       
   203 <a name="l00201"></a>00201 CMMFRecordTest::CMMFRecordTest()
       
   204 <a name="l00202"></a>00202         {
       
   205 <a name="l00203"></a>00203         }
       
   206 <a name="l00204"></a>00204 
       
   207 <a name="l00205"></a>00205 <span class="keywordtype">void</span> CMMFRecordTest::ConstructL()
       
   208 <a name="l00206"></a>00206         {
       
   209 <a name="l00207"></a>00207         iCallBack = <span class="keyword">new</span>(ELeave)CAsyncCallBack(CActive::EPriorityStandard);
       
   210 <a name="l00208"></a>00208         iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   211 <a name="l00209"></a>00209         iConsole = Console::NewL(_L(<span class="stringliteral">" RecTest "</span>), TSize(KConsFullScreen, KConsFullScreen));
       
   212 <a name="l00210"></a>00210         User::LeaveIfNull(iConsole);
       
   213 <a name="l00211"></a>00211         iRecorder = CMdaAudioRecorderUtility::NewL(*<span class="keyword">this</span>);
       
   214 <a name="l00212"></a>00212         User::LeaveIfError(iFs.Connect());
       
   215 <a name="l00213"></a>00213         
       
   216 <a name="l00214"></a>00214         iCbFn = TCallBack(Callback, <span class="keyword">this</span>);
       
   217 <a name="l00215"></a>00215         }
       
   218 <a name="l00216"></a>00216 
       
   219 <a name="l00221"></a>00221 <span class="keywordtype">void</span> CMMFRecordTest::GetPluginInformationL()
       
   220 <a name="l00222"></a>00222         {
       
   221 <a name="l00223"></a>00223         CMMFControllerPluginSelectionParameters* controllerSelection = NULL;
       
   222 <a name="l00224"></a>00224         CMMFFormatSelectionParameters* formatSelect = NULL;
       
   223 <a name="l00225"></a>00225 
       
   224 <a name="l00226"></a>00226         iControllers.ResetAndDestroy();
       
   225 <a name="l00227"></a>00227         iControllers.Close();
       
   226 <a name="l00228"></a>00228 
       
   227 <a name="l00229"></a>00229         controllerSelection = CMMFControllerPluginSelectionParameters::NewLC();
       
   228 <a name="l00230"></a>00230 
       
   229 <a name="l00231"></a>00231         RArray&lt;TUid&gt; mediaIds; <span class="comment">//Array to hold media types we wish to support</span>
       
   230 <a name="l00232"></a>00232         CleanupClosePushL(mediaIds);
       
   231 <a name="l00233"></a>00233         
       
   232 <a name="l00234"></a>00234         <span class="comment">// specify that we're interested in audio</span>
       
   233 <a name="l00235"></a>00235         mediaIds.AppendL(KUidMediaTypeAudio);
       
   234 <a name="l00236"></a>00236         controllerSelection-&gt;SetMediaIdsL(
       
   235 <a name="l00237"></a>00237                 mediaIds, CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds);
       
   236 <a name="l00238"></a>00238 
       
   237 <a name="l00239"></a>00239         formatSelect = CMMFFormatSelectionParameters::NewLC();
       
   238 <a name="l00240"></a>00240         <span class="comment">/*</span>
       
   239 <a name="l00241"></a>00241 <span class="comment">        specify that were only interested in formats for recording.</span>
       
   240 <a name="l00242"></a>00242 <span class="comment">        If you were intersted in recording to a specific format rather than just excercising</span>
       
   241 <a name="l00243"></a>00243 <span class="comment">        every record format supported by the system, you could (for example) specify which </span>
       
   242 <a name="l00244"></a>00244 <span class="comment">        format by calling formatSelect-&gt;SetMatchToMimeTypeL().  </span>
       
   243 <a name="l00245"></a>00245 <span class="comment">        */</span>
       
   244 <a name="l00246"></a>00246         controllerSelection-&gt;SetRequiredRecordFormatSupportL(*formatSelect);
       
   245 <a name="l00247"></a>00247         
       
   246 <a name="l00248"></a>00248         <span class="comment">// get the list of controller plugins that support audio recording in one or </span>
       
   247 <a name="l00249"></a>00249         <span class="comment">// more formats.</span>
       
   248 <a name="l00250"></a>00250         controllerSelection-&gt;ListImplementationsL(iControllers);
       
   249 <a name="l00251"></a>00251         
       
   250 <a name="l00252"></a>00252         <span class="comment">// iControllers now contains details of all audio controller plugins that support</span>
       
   251 <a name="l00253"></a>00253         <span class="comment">// audio recording. Each of the controller in the array will support one or more</span>
       
   252 <a name="l00254"></a>00254         <span class="comment">// recording formats.</span>
       
   253 <a name="l00255"></a>00255         Printf(_L(<span class="stringliteral">"GetPluginInformationL() - iControllers.Count() : %d"</span>), iControllers.Count());
       
   254 <a name="l00256"></a>00256 
       
   255 <a name="l00257"></a>00257         CleanupStack::PopAndDestroy(3, controllerSelection);
       
   256 <a name="l00258"></a>00258         }
       
   257 <a name="l00259"></a>00259 
       
   258 <a name="l00260"></a>00260 <span class="keywordtype">void</span> CMMFRecordTest::Printf(TRefByValue&lt;const TDesC16&gt; aFmt, ...)
       
   259 <a name="l00261"></a>00261         {
       
   260 <a name="l00262"></a>00262         VA_LIST list;
       
   261 <a name="l00263"></a>00263         VA_START(list, aFmt);
       
   262 <a name="l00264"></a>00264 
       
   263 <a name="l00265"></a>00265         <a class="code" href="class_t_truncate_overflow.html">TTruncateOverflow</a> overflow;
       
   264 <a name="l00266"></a>00266         iFormattingBuf.Zero();
       
   265 <a name="l00267"></a>00267         iFormattingBuf.AppendFormatList(aFmt, list, &amp;overflow);
       
   266 <a name="l00268"></a>00268         
       
   267 <a name="l00269"></a>00269         <span class="comment">// output the message to the console on the screen, and also to debug output</span>
       
   268 <a name="l00270"></a>00270         iConsole-&gt;Printf(iFormattingBuf);
       
   269 <a name="l00271"></a>00271         iConsole-&gt;Printf(_L(<span class="stringliteral">"\n"</span>));
       
   270 <a name="l00272"></a>00272         RDebug::RawPrint(iFormattingBuf);
       
   271 <a name="l00273"></a>00273         }
       
   272 <a name="l00274"></a>00274         
       
   273 <a name="l00275"></a>00275 TInt CMMFRecordTest::Callback(TAny* <span class="keyword">self</span>)
       
   274 <a name="l00276"></a>00276         {
       
   275 <a name="l00277"></a>00277         TState state = ((<a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>*)<span class="keyword">self</span>)-&gt;iState;
       
   276 <a name="l00278"></a>00278         TRAPD(err, ((<a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>*)<span class="keyword">self</span>)-&gt;DoCallbackL());
       
   277 <a name="l00279"></a>00279         <span class="keywordflow">if</span> (err!=KErrNone)
       
   278 <a name="l00280"></a>00280                 {
       
   279 <a name="l00281"></a>00281                 ((<a class="code" href="class_c_m_m_f_record_test.html">CMMFRecordTest</a>*)<span class="keyword">self</span>)-&gt;Printf(_L(<span class="stringliteral">"Left with %d in state %d"</span>), err, state);
       
   280 <a name="l00282"></a>00282                 }
       
   281 <a name="l00283"></a>00283         <span class="keywordflow">return</span> err;             
       
   282 <a name="l00284"></a>00284         }
       
   283 <a name="l00285"></a>00285         
       
   284 <a name="l00286"></a>00286 <span class="keywordtype">void</span> CMMFRecordTest::DoCallbackL()
       
   285 <a name="l00287"></a>00287         {
       
   286 <a name="l00288"></a>00288         iTimer-&gt;Cancel();
       
   287 <a name="l00289"></a>00289         <span class="keywordflow">switch</span> (iState)
       
   288 <a name="l00290"></a>00290                 {
       
   289 <a name="l00291"></a>00291         <span class="keywordflow">case</span> ENone:
       
   290 <a name="l00292"></a>00292                 <span class="comment">// start by getting details of all the </span>
       
   291 <a name="l00293"></a>00293                 GetPluginInformationL();
       
   292 <a name="l00294"></a>00294                 iControllerIndex = 0;
       
   293 <a name="l00295"></a>00295                 iFormatIndex = 0;
       
   294 <a name="l00296"></a>00296                 <span class="comment">// get the detail of the first format UID</span>
       
   295 <a name="l00297"></a>00297                 <span class="keywordflow">if</span> (GetNextFormatUid())
       
   296 <a name="l00298"></a>00298                         {
       
   297 <a name="l00299"></a>00299                         <span class="comment">// and begin initialization</span>
       
   298 <a name="l00300"></a>00300                         NextState(EDoOpenFile);
       
   299 <a name="l00301"></a>00301                         }
       
   300 <a name="l00302"></a>00302                 <span class="keywordflow">else</span>
       
   301 <a name="l00303"></a>00303                         {
       
   302 <a name="l00304"></a>00304                         <span class="comment">// if this fails for some reason, move onto the next controller</span>
       
   303 <a name="l00305"></a>00305                         Next();
       
   304 <a name="l00306"></a>00306                         }
       
   305 <a name="l00307"></a>00307                 <span class="keywordflow">break</span>;
       
   306 <a name="l00308"></a>00308                 
       
   307 <a name="l00309"></a>00309         <span class="keywordflow">case</span> EDoOpenFile:
       
   308 <a name="l00310"></a>00310                 InitializeFileL();
       
   309 <a name="l00311"></a>00311                 <span class="keywordflow">break</span>;
       
   310 <a name="l00312"></a>00312                 
       
   311 <a name="l00313"></a>00313         <span class="keywordflow">case</span> EDoOpenDesc:
       
   312 <a name="l00314"></a>00314                 InitializeDesL();
       
   313 <a name="l00315"></a>00315                 <span class="keywordflow">break</span>;
       
   314 <a name="l00316"></a>00316                 
       
   315 <a name="l00317"></a>00317         <span class="keywordflow">case</span> ERecordFile:
       
   316 <a name="l00318"></a>00318                 <span class="comment">// stop recording to a file after the timer expires</span>
       
   317 <a name="l00319"></a>00319                 Printf(_L(<span class="stringliteral">"call: Stop()"</span>));
       
   318 <a name="l00320"></a>00320                 iRecorder-&gt;Stop();
       
   319 <a name="l00321"></a>00321                 NextState(EDoOpenDesc);
       
   320 <a name="l00322"></a>00322                 <span class="keywordflow">break</span>;
       
   321 <a name="l00323"></a>00323 
       
   322 <a name="l00324"></a>00324         <span class="keywordflow">case</span> ERecordDesc:
       
   323 <a name="l00325"></a>00325                 <span class="comment">// stop recording to a descriptor after the timer expires</span>
       
   324 <a name="l00326"></a>00326                 Printf(_L(<span class="stringliteral">"call: Stop()"</span>));
       
   325 <a name="l00327"></a>00327                 iRecorder-&gt;Stop();
       
   326 <a name="l00328"></a>00328                 NextState(ENext);
       
   327 <a name="l00329"></a>00329                 <span class="keywordflow">break</span>;
       
   328 <a name="l00330"></a>00330 
       
   329 <a name="l00331"></a>00331         <span class="keywordflow">case</span> ENext:
       
   330 <a name="l00332"></a>00332                 Next();
       
   331 <a name="l00333"></a>00333                 <span class="keywordflow">break</span>;
       
   332 <a name="l00334"></a>00334                 
       
   333 <a name="l00335"></a>00335         <span class="keywordflow">case</span> EDone:
       
   334 <a name="l00336"></a>00336                 CActiveScheduler::Stop();
       
   335 <a name="l00337"></a>00337                 <span class="keywordflow">break</span>;
       
   336 <a name="l00338"></a>00338         <span class="keywordflow">case</span> EInitFile:
       
   337 <a name="l00339"></a>00339         <span class="keywordflow">case</span> EInitDesc:
       
   338 <a name="l00340"></a>00340         <span class="keywordflow">default</span>:
       
   339 <a name="l00341"></a>00341                         <span class="keywordflow">break</span>;
       
   340 <a name="l00342"></a>00342 
       
   341 <a name="l00343"></a>00343                 }
       
   342 <a name="l00344"></a>00344         
       
   343 <a name="l00345"></a>00345         
       
   344 <a name="l00346"></a>00346         }
       
   345 <a name="l00347"></a>00347         
       
   346 <a name="l00351"></a>00351 <span class="keywordtype">void</span> CMMFRecordTest::Next()
       
   347 <a name="l00352"></a>00352         {
       
   348 <a name="l00353"></a>00353         <span class="keywordflow">if</span> (iControllerIndex &gt;= iControllers.Count())
       
   349 <a name="l00354"></a>00354                 {
       
   350 <a name="l00355"></a>00355                 NextState(EDone);
       
   351 <a name="l00356"></a>00356                 <span class="keywordflow">return</span>;
       
   352 <a name="l00357"></a>00357                 }
       
   353 <a name="l00358"></a>00358                 
       
   354 <a name="l00359"></a>00359         CMMFControllerImplementationInformation* info = iControllers[iControllerIndex];
       
   355 <a name="l00360"></a>00360         
       
   356 <a name="l00361"></a>00361         ++iFormatIndex;
       
   357 <a name="l00362"></a>00362         
       
   358 <a name="l00363"></a>00363         <span class="keywordflow">if</span> (iFormatIndex &gt;= info-&gt;RecordFormats().Count())
       
   359 <a name="l00364"></a>00364                 {
       
   360 <a name="l00365"></a>00365                 iFormatIndex = -1;
       
   361 <a name="l00366"></a>00366                 ++iControllerIndex;
       
   362 <a name="l00367"></a>00367                 NextState(ENext);
       
   363 <a name="l00368"></a>00368                 <span class="keywordflow">return</span>;
       
   364 <a name="l00369"></a>00369                 }       
       
   365 <a name="l00370"></a>00370                 
       
   366 <a name="l00371"></a>00371         NextState(GetNextFormatUid() ? EDoOpenFile : EDone);    
       
   367 <a name="l00372"></a>00372         }
       
   368 <a name="l00373"></a>00373         
       
   369 <a name="l00377"></a>00377 TBool CMMFRecordTest::GetNextFormatUid()
       
   370 <a name="l00378"></a>00378         {
       
   371 <a name="l00379"></a>00379         <span class="comment">// if we have already excercised all of the controllers, then finish:</span>
       
   372 <a name="l00380"></a>00380         <span class="keywordflow">if</span> (iControllerIndex &gt;= iControllers.Count())
       
   373 <a name="l00381"></a>00381                 {
       
   374 <a name="l00382"></a>00382                 <span class="keywordflow">return</span> EFalse;
       
   375 <a name="l00383"></a>00383                 }
       
   376 <a name="l00384"></a>00384                 
       
   377 <a name="l00385"></a>00385         CMMFControllerImplementationInformation* info = iControllers[iControllerIndex];
       
   378 <a name="l00386"></a>00386         
       
   379 <a name="l00387"></a>00387         <span class="comment">// if we have already tried all record formats supported by the current</span>
       
   380 <a name="l00388"></a>00388         <span class="comment">// controller, then move onto the next:</span>
       
   381 <a name="l00389"></a>00389         <span class="keywordflow">if</span> (iFormatIndex &gt;= info-&gt;RecordFormats().Count())
       
   382 <a name="l00390"></a>00390                 {
       
   383 <a name="l00391"></a>00391                 <span class="keywordflow">return</span> EFalse;
       
   384 <a name="l00392"></a>00392                 }
       
   385 <a name="l00393"></a>00393                 
       
   386 <a name="l00394"></a>00394         <span class="comment">// get the unique IDs of the controller and the record format we're using</span>
       
   387 <a name="l00395"></a>00395         iControllerUid = info-&gt;Uid();
       
   388 <a name="l00396"></a>00396         iDestinationFormatUid = info-&gt;RecordFormats()[iFormatIndex]-&gt;Uid();
       
   389 <a name="l00397"></a>00397         
       
   390 <a name="l00398"></a>00398         <span class="comment">// find the recommended extension for a file of this format</span>
       
   391 <a name="l00399"></a>00399         iExtension.Zero();
       
   392 <a name="l00400"></a>00400         <span class="keyword">const</span> CDesC8Array&amp; extns = info-&gt;RecordFormats()[iFormatIndex]-&gt;SupportedFileExtensions();
       
   393 <a name="l00401"></a>00401         <span class="keywordflow">if</span> (extns.Count()&gt;0)
       
   394 <a name="l00402"></a>00402                 {
       
   395 <a name="l00403"></a>00403                 iExtension.Copy(extns[0]);
       
   396 <a name="l00404"></a>00404                 }
       
   397 <a name="l00405"></a>00405         
       
   398 <a name="l00406"></a>00406         <span class="comment">// finally display some information about the format we're using</span>
       
   399 <a name="l00407"></a>00407         Printf(_L(<span class="stringliteral">"Using controller '%S', record format '%S'"</span>), &amp;info-&gt;DisplayName(), &amp;info-&gt;RecordFormats()[iFormatIndex]-&gt;DisplayName());
       
   400 <a name="l00408"></a>00408                 
       
   401 <a name="l00409"></a>00409                 
       
   402 <a name="l00410"></a>00410         <span class="keywordflow">return</span> ETrue;
       
   403 <a name="l00411"></a>00411         }
       
   404 <a name="l00412"></a>00412 
       
   405 <a name="l00413"></a>00413 <span class="keywordtype">void</span> CMMFRecordTest::DeleteFileL(<span class="keyword">const</span> TDesC&amp; aFileName)
       
   406 <a name="l00414"></a>00414         {
       
   407 <a name="l00415"></a>00415         TInt result = BaflUtils::DeleteFile(iFs, aFileName);
       
   408 <a name="l00416"></a>00416 
       
   409 <a name="l00417"></a>00417         <span class="keywordflow">if</span> ((result != KErrNotFound)&amp;&amp;(result!=KErrPathNotFound))
       
   410 <a name="l00418"></a>00418                 {
       
   411 <a name="l00419"></a>00419                 User::LeaveIfError(result);
       
   412 <a name="l00420"></a>00420                 }
       
   413 <a name="l00421"></a>00421         }
       
   414 <a name="l00422"></a>00422 
       
   415 <a name="l00427"></a>00427 <span class="keywordtype">void</span> CMMFRecordTest::InitializeFileL()
       
   416 <a name="l00428"></a>00428         {
       
   417 <a name="l00429"></a>00429         iFileName.Zero();
       
   418 <a name="l00430"></a>00430         iFileName.Format(KFileNameFormat, iFileNum, &amp;iExtension);
       
   419 <a name="l00431"></a>00431         
       
   420 <a name="l00432"></a>00432         <span class="comment">// delte the file if it already exists</span>
       
   421 <a name="l00433"></a>00433         DeleteFileL(iFileName);
       
   422 <a name="l00434"></a>00434         
       
   423 <a name="l00435"></a>00435         Printf(_L(<span class="stringliteral">"call: OpenFileL(%S, %x, %x, %x)"</span>), &amp;iFileName, iControllerUid, KNullUid, iDestinationFormatUid);
       
   424 <a name="l00436"></a>00436         iState = EInitFile;
       
   425 <a name="l00437"></a>00437         iRecorder-&gt;OpenFileL(iFileName, iControllerUid, KNullUid, iDestinationFormatUid);
       
   426 <a name="l00438"></a>00438         
       
   427 <a name="l00439"></a>00439         ++iFileNum;
       
   428 <a name="l00440"></a>00440         }
       
   429 <a name="l00441"></a>00441         
       
   430 <a name="l00446"></a>00446 <span class="keywordtype">void</span> CMMFRecordTest::InitializeDesL()
       
   431 <a name="l00447"></a>00447         {
       
   432 <a name="l00448"></a>00448         Printf(_L(<span class="stringliteral">"call: OpenDesL(buf, %x, %x, %x)"</span>), iControllerUid, KNullUid, iDestinationFormatUid);
       
   433 <a name="l00449"></a>00449         iState = EInitDesc;
       
   434 <a name="l00450"></a>00450         iRecorder-&gt;OpenDesL(iRecBuf, iControllerUid, KNullUid, iDestinationFormatUid);
       
   435 <a name="l00451"></a>00451         }
       
   436 <a name="l00452"></a>00452 
       
   437 <a name="l00453"></a>00453 
       
   438 <a name="l00454"></a>00454 
       
   439 <a name="l00455"></a>00455         
       
   440 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:33:00 2010 for TB10.1 Example Applications by&nbsp;
       
   441 <a href="http://www.doxygen.org/index.html">
       
   442 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
       
   443 </body>
       
   444 </html>