本文整理汇总了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;
}
示例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;
}