void DASHManager::OnAudioSampleDecoded (int16_t * buffer, audioFrameProperties* props) { /* TODO: some error handling here */ if (buffer == NULL || props->fireError) return; AudioFormat *format = new AudioFormat(); format->setSampleRate(props->sampleRate); format->setSampleCount(props->samples); format->setChannelCount(props->channels); format->setSampleSize(16); format->setCodec(AUDIO_PCM); format->setByteOrder(LITTLE_ENDIAN); //format->setSampleType(); AudioChunk *samples = new AudioChunk(format, (char*)buffer, props->linesize); this->multimediaStream->AddSamples(samples); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) , m_recorder(new Recorder(this)) , m_cameraGrabber(new CameraGrabber(this)) , m_audioGrabber(new AudioGrabber(this)) { ui->setupUi(this); ui->cbDevices->addItems(CameraGrabber::availableDeviceNames()); //setup the camera grabber m_cameraGrabber->setLatency(65); m_recorder->setImageGrabber(m_cameraGrabber); //setup the audio grabber AudioFormat format; format.setChannelCount(2); format.setSampleRate(44100); format.setFormat(AudioFormat::SignedInt16); m_audioGrabber->setDeviceIndex(0); m_audioGrabber->setFormat(format); m_recorder->setAudioGrabber(m_audioGrabber); //setup the encoder m_recorder->encoder()->setVideoCodecSettings(videoCodecSettings()); m_recorder->encoder()->setAudioCodecSettings(audioCodecSettings()); m_recorder->encoder()->setVideoCodec(EncoderGlobal::H264); m_recorder->encoder()->setAudioCodec(EncoderGlobal::MP3); m_recorder->encoder()->setOutputPixelFormat(EncoderGlobal::YUV420P); initFrameLabel(); connect(m_recorder->encoder(), SIGNAL(error(Encoder::Error)), this, SLOT(onEncoderError(Encoder::Error))); connect(m_cameraGrabber, SIGNAL(error(AbstractGrabber::Error)), this, SLOT(onGrabberError(AbstractGrabber::Error))); connect(m_audioGrabber, SIGNAL(error(AbstractGrabber::Error)), this, SLOT(onGrabberError(AbstractGrabber::Error))); }