Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
AudioFrame AudioDecoderFFmpeg::frame()
{
    DPTR_D(AudioDecoderFFmpeg);
    AudioFormat fmt;
    fmt.setSampleFormatFFmpeg(d.frame->format);
    fmt.setChannelLayoutFFmpeg(d.frame->channel_layout);
    fmt.setSampleRate(d.frame->sample_rate);
    if (!fmt.isValid()) {// need more data to decode to get a frame
        return AudioFrame();
    }
    AudioFrame f(fmt);
    //av_frame_get_pkt_duration ffmpeg
    f.setBits(d.frame->extended_data); // TODO: ref
    f.setBytesPerLine(d.frame->linesize[0], 0); // for correct alignment
    f.setSamplesPerChannel(d.frame->nb_samples);
    // TODO: ffplay check AVFrame.pts, pkt_pts, last_pts+nb_samples. move to AudioFrame::from(AVFrame*)
    f.setTimestamp((double)d.frame->pkt_pts/1000.0);
    f.setAudioResampler(d.resampler); // TODO: remove. it's not safe if frame is shared. use a pool or detach if ref >1
    return f;
}
Exemplo n.º 3
0
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)));
}