Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_audio_stream_engine_8h_source.html
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 6 43e37759235e
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>TB9.2 Example Applications: examples/ForumNokia/AudioStreamExample/inc/AudioStreamEngine.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2 -->
<h1>examples/ForumNokia/AudioStreamExample/inc/AudioStreamEngine.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright © 2008 Nokia Corporation.</span>
<a name="l00003"></a>00003 <span class="comment"> */</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef AUDIOSTREAMENGINE_H</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define AUDIOSTREAMENGINE_H</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="comment">// INCLUDES</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;e32base.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;aknviewappui.h&gt;</span> 
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;mda\common\audio.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;MdaAudioInputStream.h&gt;</span>    <span class="comment">// audio input stream</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;MdaAudioOutputStream.h&gt;</span>   <span class="comment">// audio output stream</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;AudioStream.hrh&quot;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;AudioStreamView.h&quot;</span>    
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;AudioStreamAppUi.h&quot;</span>   
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">// FORWARD DECLARATIONS</span>
<a name="l00021"></a>00021 <span class="keyword">class </span><a class="code" href="class_c_audio_stream_view.html">CAudioStreamView</a>;
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="comment">// CLASS DECLARATION</span>
<a name="l00024"></a>00024 
<a name="l00029"></a><a class="code" href="class_c_audio_stream_engine.html">00029</a> <span class="keyword">class </span><a class="code" href="class_c_audio_stream_engine.html">CAudioStreamEngine</a> : <span class="keyword">public</span> CBase, MMdaAudioInputStreamCallback, 
<a name="l00030"></a>00030     MMdaAudioOutputStreamCallback
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 <span class="keyword">public</span>:
<a name="l00039"></a>00039     <span class="keyword">static</span> <a class="code" href="class_c_audio_stream_engine.html">CAudioStreamEngine</a>* <a class="code" href="class_c_audio_stream_engine.html#a642c7bef4022a84b0235c87046e261fe">NewL</a>(<a class="code" href="class_c_audio_stream_app_ui.html">CAudioStreamAppUi</a>* <span class="comment">/* aAppUi */</span>);
<a name="l00040"></a>00040 
<a name="l00048"></a>00048     <span class="keyword">static</span> <a class="code" href="class_c_audio_stream_engine.html">CAudioStreamEngine</a>* <a class="code" href="class_c_audio_stream_engine.html#a91672b67faf4b872f536dfa30a0cb087">NewLC</a>(<a class="code" href="class_c_audio_stream_app_ui.html">CAudioStreamAppUi</a>* <span class="comment">/* aAppUi */</span>);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 
<a name="l00056"></a>00056     <a class="code" href="class_c_audio_stream_engine.html#a4da8b5eecd664fea1aea40a95adc03fa">~CAudioStreamEngine</a>();
<a name="l00057"></a>00057         
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="keyword">public</span>: <span class="comment">// New functions</span>
<a name="l00060"></a>00060     
<a name="l00066"></a>00066     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#af71152acf3592c67fec809e00c7246ff">Play</a>();
<a name="l00072"></a>00072     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#a7b74589268bba7a746628c9712d7567f">Record</a>();
<a name="l00078"></a>00078     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#a6c3450de52c2fe602ed8dceaed90d6b3">Stop</a>();
<a name="l00079"></a>00079     
<a name="l00085"></a>00085     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#a2cd495294ea2a4cadfd9816b60acd587">LoadAudioFileL</a>();
<a name="l00091"></a>00091     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#af2c0f47a5bca2d3d960ea1433696b376">SaveAudioFileL</a>();
<a name="l00092"></a>00092 
<a name="l00100"></a>00100     <span class="keywordtype">void</span> <a class="code" href="class_c_audio_stream_engine.html#a939d7fb72ca466a389e413d680faafcd">SetEncodingL</a>(TBool aAmr);
<a name="l00101"></a>00101     
<a name="l00102"></a>00102 <span class="keyword">private</span>: <span class="comment">// in-class methods</span>
<a name="l00103"></a>00103 
<a name="l00113"></a>00113     TPtr8&amp; CAudioStreamEngine::GetFrame(TUint aFrameIdx);
<a name="l00123"></a>00123     TPtr8&amp; CAudioStreamEngine::GetPlaybackFrames(TUint aLastFrame);
<a name="l00124"></a>00124 
<a name="l00134"></a>00134     <span class="keywordtype">void</span> ShowMessage(<span class="keyword">const</span> TDesC&amp; <span class="comment">/* aMsg */</span>, TBool <span class="comment">/* aReset=false */</span>);
<a name="l00135"></a>00135     
<a name="l00146"></a>00146     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaiscOpenComplete(TInt aError);
<a name="l00157"></a>00157     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaiscBufferCopied(TInt aError, <span class="keyword">const</span> TDesC8&amp; aBuffer);
<a name="l00167"></a>00167     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaiscRecordComplete(TInt aError);
<a name="l00168"></a>00168 
<a name="l00179"></a>00179     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaoscOpenComplete(TInt aError);
<a name="l00194"></a>00194     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaoscBufferCopied(TInt aError, <span class="keyword">const</span> TDesC8&amp; aBuffer);
<a name="l00195"></a>00195     
<a name="l00205"></a>00205     <span class="keyword">virtual</span> <span class="keywordtype">void</span> MaoscPlayComplete(TInt aError);
<a name="l00206"></a>00206 
<a name="l00207"></a>00207     <span class="keyword">static</span> TInt BackgroundStop( TAny *aStream );
<a name="l00208"></a>00208     
<a name="l00209"></a>00209 <span class="keyword">public</span>: <span class="comment">// Functions from base classes</span>
<a name="l00210"></a>00210 
<a name="l00211"></a>00211 <span class="keyword">private</span>: <span class="comment">// Basic two-phase EPOC constructors</span>
<a name="l00212"></a>00212 
<a name="l00219"></a>00219     <span class="keywordtype">void</span> ConstructL();
<a name="l00220"></a>00220  
<a name="l00226"></a>00226     <a class="code" href="class_c_audio_stream_engine.html">CAudioStreamEngine</a>(<a class="code" href="class_c_audio_stream_app_ui.html">CAudioStreamAppUi</a>* <span class="comment">/* aAppUi */</span>);
<a name="l00227"></a>00227 
<a name="l00228"></a>00228 <span class="keyword">private</span>:    
<a name="l00229"></a>00229 
<a name="l00230"></a>00230     <span class="comment">// enumeration of input/output stream status</span>
<a name="l00231"></a>00231     <span class="keyword">enum</span> TStatus
<a name="l00232"></a>00232         {
<a name="l00233"></a>00233         ENotReady,
<a name="l00234"></a>00234         EOpen
<a name="l00235"></a>00235         };
<a name="l00236"></a>00236 
<a name="l00237"></a>00237         
<a name="l00238"></a>00238 <span class="keyword">private</span>:    <span class="comment">// data members</span>
<a name="l00239"></a>00239 
<a name="l00240"></a>00240     <span class="comment">// application UI object reference</span>
<a name="l00241"></a>00241     <a class="code" href="class_c_audio_stream_app_ui.html">CAudioStreamAppUi</a>* iAppUi;
<a name="l00242"></a>00242     <span class="comment">// audio input stream object reference</span>
<a name="l00243"></a>00243     CMdaAudioInputStream* iInputStream;
<a name="l00244"></a>00244     <span class="comment">// audio output stream object reference</span>
<a name="l00245"></a>00245     CMdaAudioOutputStream* iOutputStream;
<a name="l00246"></a>00246 
<a name="l00247"></a>00247     <span class="comment">// Handle to CCoeEnv&#39;s file server</span>
<a name="l00248"></a>00248     RFs iFs;
<a name="l00249"></a>00249 
<a name="l00250"></a>00250     <span class="comment">// Do we use AMR-NB encoding?</span>
<a name="l00251"></a>00251     TBool iUseAMR;
<a name="l00252"></a>00252     <span class="comment">// The path to the sample audio file (sample.aud or sample.amr)</span>
<a name="l00253"></a>00253     TFileName iAudioFilePath;
<a name="l00254"></a>00254     <span class="comment">// The audio file to be used (sample.aud or sample.amr)</span>
<a name="l00255"></a>00255     TFileName iAudioFile;   
<a name="l00256"></a>00256     <span class="comment">// The frame size for the current encoding</span>
<a name="l00257"></a>00257     TUint iFrameSize;
<a name="l00258"></a>00258     <span class="comment">// The number of frames to be buffered</span>
<a name="l00259"></a>00259     TUint iFrameCount;
<a name="l00260"></a>00260 
<a name="l00261"></a>00261     <span class="comment">// A buffer containing the audio frames</span>
<a name="l00262"></a>00262     HBufC8* iStreamBuffer;  
<a name="l00263"></a>00263     <span class="comment">// Modifiable pointer used to reference a single frame in iStreamBuffer </span>
<a name="l00264"></a>00264     <span class="comment">// while recording, and all the valid frames in iStreamBuffer while playback (the</span>
<a name="l00265"></a>00265     <span class="comment">// iStreamBuffer might not always be fully recorded in this example).</span>
<a name="l00266"></a>00266     TPtr8 iFramePtr;
<a name="l00267"></a>00267     <span class="comment">// Buffer status (does it contain valid audio data)</span>
<a name="l00268"></a>00268     TBool iBufferOK;
<a name="l00269"></a>00269     <span class="comment">// The default encoding used by the platform</span>
<a name="l00270"></a>00270     TFourCC iDefaultEncoding;
<a name="l00271"></a>00271     <span class="comment">// The encoding we are currently using</span>
<a name="l00272"></a>00272     TFourCC iCurrentEncoding;
<a name="l00273"></a>00273 
<a name="l00274"></a>00274     <span class="comment">// Audio data stream settings for input and output streams</span>
<a name="l00275"></a>00275     TMdaAudioDataSettings iStreamSettings;
<a name="l00276"></a>00276     <span class="comment">// Status enumeration of input stream</span>
<a name="l00277"></a>00277     TStatus iInputStatus;
<a name="l00278"></a>00278     <span class="comment">// Status enumeration of output stream  </span>
<a name="l00279"></a>00279     TStatus iOutputStatus;
<a name="l00280"></a>00280     <span class="comment">// Index of audio data block currently being played/recorded on the buffer</span>
<a name="l00281"></a>00281     TUint iStreamIdx;
<a name="l00282"></a>00282     <span class="comment">// Application status message displayed to user</span>
<a name="l00283"></a>00283     TBuf&lt;255&gt; iMsg;
<a name="l00284"></a>00284     <span class="comment">// Stream start (first audio block in buffer) and end index</span>
<a name="l00285"></a>00285     TUint iStreamStart;
<a name="l00286"></a>00286     TUint iStreamEnd;
<a name="l00287"></a>00287     
<a name="l00288"></a>00288     CIdle* iStop;
<a name="l00289"></a>00289     
<a name="l00290"></a>00290 };
<a name="l00291"></a>00291 
<a name="l00292"></a>00292 <span class="preprocessor">#endif // AUDIOSTREAMENGINE_H</span>
<a name="l00293"></a>00293 <span class="preprocessor"></span>
<a name="l00294"></a>00294 
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>