亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美日本在线观看| 国产精品一区二区在线观看网站 | 丁香六月综合激情| 成人毛片老司机大片| 色婷婷国产精品| 欧美一区二区私人影院日本| 精品999在线播放| 中文字幕一区二区三区四区| 亚洲不卡av一区二区三区| 国产一区久久久| 在线亚洲人成电影网站色www| 欧美一级黄色片| 欧美国产禁国产网站cc| 亚洲国产va精品久久久不卡综合 | 久久先锋影音av| 亚洲男女一区二区三区| 久色婷婷小香蕉久久| 91小视频免费看| 精品伦理精品一区| 一区二区三区在线视频观看58| 青青青伊人色综合久久| jizz一区二区| 欧美一级免费观看| 亚洲欧美日韩久久| 国产露脸91国语对白| 欧美三级一区二区| 欧美国产日韩精品免费观看| 午夜精品福利在线| 成人av电影在线网| 精品久久久三级丝袜| 亚洲主播在线播放| www.色精品| 久久亚洲精品国产精品紫薇| 亚洲成va人在线观看| 9色porny自拍视频一区二区| 日韩欧美在线一区二区三区| 亚洲六月丁香色婷婷综合久久| 黑人巨大精品欧美黑白配亚洲| 欧美性猛片xxxx免费看久爱| 日本一区二区动态图| 久久99久久99精品免视看婷婷| 91国偷自产一区二区三区观看 | 成人亚洲一区二区一| 日韩一区二区免费在线电影| 一区二区三区影院| 大尺度一区二区| 久久新电视剧免费观看| 免费的成人av| 欧美日韩国产小视频在线观看| 亚洲欧洲一区二区三区| 国产一区二区三区四| 日韩一区二区三区四区五区六区| 亚洲精品videosex极品| 成人看片黄a免费看在线| 久久久.com| 国产综合一区二区| 欧美变态口味重另类| 蜜臀av亚洲一区中文字幕| 欧美日韩视频第一区| 亚洲在线免费播放| 色噜噜偷拍精品综合在线| 亚洲欧洲av色图| 成人ar影院免费观看视频| 欧美国产欧美综合| 国产福利不卡视频| 国产日韩欧美综合一区| 国模冰冰炮一区二区| 久久蜜桃一区二区| 国产乱国产乱300精品| 久久久电影一区二区三区| 国产一级精品在线| 国产亚洲欧美激情| 成人国产亚洲欧美成人综合网| 国产女人18毛片水真多成人如厕| 狠狠色狠狠色合久久伊人| 欧美成人乱码一区二区三区| 免费的成人av| 久久久精品影视| 成人免费视频app| 中文字幕一区二区三| 色域天天综合网| 亚洲在线成人精品| 欧美女孩性生活视频| 免费看日韩a级影片| 欧美成va人片在线观看| 国产成人在线电影| 国产精品美女久久久久aⅴ| 99精品视频在线观看| 亚洲猫色日本管| 欧美日韩精品一区二区三区| 秋霞成人午夜伦在线观看| 精品成人一区二区| 丰满亚洲少妇av| 一区二区高清免费观看影视大全| 欧美色综合久久| 麻豆国产精品视频| 国产欧美日韩精品a在线观看| 成人av先锋影音| 午夜视频久久久久久| 欧美大尺度电影在线| 粉嫩嫩av羞羞动漫久久久| 综合久久一区二区三区| 欧美精品一二三四| 国产精品99久久久久久宅男| 日韩美女视频一区| 在线播放中文字幕一区| 国产乱码精品一区二区三区五月婷 | 综合自拍亚洲综合图不卡区| 日本韩国精品一区二区在线观看| 五月天激情综合网| 久久麻豆一区二区| 91成人看片片| 精品一区二区三区免费视频| 国产精品伦理一区二区| 欧美日韩精品福利| 国产精品99久久久久久久女警| 亚洲精品水蜜桃| 久久夜色精品国产噜噜av| 色婷婷久久久综合中文字幕| 日韩影院免费视频| 国产精品久久久久aaaa樱花| 欧美电影在线免费观看| 国产麻豆视频一区| 香蕉久久一区二区不卡无毒影院| 国产欧美日韩不卡| 欧美肥妇bbw| 91原创在线视频| 美女在线观看视频一区二区| 国产精品色哟哟网站| 91精品国产色综合久久久蜜香臀| 国产成人一区在线| 亚洲成av人在线观看| 国产日韩在线不卡| 欧美精品乱码久久久久久按摩| 成人午夜大片免费观看| 日韩国产欧美在线观看| 中文字幕日韩av资源站| 精品99久久久久久| 91精品午夜视频| 91黄视频在线观看| 国产大陆亚洲精品国产| 日本亚洲最大的色成网站www| 亚洲色图色小说| 久久中文娱乐网| 91精品国产免费| 色琪琪一区二区三区亚洲区| 国产成人高清视频| 麻豆成人综合网| 亚洲超碰97人人做人人爱| 中文字幕一区二区三| 国产亚洲美州欧州综合国| 91精品国产福利| 精品视频资源站| 色综合久久99| 国产suv精品一区二区883| 久久精品国产久精国产爱| 亚洲成人综合在线| 亚洲中国最大av网站| 国产精品第13页| 亚洲国产精品黑人久久久| 精品欧美乱码久久久久久| 欧美一区二区女人| 欧美精品一卡两卡| 欧美日韩国产欧美日美国产精品| 99久久免费国产| av电影在线观看不卡| 国产成人综合自拍| 国产一区二区三区精品欧美日韩一区二区三区| 婷婷一区二区三区| 天天av天天翘天天综合网| 亚洲综合999| 亚洲成人免费视| 亚洲五码中文字幕| 亚洲午夜视频在线| 亚洲一区在线观看视频| 一区二区国产视频| 亚洲国产中文字幕在线视频综合| 亚洲激情综合网| 亚洲高清免费视频| 日韩国产欧美在线观看| 视频一区国产视频| 日本成人中文字幕| 久久99最新地址| 国产一区二区美女诱惑| 精品一区二区久久| 国产一区不卡视频| 成人国产在线观看| 色婷婷久久久亚洲一区二区三区| 一本大道久久a久久综合| 在线国产亚洲欧美| 8x8x8国产精品| 亚洲精品一区二区在线观看| 久久久久久久免费视频了| 欧美激情一区二区在线| 国产精品毛片久久久久久| 亚洲日本免费电影| 亚洲国产精品一区二区尤物区| 亚洲1区2区3区视频| 免费看日韩精品| 国产91丝袜在线播放|