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


C++ AudioSegment::Init方法代码示例

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


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

示例1: printf

//Loop back audio through media-stream
nsresult
MediaEngineWebrtcAudioSource::Start(SourceMediaStream* aStream, TrackID aID)
{
  const int DEFAULT_PORT = 55555;
  printf("\n MediaEngineWebrtcAudioSource : Start: Entered ");
  if (false == mInitDone || mState != kAllocated) {
    return NULL;
  }

  if(!aStream)
  	return NULL;

  mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
  if (!mTimer) {
    return NULL;
  }

  mSource = aStream;

  AudioSegment* segment = new AudioSegment();
  segment->Init(CHANNELS);
  //segment->InsertNullDataAtStart(1);
  mSource->AddTrack(aID, PLAYOUT_SAMPLE_FREQUENCY, 0, segment);
  mSource->AdvanceKnownTracksTime(STREAM_TIME_MAX);
  mTrackID = aID;

  printf("\n Starting the audio engine ");
  mVoEBase->SetLocalReceiver(mChannel,DEFAULT_PORT);
  mVoEBase->SetSendDestination(mChannel,DEFAULT_PORT,"127.0.0.1");

  if(-1 == mVoEXmedia->SetExternalPlayoutStatus(true)) {
    printf("\n SetExternalPlayoutStatus failed %d ", mVoEBase->LastError() );
  	return NULL;
  } 
  //loopback audio
  mVoEBase->StartPlayout(mChannel);
  mVoEBase->StartSend(mChannel);
  mVoEBase->StartReceive(mChannel);
   
  mState = kStarted;
  // call every 10 milliseconds
  mTimer->InitWithCallback(this, 10, nsITimer::TYPE_REPEATING_SLACK);
  return NS_OK;
}
开发者ID:aftabmd,项目名称:GetUserMedia-Webrtc,代码行数:45,代码来源:MediaEngineWebrtc.cpp

示例2: enter

void
MediaEngineWebRTCAudioSource::Process(const int channel,
  const webrtc::ProcessingTypes type, sample* audio10ms,
  const int length, const int samplingFreq, const bool isStereo)
{
  ReentrantMonitorAutoEnter enter(mMonitor);
  if (mState != kStarted)
    return;

  nsRefPtr<SharedBuffer> buffer = SharedBuffer::Create(length * sizeof(sample));

  sample* dest = static_cast<sample*>(buffer->Data());
  memcpy(dest, audio10ms, length * sizeof(sample));

  AudioSegment segment;
  segment.Init(CHANNELS);
  segment.AppendFrames(
    buffer.forget(), length, 0, length, AUDIO_FORMAT_S16
  );
  mSource->AppendToTrack(mTrackID, &segment);

  return;
}
开发者ID:allstarschh,项目名称:releases-mozilla-central,代码行数:23,代码来源:MediaEngineWebRTCAudio.cpp


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