AudioClipWorkflow.h 3.02 KB
Newer Older
1 2 3
/*****************************************************************************
 * AudioClipWorkflow.h : Clip workflow. Will extract a single frame from a VLCMedia
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef AUDIOCLIPWORKFLOW_H
#define AUDIOCLIPWORKFLOW_H

#include "ClipWorkflow.h"

28
#include <QPointer>
29
#include <QQueue>
30

31 32
namespace Workflow
{
33
    class  AudioSample;
34 35
}

36 37
class   AudioClipWorkflow : public ClipWorkflow
{
38 39
    Q_OBJECT

40
    public:
41
        AudioClipWorkflow( ClipHelper* ch );
42
        ~AudioClipWorkflow();
43 44
        void                        *getLockCallback() const;
        void                        *getUnlockCallback() const;
45
        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame );
46
    protected:
47 48
        virtual quint32             getNbComputedBuffers() const;
        virtual quint32             getMaxComputedBuffers() const;
49
        virtual void                flushComputedBuffers();
50
        void                        preallocate();
51
        virtual void                releasePrealocated();
52

53
    private:
54
        void                        initVlcOutput();
55 56
        Workflow::AudioSample*      createBuffer( size_t size );
        void                        insertPastBlock( Workflow::AudioSample* as );
57
        static void                 lock( AudioClipWorkflow* clipWorkflow,
58
                                          quint8** pcm_buffer , quint32 size );
59
        static void                 unlock( AudioClipWorkflow* clipWorkflow,
60 61 62 63
                                            quint8* pcm_buffer, quint32 channels,
                                            quint32 rate, quint32 nb_samples,
                                            quint32 bits_per_sample,
                                            quint32 size, qint64 pts );
64

65
    private:
66 67
        QQueue<Workflow::AudioSample*>      m_computedBuffers;
        QQueue<Workflow::AudioSample*>      m_availableBuffers;
68 69
        qint64                              m_ptsOffset;
        Workflow::AudioSample               *m_lastReturnedBuffer;
70
        static const quint32   nbBuffers = 256;
71 72 73
};

#endif // AUDIOCLIPWORKFLOW_H