亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? audiostreamengine.cpp

?? 使用Streaming方式進行AMR-NB和PCM格式的錄音和播放
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
* ============================================================================
*  Name     : CAudioStreamEngine from AudioStreamEngine.cpp
*  Part of  : AudioStream
*  Created  : April 28, 2006 by Forum Nokia
*  Implementation notes:
*
*     Initial content was generated by S60 AppWizard.
*  Version  : 2.0
*  Copyright: Nokia Corporation
* ============================================================================
*/


#include <mda\common\audio.h>
#include <mmf\common\mmfutilities.h>
#include <MdaAudioInputStream.h>	// audio input stream
#include <MdaAudioOutputStream.h>	// audio output stream
#include <s32file.h>				// RFileWriteStream and RFileReadStream

#include "AudioStreamEngine.h"
#include "audiostream.pan"

// Audio data buffer size.
// In both 3rd Edition and 2nd Edition the total buffer (iStreamBuffer) size is 
// KFrameSizePCM * KFrameCountPCM = 40960 bytes. This will contain 2560 ms 
// of 16-bit audio data. 
// In 3rd Edition the KFrameSizePCM is 4096 bytes, because CMdaAudioInputStream::ReadL() 
// returns audio data in 4096-byte chunks. In 2nd Edition, ReadL() returns data in 320-byte
// chunks.
#ifdef __SERIES60_3X__  // 3rd Edition
const TInt KFrameSizePCM = 4096;
const TInt KFrameCountPCM = 10;
#else // 2nd Edition
const TInt KFrameSizePCM = 320;
const TInt KFrameCountPCM = 128;
#endif

// Audio data buffer size for AMR encoding. For AMR, the buffer size is the same in
// both 2nd and 3rd Edition devices (20 ms per frame, a total of 2560 ms in 128 frames).
const TInt KFrameSizeAMR = 14;
const TInt KFrameCountAMR = 128;
// Header data for an AMR-encoded audio file
const TInt KAMRHeaderLength=6;
const TUint8 KAMRNBHeader[KAMRHeaderLength] = { 0x23, 0x21, 0x41, 0x4d, 0x52, 0x0a };

// Files to store the sample audio clips
_LIT(KAudioFilePCM, "sample.aud");
_LIT(KAudioFileAMR, "sample.amr");

#ifdef __WINS__
// The path to the sample files in 2nd Ed emulator
_LIT(KEmulatorPath, "c:\\system\\apps\\audiostream\\");
#endif

CAudioStreamEngine* CAudioStreamEngine::NewL(CAudioStreamAppUi* aAppUi)
	{
	CAudioStreamEngine* self = CAudioStreamEngine::NewLC(aAppUi);
    CleanupStack::Pop(self);
	return self;
	}

CAudioStreamEngine* CAudioStreamEngine::NewLC(CAudioStreamAppUi* aAppUi)
	{
	CAudioStreamEngine* self = new (ELeave) CAudioStreamEngine(aAppUi);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

// Standard EPOC 2nd phase constructor
void CAudioStreamEngine::ConstructL()
	{
	// Construct streams. We need to construct these here, so that at least the input stream
	// exists if SetEncodingL() is called before any recording has taken place 
	iInputStream = CMdaAudioInputStream::NewL(*this);
	iOutputStream = CMdaAudioOutputStream::NewL(*this);

	// Get a handle to the RFs session to be used (owned by CEikonEnv, NOT to be closed
	// when this application exits!)		
	iFs = CEikonEnv::Static()->FsSession();

	// Save the default encoding for later reference (the encoding is the same for
	// both input and output streams).
	iDefaultEncoding = iInputStream->DataType();
	// At first we are using the default encoding.
	iCurrentEncoding = iDefaultEncoding;

	// Stream buffer allocation (by default for PCM)
	iStreamBuffer = HBufC8::NewMaxL(iFrameSize * iFrameCount);
	iStreamStart=0;
	iStreamEnd=iFrameCount - 1;
	
	#ifdef __SERIES60_3X__    
	// Only in 3rd Edition. The sample.aud/amr can be found in \private\<UID3>\ folder.
    	User::LeaveIfError( iFs.CreatePrivatePath( EDriveC ) );
	User::LeaveIfError( iFs.SetSessionToPrivate( EDriveC ) );
	#else
		#ifndef __WINS__  // don't save settings to z-drive in emulator
			// In 2nd Ed device the sample.aud/amr will be in \system\apps\audiostream\ folder.
    		TFileName appFullName = iAppUi->Application()->AppFullName();
    		TParsePtr appPath(appFullName);
	    	iAudioFilePath = appPath.DriveAndPath();
		#else 
			// For 2nd Ed emulator
			iAudioFilePath.Append(KEmulatorPath);
		#endif //__WINS__
		
	#endif
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::CAudioStreamEngine(
//     CAudioStreamAppUi* aAppUi)
//
// onstructor
// ----------------------------------------------------------------------------
CAudioStreamEngine::CAudioStreamEngine(CAudioStreamAppUi* aAppUi)
: iAppUi(aAppUi), iUseAMR(EFalse), iAudioFile(KAudioFilePCM), iFrameSize(KFrameSizePCM), 
iFrameCount(KFrameCountPCM), iStreamBuffer(0), iFramePtr(0,0), iBufferOK(EFalse)
	{
	// By default we use PCM and initialise the instance variables accordingly above.
		
	// Initial audio stream properties for input and output, 8KHz mono. 
	// These settings could also be set/changed using method SetAudioPropertiesL() of
	// the input and output streams.
	iStreamSettings.iChannels=TMdaAudioDataSettings::EChannelsMono;
	iStreamSettings.iSampleRate=TMdaAudioDataSettings::ESampleRate8000Hz;
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::~CAudioStreamEngine()
//
// destructor
// ----------------------------------------------------------------------------
CAudioStreamEngine::~CAudioStreamEngine()
	{ 
	// close and delete streams
	if (iInputStream)
		{
		if (iInputStatus!=ENotReady) iInputStream->Stop();
	    delete iInputStream;
    	iInputStream=NULL;
		}
	if (iOutputStream)
		{
		if (iOutputStatus!=ENotReady) iOutputStream->Stop();
	    delete iOutputStream;
    	iOutputStream=NULL;
		}
	if (iStreamBuffer)
		{
		delete iStreamBuffer;
		iStreamBuffer = NULL;
		}
	}


// ----------------------------------------------------------------------------
// CAudioStreamEngine::Play()
//
// plays the audio data contained in the buffer
// ----------------------------------------------------------------------------
void CAudioStreamEngine::Play()
	{
	ShowMessage(_L("Play "), ETrue);
	// if either stream is active, return
	if (iInputStatus!=ENotReady || iOutputStatus!=ENotReady) 
		{
	    ShowMessage(_L("Stream in use, \ncannot play audio."), ETrue);
		return;
		}

	if(!iBufferOK)
	    {
	    ShowMessage(_L("Nothing to play - \nrecord or load \na file first."), ETrue);
	    return;
	    }
		
	// Open output stream.
	// Upon completion will receive callback in 
	// MMdaAudioOutputStreamCallback::MaoscOpenComplete().
	#ifndef __SERIES60_3X__  // Not 3rd Ed
		// Some 2nd Edition, FP2 devices (such as Nokia 6630) require the stream to be
		// reconstructed each time before calling Open() - otherwise the callback
		// never gets called.
		if (iOutputStream) delete iOutputStream;
		iOutputStream = NULL; // In case the following NewL leaves
		TRAPD(err, iOutputStream = CMdaAudioOutputStream::NewL(*this));
		PanicIfError(err);
	#endif
	iOutputStream->Open(&iStreamSettings);
	}


// ----------------------------------------------------------------------------
// CAudioStreamEngine::Record()
//
// records audio data into the buffer
// ----------------------------------------------------------------------------
void CAudioStreamEngine::Record()
	{
	// If either stream is active, return
	if (iInputStatus!=ENotReady || iOutputStatus!=ENotReady) 
	{
	    ShowMessage(_L("Stream in use, \ncannot record audio."), ETrue);
		return;
	}

	// Open input stream.
	// Upon completion will receive callback in 
	// MMdaAudioInputStreamCallback::MaiscOpenComplete().
	#ifndef __SERIES60_3X__  // Not 3rd Ed
		// Some 2nd Edition, FP2 devices (such as Nokia 6630) require the stream to be
		// reconstructed each time before calling Open() - otherwise the callback
		// never gets called.
		if (iInputStream) delete iInputStream;
		iInputStream = NULL; // In case the following NewL leaves
		TRAPD(err, iInputStream = CMdaAudioInputStream::NewL(*this));
		PanicIfError(err);
	#endif
	iInputStream->Open(&iStreamSettings);
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::Stop()
//
// stops playing/recording
// ----------------------------------------------------------------------------
void CAudioStreamEngine::Stop()
	{
	// if input or output streams are active, close them
	if (iInputStatus!=ENotReady) 
		{
		iInputStream->Stop();
		ShowMessage(_L("\nRecording stopped!"), EFalse);
		iBufferOK = ETrue;
		}		
	if (iOutputStatus!=ENotReady) 
		{
		iOutputStream->Stop();
		ShowMessage(_L("\nPlayback stopped!"), ETrue);
		}
	}


// ----------------------------------------------------------------------------
// CAudioStreamEngine::LoadAudioFileL()
//
// loads the audio data from a file into the buffer
// ----------------------------------------------------------------------------
void CAudioStreamEngine::LoadAudioFileL()
	{
	RFileReadStream audiofile;

	// open file
	TFileName fileName;
	fileName.Copy(iAudioFilePath);
	fileName.Append(iAudioFile);

	TInt err = audiofile.Open(iFs, fileName, EFileRead|EFileStream);
	iStreamBuffer->Des().FillZ(iFrameCount * iFrameSize);  // Empty the stream buffer
	if (err==KErrNone) 
		{
		// file opened ok, proceed reading
		if (iUseAMR)
			{
			// Read the AMR header (the first 6 bytes). We don't need to save/use the header,
			// since while playback we already know it's an AMR-NB encoded stream.
			TBuf8<KAMRHeaderLength> temp;
			audiofile.ReadL(temp, KAMRHeaderLength);
			}

		TUint idx=0;
		while (idx < iFrameCount)
			{
			TRAPD(fstatus, audiofile.ReadL(GetFrame(idx), iFrameSize));
			if (fstatus!=KErrNone)
				break;
			idx++;
			}
		iStreamStart=0;
		iStreamEnd=idx-1;
		ShowMessage(_L("Loading complete!"), ETrue);
		iBufferOK = ETrue;	
		}	
	else 
		{
		// failed to open file
		ShowMessage(_L("Error loading \naudio sample!"), ETrue); 
		iBufferOK = EFalse;
		}
	audiofile.Close();
	}


// ----------------------------------------------------------------------------
// CAudioStreamEngine::SaveAudioFileL()
//
// saves the audio data in the buffer into a file
// ----------------------------------------------------------------------------
void CAudioStreamEngine::SaveAudioFileL()
	{
	if (!iBufferOK)
	{
		// In case the encoding was changed between recording and trying to save the file
		ShowMessage(_L("Recorded buffer does not \nmatch current encoding."), ETrue);	
		ShowMessage(_L("\nPlease re-record and \ntry again."), EFalse);	
		return;
	}
	RFileWriteStream audiofile;

	// Check for free space for saving the sample
	TVolumeInfo volinfo;
	TInt err=iFs.Volume(volinfo,EDriveC);
	if ( volinfo.iFree<(iFrameCount*iFrameSize))
		{
		// Not enough free space on drive for saving, report and exit
		ShowMessage(_L("Cannot save file:\nnot enough space!"), ETrue);	
		return;
		}

	TFileName fileName;
	fileName.Copy(iAudioFilePath);
	fileName.Append(iAudioFile);
	err = audiofile.Replace(iFs, fileName, EFileWrite|EFileStream);
	if (err==KErrNone) 
		{
		if (iUseAMR)
			{
				// Write the six-byte AMR header, so that the file can be used by other
				// applications as well.
				for (int i = 0; i < KAMRHeaderLength; i++)
					audiofile.WriteUint8L(KAMRNBHeader[i]);
			}
			
		// File opened ok, proceed writing.
		// Write audio data directly from iStreamBuffer
		for (TUint idx=iStreamStart; idx<=iStreamEnd; idx++)//iFrameCount; idx++)
			{
			audiofile.WriteL(GetFrame(idx));
			}
		ShowMessage(_L("Saving complete!"), ETrue);	
		}	
	else 
		{
		// failed to open file
		ShowMessage(_L("Error saving \naudio sample!"), ETrue);	
		}
	audiofile.Close();
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::SetEncodingL(TBool aAmr)
//
// If argument is ETrue, AMR-NB encoding will be used in audio input/output.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区在线观看欧美| 色综合久久中文综合久久97| 成人国产精品免费观看| 欧美日韩精品电影| 国产精品视频第一区| 美日韩一区二区| 在线日韩一区二区| 国产欧美一区二区精品忘忧草| 亚洲一区二区三区视频在线| 粉嫩绯色av一区二区在线观看| 欧美一级一区二区| 亚洲一区中文在线| 色偷偷久久一区二区三区| 国产女人18毛片水真多成人如厕| 九九精品一区二区| 欧美性猛交xxxx黑人交| 亚洲乱码国产乱码精品精可以看 | 日韩一区二区三区四区| 综合电影一区二区三区| 成人av在线一区二区| 久久综合久色欧美综合狠狠| 日韩av一区二区三区四区| 欧美影视一区在线| 一区二区三区四区中文字幕| 色www精品视频在线观看| 中文字幕一区二区在线播放| 波多野结衣视频一区| 国产精品久久网站| 99视频精品在线| 亚洲丝袜另类动漫二区| 91丝袜国产在线播放| 国产精品久久久一本精品| 豆国产96在线|亚洲| 国产日韩综合av| thepron国产精品| 亚洲欧美偷拍另类a∨色屁股| 波波电影院一区二区三区| 欧美国产精品v| 91欧美激情一区二区三区成人| 国产精品久久久久影院亚瑟| 91视频国产资源| 亚洲夂夂婷婷色拍ww47| 欧美日韩中文精品| 日韩成人一级大片| 精品国产一区二区国模嫣然| 国产精品综合在线视频| 国产精品入口麻豆九色| 色婷婷香蕉在线一区二区| 亚洲一区二区三区四区不卡| 欧美三级电影在线看| 日韩黄色在线观看| 亚洲免费观看高清完整版在线| 91美女片黄在线| 亚洲主播在线观看| 欧美一级在线观看| 国产成人亚洲综合a∨猫咪| 国产精品电影院| 538在线一区二区精品国产| 激情小说欧美图片| 亚洲人成7777| 日韩精品最新网址| 成人久久久精品乱码一区二区三区 | 91玉足脚交白嫩脚丫在线播放| 亚洲精品videosex极品| 欧美男同性恋视频网站| 国产真实乱偷精品视频免| 亚洲图片你懂的| 精品美女一区二区三区| 99久久精品99国产精品| 奇米在线7777在线精品| 国产精品欧美久久久久无广告| 欧美日韩一级片网站| 国产成人av在线影院| 偷拍自拍另类欧美| 国产精品久线观看视频| 在线不卡一区二区| 99视频有精品| 激情五月激情综合网| 亚洲国产精品一区二区久久恐怖片| 日韩免费一区二区三区在线播放| av男人天堂一区| 青青草97国产精品免费观看 | 国产米奇在线777精品观看| 国产精品美女一区二区在线观看| 欧美日韩日日骚| 成人免费的视频| 国产综合色视频| 亚洲成a人在线观看| 日本一二三不卡| 精品粉嫩aⅴ一区二区三区四区| 欧美在线你懂的| 99久久久无码国产精品| 粉嫩嫩av羞羞动漫久久久 | 亚洲一区二区三区中文字幕在线| 久久综合久久综合亚洲| 欧美一区二区三区爱爱| 欧美日本韩国一区二区三区视频 | 国产乱对白刺激视频不卡| 日韩电影一二三区| 亚洲五码中文字幕| 亚洲免费大片在线观看| 欧美国产精品中文字幕| 久久精品日产第一区二区三区高清版 | 日韩精品一区二区三区老鸭窝| 欧洲另类一二三四区| 成人久久久精品乱码一区二区三区| 经典三级一区二区| 美女mm1313爽爽久久久蜜臀| 日本亚洲欧美天堂免费| 亚洲电影视频在线| 亚洲精品国久久99热| 亚洲乱码国产乱码精品精98午夜| 日本一区二区三区免费乱视频 | 国产伦精品一区二区三区免费| 久久精品国产99国产| 精品一区二区国语对白| 韩国欧美国产1区| 精品一区二区三区在线播放 | 偷拍亚洲欧洲综合| 视频一区视频二区中文字幕| 视频一区二区三区入口| 午夜精品免费在线观看| 五月天精品一区二区三区| 日韩成人免费电影| 日本亚洲最大的色成网站www| 九九国产精品视频| 国产91丝袜在线播放| 丰满少妇在线播放bd日韩电影| 99久久综合色| 欧美制服丝袜第一页| 91精品国产综合久久国产大片 | 亚洲日本成人在线观看| 亚洲精品免费在线| 青青草国产成人99久久| 国产精品亚洲一区二区三区妖精 | 国产中文字幕一区| 成人免费av资源| 久久综合资源网| 亚洲欧洲av在线| 亚洲综合色自拍一区| 美女视频黄 久久| 成人黄色a**站在线观看| 在线欧美一区二区| 91精品国产乱码| 中文字幕日韩欧美一区二区三区| 亚洲图片欧美色图| 精品一区在线看| 91视频91自| 精品乱码亚洲一区二区不卡| 一区在线观看视频| 日韩高清国产一区在线| 成人精品免费视频| 欧美日韩高清一区二区不卡| 精品免费视频一区二区| 亚洲女子a中天字幕| 精品一区二区三区在线视频| 一本一本久久a久久精品综合麻豆| 欧美一区二区精品久久911| 国产精品热久久久久夜色精品三区 | 99re热这里只有精品视频| 3d动漫精品啪啪1区2区免费| 国产亚洲欧美色| 石原莉奈一区二区三区在线观看| 床上的激情91.| 91精品久久久久久久99蜜桃 | 精品电影一区二区三区| 一区二区三区日韩| 国产精品123| 69久久夜色精品国产69蝌蚪网| 亚洲欧美综合另类在线卡通| 激情综合色播五月| 欧美日韩精品电影| 亚洲精品视频在线观看网站| 国产一区二区三区最好精华液| 欧美日韩精品欧美日韩精品一 | 日韩在线卡一卡二| 91蜜桃在线免费视频| 国产精品网站导航| 激情综合色播五月| 欧美一区二区福利视频| 亚洲一区免费观看| 91视频国产观看| 最近中文字幕一区二区三区| 岛国一区二区三区| 久久影院视频免费| 精品一区二区日韩| 欧美videos中文字幕| 男男gaygay亚洲| 91.com在线观看| 亚洲成av人片一区二区三区| 一本色道久久综合精品竹菊| 国产精品丝袜一区| 成人精品免费网站| 中文av一区二区| 成人三级伦理片| 国产精品女上位| www.一区二区| 亚洲欧美成人一区二区三区| 91官网在线观看| 亚洲一区二区三区爽爽爽爽爽|