当前位置: 首页>>代码示例>>C++>>正文


C++ AmSession::getLocalInput方法代码示例

本文整理汇总了C++中AmSession::getLocalInput方法的典型用法代码示例。如果您正苦于以下问题:C++ AmSession::getLocalInput方法的具体用法?C++ AmSession::getLocalInput怎么用?C++ AmSession::getLocalInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AmSession的用法示例。


在下文中一共展示了AmSession::getLocalInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processAudio

void AmMediaProcessorThread::processAudio(unsigned int ts)
{
  // receiving
  for(set<AmSession*>::iterator it = sessions.begin();
      it != sessions.end(); it++){

    AmSession* s = (*it);
    // todo: get frame size/checkInterval from local audio if local in+out (?)
    unsigned int frame_length = s->rtp_str.getFrameLength(); // ms

    // complete frame time reached? 
    if (s->rtp_str.checkInterval(ts)) {
      s->lockAudio();

      int rcvd_audio_len = -1;

      // get/receive audio
      if (!s->getAudioLocal(AM_AUDIO_IN)) {
	// input is not local - receive from rtp stream
	if (s->rtp_str.receiving || s->rtp_str.getPassiveMode()) {
	  int ret = s->rtp_str.receive(ts);
	  if(ret < 0){
	    switch(ret){
	      
	    case RTP_DTMF:
	    case RTP_UNKNOWN_PL:
	    case RTP_PARSE_ERROR:
	      break;
	      
	    case RTP_TIMEOUT:
	      postRequest(new SchedRequest(AmMediaProcessor::RemoveSession,s));
	      s->postEvent(new AmRtpTimeoutEvent());
	      break;
	      
	    case RTP_BUFFER_SIZE:
	    default:
	      ERROR("AmRtpAudio::receive() returned %i\n",ret);
	      postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
	      break;
	    }
	  } else {
	    rcvd_audio_len = s->rtp_str.get(ts,buffer,frame_length);
	    
	    if (s->isDtmfDetectionEnabled() && rcvd_audio_len > 0)
	      s->putDtmfAudio(buffer, rcvd_audio_len, ts);
	  }
	}
      } else {
	// input is local - get audio from local_in
	AmAudio* local_input = s->getLocalInput(); 
	if (local_input) {
	  rcvd_audio_len = local_input->get(ts,buffer,frame_length);
	}
      }

      // process received audio
      if (rcvd_audio_len >= 0) {
	AmAudio* input = s->getInput();
	if (input) {
	  int ret = input->put(ts,buffer,rcvd_audio_len);
	  if(ret < 0){
	    DBG("input->put() returned: %i\n",ret);
	    postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
	  }
	}
      }

      s->unlockAudio();
    }
  }

  // sending
  for(set<AmSession*>::iterator it = sessions.begin();
      it != sessions.end(); it++){

    AmSession* s = (*it);
    s->lockAudio();
    AmAudio* output = s->getOutput();
	    
    if(output && s->rtp_str.sendIntReached()){
      unsigned int frame_length = s->rtp_str.getFrameLength();
      int size = output->get(ts,buffer,frame_length);

      if(size <= 0){
	DBG("output->get() returned: %i\n",size);
	postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s)); 
      }
      else {
	if (!s->getAudioLocal(AM_AUDIO_OUT)) {
	  // audio should go to RTP
	  if(!s->rtp_str.mute){	     
	    if(s->rtp_str.put(ts,buffer,size)<0)
	      postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
	  }
	} else {
	  // output is local - audio should go in local_out
	  AmAudio* local_output = s->getLocalOutput(); 
	  if (local_output) {
	    if (local_output->put(ts,buffer,size)) {
	      postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:101,代码来源:AmMediaProcessor.cpp


注:本文中的AmSession::getLocalInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。