本文整理汇总了C++中MemoryPool::allocateAudioFrames方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryPool::allocateAudioFrames方法的具体用法?C++ MemoryPool::allocateAudioFrames怎么用?C++ MemoryPool::allocateAudioFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryPool
的用法示例。
在下文中一共展示了MemoryPool::allocateAudioFrames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
std::string settings_file = rx_get_exe_path() +"connection_test.xml";
if(!vs.loadSettings(settings_file)) {
STREAMER_ERROR("error: cannot find the connection_test.xml file: %s.", settings_file.c_str());
::exit(EXIT_FAILURE);
}
#if MIC_IN
AudioSettings audio_settings;
audio_settings.samplerate = AV_AUDIO_SAMPLERATE_44100;
audio_settings.mode = AV_AUDIO_MODE_STEREO;
audio_settings.bitsize = AV_AUDIO_BITSIZE_S16;
audio_settings.quality = 6;
audio_settings.bitrate = 64;
audio_settings.in_bitsize = AV_AUDIO_BITSIZE_S16;
audio_settings.in_interleaved = true;
PAudio paudio;
paudio.listDevices();
if(!paudio.openInputStream(paudio.getDefaultInputDevice(), 2, paInt16, 44100, 512)) {
STREAMER_ERROR("error: cannot set port audio.");
::exit(EXIT_FAILURE);
}
STREAMER_VERBOSE("Using input audio device: %d.", paudio.getDefaultInputDevice());
paudio.setCallback(on_audio_in, NULL);
vs.setAudioSettings(audio_settings);
//std::string output_file = rx_get_exe_path() +"test.flv";
//vs.setOutputFile(output_file);
#endif
if(!tp.setup(vs.getVideoWidth(), vs.getVideoHeight(), vs.getFrameRate(), vs.getSampleRate())) {
STREAMER_ERROR("error: cannot setup the test pattern.");
::exit(EXIT_FAILURE);
}
STREAMER_VERBOSE("Loaded streamer with: %d x %d @ %d, samplerate: %d.", vs.getVideoWidth(), vs.getVideoHeight(), vs.getFrameRate(), vs.getSampleRate());
mempool.allocateVideoFrames(10, tp.getNumVideoBytes());
mempool.allocateAudioFrames(512, tp.getNumAudioBytes());
signal(SIGINT, sighandler);
if(!vs.setup()) {
::exit(EXIT_FAILURE);
}
if(!vs.start()) {
::exit(EXIT_FAILURE);
}
#if MIC_IN
paudio.start();
#endif
tp.start();
int nbytes_video = vs.getVideoWidth() * vs.getVideoHeight() + (2 * (vs.getVideoWidth() * 0.5) * (vs.getVideoHeight() * 0.5));
must_run = true;
while(must_run) {
tp.update();
if(tp.hasVideoFrame()) {
AVPacket* vid_pkt = mempool.getFreeVideoPacket(); // packet is owned by memory pool and released by
if(vid_pkt) {
tp.generateVideoFrame(vid_pkt->data, vid_pkt->planes, vid_pkt->strides);
vid_pkt->makeVideoPacket();
vid_pkt->setTimeStamp(tp.getTimeStamp());
vs.addVideo(vid_pkt);
}
}
#if MIC_IN == 0 && USE_AUDIO == 1
if(tp.hasAudioFrame()) {
AVPacket* au_pkt = mempool.getFreeAudioPacket();
if(au_pkt) {
tp.generateAudioFrame(au_pkt->data);
au_pkt->setTimeStamp(tp.getTimeStamp());
vs.addAudio(au_pkt);
}
else {
STREAMER_ERROR("error: cannot get new audio frame.");
}
}
#endif
}
#if MIC_IN
paudio.stop();
#endif
//.........这里部分代码省略.........