⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysession.cpp

📁 G.723在ARM上的实现。实现平台为Linux2.4.8+ Intel Xscal。包括源代码
💻 CPP
字号:
#include "mysession.h"#include "goabl.h"#include <pthread.h>#include <unistd.h>#include <sys/stat.h>#include <fcntl.h>#include <iostream>using namespace std;int fd_re,fd_wr;MutexBuff compressbuf(BITS*NUM,NUM);MutexBuff speechbuf(SPEECH*NUM,NUM); void MyRTPSession::checkerror(int rtperr){	if (rtperr < 0)	{		cout << "ERROR: " << RTPGetErrorString(rtperr) <<endl;		exit(-1);	}	}void *MyRTPSession::sendpollpack(void *sess){		MyRTPSession *ses;	ses=(MyRTPSession *)sess;	int status;																	int dtxEnable=1;							IppPcmStream inputSpeech;		IppBitstream bitstream;										IppG723EncoderState	encState;				EncoderInit_G723(&encState);	inputSpeech.pBuf = (Ipp16s *) malloc(sizeof(Ipp16s)*SPEECH);	inputSpeech.len =SPEECH;	bitstream.pBuf = (Ipp8u *) malloc(sizeof(Ipp8u)*BITS);	bitstream.len=BITS;	bitstream.numFrames=5;	if ((inputSpeech.pBuf==NULL)||(bitstream.pBuf==NULL))	{		cout<<"initCodec() - memory allocation failure"<<endl;		exit(0);	}	while(1)	{			read(fd_re,inputSpeech.pBuf,SPEECH);	//	Encode_G723_16s8u(&inputSpeech,&bitstream,IPP_SPCHBR_6300,dtxEnable,IPP_G723_HPF_ENABLE,&encState);		EncodeBlock_G723_16s8u(&inputSpeech, &bitstream, dtxEnable,IPP_SPCHBR_6300, &encState);		if(bitstream.len==BITS)		{		status = ses->SendPacket(bitstream.pBuf,bitstream.len,96,false,16);		cout<<"send pack! pack's size "<<bitstream.len<<endl;		ses->checkerror(status);		}			}	}void MyRTPSession::sendthread_start(void){	pthread_t sendthread;	pthread_create(&sendthread,NULL,sendpollpack,this);	}void *MyRTPSession::uncompress(void *){	IppPcmStream outputSpeech;		IppBitstream bitstream;										IppG723DecoderState	decState;																						DecoderInit_G723(&decState);	outputSpeech.pBuf = (Ipp16s *) malloc(sizeof(Ipp16s)*SPEECH);	outputSpeech.len = SPEECH;	bitstream.pBuf = (Ipp8u *) malloc(sizeof(Ipp8u)*BITS);	bitstream.len=BITS;	bitstream.numFrames=5;	if ((outputSpeech.pBuf==NULL)||(bitstream.pBuf==NULL))	{		cout<<"initCodec() - memory allocation failure"<<endl;		exit(0);	}		int i=0;			while(1)	{			i=i%compressbuf.getframenum();		if(compressbuf.hasdata(i)==1)		{					/*	compressbuf.readbuff(i,bitstream.pBuf);				Decode_G723_8u16s(&bitstream, &outputSpeech, 			IPP_G723_NON_ERASURE_FRAME,			IPP_G723_POSTFILT_ENABLE,			 &decState);		*/	 			DecodeBlock_G723_8u16s(&bitstream,&outputSpeech,&decState);			speechbuf.writebuff(i,(unsigned char *)outputSpeech.pBuf);			i++; 				}			}		 	}void MyRTPSession::uncompresthread_start(void ){	pthread_t uncompresthread;	pthread_create(&uncompresthread,NULL,uncompress,NULL);	}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -